Этот коммит содержится в:
Mario Vitale
2023-03-27 16:28:42 +02:00
родитель da7a6825ce
Коммит ba6b97fb62
1142 изменённых файлов: 44 добавлений и 44 удалений

Просмотреть файл

@@ -0,0 +1,99 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
// ***************************************************************
// - [#] indicates a test step (e.g. #. Go to a page)
// - [*] indicates an assertion (e.g. * Check the title)
// - Use element ID when selecting an element. Create one if none.
// ***************************************************************
// Stage: @prod
// Group: @channels @enterprise @guest_account
/**
* Note: This test requires Enterprise license to be uploaded
*/
import {createPrivateChannel} from '../elasticsearch_autocomplete/helpers';
import * as TIMEOUTS from '../../../../fixtures/timeouts';
describe('Guest Account - Guest User Experience', () => {
let guestUser: Cypress.UserProfile;
let privateChannel: Cypress.Channel;
let testTeam: Cypress.Team;
before(() => {
// * Check if server has license for Guest Accounts
cy.apiRequireLicenseForFeature('GuestAccounts');
// # Enable GuestAccountSettings
cy.apiUpdateConfig({
GuestAccountsSettings: {
Enable: true,
},
ServiceSettings: {
EnableEmailInvitations: true,
},
});
// # Create User and Team
cy.apiInitSetup({userPrefix: 'guest'}).then(({user, team}) => {
guestUser = user;
testTeam = team;
});
});
it('MM-T1369 System message when user is added specifies the guest status', () => {
// # Demote Guest user if applicable
demoteGuestUser(guestUser);
// # Ceate a new team
cy.apiCreateTeam('test-team2', 'Test Team2').then(({team: teamTwo}) => {
// # Add the guest user to this team
cy.apiAddUserToTeam(teamTwo.id, guestUser.id).then(() => {
// # Login as guest user
cy.apiLogin(guestUser);
cy.reload();
});
});
// # Create Private Channel
createPrivateChannel(testTeam.id, guestUser).then((channel) => {
privateChannel = channel;
cy.visit(`/${testTeam.name}/channels/${privateChannel.name}`);
});
// * The system message should contain 'added to the channel as a guest'
cy.getLastPostId().then((id) => {
cy.get(`#postMessageText_${id}`).should('contain', `@${guestUser.username} added to the channel as a guest`);
});
});
it('MM-T1397 Guest tag in search in:', () => {
demoteGuestUser(guestUser);
cy.apiAdminLogin();
cy.visit(`/${testTeam.name}/channels/town-square`);
cy.sendDirectMessageToUser(guestUser, 'hello');
// # Search for the Guest User
cy.get('#searchBox').wait(TIMEOUTS.FIVE_SEC).type(`in:${guestUser.username}`);
// * Verify Guest Badge is not displayed at Search auto-complete
cy.get('#search-autocomplete__popover').should('be.visible');
cy.contains('.suggestion-list__item', guestUser.username).should('be.visible').within(($el) => {
cy.wrap($el).find('.Tag').should('not.exist');
});
});
});
function demoteGuestUser(guestUser) {
// # Demote user as guest user before each test
cy.apiAdminLogin();
cy.apiGetUserByEmail(guestUser.email).then(({user}) => {
if (user.roles !== 'system_guest') {
cy.apiDemoteUserToGuest(guestUser.id);
}
});
}

Просмотреть файл

@@ -0,0 +1,229 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
// ***************************************************************
// - [#] indicates a test step (e.g. #. Go to a page)
// - [*] indicates an assertion (e.g. * Check the title)
// - Use element ID when selecting an element. Create one if none.
// ***************************************************************
// Stage: @prod
// Group: @channels @enterprise @guest_account
/**
* Note: This test requires Enterprise license to be uploaded
*/
import * as TIMEOUTS from '../../../../fixtures/timeouts';
function demoteGuestUser(guestUser) {
// # Demote user as guest user before each test
cy.apiAdminLogin();
cy.apiGetUserByEmail(guestUser.email).then(({user}) => {
if (user.roles !== 'system_guest') {
cy.apiDemoteUserToGuest(guestUser.id);
}
});
}
describe('Guest Account - Guest User Experience', () => {
let guestUser: Cypress.UserProfile;
before(() => {
// * Check if server has license for Guest Accounts
cy.apiRequireLicenseForFeature('GuestAccounts');
// # Enable GuestAccountSettings
cy.apiUpdateConfig({
GuestAccountsSettings: {
Enable: true,
},
ServiceSettings: {
EnableEmailInvitations: true,
},
});
cy.apiInitSetup({userPrefix: 'guest'}).then(({user, team, channel}) => {
guestUser = user;
// # Create new team and visit its URL
cy.apiDemoteUserToGuest(user.id).then(() => {
cy.apiAddUserToTeam(team.id, guestUser.id).then(() => {
cy.apiAddUserToChannel(channel.id, guestUser.id).then(() => {
cy.apiLogin(guestUser);
cy.visit(`/${team.name}/channels/${channel.name}`);
});
});
});
});
});
it('MM-T1354 Verify Guest User Restrictions', () => {
// # Open team menu
cy.uiOpenTeamMenu();
// * Verify reduced options in Team Menu
const missingMainOptions = [
'Invite People',
'Team Settings',
'Manage Members',
'Join Another Team',
'Create a Team',
];
missingMainOptions.forEach((missingOption) => {
cy.uiGetLHSTeamMenu().should('not.contain', missingOption);
});
const includeMainOptions = [
'View Members',
'Leave Team',
];
includeMainOptions.forEach((includeOption) => {
cy.uiGetLHSTeamMenu().findByText(includeOption);
});
// * Verify Reduced Options in LHS
cy.uiGetLHSAddChannelButton().should('not.exist');
// * Verify Guest Badge in Channel Header
cy.get('#channelHeaderDescription').within(($el) => {
cy.wrap($el).find('.has-guest-header').should('be.visible').and('have.text', 'This channel has guests');
});
// * Verify list of Users in Direct Messages Dialog
cy.uiAddDirectMessage().click().wait(TIMEOUTS.FIVE_SEC);
cy.get('#multiSelectList').should('be.visible').within(($el) => {
// * Verify only 2 users - Guest and sysadmin are listed
cy.wrap($el).children().should('have.length', 2);
});
cy.uiClose();
// * Verify Guest Badge when guest user posts a message
cy.postMessage('testing');
cy.getLastPostId().then((postId) => {
cy.get(`#post_${postId}`).within(($el) => {
cy.wrap($el).find('.post__header .Tag').should('be.visible');
cy.wrap($el).find('.post__header .user-popover').should('be.visible').click().wait(TIMEOUTS.HALF_SEC);
});
});
// * Verify Guest Badge in Guest User's Profile Popover
cy.get('#user-profile-popover').should('be.visible').within(($el) => {
cy.wrap($el).find('.GuestTag').should('be.visible').and('have.text', 'GUEST');
});
// # Close the profile popover
cy.get('#channel-header').click();
// * Verify Guest User can see only 1 additional channel in LHS plus off-topic and off-topic
cy.uiGetLhsSection('CHANNELS').find('.SidebarChannel').should('have.length', 3);
// * Verify list of Users a Guest User can see in Team Members dialog
cy.uiOpenTeamMenu('View Members');
cy.get('#searchableUserListTotal').should('be.visible').and('have.text', '1 - 2 members of 2 total');
});
it('MM-18049 Verify Guest User Restrictions is removed when promoted', () => {
// # Promote a Guest user to a member and reload
cy.apiAdminLogin();
cy.apiPromoteGuestToUser(guestUser.id);
// # Login as guest user
cy.apiLogin(guestUser);
cy.reload();
// * Verify options in team menu are changed
cy.uiOpenTeamMenu();
const includeOptions = [
'Invite People',
'View Members',
'Leave Team',
'Create a Team',
];
includeOptions.forEach((option) => {
cy.uiGetLHSTeamMenu().findByText(option);
});
// # Close the main menu
cy.uiGetLHSHeader().click();
// * Verify Options in LHS are changed
cy.uiGetLHSAddChannelButton();
// * Verify Guest Badge in Channel Header is removed
cy.get('#sidebarItem_off-topic').click();
cy.get('#channelIntro').should('be.visible');
cy.get('#channelHeaderDescription').within(($el) => {
cy.wrap($el).find('.has-guest-header').should('not.exist');
});
// * Verify Guest Badge is removed when user posts a message
cy.get('#sidebarItem_off-topic').click({force: true});
cy.postMessage('testing');
cy.getLastPostId().then((postId) => {
cy.get(`#post_${postId}`).within(($el) => {
cy.wrap($el).find('.post__header .Tag').should('not.exist');
cy.wrap($el).find('.post__header .user-popover').should('be.visible').click().wait(TIMEOUTS.HALF_SEC);
});
});
// * Verify Guest Badge is not displayed in User's Profile Popover
cy.get('#user-profile-popover').should('be.visible').within(($el) => {
cy.wrap($el).find('.user-popover__role').should('not.exist');
});
// # Close the profile popover
cy.get('#channel-header').click();
});
it('MM-T1417 Add Guest User to New Team from System Console', () => {
// # Demote Guest user if applicable
demoteGuestUser(guestUser);
// # Create a new team
cy.apiCreateTeam('test-team2', 'Test Team2').then(({team: teamTwo}) => {
// # Add the guest user to this team
cy.apiAddUserToTeam(teamTwo.id, guestUser.id).then(() => {
// # Login as guest user
cy.apiLogin(guestUser);
cy.reload();
// # Click team button
cy.get(`#${teamTwo.name}TeamButton`, {timeout: TIMEOUTS.ONE_MIN}).should('be.visible').click();
// * Verify if Channel Not found is displayed
cy.findByText('Channel Not Found').should('be.visible');
cy.findByText('Your guest account has no channels assigned. Please contact an administrator.').should('be.visible');
cy.findByText('Back').should('be.visible').click();
// * Verify if user is redirected to a valid channel
cy.findByTestId('post_textbox').should('be.visible');
});
});
});
it('MM-T1412 Revoke Guest User Sessions when Guest feature is disabled', () => {
// # Demote Guest user if applicable
demoteGuestUser(guestUser);
// # Disable Guest Access
cy.apiUpdateConfig({
GuestAccountsSettings: {
Enable: false,
},
});
// # Wait for page to load and then logout
cy.uiGetPostTextBox().wait(TIMEOUTS.TWO_SEC);
cy.apiLogout();
cy.visit('/');
// # Login with guest user credentials and check the error message
cy.get('#input_loginId').type(guestUser.username);
cy.get('#input_password-input').type('passwd');
cy.get('#saveSetting').should('not.be.disabled').click();
// * Verify if guest account is deactivated
cy.findByText('Login failed because your account has been deactivated. Please contact an administrator.').should('be.visible');
});
});

