Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

Commit

Permalink
Fix emoji, guest accounts (#5299)
Browse files Browse the repository at this point in the history
* Reset config globally on before hook

* Fix emoji and guest accounts specs
  • Loading branch information
Joseph Baylon committed Apr 9, 2020
1 parent b958be4 commit 56badfe
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,27 @@ import * as TIMEOUTS from '../../fixtures/timeouts';
import * as MESSAGES from '../../fixtures/messages';
import users from '../../fixtures/users.json';

const newChannelName = `channel-react-to-last-message-${Date.now()}`;
let channelId = '';
let newChannel = {};

describe('Keyboard shortcut for adding reactions to last message in channel or thread', () => {
before(() => {
const newChannelName = `channel-react-to-last-message-${Date.now()}`;
let testChannel;
let channelId;
let isArchived;

beforeEach(() => {
testChannel = null;
isArchived = false;

// # Login as sysadmin
cy.apiLogin('sysadmin');

// # Enable Experimental View Archived Channels
cy.apiUpdateConfig({
TeamSettings: {
ExperimentalViewArchivedChannels: true,
},
});

// # Visit the Town Square channel
cy.visit('/ad-1/channels/town-square');

// # Get the current channels Id for later use such as posting message with other user
Expand All @@ -37,22 +45,20 @@ describe('Keyboard shortcut for adding reactions to last message in channel or t
// # Create a new channel for later use such as when channel is empty test
cy.getCurrentTeamId().then((teamId) => {
// eslint-disable-next-line no-magic-numbers
cy.apiCreateChannel(teamId, newChannelName, newChannelName).then(
(response) => {
newChannel = Object.assign({}, response.body);
}
);
cy.apiCreateChannel(teamId, newChannelName, newChannelName).then((response) => {
testChannel = response.body;
});
});
});

beforeEach(() => {
// # Make sure there is at least a message without reaction for each test
cy.postMessage(MESSAGES.TINY);
});

afterEach(() => {
// # Close any emoji picker if open
cy.get('body').type('{esc}');
cy.apiLogin('sysadmin');
if (testChannel && testChannel.id && !isArchived) {
cy.apiDeleteChannel(testChannel.id);
}
});

it('Should open emoji picker for last message by shortcut in the channel view when focus is on the center text box', () => {
Expand Down Expand Up @@ -495,7 +501,7 @@ describe('Keyboard shortcut for adding reactions to last message in channel or t
cy.findByLabelText('Expand').click();

// # Open the Pinned Posts
cy.findByLabelText('See pinned posts').click();
cy.findByLabelText('Pinned posts').click();

// # Expand the Pinned Posts
cy.findByLabelText('Expand').click();
Expand Down Expand Up @@ -538,7 +544,7 @@ describe('Keyboard shortcut for adding reactions to last message in channel or t

it('Should not open emoji picker by shortcut if last post is a system message', () => {
// # Visit the new empty channel
cy.visit(`/ad-1/channels/${newChannel.name}`);
cy.visit(`/ad-1/channels/${testChannel.name}`);

// * Check that there are no posts except you joined message
cy.findAllByTestId('postView').should('have.length', 1);
Expand Down Expand Up @@ -573,7 +579,8 @@ describe('Keyboard shortcut for adding reactions to last message in channel or t
cy.postMessage(MESSAGES.TINY);

// # Archive the channel after posting a message
cy.apiDeleteChannel(newChannel.id);
cy.apiDeleteChannel(testChannel.id);
isArchived = true;

// # Emulate react to last message shortcut
pressShortcutReactToLastMessage();
Expand Down Expand Up @@ -620,7 +627,8 @@ function addingReactionWithEmojiPicker() {
should('exist').
within(() => {
// # Search for an emoji and add it to message.
cy.findByPlaceholderText('Search emojis').type('smile{enter}');
cy.findByPlaceholderText('Search emojis').type('smile').wait(TIMEOUTS.TINY);
cy.findByTestId('smile').should('be.visible').click();
});
cy.wait(TIMEOUTS.TINY);
}
Expand Down Expand Up @@ -654,13 +662,13 @@ function verifyShortcutReactToLastMessageIsBlocked(from) {
}

function openMainMenuOptions(menu) {
cy.get('body').type('{esc}');
cy.get('body').type('{esc}').wait(TIMEOUTS.TINY);
cy.findByLabelText('main menu').click();
cy.findByText(menu).scrollIntoView().click();
}

function openChannelMainOptions(menu) {
cy.get('body').type('{esc}');
cy.get('body').type('{esc}').wait(TIMEOUTS.TINY);
cy.findByLabelText('channel menu').click();
cy.findByText(menu).scrollIntoView().should('be.visible').click();
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,14 @@ let newUser;
const user1 = users['user-1'];

function changeGuestFeatureSettings(featureFlag = true, emailInvitation = true, whitelistedDomains = '') {
// # Update Guest Account Settings
// # Update Guest Accounts, Email Invitations, and Whitelisted Domains
cy.apiUpdateConfig({
GuestAccountsSettings: {
Enable: featureFlag,
RestrictCreationToDomains: whitelistedDomains,
},
ServiceSettings: {
EnableEmailInvitations: emailInvitation,
IdleTimeout: 300,
},
});
}
Expand Down Expand Up @@ -111,12 +110,16 @@ function verifyInvitationSuccess(user, successText, verifyGuestBadge = false) {
}

describe('Guest Account - Guest User Invitation Flow', () => {
before(() => {
// * Login as sysadmin and check if server has license for Guest Accounts
beforeEach(() => {
testTeam = null;

// # Login as sysadmin
cy.apiLogin('sysadmin');

// * Check if server has license for Guest Accounts
cy.requireLicenseForFeature('GuestAccounts');

// # Enable Guest Account Settings
// # Reset Guest Feature settings
changeGuestFeatureSettings();

// # Create new team and visit its URL
Expand All @@ -134,15 +137,7 @@ describe('Guest Account - Guest User Invitation Flow', () => {
});

afterEach(() => {
// # Reload current page after each test to close any popup/modals left open
cy.reload();
});

after(() => {
// # Reset Guest Feature settings
changeGuestFeatureSettings();

// # Delete the new team as sysadmin
cy.apiLogin('sysadmin');
if (testTeam && testTeam.id) {
cy.apiDeleteTeam(testTeam.id);
}
Expand All @@ -162,7 +157,7 @@ describe('Guest Account - Guest User Invitation Flow', () => {

// * Verify the header has changed in the modal
cy.findByTestId('invitationModal').within(() => {
cy.get('h1').should('have.text', 'Invite Guests to Test Team');
cy.get('h1').should('have.text', `Invite Guests to ${testTeam.display_name}`);
});

// * Verify Invite Guests button is disabled by default
Expand Down Expand Up @@ -287,7 +282,8 @@ describe('Guest Account - Guest User Invitation Flow', () => {
});

it('MM-18050 Verify when different feature settings are disabled', () => {
// # Disable Guest Account Feature
// # Disable Guest Accounts
// # Enable Email Invitations
changeGuestFeatureSettings(false, true);

// # reload current page
Expand All @@ -298,7 +294,7 @@ describe('Guest Account - Guest User Invitation Flow', () => {
cy.get('#invitePeople').should('be.visible').click();

// * Verify if Invite Members modal is displayed when guest account feature is disabled
cy.findByTestId('invitationModal').find('h1').should('have.text', 'Invite Members to Test Team');
cy.findByTestId('invitationModal').find('h1').should('have.text', `Invite Members to ${testTeam.display_name}`);

// * Verify Share Link Header and helper text
cy.findByTestId('shareLink').should('be.visible').within(() => {
Expand All @@ -309,7 +305,8 @@ describe('Guest Account - Guest User Invitation Flow', () => {
// # Close the Modal
cy.get('#closeIcon').should('be.visible').click();

// # Enable Guest Account Feature and disable Email Invitation
// # Enable Guest Accounts
// # Disable Email Invitations
changeGuestFeatureSettings(true, false);

// # Reload the current page
Expand Down

0 comments on commit 56badfe

Please sign in to comment.