Просмотреть файл

@@ -0,0 +1,91 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
// ***************************************************************
// - [#] indicates a test step (e.g. #. Go to a page)
// - [*] indicates an assertion (e.g. * Check the title)
// - Use element ID when selecting an element. Create one if none.
// ***************************************************************
// Stage: @prod
// Group: @channels @enterprise @guest_account
/**
* Note: This test requires Enterprise license to be uploaded
*/
describe('Guest Accounts', () => {
let guestUser: Cypress.UserProfile;
before(() => {
cy.apiRequireLicenseForFeature('GuestAccounts');
cy.apiCreateGuestUser({}).then(({guest}) => {
guestUser = guest;
});
});
it('MM-T1411 Update Guest Users in User Management when Guest feature is disabled', () => {
// # Navigate to Guest Access page.
cy.visit('/admin_console/authentication/guest_access');
// # Enable guest accounts.
cy.findByTestId('GuestAccountsSettings.Enabletrue').check();
// # Click "Save".
cy.get('#saveSetting').then((btn) => {
if (btn.is(':enabled')) {
btn.on('click', () => {});
cy.waitUntil(() => cy.get('#saveSetting').then((el) => {
return el[0].innerText === 'Save';
}));
}
});
// # Ensure there are active Guest users.
checkUserListStatus(guestUser, 'Guest');
// # Navigate to System Console ➜ Guest Access.
cy.visit('/admin_console/authentication/guest_access');
// # Set Enable Guest Access to false.
cy.findByTestId('GuestAccountsSettings.Enablefalse').check();
// # Click "Save".
cy.get('#saveSetting').scrollIntoView().click();
cy.get('#confirmModal').should('be.visible').within(() => {
cy.get('#confirmModalButton').should('have.text', 'Save and Disable Guest Access').click();
});
// * Guest users are shown as "Inactive".
checkUserListStatus(guestUser, 'Inactive');
// # Navigate to Guest Access page.
cy.visit('/admin_console/authentication/guest_access');
// # Enable guest accounts.
cy.findByTestId('GuestAccountsSettings.Enabletrue').check();
// # Click "Save".
cy.get('#saveSetting').scrollIntoView().click();
// * Guest users are shown as "Inactive".
checkUserListStatus(guestUser, 'Inactive');
});
function getInnerText(el) {
return el[0].innerText.replace(/\n/g, '').replace(/\s/g, ' ');
}
function checkUserListStatus(user, status) {
// # Go to System Console ➜ Users.
cy.visit('/admin_console/user_management/users');
cy.get('#searchUsers').should('be.visible').type(user.username);
cy.get('#selectUserStatus').select(status);
cy.get('.more-modal__details > .more-modal__name').should('be.visible').then((el) => {
expect(getInnerText(el)).contains(`@${user.username}`);
});
}
});

Просмотреть файл

@@ -0,0 +1,163 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
// ***************************************************************
// - [#] indicates a test step (e.g. #. Go to a page)
// - [*] indicates an assertion (e.g. * Check the title)
// - Use element ID when selecting an element. Create one if none.
// ***************************************************************
// Group: @channels @not_cloud @enterprise @guest_account @mfa
/**
* Note: This test requires Enterprise license to be uploaded
*/
import authenticator from 'authenticator';
import * as TIMEOUTS from '../../../../fixtures/timeouts';
import {
getJoinEmailTemplate,
getRandomId,
reUrl,
verifyEmailBody,
} from '../../../../utils';
describe('Guest Accounts', () => {
let sysadmin: Cypress.UserProfile;
let testTeam: Cypress.Team;
let testChannel: Cypress.Channel;
let adminMFASecret: string;
const username = 'g' + getRandomId(); // username has to start with a letter.
before(() => {
cy.shouldNotRunOnCloudEdition();
cy.apiRequireLicenseForFeature('GuestAccounts');
cy.apiInitSetup().then(({team, channel}) => {
testTeam = team;
testChannel = channel;
});
// # Log in as a team admin.
cy.apiAdminLogin().then((user) => {
sysadmin = user;
});
});
after(() => {
// # Login back as admin.
// cy.log("############################" + adminMFASecret)
const token = authenticator.generateToken(adminMFASecret);
cy.apiAdminLoginWithMFA(token);
// # Update Configs.
cy.apiUpdateConfig({
ServiceSettings: {
EnableMultifactorAuthentication: false,
EnforceMultifactorAuthentication: false,
},
GuestAccountsSettings: {
Enable: true,
EnforceMultifactorAuthentication: false,
},
});
});
it('MM-T1390 Enforce Guest MFA when MFA is enabled and enforced', () => {
// # Navigate to System Console -> Authentication -> MFA Page.
cy.visit('/admin_console/authentication/mfa');
// # Ensure the setting 'Enable Multi factor authentication' is set to true in the MFA page.
cy.findByTestId('ServiceSettings.EnableMultifactorAuthenticationtrue').check();
// # Also ensure that this MFA setting is enforced.
cy.findByTestId('ServiceSettings.EnforceMultifactorAuthenticationtrue').check();
// # Click "Save".
cy.findByText('Save').click().wait(TIMEOUTS.ONE_SEC);
// # Get MFA secret
cy.uiGetMFASecret(sysadmin.id).then((secret) => {
adminMFASecret = secret;
});
// # Navigate to Guest Access page.
cy.visit('/admin_console/authentication/guest_access');
// # Enable guest accounts.
cy.findByTestId('GuestAccountsSettings.Enabletrue').check();
// # Check if user is allowed to enforce MFA for Guest accounts.
cy.findByTestId('GuestAccountsSettings.EnforceMultifactorAuthenticationtrue').check();
// # Click "Save".
cy.get('#saveSetting').scrollIntoView().click();
const email = `${username}@sample.mattermost.com`;
// # From the main page, invite a Guest user and click on the Join Team in the email sent to the guest user.
cy.visit(`/${testTeam.name}/channels/town-square`);
// # Open team menu, click Invite People, then invite guest
cy.uiOpenTeamMenu('Invite People');
cy.findByTestId('inviteGuestLink').click();
// # Type guest user e-mail address.
cy.get('.users-emails-input__control').should('be.visible').within(() => {
cy.get('input').typeWithForce(email + '{enter}');
});
cy.get('.users-emails-input__menu').
children().should('have.length', 1).
eq(0).should('contain', `Invite ${email} as a guest`).click();
// # Search and add to a Channel.
cy.get('.channels-input__control').should('be.visible').within(() => {
cy.get('input').typeWithForce(testChannel.name);
});
cy.get('.channels-input__menu').
children().should('have.length', 1).
eq(0).should('contain', testChannel.name).click();
cy.get('#inviteGuestButton').scrollIntoView().click();
cy.findByTestId('confirm-done').should('be.visible').click();
// # Get invitation link.
cy.getRecentEmail({username, email}).then((data) => {
const {body: actualEmailBody, subject} = data;
// # Verify that the email subject is about joining.
expect(subject).to.contain(`${sysadmin.username} invited you to join the team ${testTeam.display_name} as a guest`);
const expectedEmailBody = getJoinEmailTemplate(sysadmin.username, email, testTeam, true);
verifyEmailBody(expectedEmailBody, actualEmailBody);
// # Extract invitation link from the invitation e-mail.
const invitationLink = actualEmailBody[3].match(reUrl)[0];
// # Logout sysadmin.
cy.apiLogout();
cy.visit(invitationLink);
});
// # Create an account with Email and Password.
cy.get('#input_name').type(username);
cy.get('#input_password-input').type(username);
cy.findByText('Create Account').click();
// * When MFA is enforced for Guest Access, guest user should be forced to configure MFA while creating an account.
cy.url().should('include', 'mfa/setup');
cy.get('#mfa').wait(TIMEOUTS.HALF_SEC).find('.col-sm-12').then((p) => {
const secretp = p.text();
const secret = secretp.split(' ')[1];
const token = authenticator.generateToken(secret);
cy.get('#mfa').find('.form-control').type(token);
cy.get('#mfa').find('.btn.btn-primary').click();
cy.wait(TIMEOUTS.ONE_SEC);
cy.get('#mfa').find('.btn.btn-primary').click();
});
cy.apiLogout();
});
});

Просмотреть файл

@@ -0,0 +1,69 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
// ***************************************************************
// - [#] indicates a test step (e.g. #. Go to a page)
// - [*] indicates an assertion (e.g. * Check the title)
// - Use element ID when selecting an element. Create one if none.
// ***************************************************************
// Stage: @prod
// Group: @channels @enterprise @guest_account @not_cloud
import * as TIMEOUTS from '../../../../fixtures/timeouts';
describe('Verify Guest User Identification in different screens', () => {
let guestUser: Cypress.UserProfile;
let testChannel: Cypress.Channel;
before(() => {
cy.shouldNotRunOnCloudEdition();
// * Check if server has license for Guest Accounts
cy.apiRequireLicenseForFeature('GuestAccounts');
// # Enable GuestAccountSettings
cy.apiUpdateConfig({
GuestAccountsSettings: {
Enable: true,
},
ServiceSettings: {
EnableEmailInvitations: true,
},
});
cy.apiInitSetup().then(({team, channel, user}) => {
testChannel = channel;
cy.apiCreateGuestUser({}).then(({guest}) => {
guestUser = guest;
cy.apiAddUserToTeam(team.id, guest.id).then(() => {
cy.apiAddUserToChannel(channel.id, guest.id);
});
});
// # Login as regular user and visit the channel with guest
cy.apiLogin(user);
cy.visit(`/${team.name}/channels/${channel.name}`);
});
});
it('MM-T1419 Deactivating a Guest removes "This channel has guests" message from channel header', () => {
// * Verify the text 'This channel has guests' is displayed in the header
cy.get('#channelHeaderDescription').within(($el) => {
cy.wrap($el).find('.has-guest-header').should('be.visible').and('have.text', 'This channel has guests');
});
// # Deactivate Guest user
cy.externalActivateUser(guestUser.id, false).wait(TIMEOUTS.FIVE_SEC);
// # Switch channels away and back to reload the header
cy.get('.SidebarChannel:contains(Town Square)').click();
cy.get(`.SidebarChannel:contains(${testChannel.display_name})`).click();
// * Verify the text 'This channel has guests' is removed from the header
cy.get('#channelHeaderDescription').within(($el) => {
cy.wrap($el).find('.has-guest-header').should('not.exist');
});
});
});

Просмотреть файл

@@ -0,0 +1,225 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
// ***************************************************************
// - [#] indicates a test step (e.g. #. Go to a page)
// - [*] indicates an assertion (e.g. * Check the title)
// - Use element ID when selecting an element. Create one if none.
// ***************************************************************
// Stage: @prod
// Group: @channels @enterprise @guest_account
/**
* Note: This test requires Enterprise license to be uploaded
*/
import dayjs from 'dayjs';
import * as TIMEOUTS from '../../../../fixtures/timeouts';
import {getAdminAccount} from '../../../../support/env';
describe('Verify Guest User Identification in different screens', () => {
const admin = getAdminAccount();
let regularUser: Cypress.UserProfile;
let guestUser: Cypress.UserProfile;
let testTeam: Cypress.Team;
let testChannel: Cypress.Channel;
before(() => {
// * Check if server has license for Guest Accounts
cy.apiRequireLicenseForFeature('GuestAccounts');
// # Enable GuestAccountSettings
cy.apiUpdateConfig({
GuestAccountsSettings: {
Enable: true,
},
ServiceSettings: {
EnableEmailInvitations: true,
},
});
cy.apiInitSetup().then(({team, channel, user}) => {
regularUser = user;
testTeam = team;
testChannel = channel;
cy.apiCreateGuestUser({}).then(({guest}) => {
guestUser = guest;
cy.apiAddUserToTeam(testTeam.id, guestUser.id).then(() => {
cy.apiAddUserToChannel(testChannel.id, guestUser.id);
});
});
// # Login as regular user and visit test channel
cy.apiLogin(regularUser);
cy.visit(`/${team.name}/channels/${testChannel.name}`);
});
});
it('MM-T1370 Verify Guest Badge in Channel Members dropdown and dialog', () => {
// # Open Channel Members RHS
cy.get('#channelHeaderDropdownIcon').click();
cy.get('#channelManageMembers').click().wait(TIMEOUTS.HALF_SEC);
cy.uiGetRHS().findByTestId(`memberline-${guestUser.id}`).within(($el) => {
cy.wrap($el).get('.Tag').should('be.visible').should('have.text', 'GUEST');
});
});
it('Verify Guest Badge in Team Members dialog', () => {
// # Open team menu and click 'View Members'
cy.uiOpenTeamMenu('View Members');
cy.get('#teamMembersModal').should('be.visible').within(($el) => {
cy.wrap($el).findAllByTestId('userListItemDetails').each(($elChild) => {
cy.wrap($elChild).invoke('text').then((username) => {
// * Verify Guest Badge in Channel Members List
if (username === guestUser.username) {
cy.wrap($elChild).find('.Tag').should('be.visible').and('have.text', 'GUEST');
}
});
});
// #Close Channel Members Dialog
cy.wrap($el).find('.close').click();
});
});
it('MM-T1372 Verify Guest Badge in Posts in Center Channel, RHS and User Profile Popovers', () => {
cy.visit(`/${testTeam.name}/channels/${testChannel.name}`);
// # Get yesterdays date in UTC
const yesterdaysDate = dayjs().subtract(1, 'days').valueOf();
// # Post a day old message
cy.postMessageAs({sender: guestUser, message: 'Hello from yesterday', channelId: testChannel.id, createAt: yesterdaysDate}).
its('id').
should('exist').
as('yesterdaysPost');
// * Verify Guest Badge when guest user posts a message in Center Channel
cy.get('@yesterdaysPost').then((postId) => {
cy.get(`#post_${postId}`).within(($el) => {
cy.wrap($el).find('.post__header .Tag').should('be.visible');
cy.wrap($el).find('.post__header .user-popover').should('be.visible').click().wait(TIMEOUTS.HALF_SEC);
});
});
// * Verify Guest Badge in Guest User's Profile Popover
cy.get('#user-profile-popover').should('be.visible').within(($el) => {
cy.wrap($el).find('.GuestTag').should('be.visible').and('have.text', 'GUEST');
});
// # Close the profile popover
cy.get('#channel-header').click();
// # Open RHS comment menu
cy.get('@yesterdaysPost').then((postId) => {
cy.clickPostCommentIcon(postId.toString());
// * Verify Guest Badge in RHS
cy.get(`#rhsPost_${postId}`).within(($el) => {
cy.wrap($el).find('.post__header .Tag').should('be.visible');
});
// # Close RHS
cy.uiCloseRHS();
});
});
it('Verify Guest Badge in Switch Channel Dialog', () => {
// # Open Find Channels
cy.uiOpenFindChannels();
// # Type the guest user name on Channel switcher input
cy.findByRole('textbox', {name: 'quick switch input'}).type(guestUser.username).wait(TIMEOUTS.HALF_SEC);
// * Verify if Guest badge is displayed for the guest user in the Switch Channel Dialog
cy.get('#suggestionList').should('be.visible');
cy.findByTestId(guestUser.username).within(($el) => {
cy.wrap($el).find('.Tag').should('be.visible').and('have.text', 'GUEST');
});
// # Close Dialog
cy.get('#quickSwitchModalLabel > .close').click();
});
it('MM-T1377 Verify Guest Badge in DM Search dialog', () => {
// #Click on plus icon of Direct Messages
cy.uiAddDirectMessage().click().wait(TIMEOUTS.HALF_SEC);
// # Search for the Guest User
cy.focused().type(guestUser.username, {force: true}).wait(TIMEOUTS.HALF_SEC);
cy.get('#multiSelectList').should('be.visible').within(($el) => {
// * Verify if Guest badge is displayed in the DM Search
cy.wrap($el).find('.Tag').should('be.visible').and('have.text', 'GUEST');
});
// # Close the Direct Messages dialog
cy.get('#moreDmModal .close').click();
});
it('Verify Guest Badge in DM header and GM header', () => {
// # Open a DM with Guest User
cy.uiAddDirectMessage().click();
cy.findByRole('dialog', {name: 'Direct Messages'}).should('be.visible').wait(TIMEOUTS.ONE_SEC);
cy.findByRole('textbox', {name: 'Search for people'}).
should('have.focused').
typeWithForce(guestUser.username).
wait(TIMEOUTS.ONE_SEC).
typeWithForce('{enter}');
cy.uiGetButton('Go').click().wait(TIMEOUTS.HALF_SEC);
// * Verify Guest Badge in DM header
cy.get('#channelHeaderTitle').should('be.visible').find('.Tag').should('be.visible').and('have.text', 'GUEST');
cy.get('#channelHeaderDescription').within(($el) => {
cy.wrap($el).find('.has-guest-header').should('be.visible').and('have.text', 'This channel has guests');
});
// # Open a GM with Guest User and Sysadmin
cy.uiAddDirectMessage().click();
cy.findByRole('dialog', {name: 'Direct Messages'}).should('be.visible').wait(TIMEOUTS.ONE_SEC);
cy.findByRole('textbox', {name: 'Search for people'}).
should('have.focused').
typeWithForce(guestUser.username).
wait(TIMEOUTS.ONE_SEC).
typeWithForce('{enter}');
cy.findByRole('textbox', {name: 'Search for people'}).
should('have.focused').
typeWithForce(admin.username).
wait(TIMEOUTS.ONE_SEC).
typeWithForce('{enter}');
cy.uiGetButton('Go').click().wait(TIMEOUTS.HALF_SEC);
// * Verify Guest Badge in GM header
cy.get('#channelHeaderTitle').should('be.visible').find('.Tag').should('be.visible').and('have.text', 'GUEST');
cy.get('#channelHeaderDescription').within(($el) => {
cy.wrap($el).find('.has-guest-header').should('be.visible').and('have.text', 'This group message has guests');
});
});
it('Verify Guest Badge in @mentions Autocomplete', () => {
// # Start a draft in Channel containing "@user"
cy.uiGetPostTextBox().type(`@${guestUser.username}`);
// * Verify Guest Badge is displayed at mention auto-complete
cy.get('#suggestionList').should('be.visible');
cy.findByTestId(`mentionSuggestion_${guestUser.username}`).within(($el) => {
cy.wrap($el).find('.Tag').should('be.visible').and('have.text', 'GUEST');
});
});
it('Verify Guest Badge not displayed in Search Autocomplete', () => {
// # Search for the Guest User
cy.get('#searchBox').type('from:');
// * Verify Guest Badge is not displayed at Search auto-complete
cy.get('#search-autocomplete__popover').should('be.visible');
cy.contains('.suggestion-list__item', guestUser.username).scrollIntoView().should('be.visible').within(($el) => {
cy.wrap($el).find('.Tag').should('not.exist');
});
// # Close and Clear the Search Autocomplete
cy.get('#searchFormContainer').find('.input-clear-x').click({force: true});
});
});

Просмотреть файл

@@ -0,0 +1,146 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
// ***************************************************************
// - [#] indicates a test step (e.g. #. Go to a page)
// - [*] indicates an assertion (e.g. * Check the title)
// - Use element ID when selecting an element. Create one if none.
// ***************************************************************
// Stage: @prod
// Group: @channels @enterprise @guest_account
/**
* Note: This test requires Enterprise license to be uploaded
*/
import {getRandomId} from '../../../../utils';
import * as TIMEOUTS from '../../../../fixtures/timeouts';
import {
changeGuestFeatureSettings,
invitePeople,
verifyInvitationError,
verifyInvitationSuccess,
} from './helpers';
describe('Guest Account - Guest User Invitation Flow', () => {
let testTeam: Cypress.Team;
before(() => {
// * Check if server has license for Guest Accounts
cy.apiRequireLicenseForFeature('GuestAccounts');
});
beforeEach(() => {
// # Login as sysadmin
cy.apiAdminLogin();
// # Reset Guest Feature settings
changeGuestFeatureSettings();
cy.apiInitSetup().then(({team}) => {
testTeam = team;
// # Go to town square
cy.visit(`/${team.name}/channels/town-square`);
});
});
it('MM-T1336 Invite Guests - Existing Team Member', () => {
cy.apiCreateUser().then(({user: newUser}) => {
cy.apiAddUserToTeam(testTeam.id, newUser.id).then(() => {
// # Search and add an existing member by username who is part of the team
invitePeople(newUser.username, 1, newUser.username);
// * Verify the content and message in next screen
verifyInvitationError(newUser.username, testTeam, 'This person is already a member.');
});
});
});
it('MM-T1337 Invite Guests - Existing Team Guest', () => {
cy.apiCreateGuestUser({}).then(({guest}) => {
cy.apiAddUserToTeam(testTeam.id, guest.id).then(() => {
// # Search and add an existing guest by first name, who is part of the team but not channel
invitePeople(guest.first_name, 1, guest.username, 'Off-Topic');
// * Verify the content and message in next screen
verifyInvitationSuccess(guest.username, testTeam, 'This guest has been added to the team and channel.');
// # Search and add an existing guest by last name, who is part of the team and channel
invitePeople(guest.last_name, 1, guest.username, 'Off-Topic');
// * Verify the content and message in next screen
verifyInvitationError(guest.username, testTeam, 'This person is already a member of all the channels.', true);
});
});
});
it('MM-T1338 Invite Guests - Existing Member not on the team', () => {
cy.apiCreateUser().then(({user: regularUser}) => {
// # Search and add an existing member by email who is not part of the team
invitePeople(regularUser.email, 1, regularUser.username);
// * Verify the content and message in next screen
verifyInvitationError(regularUser.username, testTeam, 'This person is already a member.');
});
});
it('MM-T1339 Invite Guests - Existing Guest not on the team', () => {
// # Search and add an existing guest by email, who is not part of the team
cy.apiCreateGuestUser({}).then(({guest}) => {
invitePeople(guest.email, 1, guest.username);
verifyInvitationSuccess(guest.username, testTeam, 'This guest has been added to the team and channel.', true);
});
});
it('MM-T1340 Invite Guests - New User not in the system', () => {
// # Search and add a new guest by email, who is not part of the team
const email = `temp-${getRandomId()}@mattermost.com`;
invitePeople(email, 1, email);
// * Verify the content and message in next screen
verifyInvitationSuccess(email, testTeam, 'An invitation email has been sent.');
});
it('MM-T1394 Change Email not whitelisted for Guest user', () => {
// # Configure a whitelisted domain
changeGuestFeatureSettings(true, true, 'example.com');
// # Visit to newly created team
cy.reload();
cy.visit(`/${testTeam.name}/channels/town-square`);
// # Invite a Guest by email
const email = `temp-${getRandomId()}@mattermost.com`;
invitePeople(email, 1, email);
// * Verify the content and message in next screen
const expectedError = `The following email addresses do not belong to an accepted domain: ${email}. Please contact your System Administrator for details.`;
verifyInvitationError(email, testTeam, expectedError);
// # From System Console try to update email of guest user
cy.apiCreateGuestUser({}).then(({guest}) => {
// # Navigate to System Console Users listing page
cy.visit('/admin_console/user_management/users');
// # Search for User by username and select the option to update email
cy.get('#searchUsers').should('be.visible').type(guest.username);
// # Click on the option to update email
cy.wait(TIMEOUTS.HALF_SEC);
cy.findByTestId('userListRow').find('.MenuWrapper a').should('be.visible').click();
cy.findByText('Update Email').should('be.visible').click();
// * Update email outside whitelisted domain and verify error message
cy.findByTestId('resetEmailModal').should('be.visible').within(() => {
cy.findByTestId('resetEmailForm').should('be.visible').get('input').type(email);
cy.findByTestId('resetEmailButton').click();
cy.get('.error').should('be.visible').and('have.text', 'The email you provided does not belong to an accepted domain for guest accounts. Please contact your administrator or sign up with a different email.');
cy.get('.close').click();
});
});
});
});

Просмотреть файл

@@ -0,0 +1,226 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
// ***************************************************************
// - [#] indicates a test step (e.g. #. Go to a page)
// - [*] indicates an assertion (e.g. * Check the title)
// - Use element ID when selecting an element. Create one if none.
// ***************************************************************
// Stage: @prod
// Group: @channels @enterprise @guest_account
/**
* Note: This test requires Enterprise license to be uploaded
*/
import {getRandomId} from '../../../../utils';
import {
changeGuestFeatureSettings,
invitePeople,
verifyInvitationSuccess,
} from './helpers';
describe('Guest Account - Guest User Invitation Flow', () => {
let testTeam: Cypress.Team;
let newUser: Cypress.UserProfile;
before(() => {
// * Check if server has license for Guest Accounts
cy.apiRequireLicenseForFeature('GuestAccounts');
});
beforeEach(() => {
// # Login as sysadmin
cy.apiAdminLogin();
// # Reset Guest Feature settings
changeGuestFeatureSettings();
cy.apiInitSetup().then(({team}) => {
testTeam = team;
cy.apiCreateUser().then(({user}) => {
newUser = user;
cy.apiAddUserToTeam(testTeam.id, newUser.id);
});
// # Go to town square
cy.visit(`/${team.name}/channels/town-square`);
});
});
it('MM-T4451 Verify UI Elements of Guest User Invitation Flow', () => {
// # Open team menu and click 'Invite People'
cy.uiOpenTeamMenu('Invite People');
// * Verify Invite Guest link
cy.findByTestId('inviteGuestLink').should('be.visible').click();
cy.findByText('Add to channels').should('be.visible');
// * Verify the header has changed in the modal
cy.findByTestId('invitationModal').within(() => {
cy.get('h1').should('have.text', `Invite guests to ${testTeam.display_name}`);
});
// * Verify Invite Guests button is disabled by default
cy.get('#inviteGuestButton').scrollIntoView().should('be.visible').and('be.disabled');
// * Verify Invite People field
const email = `temp-${getRandomId()}@mattermost.com`;
cy.get('.users-emails-input__control').should('be.visible').within(() => {
// * Verify the input placeholder text
cy.get('.users-emails-input__placeholder').should('have.text', 'Enter a name or email address');
// # Type the email of the new user
cy.get('input').typeWithForce(email);
});
cy.get('.users-emails-input__menu').
children().should('have.length', 1).
eq(0).should('contain', `Invite ${email} as a guest`).click();
cy.get('.channels-input__control').should('be.visible').within(() => {
// * Verify the input placeholder text
cy.get('.channels-input__placeholder').should('have.text', 'e.g. Town Square');
// # Type the channel name
cy.get('input').typeWithForce('town sq');
});
cy.get('.channels-input__menu').
children().should('have.length', 1).
eq(0).should('contain', 'Town Square').click();
// * Verify Set Custom Message before clicking on the link
cy.get('.AddToChannels').should('be.visible').within(() => {
cy.get('textarea').should('not.exist');
// #Verify link text and click on it
cy.get('a').should('have.text', 'Set a custom message').click();
});
// * Verify Set Custom Message after clicking on the link
cy.get('.AddToChannels').should('be.visible').within(() => {
cy.get('a').should('not.exist');
cy.get('.AddToChannels__customMessageTitle').findByText('Custom message');
cy.get('textarea').should('be.visible');
});
});
it('MM-T1386 Verify when different feature settings are disabled', () => {
// # Disable Guest Accounts
// # Enable Email Invitations
changeGuestFeatureSettings(false, true);
// # reload current page
cy.visit(`/${testTeam.name}/channels/town-square`);
// # Open team menu and click 'Invite People'
cy.uiOpenTeamMenu('Invite People');
// * Verify if Invite Members modal is displayed when guest account feature is disabled
cy.findByTestId('invitationModal').find('h1').should('have.text', `Invite people to ${testTeam.display_name}`);
// * Verify Share Link Header and helper text
cy.findByTestId('InviteView__copyInviteLink').should('be.visible').within(() => {
cy.findByText('Copy invite link').should('be.visible');
});
// # Close the Modal
cy.get('#closeIcon').should('be.visible').click();
// # Enable Guest Accounts
// # Disable Email Invitations
changeGuestFeatureSettings(true, false);
// # Reload the current page
cy.reload();
const email = `temp-${getRandomId()}@mattermost.com`;
invitePeople(email, 1, email, 'Town Square', false);
// * Verify Invite Guests button is disabled
cy.get('#inviteGuestButton').should('be.disabled');
});
it('MM-T4449 Invite Guest via Email containing upper case letters', () => {
// # Reset Guest Feature settings
changeGuestFeatureSettings();
// # Visit Team page
cy.visit(`/${testTeam.name}/channels/town-square`);
// # Invite a email containing uppercase letters
const email = `tEMp-${getRandomId()}@mattermost.com`;
invitePeople(email, 1, email);
// * Verify the content and message in next screen
verifyInvitationSuccess(email.toLowerCase(), testTeam, 'An invitation email has been sent.');
});
it('MM-T1414 Add Guest from Add New Members dialog', () => {
// # Demote the user from member to guest
cy.apiDemoteUserToGuest(newUser.id);
// # Open team menu and click 'Invite People'
cy.uiOpenTeamMenu('Invite People');
// # Click invite members if needed
cy.get('.InviteAs').findByTestId('inviteMembersLink').click();
// # Search and add a member
cy.get('.users-emails-input__control').should('be.visible').within(() => {
cy.get('input').typeWithForce(newUser.username);
});
cy.get('.users-emails-input__menu').
children().should('have.length', 1).eq(0).should('contain', newUser.username).click();
// # Click Invite Members
cy.get('#inviteMembersButton').scrollIntoView().click();
// * Verify the content and error message in the Invitation Modal
cy.findByTestId('invitationModal').within(() => {
cy.get('div.invitation-modal-confirm--sent').should('not.exist');
cy.get('div.invitation-modal-confirm--not-sent').should('be.visible').within(() => {
cy.get('h2 > span').should('have.text', 'Invitations Not Sent');
cy.get('.people-header').should('have.text', 'People');
cy.get('.details-header').should('have.text', 'Details');
cy.get('.username-or-icon').should('contain', newUser.username);
cy.get('.reason').should('have.text', 'Contact your admin to make this guest a full member.');
cy.get('.username-or-icon .Tag').should('be.visible').and('have.text', 'GUEST');
});
});
});
it('MM-T1415 Check invite more button available on both successful and failed invites', () => {
// # Search and add an existing member by username who is part of the team
invitePeople(newUser.username, 1, newUser.username);
// * Verify the content and message in next screen
cy.findByText('This person is already a member.').should('be.visible');
// # Click on invite more button
cy.findByTestId('invite-more').click();
// * Verify the channel is preselected
cy.get('.channels-input__control').should('be.visible').within(() => {
cy.get('.public-channel-icon').should('be.visible');
cy.findByText('Town Square').should('be.visible');
});
// * Verify the email field is empty
const email = `temp-${getRandomId()}@mattermost.com`;
cy.get('.users-emails-input__control').should('be.visible').within(() => {
cy.get('.users-emails-input__multi-value').should('not.exist');
cy.get('input').typeWithForce(email);
});
cy.get('.users-emails-input__menu').children().should('have.length', 1).eq(0).should('contain', email).click();
// # Click Invite Guests Button
cy.get('#inviteGuestButton').scrollIntoView().click();
// * Verify invite more button is present
cy.findByTestId('invite-more').should('be.visible');
});
});

Просмотреть файл

@@ -0,0 +1,73 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
// ***************************************************************
// - [#] indicates a test step (e.g. #. Go to a page)
// - [*] indicates an assertion (e.g. * Check the title)
// - Use element ID when selecting an element. Create one if none.
// ***************************************************************
// Group: @channels @enterprise @guest_account
/**
* Note: This test requires Enterprise license to be uploaded
*/
import * as TIMEOUTS from '../../../../fixtures/timeouts';
describe('Guest Account - Guest User Badge and Popover', () => {
let regularUser: Cypress.UserProfile;
let guestUser: Cypress.UserProfile;
let testTeam: Cypress.Team;
let testChannel: Cypress.Channel;
before(() => {
// * Check if server has license for Guest Accounts
cy.apiRequireLicenseForFeature('GuestAccounts');
// # Enable GuestAccountSettings
cy.apiUpdateConfig({
GuestAccountsSettings: {
Enable: true,
},
ServiceSettings: {
EnableEmailInvitations: true,
},
});
cy.apiInitSetup().then(({team, channel, user}) => {
regularUser = user;
testTeam = team;
testChannel = channel;
cy.apiCreateGuestUser({}).then(({guest}) => {
guestUser = guest;
cy.log(`Guest Id: ${guestUser.id}`);
cy.log(`Guest Username ${guestUser.username}`);
cy.apiAddUserToTeam(testTeam.id, guestUser.id).then(() => {
cy.apiAddUserToChannel(testChannel.id, guestUser.id);
});
});
// # Login as regular user and go to town square
cy.apiLogin(regularUser);
cy.visit(`/${team.name}/channels/${testChannel.name}`);
});
});
it('MM-T1371 User profile popover shows guest badge', () => {
// # Post a day old message
cy.postMessageAs({sender: guestUser, message: 'Hello from yesterday', channelId: testChannel.id}).
its('id').
should('exist').
as('yesterdaysPost');
// * Verify Guest Badge when guest user posts a message in Center Channel
cy.get('@yesterdaysPost').then((postId) => {
cy.get(`#post_${postId}`).within(($el) => {
cy.wrap($el).find('.post__header .Tag').should('be.visible');
cy.wrap($el).find('.post__header .user-popover').should('be.visible').click().wait(TIMEOUTS.HALF_SEC);
});
});
});
});

Просмотреть файл

@@ -0,0 +1,106 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
// ***************************************************************
// - [#] indicates a test step (e.g. #. Go to a page)
// - [*] indicates an assertion (e.g. * Check the title)
// - Use element ID when selecting an element. Create one if none.
// ***************************************************************
// Stage: @prod
// Group: @channels @enterprise @guest_account
/**
* Note: This test requires Enterprise license to be uploaded
*/
import * as TIMEOUTS from '../../../../fixtures/timeouts';
function removeUserFromAllChannels(verifyAlert, user) {
// # Remove the Guest user from all channels of a team as a sysadmin
const channels = ['Town Square', 'Off-Topic'];
// # Always click on the Town Square channel first
cy.get('#sidebarItem_town-square').click({force: true});
channels.forEach((channel) => {
// # Remove the Guest User from channel
cy.getCurrentChannelId().then((channelId) => {
cy.removeUserFromChannel(channelId, user.id);
});
// * Verify if guest user gets a message when the channel is removed. Does not appears when removed from last channel of the last team
if (channel === 'Town Square' || verifyAlert) {
cy.get('#removeFromChannelModalLabel').should('be.visible').and('have.text', `Removed from ${channel}`);
cy.get('.modal-body').should('be.visible').contains(`removed you from ${channel}`);
cy.get('#removedChannelBtn').should('be.visible').and('have.text', 'Okay').click().wait(TIMEOUTS.HALF_SEC);
}
});
}
describe('Guest Account - Guest User Removal Experience', () => {
let team1: Cypress.Team;
let team2: Cypress.Team;
let guest: Cypress.UserProfile;
before(() => {
// * Check if server has license for Guest Accounts
cy.apiRequireLicenseForFeature('GuestAccounts');
cy.apiInitSetup().then(({team}) => {
team1 = team;
// # Create new team and visit its URL
cy.apiCreateTeam('test-team2', 'Test Team2').then(({team}) => {
team2 = team;
cy.apiCreateUser().then(({user}) => {
guest = user;
cy.apiAddUserToTeam(team1.id, guest.id);
cy.apiAddUserToTeam(team2.id, guest.id).then(() => {
cy.apiLogin(guest);
cy.visit(`/${team2.name}/channels/town-square`);
});
});
});
});
});
it('MM-T1360 Taken to login screen when removed from last channel', () => {
// # Demote the current member to a guest user
cy.apiAdminLogin();
cy.apiDemoteUserToGuest(guest.id);
// # Login as guest user
cy.apiLogin(guest);
cy.reload();
// * Verify team Sidebar is visible
cy.get('#teamSidebarWrapper').should('be.visible');
// # Remove User from all the channels of the team as a sysadmin
removeUserFromAllChannels(true, guest);
// * Verify if user is automatically redirected to the other team
cy.url().should('include', team1.name);
// * Verify team Sidebar is not present
cy.get('#teamSidebarWrapper').should('not.exist');
// // # Remove User from all the channels of the team as a sysadmin
removeUserFromAllChannels(false, guest);
// * Verify if the user is redirected to the Select Team page
cy.url().should('include', '/select_team');
cy.get('.signup__content').should('be.visible').and('have.text', 'Your guest account has no channels assigned. Please contact an administrator.');
// Login as sysadmin and verify test team 2
cy.apiAdminLogin();
cy.reload().visit(`/${team2.name}/channels/town-square`);
// * Verify if status is displayed indicating guest user is removed from the channel
cy.getLastPost().
should('contain', 'System').
and('contain', `You and @${guest.username} joined the team.`).
and('contain', `@${guest.username} was removed from the channel.`);
});
});

Просмотреть файл

@@ -0,0 +1,93 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
export function changeGuestFeatureSettings(featureFlag = true, emailInvitation = true, whitelistedDomains = '') {
// # Update Guest Accounts, Email Invitations, and Whitelisted Domains
cy.apiUpdateConfig({
GuestAccountsSettings: {
Enable: featureFlag,
RestrictCreationToDomains: whitelistedDomains,
},
ServiceSettings: {
EnableEmailInvitations: emailInvitation,
},
});
}
export function invitePeople(typeText: string, resultsCount: number, verifyText: string, channelName = 'Town Square', clickInvite = true) {
// # Open team menu and click 'Invite People'
cy.uiOpenTeamMenu('Invite People');
// # Click on the next icon to invite guest
cy.findByTestId('inviteGuestLink').click();
// # Search and add a user
cy.get('.users-emails-input__control').should('be.visible').within(() => {
cy.get('input').typeWithForce(typeText);
});
cy.get('.users-emails-input__menu').
children().should('have.length', resultsCount).eq(0).should('contain', verifyText).click();
// # Search and add a Channel
cy.get('.channels-input__control').should('be.visible').within(() => {
cy.get('input').typeWithForce(channelName);
});
cy.get('.channels-input__menu').
children().should('have.length', 1).
eq(0).should('contain', channelName).click();
if (clickInvite) {
// # Click Invite Guests Button
cy.get('#inviteGuestButton').scrollIntoView().click();
}
}
export function verifyInvitationError(user: string, team: Cypress.Team, errorText: string, verifyGuestBadge = false) {
// * Verify the content and error message in the Invitation Modal
cy.findByTestId('invitationModal').within(() => {
cy.get('h1').should('have.text', `Guests invited to ${team.display_name}`);
cy.get('div.invitation-modal-confirm--sent').should('not.exist');
cy.get('div.invitation-modal-confirm--not-sent').should('be.visible').within(() => {
cy.get('h2 > span').should('have.text', 'Invitations Not Sent');
cy.get('.people-header').should('have.text', 'People');
cy.get('.details-header').should('have.text', 'Details');
cy.get('.username-or-icon').should('contain', user);
cy.get('.reason').should('have.text', errorText);
if (verifyGuestBadge) {
cy.get('.username-or-icon .Tag').should('be.visible').and('have.text', 'GUEST');
}
});
cy.findByTestId('confirm-done').should('be.visible').and('not.be.disabled').click();
});
// * Verify if Invitation Modal was closed
cy.get('.InvitationModal').should('not.exist');
}
export function verifyInvitationSuccess(user: string, team: Cypress.Team, successText: string, verifyGuestBadge = false) {
// * Verify the content and success message in the Invitation Modal
cy.findByTestId('invitationModal').within(() => {
cy.get('h1').should('have.text', `Guests invited to ${team.display_name}`);
cy.get('div.invitation-modal-confirm--not-sent').should('not.exist');
cy.get('div.invitation-modal-confirm--sent').should('be.visible').within(() => {
cy.get('h2 > span').should('have.text', 'Successful Invites');
cy.get('.people-header').should('have.text', 'People');
cy.get('.details-header').should('have.text', 'Details');
cy.get('.username-or-icon').should('contain', user);
cy.get('.reason').should('have.text', successText);
if (verifyGuestBadge) {
cy.get('.username-or-icon .Tag').should('be.visible').and('have.text', 'GUEST');
}
});
cy.findByTestId('confirm-done').should('be.visible').and('not.be.disabled').click();
});
// * Verify if Invitation Modal was closed
cy.get('.InvitationModal').should('not.exist');
}
export function verifyGuest(userStatus = 'Guest ') {
// * Verify if Guest User is displayed
cy.findAllByTestId('userListRow').should('have.length', 1);
cy.findByTestId('userListRow').find('.MenuWrapper a').should('be.visible').and('have.text', userStatus);
}

Просмотреть файл

@@ -0,0 +1,320 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
// ***************************************************************
// - [#] indicates a test step (e.g. # Go to a page)
// - [*] indicates an assertion (e.g. * Check the title)
// - Use element ID when selecting an element. Create one if none.
// ***************************************************************
// Group: @channels @enterprise @guest_account
/**
* Note: This test requires Enterprise license to be uploaded
*/
import {getRandomId, stubClipboard} from '../../../../utils';
import {getAdminAccount} from '../../../../support/env';
import * as TIMEOUTS from '../../../../fixtures/timeouts';
describe('Guest Account - Member Invitation Flow', () => {
const sysadmin = getAdminAccount();
let testTeam: Cypress.Team;
let testUser: Cypress.UserProfile;
beforeEach(() => {
// # Login as sysadmin
cy.apiAdminLogin();
// * Check if server has license for Guest Accounts
cy.apiRequireLicenseForFeature('GuestAccounts');
// # Enable GuestAccountSettings
cy.apiUpdateConfig({
GuestAccountsSettings: {
Enable: true,
},
ServiceSettings: {
EnableEmailInvitations: true,
},
});
cy.apiInitSetup().then(({team, user}) => {
testUser = user;
testTeam = team;
// # Go to town square
cy.visit(`/${testTeam.name}/channels/town-square`);
});
});
it('MM-T1323 Verify UI Elements of Members Invitation Flow - Accessing Invite People', () => {
const email = `temp-${getRandomId()}@mattermost.com`;
// # Open team menu and click 'Invite People'
cy.uiOpenTeamMenu('Invite People');
// * Verify UI Elements in initial step
cy.findByTestId('invitationModal').within(() => {
cy.get('h1').should('have.text', `Invite people to ${testTeam.display_name}`);
});
stubClipboard().as('clipboard');
// * Verify share link button
cy.findByTestId('InviteView__copyInviteLink').should('be.visible').should('have.text', 'Copy invite link').click();
// * Verify share link url
const baseUrl = Cypress.config('baseUrl');
cy.get('@clipboard').its('contents').should('eq', `${baseUrl}/signup_user_complete/?id=${testTeam.invite_id}`);
cy.get('#inviteMembersButton').scrollIntoView().should('be.visible').and('be.disabled');
cy.get('.users-emails-input__control').should('be.visible').within(() => {
// * Verify the input placeholder text
cy.get('.users-emails-input__placeholder').should('have.text', 'Enter a name or email address');
// # Type the email of the new user
cy.get('input').typeWithForce(email);
});
cy.get('.users-emails-input__menu').
children().should('have.length', 1).
eq(0).should('contain', `Invite ${email} as a team member`).click();
// * Verify the clicking the close icon closes the modal
cy.get('#closeIcon').should('be.visible').click();
cy.get('.InvitationModal').should('not.exist');
});
it('MM-T1324 Invite Members - Team Link - New User', () => {
// # Wait for page to load and then logout. Else invite members link will be redirected to login page
cy.uiGetPostTextBox().wait(TIMEOUTS.TWO_SEC);
const inviteMembersLink = `/signup_user_complete/?id=${testTeam.invite_id}`;
cy.apiLogout();
// # Visit the Invite Members link
cy.visit(inviteMembersLink);
// * Verify the sign up options
cy.findByText('AD/LDAP Credentials').scrollIntoView().should('be.visible');
cy.findByText('Email address').should('be.visible');
cy.findByPlaceholderText('Choose a Password').should('be.visible');
// # Sign up via email
const username = `temp-${getRandomId()}`;
const email = `${username}@mattermost.com`;
cy.get('#input_email').type(email);
cy.get('#input_name').type(username);
cy.get('#input_password-input').type('Testing123');
cy.findByText('Create Account').click();
// * Verify if user is added to the invited team
cy.uiGetLHSHeader().findByText(testTeam.display_name);
// * Verify if user has access to the default channels
cy.uiGetLhsSection('CHANNELS').within(() => {
cy.findByText('Off-Topic').should('be.visible');
cy.findByText('Town Square').should('be.visible');
});
});
it('MM-T1325 Invite Members - Team Link - Existing User', () => {
// # Login as sysadmin and create a new team
cy.apiAdminLogin();
cy.apiCreateTeam('team', 'Team').then(({team}) => {
// # Visit the team and wait for page to load and then logout.
cy.visit(`/${team.name}/channels/town-square`);
cy.uiGetPostTextBox().wait(TIMEOUTS.TWO_SEC);
const inviteMembersLink = `/signup_user_complete/?id=${team.invite_id}`;
cy.apiLogout();
// # Visit the Invite Members link
cy.visit(inviteMembersLink);
// # Click on the login option
cy.findByText('Log in').should('be.visible').click();
// # Login as user
cy.get('#input_loginId').type(testUser.username);
cy.get('#input_password-input').type('passwd');
cy.get('#saveSetting').should('not.be.disabled').click();
// * Verify if user is added to the invited team
cy.get(`#${testTeam.name}TeamButton`).as('teamButton').should('be.visible').within(() => {
cy.get('.badge').should('be.visible').and('have.text', 1);
});
cy.get('@teamButton').click().wait(TIMEOUTS.TWO_SEC);
// * Verify if user has access to the default channels in the invited teams
cy.uiGetLhsSection('CHANNELS').within(() => {
cy.findByText('Off-Topic').should('be.visible');
cy.findByText('Town Square').should('be.visible');
});
});
});
it('MM-T1326 Verify Invite Members - Existing Team Member', () => {
cy.apiCreateTeam('team', 'Team').then(({team}) => {
// # Login as new user
loginAsNewUser(team);
// # Search and add an existing member by username who is part of the team
invitePeople(sysadmin.username, 1, sysadmin.username);
// * Verify the content and message in next screen
verifyInvitationError(sysadmin.username, team, 'This person is already a team member.');
});
});
it('MM-T1328 Invite Members - Existing Member not on the team', () => {
cy.apiCreateTeam('team', 'Team').then(({team}) => {
// # Login as new user
loginAsNewUser(team);
// # Search and add an existing member by email who is not part of the team
invitePeople(testUser.email, 1, testUser.username);
// * Verify the content and message in next screen
verifyInvitationSuccess(testUser.username, team, 'This member has been added to the team.');
});
});
it('MM-T1329 Invite Members - Invite People - Existing Guest not on the team', () => {
cy.apiCreateTeam('team', 'Team').then(({team}) => {
// # Login as new user
loginAsNewUser(team);
// # Search and add a new member by email who is not part of the team
const email = `temp-${getRandomId()}@mattermost.com`;
invitePeople(email, 1, email);
// * Verify the content and message in next screen
verifyInvitationSuccess(email, team, 'An invitation email has been sent.');
});
});
it('MM-T4450 Invite Member via Email containing upper case letters', () => {
// # Login as new user
loginAsNewUser(testTeam);
// # Invite a email containing uppercase letters
const email = `tEMp-${getRandomId()}@mattermost.com`;
invitePeople(email, 1, email);
// * Verify the content and message in next screen
verifyInvitationSuccess(email, testTeam, 'An invitation email has been sent.');
});
it('MM-T1330 Invite Members - New User not in the system', () => {
// # Login as sysadmin and create a new team
cy.apiAdminLogin();
cy.apiCreateTeam('team', 'Team').then(({team}) => {
// # Login as new user
loginAsNewUser(team);
// # Search and add an existing member by username who is part of the team
invitePeople(testUser.email, 1, testUser.username, false);
// # Add a random username without proper email address format
const username = `temp-${getRandomId()}`;
cy.get('.users-emails-input__control').should('be.visible').within(() => {
cy.get('input').typeWithForce(username).tab();
});
// # Click Invite Members
cy.get('#inviteMembersButton').scrollIntoView().click();
// * Verify the content and message in the Invitation Modal
cy.findByTestId('invitationModal').within(() => {
cy.get('h1').should('have.text', `Members invited to ${team.display_name}`);
cy.get('div.invitation-modal-confirm--not-sent').should('be.visible').within(() => {
cy.get('h2 > span').should('have.text', 'Invitations Not Sent');
cy.get('.people-header').should('have.text', 'People');
cy.get('.details-header').should('have.text', 'Details');
cy.get('.username-or-icon').should('contain', username);
cy.get('.reason').should('have.text', 'Does not match a valid user or email.');
});
cy.get('div.invitation-modal-confirm--sent').should('be.visible').within(() => {
cy.get('h2 > span').should('have.text', 'Successful Invites');
cy.get('.people-header').should('have.text', 'People');
cy.get('.details-header').should('have.text', 'Details');
cy.get('.username-or-icon').should('contain', testUser.username);
cy.get('.reason').should('have.text', 'This member has been added to the team.');
});
});
});
});
});
function invitePeople(typeText, resultsCount, verifyText, clickInvite = true) {
// # Open team menu and click 'Invite People'
cy.uiOpenTeamMenu('Invite People');
// # Search and add a member
cy.get('.users-emails-input__control').should('be.visible').within(() => {
cy.get('input').typeWithForce(typeText);
});
cy.get('.users-emails-input__menu').
children().should('have.length', resultsCount).eq(0).should('contain', verifyText).click();
cy.get('.users-emails-input__control').should('be.visible').within(() => {
cy.get('input').tab();
});
// # Click Invite Members
if (clickInvite) {
cy.get('#inviteMembersButton').scrollIntoView().click();
}
}
function verifyInvitationError(user, team, errorText) {
// * Verify the content and error message in the Invitation Modal
cy.findByTestId('invitationModal').within(() => {
cy.get('h1').should('have.text', `Members invited to ${team.display_name}`);
cy.get('div.invitation-modal-confirm--sent').should('not.exist');
cy.get('div.invitation-modal-confirm--not-sent').should('be.visible').within(() => {
cy.get('h2 > span').should('have.text', 'Invitations Not Sent');
cy.get('.people-header').should('have.text', 'People');
cy.get('.details-header').should('have.text', 'Details');
cy.get('.username-or-icon').should('contain', user);
cy.get('.reason').should('have.text', errorText);
});
cy.findByTestId('confirm-done').should('be.visible').and('not.be.disabled').click();
});
// * Verify if Invitation Modal was closed
cy.get('.InvitationModal').should('not.exist');
}
function verifyInvitationSuccess(user, team, successText) {
// * Verify the content and success message in the Invitation Modal
cy.findByTestId('invitationModal').within(() => {
cy.get('h1').should('have.text', `Members invited to ${team.display_name}`);
cy.get('div.invitation-modal-confirm--not-sent').should('not.exist');
cy.get('div.invitation-modal-confirm--sent').should('be.visible').within(() => {
cy.get('h2 > span').should('have.text', 'Successful Invites');
cy.get('.people-header').should('have.text', 'People');
cy.get('.details-header').should('have.text', 'Details');
cy.get('.username-or-icon').should('contain', user);
cy.get('.reason').should('have.text', successText);
});
cy.findByTestId('confirm-done').should('be.visible').and('not.be.disabled').click();
});
// * Verify if Invitation Modal was closed
cy.get('.InvitationModal').should('not.exist');
}
function loginAsNewUser(team) {
// # Login as new user and get the user id
cy.apiCreateUser().then(({user}) => {
cy.apiAddUserToTeam(team.id, user.id);
cy.apiLogin(user);
cy.visit(`/${team.name}`);
});
}

Просмотреть файл

@@ -0,0 +1,112 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
// ***************************************************************
// - [#] indicates a test step (e.g. #. Go to a page)
// - [*] indicates an assertion (e.g. * Check the title)
// - Use element ID when selecting an element. Create one if none.
// ***************************************************************
// Stage: @prod
// Group: @channels @enterprise @guest_account @mfa
/**
* Note: This test requires Enterprise license to be uploaded
*/
import * as TIMEOUTS from '../../../../fixtures/timeouts';
describe('Guest Account - Verify Guest Access UI', () => {
beforeEach(() => {
// * Check if server has license for Guest Accounts
cy.apiRequireLicenseForFeature('GuestAccounts');
// # Enable GuestAccountSettings
cy.apiUpdateConfig({
GuestAccountsSettings: {
Enable: true,
},
ServiceSettings: {
EnableMultifactorAuthentication: false,
},
});
// # Visit System Console Users page
cy.visit('/admin_console/authentication/guest_access');
});
it('MM-18046 Verify Guest Access Screen', () => {
// * Verify Enable Guest Access field
cy.findByTestId('GuestAccountsSettings.Enable').should('be.visible').within(() => {
cy.get('.control-label').should('be.visible').and('have.text', 'Enable Guest Access: ');
});
cy.findByTestId('GuestAccountsSettings.Enablehelp-text').should('be.visible').and('have.text', 'When true, external guest can be invited to channels within teams. Please see Permissions Schemes for which roles can invite guests.');
// * Verify Whitelisted Guest Domains field
cy.findByTestId('GuestAccountsSettings.RestrictCreationToDomains').should('be.visible').within(() => {
cy.get('.control-label').should('be.visible').and('have.text', 'Whitelisted Guest Domains:');
});
cy.findByTestId('GuestAccountsSettings.RestrictCreationToDomainshelp-text').should('be.visible').and('have.text', '(Optional) Guest accounts can be created at the system level from this list of allowed guest domains.');
// * Verify Guest MFA field when System MFA is not enabled
cy.findByTestId('GuestAccountsSettings.EnforceMultifactorAuthentication').should('be.visible').within(() => {
cy.get('.control-label').should('be.visible').and('have.text', 'Enforce Multi-factor Authentication: ');
});
cy.findByTestId('GuestAccountsSettings.EnforceMultifactorAuthenticationhelp-text').should('be.visible').and('have.text', 'Multi-factor authentication is currently not enabled.');
// # Enable GuestAccountSettings
cy.apiUpdateConfig({
ServiceSettings: {
EnableMultifactorAuthentication: true,
},
});
// # Visit System Console Users page
cy.visit('/admin_console/authentication/guest_access');
// * Verify Guest MFA field when System MFA is enabled
cy.findByTestId('GuestAccountsSettings.EnforceMultifactorAuthenticationhelp-text').should('be.visible').and('have.text', 'Multi-factor authentication is currently not enforced.');
});
it('MM-T1410 Confirmation Modal when Guest Access is disabled', () => {
// # Disable Guest Access and save
cy.findByTestId('GuestAccountsSettings.Enablefalse').click();
// * Verify the warning message
cy.get('.error-message').should('be.visible').within(() => {
cy.findByText('All current guest account sessions will be revoked, and marked as inactive').should('be.visible');
});
// # Click on the Save Settings
cy.get('#saveSetting').should('be.visible').click();
// * Verify the confirmation message displayed
cy.get('#confirmModal').should('be.visible').within(() => {
cy.get('#confirmModalLabel').should('be.visible').and('have.text', 'Save and Disable Guest Access?');
cy.get('.modal-body').should('be.visible').and('have.text', 'Disabling guest access will revoke all current Guest Account sessions. Guests will no longer be able to login and new guests cannot be invited into Mattermost. Guest users will be marked as inactive in user lists. Enabling this feature will not reinstate previous guest accounts. Are you sure you wish to remove these users?');
cy.get('#confirmModalButton').should('have.text', 'Save and Disable Guest Access');
});
// * Verify the behavior when Cancel button in the confirmation message is clicked
cy.get('#cancelModalButton').click();
cy.get('#confirmModal').should('not.exist');
cy.get('.error-message').should('be.visible');
// # Click on the Save Settings, confirm and wait for some time to complete successful save
cy.get('#saveSetting').should('be.visible').click();
cy.get('#confirmModalButton').should('be.visible').click().wait(TIMEOUTS.TWO_SEC);
// # Visit the chat facing application
cy.get('.header__info').should('be.visible').click();
cy.findByLabelText('Admin Console Menu').should('exist').within(() => {
cy.findByText('Switch to eligendi').click();
});
// # Open team menu and click 'Invite People'
cy.uiOpenTeamMenu('Invite People');
// * Verify that an option to Invite via Guest should not be available
cy.findByTestId('inviteGuestLink').should('not.exist');
cy.get('.users-emails-input__control').should('be.visible');
});
});

Просмотреть файл

@@ -0,0 +1,103 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
// ***************************************************************
// - [#] indicates a test step (e.g. #. Go to a page)
// - [*] indicates an assertion (e.g. * Check the title)
// - Use element ID when selecting an element. Create one if none.
// ***************************************************************
// Stage: @prod
// Group: @channels @enterprise @guest_account @not_cloud
import * as TIMEOUTS from '../../../../fixtures/timeouts';
import {verifyGuest} from './helpers';
describe('Guest Account - Verify Manage Guest Users', () => {
let guestUser: Cypress.UserProfile;
let testTeam: Cypress.Team;
let testChannel: Cypress.Channel;
before(() => {
cy.shouldNotRunOnCloudEdition();
// * Check if server has license for Guest Accounts
cy.apiRequireLicenseForFeature('GuestAccounts');
// # Enable GuestAccountSettings
cy.apiUpdateConfig({
GuestAccountsSettings: {
Enable: true,
},
});
// # Create team and guest user account
cy.apiInitSetup().then(({team, channel}) => {
testTeam = team;
testChannel = channel;
cy.apiCreateGuestUser({}).then(({guest}) => {
guestUser = guest;
cy.apiAddUserToTeam(testTeam.id, guestUser.id).then(() => {
cy.apiAddUserToChannel(testChannel.id, guestUser.id);
});
});
});
// # Visit System Console Users page
cy.visit('/admin_console/user_management/users');
});
beforeEach(() => {
// # Reload current page before each test
cy.reload();
// # Search for Guest User by username
cy.get('#searchUsers', {timeout: TIMEOUTS.HALF_MIN}).should('be.visible').type(guestUser.username);
});
it('MM-18048 Deactivate Guest User and Verify', () => {
// # Click on the Deactivate option
cy.wait(TIMEOUTS.HALF_SEC).findByTestId('userListRow').find('.MenuWrapper a').should('be.visible').click();
cy.wait(TIMEOUTS.HALF_SEC).findByText('Deactivate').click();
// * Verify the confirmation message displayed
cy.get('#confirmModal').should('be.visible').within(() => {
cy.get('#confirmModalLabel').should('be.visible').and('have.text', `Deactivate ${guestUser.username}`);
cy.get('.modal-body').should('be.visible').and('have.text', `This action deactivates ${guestUser.username}. They will be logged out and not have access to any teams or channels on this system. Are you sure you want to deactivate ${guestUser.username}?`);
});
// * Verify the behavior when Cancel button in the confirmation message is clicked
cy.get('#cancelModalButton').click();
cy.get('#confirmModal').should('not.exist');
verifyGuest();
// * Verify the behavior when Deactivate button in the confirmation message is clicked
cy.wait(TIMEOUTS.HALF_SEC).findByTestId('userListRow').find('.MenuWrapper a').should('be.visible').click();
cy.wait(TIMEOUTS.HALF_SEC).findByText('Deactivate').click();
cy.get('#confirmModalButton').click();
cy.get('#confirmModal').should('not.exist');
verifyGuest('Inactive ');
// # Reload and verify if behavior is same
cy.reload();
cy.get('#searchUsers').should('be.visible').type(guestUser.username);
verifyGuest('Inactive ');
});
it('MM-18048 Activate Guest User and Verify', () => {
// # Click on the Activate option
cy.wait(TIMEOUTS.HALF_SEC).findByTestId('userListRow').find('.MenuWrapper a').should('be.visible').click();
cy.wait(TIMEOUTS.HALF_SEC).findByText('Activate').click();
// * Verify if User's status is activated again
verifyGuest();
// # Reload and verify if behavior is same
cy.reload();
cy.get('#searchUsers').should('be.visible').type(guestUser.username);
verifyGuest();
});
});

Просмотреть файл

@@ -0,0 +1,138 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
// ***************************************************************
// - [#] indicates a test step (e.g. #. Go to a page)
// - [*] indicates an assertion (e.g. * Check the title)
// - Use element ID when selecting an element. Create one if none.
// ***************************************************************
// Stage: @prod
// Group: @channels @enterprise @guest_account
/**
* Note: This test requires Enterprise license to be uploaded
*/
import * as TIMEOUTS from '../../../../fixtures/timeouts';
import {getRandomId} from '../../../../utils';
import {getAdminAccount} from '../../../../support/env';
import {verifyGuest} from './helpers';
describe('Guest Account - Verify Manage Guest Users', () => {
const admin = getAdminAccount();
let guestUser: Cypress.UserProfile;
let testTeam: Cypress.Team;
let testChannel: Cypress.Channel;
before(() => {
// * Check if server has license for Guest Accounts
cy.apiRequireLicenseForFeature('GuestAccounts');
// # Enable GuestAccountSettings
cy.apiUpdateConfig({
GuestAccountsSettings: {
Enable: true,
},
});
// # Create team and guest user account
cy.apiInitSetup().then(({team, channel}) => {
testTeam = team;
testChannel = channel;
cy.apiCreateGuestUser({}).then(({guest}) => {
guestUser = guest;
cy.apiAddUserToTeam(testTeam.id, guestUser.id).then(() => {
cy.apiAddUserToChannel(testChannel.id, guestUser.id);
});
});
});
// # Visit System Console Users page
cy.visit('/admin_console/user_management/users');
});
beforeEach(() => {
// # Reload current page before each test
cy.reload();
// # Search for Guest User by username
cy.get('#searchUsers', {timeout: TIMEOUTS.HALF_MIN}).should('be.visible').type(guestUser.username);
});
it('MM-T1391 Verify the manage options displayed for Guest User', () => {
// * Verify Guest user
verifyGuest();
// # Click on the Manage User option
cy.wait(TIMEOUTS.HALF_SEC).findByTestId('userListRow').find('.MenuWrapper a').should('be.visible').click();
// * Verify the manage options which should be displayed for Guest User
const includeOptions = ['Deactivate', 'Manage Roles', 'Manage Teams', 'Reset Password', 'Update Email', 'Promote to Member', 'Revoke Sessions'];
includeOptions.forEach((includeOption) => {
cy.findByText(includeOption).should('be.visible');
});
// * Verify the manage options which should not be displayed for Guest user
const missingOptions = ['Demote to Guest'];
missingOptions.forEach((missingOption) => {
cy.findByText(missingOption).should('not.exist');
});
});
it('MM-18048 Change Email of a Guest User and Verify', () => {
// # Click on the Update Email option
cy.wait(TIMEOUTS.HALF_SEC).findByTestId('userListRow').find('.MenuWrapper a').should('be.visible').click();
cy.wait(TIMEOUTS.HALF_SEC).findByText('Update Email').click();
// * Update email of Guest User
const email = `temp-${getRandomId()}@mattermost.com`;
cy.findByTestId('resetEmailModal').should('be.visible').within(() => {
cy.findByTestId('resetEmailForm').should('be.visible').get('input').type(email);
cy.findByTestId('resetEmailButton').click();
});
// * Verify if Guest's email was updated
cy.findByText(email).should('be.visible');
// # Reload and verify if behavior is same
cy.reload();
cy.get('#searchUsers').should('be.visible').type(guestUser.username);
cy.findByText(email).should('be.visible');
});
it('MM-18048 Revoke Session of a Guest User and Verify', () => {
// # Click on the Revoke Session option
cy.wait(TIMEOUTS.HALF_SEC).findByTestId('userListRow').find('.MenuWrapper a').should('be.visible').click();
cy.wait(TIMEOUTS.HALF_SEC).findByText('Revoke Sessions').click();
// * Verify the confirmation message displayed
cy.get('#confirmModal').should('be.visible').within(() => {
cy.get('#confirmModalLabel').should('be.visible').and('have.text', `Revoke Sessions for ${guestUser.username}`);
cy.get('.modal-body').should('be.visible').and('have.text', `This action revokes all sessions for ${guestUser.username}. They will be logged out from all devices. Are you sure you want to revoke all sessions for ${guestUser.username}?`);
});
// * Verify the behavior when Cancel button in the confirmation message is clicked
cy.get('#cancelModalButton').click();
cy.get('#confirmModal').should('not.exist');
// # Logout sysadmin and login as Guest User to verify if Revoke Session works
cy.apiLogout();
cy.apiLogin(guestUser);
cy.visit(`/${testTeam.name}/channels/${testChannel.name}`);
cy.get(`#sidebarItem_${testChannel.name}`).click({force: true});
// # Issue a Request to Revoke All Sessions as SysAdmin
cy.externalRequest({user: admin, method: 'post', path: `users/${guestUser.id}/sessions/revoke/all`}).then(() => {
// # Initiate browser activity like visit on test channel
cy.visit(`/${testTeam.name}/channels/${testChannel.name}`);
// * Verify if the regular member is logged out and redirected to login page
cy.url({timeout: TIMEOUTS.HALF_MIN}).should('include', '/login');
cy.get('.login-body-card', {timeout: TIMEOUTS.HALF_MIN}).should('be.visible');
});
});
});