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

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

@@ -0,0 +1,74 @@
// 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 @team_settings
import * as TIMEOUTS from '../../../fixtures/timeouts';
describe('Teams Settings', () => {
let sysadmin: Cypress.UserProfile;
before(() => {
cy.apiCreateCustomAdmin({loginAfter: true}).then(({sysadmin: admin}) => {
sysadmin = admin;
});
});
it('MM-T5299 User tries to go to archived team', () => {
// # Create a new user
cy.apiCreateUser().then(({user}) => {
// # Create a new team 1
cy.apiCreateTeam('team1', 'team1').then(({team: team1}) => {
// # Create a new team 2
cy.apiCreateTeam('team2', 'team2').then(({team: team2}) => {
// # Add user to both teams
cy.apiAddUserToTeam(team1.id, user.id);
cy.apiAddUserToTeam(team2.id, user.id);
cy.apiLogin(user);
// # Visit team 1 so the previous team is set to team 1 in local storage
cy.visit(`/${team1.name}/channels/town-square`);
// * Verify user is part of both teams
cy.get(`#${team1.name}TeamButton`, {timeout: TIMEOUTS.TEN_SEC}).should('be.visible');
cy.get(`#${team2.name}TeamButton`, {timeout: TIMEOUTS.TEN_SEC}).should('be.visible');
// # Logout the user
cy.apiLogout();
cy.clearLocalStorage();
cy.reload();
// # Login as admin
cy.apiLogin(sysadmin);
// # Archive team 1
cy.apiDeleteTeam(team1.id);
// # Logout the admin
cy.apiLogout();
// # Login as user
cy.apiLogin(user);
cy.visit('/');
// * Verify we landed on team 2 url
cy.url().should('include', `/${team2.name}/channels/town-square`);
// # Try to visit team 1 from the url
cy.visit(`/${team1.name}/channels/town-square`);
// * Verify we are redirected to team not found
cy.url().should('include', '/error?type=team_not_found');
});
});
});
});
});

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

@@ -0,0 +1,126 @@
// 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 @team_settings
import {getAdminAccount} from '../../../support/env';
import * as TIMEOUTS from '../../../fixtures/timeouts';
import {
getJoinEmailTemplate,
getRandomId,
reUrl,
verifyEmailBody,
} from '../../../utils';
describe('Team Settings', () => {
const sysadmin = getAdminAccount();
const randomId = getRandomId();
const username = `user${randomId}`;
const email = `user${randomId}@sample.mattermost.com`;
const password = 'passwd';
let testTeam;
let siteName;
let isLicensed;
before(() => {
cy.apiGetClientLicense().then((data) => {
({isLicensed} = data);
});
// # Disable LDAP and do email test if setup properly
cy.apiUpdateConfig({
LdapSettings: {Enable: false},
ServiceSettings: {EnableOnboardingFlow: true},
TeamSettings: {
EnableOpenServer: false,
},
}).then(({config}) => {
siteName = config.TeamSettings.SiteName;
});
cy.shouldHaveEmailEnabled();
cy.apiInitSetup().then(({team}) => {
testTeam = team;
cy.visit(`/${team.name}/channels/town-square`);
});
});
it('MM-T385 Invite new user to closed team using email invite', () => {
// # Open 'Team Settings' modal
cy.uiOpenTeamMenu('Team Settings');
// * Check that the 'Team Settings' modal was opened
cy.get('#teamSettingsModal').should('exist').within(() => {
cy.get('#open_inviteDesc').should('have.text', 'No');
// # Click on the 'Allow only users with a specific email domain to join this team' edit button
cy.get('#allowed_domainsEdit').should('be.visible').click();
// * Verify that the '#allowedDomains' input field is empty
cy.get('#allowedDomains').should('be.empty');
// # Close the modal
cy.get('#teamSettingsModalLabel').find('button').should('be.visible').click();
});
// # Open the 'Invite People' full screen modal
cy.uiOpenTeamMenu('Invite People');
// # Wait half a second to ensure that the modal has been fully loaded
cy.wait(TIMEOUTS.HALF_SEC);
if (isLicensed) {
// # Click invite members if needed
cy.get('.InviteAs').findByTestId('inviteMembersLink').click();
}
cy.findByRole('textbox', {name: 'Add or Invite People'}).type(email, {force: true}).wait(TIMEOUTS.HALF_SEC).type('{enter}', {force: true});
cy.get('#inviteMembersButton').click();
// # Wait for a while to ensure that email notification is sent and logout from sysadmin account
cy.wait(TIMEOUTS.FIVE_SEC);
cy.apiLogout();
// # Invite a new user (with the email declared in the parent scope)
cy.getRecentEmail({username, email}).then((data) => {
const {body: actualEmailBody, subject} = data;
// * Verify email subject
expect(subject).to.contain(`[${siteName}] ${sysadmin.username} invited you to join ${testTeam.display_name} Team`);
// * Verify email body
const expectedEmailBody = getJoinEmailTemplate(sysadmin.username, email, testTeam);
verifyEmailBody(expectedEmailBody, actualEmailBody);
// # Visit permalink (e.g. click on email link)
const permalink = actualEmailBody[3].match(reUrl)[0];
cy.visit(permalink);
});
// # Type username and password
cy.wait(TIMEOUTS.HALF_SEC);
cy.get('#input_name').type(username);
cy.wait(TIMEOUTS.HALF_SEC);
cy.get('#input_password-input').type(password);
// # Attempt to create an account by clicking on the 'Create Account' button
cy.findByText('Create Account').click();
// # Close the onboarding tutorial
cy.uiCloseOnboardingTaskList();
// * Check that the display name of the team the user was invited to is being correctly displayed
cy.uiGetLHSHeader().findByText(testTeam.display_name);
// * Check that the 'Beginning of Town Square' message is visible
cy.findByText('Beginning of Town Square').should('be.visible');
});
});

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

@@ -0,0 +1,61 @@
// 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 @te_only @team_settings
import {getAdminAccount} from '../../../support/env';
import {generateRandomUser} from '../../../support/api/user';
import {allowOnlyUserFromSpecificDomain, inviteUserByEmail, verifyEmailInviteAndVisitLink, signupAndVerifyTutorial} from './helpers';
describe('Team Settings', () => {
const sysadmin = getAdminAccount();
const {username, password} = generateRandomUser();
const email = `${username}@gmail.com`;
const emailDomain = 'gmail.com';
let testTeam;
let siteName;
before(() => {
cy.shouldRunOnTeamEdition();
cy.apiUpdateConfig({
LdapSettings: {Enable: false},
ServiceSettings: {EnableOnboardingFlow: true},
}).then(({config}) => {
siteName = config.TeamSettings.SiteName;
});
// # Do email test if setup properly
cy.shouldHaveEmailEnabled();
cy.apiInitSetup().then(({team}) => {
testTeam = team;
cy.visit(`/${team.name}/channels/town-square`);
});
});
it('MM-T389 Invite new user to closed team with \'Allow only users with a specific email domain to join this team\' set to an email that is NOT \'sample.mattermost.com\'', () => {
// # Allow only users from 'gmail.com' domain
allowOnlyUserFromSpecificDomain(emailDomain);
// # Invite a new user (with the email declared in the parent scope)
inviteUserByEmail(email);
// # Logout from sysadmin account
cy.apiLogout();
// # Verify that the invite email is correct, and visit the link provided in the email
verifyEmailInviteAndVisitLink(sysadmin.username, username, email, testTeam, siteName);
// # Signup and verify the initial tutorial
signupAndVerifyTutorial(username, password, testTeam.display_name);
});
});

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

@@ -0,0 +1,60 @@
// 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 @te_only @team_settings
import {getAdminAccount} from '../../../support/env';
import {generateRandomUser} from '../../../support/api/user';
import {allowOnlyUserFromSpecificDomain, inviteUserByEmail, verifyEmailInviteAndVisitLink, signupAndVerifyTutorial} from './helpers';
describe('Team Settings', () => {
const sysadmin = getAdminAccount();
const {username, email, password} = generateRandomUser();
const emailDomain = 'sample.mattermost.com';
let testTeam;
let siteName;
before(() => {
cy.shouldRunOnTeamEdition();
cy.apiUpdateConfig({
LdapSettings: {Enable: false},
ServiceSettings: {EnableOnboardingFlow: true},
}).then(({config}) => {
siteName = config.TeamSettings.SiteName;
});
// # Do email test if setup properly
cy.shouldHaveEmailEnabled();
cy.apiInitSetup().then(({team}) => {
testTeam = team;
cy.visit(`/${team.name}/channels/town-square`);
});
});
it('MM-T386 Invite new user to closed team with \'Allow only users with a specific email domain to join this team\' set to \'sample.mattermost.com\'', () => {
// # Allow only users from 'sample.mattermost.com' domain
allowOnlyUserFromSpecificDomain(emailDomain);
// # Invite user via email
inviteUserByEmail(email);
// # Logout from sysadmin account
cy.apiLogout();
// # Invite a new user (with the email declared in the parent scope)
verifyEmailInviteAndVisitLink(sysadmin.username, username, email, testTeam, siteName);
// # Signup and verify the initial tutorial
signupAndVerifyTutorial(username, password, testTeam.display_name);
});
});

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

@@ -0,0 +1,96 @@
// 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 @team_settings @smoke
import {getRandomId} from '../../../utils';
describe('Teams Suite', () => {
before(() => {
// # Login as test user and visit town-square
cy.apiInitSetup({loginAfter: true}).then(({offTopicUrl}) => {
cy.visit(offTopicUrl);
cy.postMessage('hello');
});
});
it('MM-T383 Create a new team', () => {
// # Open team menu and click "Create a Team"
cy.uiOpenTeamMenu('Create a Team');
// # Input team name as Team Test
const teamName = 'Team Test';
cy.get('#teamNameInput').should('be.visible').type(teamName);
// # Click Next button
cy.get('#teamNameNextButton').should('be.visible').click();
// # Input team URL as variable teamURl
const teamURL = `team-${getRandomId()}`;
cy.get('#teamURLInput').should('be.visible').type(teamURL);
// # Click finish button
cy.get('#teamURLFinishButton').should('be.visible').click();
// * Should redirect to Town Square channel
cy.get('#channelHeaderTitle').should('contain', 'Town Square');
// * check url is correct
cy.url().should('include', teamURL + '/channels/town-square');
// * Team name should displays correctly at top of LHS
cy.uiGetLHSHeader().findByText(teamName);
});
it('MM-T1437 Try to create a new team using restricted words', () => {
// * Enter different reserved words and verify the error message
[
'plugins',
'login',
'admin',
'channel',
'post',
'api',
'oauth',
'error',
'help',
].forEach((reservedTeamPath) => {
tryReservedTeamURLAndVerifyError(reservedTeamPath);
});
});
});
function tryReservedTeamURLAndVerifyError(teamURL) {
// # Open team menu and click "Create a Team"
cy.uiOpenTeamMenu('Create a Team');
// # Input passed in team name
cy.get('#teamNameInput').should('be.visible').type(teamURL);
// # Click Next button
cy.findByText('Next').should('be.visible').click();
// # Input a passed in value of the team url
cy.get('#teamURLInput').should('be.visible').clear().type(teamURL);
// # Hit finish button
cy.findByText('Finish').should('exist').click();
// * Verify that we get error message for reserved team url
cy.get('form').within(() => {
// # Split search into multiple lines as text contains links and new lines
cy.findByText(/This URL\s/).should('exist');
cy.findByText(/starts with a reserved word/).should('exist');
cy.findByText(/\sor is unavailable. Please try another./).should('exist');
});
// # Close the modal
cy.findByText('Back').click();
}

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

@@ -0,0 +1,90 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import * as TIMEOUTS from '../../../fixtures/timeouts';
import {
getJoinEmailTemplate,
reUrl,
verifyEmailBody,
} from '../../../utils';
export const allowOnlyUserFromSpecificDomain = (domain) => {
// # Open 'Team Settings' modal
cy.uiOpenTeamMenu('Team Settings');
// * Check that the 'Team Settings' modal was opened
cy.get('#teamSettingsModal').should('exist').within(() => {
// * Ensure that 'Allow any user with an account on this server' is set to 'No'
cy.get('#open_inviteDesc').should('have.text', 'No');
// # Click on the 'Allow only users with a specific email domain to join this team' edit button
cy.get('#allowed_domainsEdit').should('be.visible').click();
// # Set the allowed domain as the one received as the param and save
cy.focused().type(domain);
cy.findByText('Save').should('be.visible').click();
// # Close the modal
cy.get('#teamSettingsModalLabel').find('button').should('be.visible').click();
});
};
export const inviteUserByEmail = (email) => {
// # Open team menu and click 'Invite People'
cy.uiOpenTeamMenu('Invite People');
// # Wait half a second to ensure that the modal has been fully loaded
cy.wait(TIMEOUTS.HALF_SEC);
cy.findByRole('textbox', {name: 'Add or Invite People'}).
typeWithForce(email).
wait(TIMEOUTS.HALF_SEC).
typeWithForce('{enter}');
cy.get('#inviteMembersButton').click();
// # Wait for a while to ensure that email notification is sent
cy.wait(TIMEOUTS.TWO_SEC);
};
export const verifyEmailInviteAndVisitLink = (sender, username, email, team, siteName) => {
// # Invite a new user
cy.getRecentEmail({username, email}).then((data) => {
const {body: actualEmailBody, subject} = data;
// * Verify email subject
expect(subject).to.contain(`[${siteName}] ${sender} invited you to join ${team.display_name} Team`);
// * Verify email body
const expectedEmailBody = getJoinEmailTemplate(sender, email, team);
verifyEmailBody(expectedEmailBody, actualEmailBody);
// # Visit permalink (e.g. click on email link)
const permalink = actualEmailBody[3].match(reUrl)[0];
cy.visit(permalink);
// * Verify it redirects into the signup page
cy.get('.signup-body', {timeout: TIMEOUTS.HALF_MIN}).should('be.visible');
});
};
export const signupAndVerifyTutorial = (username, password, teamDisplayName) => {
cy.get('#name', {timeout: TIMEOUTS.HALF_MIN}).should('be.visible').type(username);
cy.get('#password').should('be.visible').type(password);
// # Attempt to create an account by clicking on the 'Create Account' button
cy.get('#createAccountButton').click();
// # Close the onboarding tutorial
cy.uiCloseOnboardingTaskList();
// * Check that the display name of the team the user was invited to is being correctly displayed
cy.uiGetLHSHeader().findByText(teamDisplayName);
// * Check that the 'Beginning of Town Square' message is visible
cy.findByText('Beginning of Town Square').should('be.visible');
// * Check that 'Town Square' is currently being selected
cy.get('.active').within(() => {
cy.get('#sidebarItem_town-square').should('exist');
});
};

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

@@ -0,0 +1,64 @@
// 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 @team_settings
describe('Invite Members', () => {
before(() => {
// # Enable API Team Deletion
// # Disable Require Email Verification
cy.apiUpdateConfig({
ServiceSettings: {
EnableAPITeamDeletion: true,
},
EmailSettings: {
RequireEmailVerification: false,
},
});
});
describe('Invite members - backdrop click', () => {
beforeEach(() => {
// # Login and visit
cy.apiAdminLogin();
cy.visit('/');
// # Open and select invite menu item
cy.uiOpenTeamMenu('Invite People');
});
it('allows user to exit when there are no inputs', () => {
// # Verify modal closed
testBackdropClickCloses(true);
});
it('does not close modal if user has inputs', () => {
// # Enter input into field
cy.get('.users-emails-input__control input').typeWithForce('some.user@mattermost.com');
// * Verify modal was not closed, and users work is preserved
testBackdropClickCloses(false);
});
});
});
function testBackdropClickCloses(shouldClose) {
// # Click on modal
cy.get('.modal-backdrop').click({force: true});
if (shouldClose) {
// * Verify modal was closed
cy.get('.InvitationModal').should('not.exist');
} else {
// * Verify modal was not closed
cy.get('.InvitationModal').should('be.visible');
}
}

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

@@ -0,0 +1,214 @@
// 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 @team_settings
describe('Invite Members', () => {
let testUser;
let testTeam;
let userToBeInvited;
before(() => {
// # Enable API Team Deletion
// # Disable Require Email Verification
cy.apiUpdateConfig({
ServiceSettings: {
EnableAPITeamDeletion: true,
},
EmailSettings: {
RequireEmailVerification: false,
},
});
});
afterEach(() => {
// # close modal
closeAndComplete();
});
describe('Invite members - user to be invited not added to existing team', () => {
beforeEach(() => {
cy.apiAdminLogin();
cy.apiInitSetup().then(({team, user}) => {
testUser = user;
testTeam = team;
cy.apiCreateUser({bypassTutorial: false}).then(({user: otherUser}) => {
userToBeInvited = otherUser;
});
});
});
// By default, member don't have "InviteGuest" permission
// should go directly to "InviteMembers" modal
it('Invite members to Team as Member - invitation sent', () => {
inviteUserToTeamAsMember(testUser, testTeam, userToBeInvited);
// * Verify Invitation was created successfully
verifyInvitationSuccess(testTeam, userToBeInvited);
// * Verify returned to "InviteMembers" modal
verifyInviteMembersModal(testTeam);
});
// By default, sysadmin can Invite Guests, should go to "InvitePeople" modal
it('Invite members to Team as SysAdmin - invitation sent', () => {
inviteUserToTeamAsSysadmin(testTeam, userToBeInvited);
// * Verify Invitation was created successfully
verifyInvitationSuccess(testTeam, userToBeInvited);
});
});
describe('Invite members - user to be invited already member of existing team', () => {
beforeEach(() => {
cy.apiAdminLogin();
cy.apiInitSetup().then(({team, user}) => {
testUser = user;
testTeam = team;
cy.apiCreateUser({bypassTutorial: false}).then(({user: otherUser}) => {
userToBeInvited = otherUser;
cy.apiAddUserToTeam(testTeam.id, userToBeInvited.id);
});
});
});
// By default, member don't have "InviteGuest" permission
// should go directly to "InviteMembers" modal
it('Invite members to Team as Member - invitation not sent', () => {
inviteUserToTeamAsMember(testUser, testTeam, userToBeInvited);
// * Verify Invitation was not sent
verifyInvitationError(testTeam, userToBeInvited);
// * Verify returned to "InviteMembers" modal
verifyInviteMembersModal(testTeam);
});
// By default, sysadmin can Invite Guests, should go to "InvitePeople" modal
it('Invite members to Team as SysAdmin - invitation not sent', () => {
inviteUserToTeamAsSysadmin(testTeam, userToBeInvited);
// * Verify Invitation was not sent
verifyInvitationError(testTeam, userToBeInvited);
});
});
describe('default interface', () => {
it('focuses user email input by default', () => {
// # Login and visit
cy.apiLogin(testUser);
cy.visit(`/${testTeam.name}/channels/town-square`);
// # Open and select invite menu item
cy.uiOpenTeamMenu('Invite People');
// * Users emails input is focused by default
cy.get('.users-emails-input__control--is-focused').should('be.visible');
});
});
});
function verifyInvitationTable($subel, tableTitle, user, reason) {
cy.wrap($subel).find('h2 > span').should('have.text', tableTitle);
cy.wrap($subel).find('.people-header').should('have.text', 'People');
cy.wrap($subel).find('.details-header').should('have.text', 'Details');
cy.wrap($subel).find('.username-or-icon').should('contain', `@${user.username} - ${user.first_name} ${user.last_name} (${user.nickname})`);
cy.wrap($subel).find('.reason').should('have.text', reason);
}
function verifyInvitationResult(team, user, reason, isInvitationSent) {
// * Verify the content and success message in the Invitation Modal
cy.findByTestId('invitationModal').within(($el) => {
cy.wrap($el).find('h1').should('have.text', `Members invited to ${team.display_name}`);
if (isInvitationSent) {
cy.wrap($el).find('div.invitation-modal-confirm--not-sent').should('not.exist');
cy.wrap($el).find('div.invitation-modal-confirm--sent').should('be.visible').within(($subel) => {
verifyInvitationTable($subel, 'Successful Invites', user, reason);
});
} else {
cy.wrap($el).find('div.invitation-modal-confirm--sent').should('not.exist');
cy.wrap($el).find('div.invitation-modal-confirm--not-sent').should('be.visible').within(($subel) => {
verifyInvitationTable($subel, 'Invitations Not Sent', user, reason);
});
}
cy.wrap($el).findByTestId('confirm-done').should('be.visible');
cy.wrap($el).findByTestId('invite-more').should('be.visible').and('not.be.disabled').click();
});
}
function verifyInvitationSuccess(team, user) {
verifyInvitationResult(team, user, 'This member has been added to the team.', true);
}
function verifyInvitationError(team, user) {
verifyInvitationResult(team, user, 'This person is already a team member.', false);
}
function verifyInviteMembersModal(team) {
// * Verify the header has changed in the modal
cy.findByTestId('invitationModal').within(($el) => {
cy.wrap($el).find('h1').should('have.text', `Invite people to ${team.display_name}`);
});
// * Verify Share Link Header and helper text
cy.findByTestId('InviteView__copyInviteLink').should('be.visible').should('have.text', 'Copy invite link');
}
function inviteUser(user) {
// # Input email, select member
cy.get('.users-emails-input__control input').type(user.email, {force: true});
cy.get('.users-emails-input__menu').children().eq(0).should('contain', user.username).click();
// # Click Invite Members
cy.get('#inviteMembersButton').scrollIntoView().click();
}
function inviteUserToTeamAsMember(testUser, testTeam, user) {
// # Login and visit
cy.apiLogin(testUser);
cy.visit(`/${testTeam.name}/channels/town-square`);
// # Open and select invite menu item
cy.uiOpenTeamMenu('Invite People');
// * Verify Invite Members
verifyInviteMembersModal(testTeam);
// # Invite user
inviteUser(user);
}
function inviteUserToTeamAsSysadmin(testTeam, user) {
// # Login and visit
cy.apiAdminLogin();
cy.visit(`/${testTeam.name}/channels/off-topic`);
// # Open and select invite menu item
cy.uiOpenTeamMenu('Invite People');
// * Verify Invite Members
verifyInviteMembersModal(testTeam);
// # Invite user
inviteUser(user);
}
function closeAndComplete() {
// # Close modal
cy.uiClose();
// * Verify the modal closed
cy.get('.InvitationModal').should('not.exist');
}

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

@@ -0,0 +1,87 @@
// 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 @team_settings
import {getRandomId} from '../../../utils';
import * as TIMEOUTS from '../../../fixtures/timeouts';
describe('Team Settings', () => {
let newUser;
before(() => {
cy.apiInitSetup().then(({team}) => {
cy.apiCreateUser().then(({user}) => {
newUser = user;
});
cy.visit(`/${team.name}`);
});
});
it('MM-T388 - Invite new user to closed team with "Allow only users with a specific email domain to join this team" set to "sample.mattermost.com" AND include a non-sample.mattermost.com email address in the invites', () => {
const emailDomain = 'sample.mattermost.com';
const invalidEmail = `user.${getRandomId()}@invalid.com`;
const userDetailsString = `@${newUser.username} - ${newUser.first_name} ${newUser.last_name} (${newUser.nickname})`;
const inviteSuccessMessage = 'This member has been added to the team.';
const inviteFailedMessage = `The following email addresses do not belong to an accepted domain: ${invalidEmail}. Please contact your System Administrator for details.`;
// # Open team menu and click 'Team Settings'
cy.uiOpenTeamMenu('Team Settings');
// * Check that the 'Team Settings' modal was opened
cy.get('#teamSettingsModal').should('exist').within(() => {
// # Click on the 'Allow only users with a specific email domain to join this team' edit button
cy.get('#allowed_domainsEdit').should('be.visible').click();
// # Set 'sample.mattermost.com' as the only allowed email domain and save
cy.wait(TIMEOUTS.HALF_SEC);
cy.focused().type(emailDomain);
cy.findByText('Save').should('be.visible').click();
// # Close the modal
cy.get('#teamSettingsModalLabel').find('button').should('be.visible').click();
});
// # Open team menu and click 'Invite People'
cy.uiOpenTeamMenu('Invite People');
// # Invite user with valid email domain that is not in the team
inviteNewMemberToTeam(newUser.email);
// * Assert that the user has successfully been invited to the team
cy.get('.invitation-modal-confirm--sent').should('be.visible').within(() => {
cy.get('.username-or-icon').find('span').eq(0).should('have.text', userDetailsString);
cy.get('.InviteResultRow').find('div').eq(1).should('have.text', inviteSuccessMessage);
});
// # Click on the 'Invite More People button'
cy.findByTestId('invite-more').click();
// # Invite a user with an invalid email domain (not sample.mattermost.com)
inviteNewMemberToTeam(invalidEmail);
// * Assert that the invite failed and the correct error message is shown
cy.get('.invitation-modal-confirm--not-sent').should('be.visible').within(() => {
cy.get('.username-or-icon').find('span').eq(1).should('have.text', invalidEmail);
cy.get('.InviteResultRow').find('div').eq(1).should('have.text', inviteFailedMessage);
});
});
function inviteNewMemberToTeam(email) {
cy.wait(TIMEOUTS.HALF_SEC);
cy.findByRole('textbox', {name: 'Add or Invite People'}).
typeWithForce(email).
wait(TIMEOUTS.HALF_SEC).
typeWithForce('{enter}');
cy.get('#inviteMembersButton').click();
}
});

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

@@ -0,0 +1,144 @@
// 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 @team_settings
import {getRandomId, stubClipboard} from '../../../utils';
import * as TIMEOUTS from '../../../fixtures/timeouts';
describe('Team Settings', () => {
const randomId = getRandomId();
const emailDomain = 'sample.mattermost.com';
let testTeam;
before(() => {
cy.apiUpdateConfig({
GuestAccountsSettings: {
Enable: false,
},
LdapSettings: {
Enable: false,
},
});
});
beforeEach(() => {
// # Login as sysadmin
cy.apiAdminLogin();
cy.apiInitSetup().then(({team}) => {
testTeam = team;
cy.visit(`/${team.name}`);
});
});
it('MM-T387 - Try to join a closed team from a NON-mattermost email address via "Get Team Invite Link" while "Allow only users with a specific email domain to join this team" set to "sample.mattermost.com"', () => {
stubClipboard().as('clipboard');
// # Open team menu and click 'Team Settings'
cy.uiOpenTeamMenu('Team Settings');
// * Check that the 'Team Settings' modal was opened
cy.get('#teamSettingsModal').should('exist').within(() => {
// # Click on the 'Allow only users with a specific email domain to join this team' edit button
cy.get('#allowed_domainsEdit').should('be.visible').click();
// # Set 'sample.mattermost.com' as the only allowed email domain, save then close
cy.wait(TIMEOUTS.HALF_SEC);
cy.focused().type(emailDomain);
cy.uiSaveAndClose();
});
// # Open team menu and click 'Invite People'
cy.uiOpenTeamMenu('Invite People');
// # Get the invite URL
cy.findByTestId('InviteView__copyInviteLink').should('be.visible').click();
cy.get('@clipboard').its('contents').then((val) => {
const inviteLink = val;
// # Logout from admin account and visit the invite url
cy.apiLogout();
cy.visit(inviteLink);
const email = `user${randomId}@sample.gmail.com`;
const username = `user${randomId}`;
const password = 'passwd';
const errorMessage = `The following email addresses do not belong to an accepted domain: ${emailDomain}. Please contact your System Administrator for details.`;
// # Type email, username and password
cy.get('#input_email').should('be.visible').type(email);
cy.get('#input_name').type(username);
cy.get('#input_password-input').type(password);
// # Attempt to create an account by clicking on the 'Create Account' button
cy.findByText('Create Account').click();
// * Assert that the expected error message from creating an account with an email not from the allowed email domain exists and is visible
cy.findByText(errorMessage).should('be.visible');
});
});
it('MM-T2341 Cannot add a user to a team if the user\'s email is not from the correct domain', () => {
// # Open team menu and click 'Team Settings'
cy.uiOpenTeamMenu('Team Settings');
// * Check that the 'Team Settings' modal was opened
cy.get('#teamSettingsModal').should('exist').within(() => {
// # Click on the 'Allow any user with an account on this server to join this team' edit button
cy.get('#open_inviteEdit').should('be.visible').click();
// # Enable any user with an account on the server to join the team
cy.get('#teamOpenInvite').should('be.visible').check();
// # Save and verify it took effect
cy.uiSave();
cy.get('#open_inviteDesc').should('be.visible').and('have.text', 'Yes');
// # Click on the 'Allow only users with a specific email domain to join this team' edit button
cy.get('#allowed_domainsEdit').should('be.visible').click();
// # Set 'sample.mattermost.com' as the only allowed email domain and save
cy.wait(TIMEOUTS.HALF_SEC);
cy.findByRole('textbox', {name: 'Allowed Domains'}).should('be.visible').and('be.focused').type(emailDomain);
// # Save and verify it took effect
cy.uiSave();
cy.get('#allowed_domainsDesc').should('be.visible').and('have.text', emailDomain);
// # Close the modal
cy.uiClose();
});
// # Create a new user
cy.apiCreateUser({user: {email: `user${randomId}@sample.gmail.com`, username: `user${randomId}`, password: 'passwd'}}).then(({user}) => {
// # Create a second team
cy.apiCreateTeam('other-team', 'Other Team').then(({team: otherTeam}) => {
// # Add user to the other team
cy.apiAddUserToTeam(otherTeam.id, user.id).then(() => {
// # Login as new team admin
cy.apiLogin(user);
// # Go to Town Square
cy.visit(`/${otherTeam.name}/channels/town-square`);
// # Open team menu and click 'Join Another Team'
cy.uiOpenTeamMenu('Join Another Team');
// # Try to join the existing team
cy.get('.signup-team-dir').find(`#${testTeam.display_name.replace(' ', '_')}`).scrollIntoView().click();
// * Verify that they get a 'Cannot join' screen
cy.get('div.has-error').should('contain', 'The user cannot be added as the domain associated with the account is not permitted.');
});
});
});
});
});

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

@@ -0,0 +1,176 @@
// 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 @team_settings
import {
promoteToChannelOrTeamAdmin,
} from '../enterprise/system_console/channel_moderation/helpers.js';
describe('Manage Members', () => {
let testTeam;
let testUser;
beforeEach(() => {
// # Login as sysadmin
cy.apiAdminLogin();
// # Login as test user and visit town-square
cy.apiInitSetup().then(({team, user}) => {
testTeam = team;
testUser = user;
});
});
it('MM-T2331 System Admin can promote Member to Team Admin', () => {
// # Go to Town Square
cy.visit(`/${testTeam.name}/channels/town-square`);
// # Open team menu and click 'Manage Members'
cy.uiOpenTeamMenu('Manage Members');
// # Open member dropdown
cy.get(`#teamMembersDropdown_${testUser.username}`).should('be.visible').click();
// # Click Make Team Admin
cy.get(`#teamMembersDropdown_${testUser.username} ~ div button:contains(Make Team Admin)`).should('be.visible').click();
// * Verify dropdown shows that user is now a Team Admin
cy.get(`#teamMembersDropdown_${testUser.username} span:contains(Team Admin)`).should('be.visible');
});
it('MM-T2334 Team Admin can promote Member to Team Admin', () => {
// # Make the test user a Team Admin
promoteToChannelOrTeamAdmin(testUser.id, testTeam.id, 'teams');
// # Create a new user
cy.apiCreateUser({prefix: 'nonAdminUser'}).then(({user}) => {
// # Add user to the team
cy.apiAddUserToTeam(testTeam.id, user.id).then(() => {
// # Login as new team admin
cy.apiLogin(testUser);
// # Go to Town Square
cy.visit(`/${testTeam.name}/channels/town-square`);
// # Open team menu and click 'Manage Members'
cy.uiOpenTeamMenu('Manage Members');
// # Open member dropdown
cy.get(`#teamMembersDropdown_${user.username}`).should('be.visible').click();
// # Click Make Team Admin
cy.get(`#teamMembersDropdown_${user.username} ~ div button:contains(Make Team Admin)`).should('be.visible').click();
// * Verify dropdown shows that user is now a Team Admin
cy.get(`#teamMembersDropdown_${user.username} span:contains(Team Admin)`).should('be.visible');
});
});
});
it('MM-T2335 Remove a team member and ensure they cannot rejoin if the team is not joinable', () => {
// # Make the test user a Team Admin
promoteToChannelOrTeamAdmin(testUser.id, testTeam.id, 'teams');
// # Create a new user
cy.apiCreateUser({prefix: 'nonAdminUser'}).then(({user}) => {
// # Add user to the team
cy.apiAddUserToTeam(testTeam.id, user.id).then(() => {
// # Create a second team
cy.apiCreateTeam('other-team', 'Other Team').then(({team: otherTeam}) => {
// # Add user to the other team
cy.apiAddUserToTeam(otherTeam.id, user.id).then(() => {
// # Login as new team admin
cy.apiLogin(testUser);
// # Go to Town Square
cy.visit(`/${testTeam.name}/channels/town-square`);
// # Open team menu and click 'Manage Members'
cy.uiOpenTeamMenu('Manage Members');
// # Open member dropdown
cy.get(`#teamMembersDropdown_${user.username}`).should('be.visible').click();
// # Click Remove from Team
cy.get(`#teamMembersDropdown_${user.username} ~ div button:contains(Remove from Team)`).should('be.visible').click();
// * Verify teammate no longer appears
cy.get(`#teamMembersDropdown_${user.username}`).should('not.exist');
// # Login as non admin user
cy.apiLogin(user);
// # Go to team that they are still a member of
cy.visit(`/${otherTeam.name}/channels/town-square`);
// * Verify they are still a member
cy.uiGetLHSHeader().should('contain', otherTeam.display_name);
// # Go to team that they were removed from
cy.visit(`/${testTeam.name}/channels/town-square`);
// * Verify that they get a 'Team Not Found' screen
cy.url().should('include', '/error?type=team_not_found');
});
});
});
});
});
it('MM-T2338 Remove a team member and ensure they can rejoin with invite link', () => {
promoteToChannelOrTeamAdmin(testUser.id, testTeam.id, 'teams');
// # Create a new user
cy.apiCreateUser({prefix: 'nonAdminUser'}).then(({user}) => {
// # Add user to the team
cy.apiAddUserToTeam(testTeam.id, user.id).then(() => {
// # Login as new team admin
cy.apiLogin(testUser);
// # Go to Town Square
cy.visit(`/${testTeam.name}/channels/town-square`);
// # Open team menu and click 'Manage Members'
cy.uiOpenTeamMenu('Manage Members');
// # Open member dropdown
cy.get(`#teamMembersDropdown_${user.username}`).should('be.visible').click();
// # Click Remove from Team
cy.get(`#teamMembersDropdown_${user.username} ~ div button:contains(Remove from Team)`).should('be.visible').click();
// * Verify teammate no longer appears
cy.get(`#teamMembersDropdown_${user.username}`).should('not.exist');
// # Close the modal
cy.get('#teamMembersModal').find('button.close').should('be.visible').click();
// # Get the invite link
cy.getInvitePeopleLink({user: testUser}).then((inviteLink) => {
// # Login as non admin user
cy.apiLogin(user);
// # Go to team that they were removed from
cy.visit(`/${testTeam.name}/channels/town-square`);
// * Verify that they get a 'Team Not Found' screen
cy.url().should('include', '/error?type=team_not_found');
// # Go to the invite link
cy.visit(inviteLink);
// * Verify that the user has rejoined the team
cy.uiGetLHSHeader().should('contain', testTeam.display_name);
});
});
});
});
});

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

@@ -0,0 +1,96 @@
// 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 @team_settings
describe('Teams Settings', () => {
let testTeam;
before(() => {
// # Update config
cy.apiUpdateConfig({EmailSettings: {RequireEmailVerification: false}});
cy.apiInitSetup().then(({team}) => {
testTeam = team;
cy.visit(`/${testTeam.name}/channels/town-square`);
});
});
it('MM-T391 Remove team icon', () => {
// # Open team settings dialog
openTeamSettingsDialog();
// * Verify the settings picture button is visible to click
cy.findByTestId('inputSettingPictureButton').should('be.visible').click();
// * Before uploading the picture the save button must be disabled
cy.uiSaveButton().should('be.disabled');
// # Upload a file on center view
cy.findByTestId('uploadPicture').attachFile('mattermost-icon.png');
// * Save then close
cy.uiSaveAndClose();
// * Verify team icon
cy.get(`#${testTeam.name}TeamButton`).within(() => {
cy.findByTestId('teamIconImage').should('be.visible');
cy.findByTestId('teamIconInitial').should('not.exist');
});
// # Open the team settings dialog
openTeamSettingsDialog();
// # Click on 'X' icon to remove the image
cy.findByTestId('removeSettingPicture').should('be.visible').click();
// # Click on the cancel button
cy.findByTestId('cancelSettingPicture').should('be.visible').click();
// # Close the team settings dialog
cy.uiClose();
// * Verify the team icon image is visible and initial team holder is not visible
cy.get(`#${testTeam.name}TeamButton`).within(() => {
cy.findByTestId('teamIconImage').should('be.visible');
cy.findByTestId('teamIconInitial').should('not.exist');
});
// # Open team settings dialog
openTeamSettingsDialog();
// # Click on 'X' icon to remove the image
cy.findByTestId('removeSettingPicture').should('be.visible').click();
// # Save and close the modal
cy.uiSaveAndClose();
// * After removing the team icon initial team holder is visible but not team icon holder
cy.get(`#${testTeam.name}TeamButton`).within(() => {
cy.findByTestId('teamIconImage').should('not.exist');
cy.findByTestId('teamIconInitial').should('be.visible');
});
});
});
function openTeamSettingsDialog() {
// # Open team menu and click 'Team Settings'
cy.uiOpenTeamMenu('Team Settings');
// * Verify the team settings dialog is open
cy.get('#teamSettingsModalLabel').should('be.visible').and('contain', 'Team Settings');
// * Verify the edit icon is visible
cy.get('#team_iconEdit').should('be.visible');
// # Click on edit button
cy.get('#team_iconEdit').click();
}

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

@@ -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.
// ***************************************************************
// Stage: @prod
// Group: @channels @team_settings
describe('Teams Suite', () => {
before(() => {
// # Build data to test and login as team admin
cy.apiInitSetup().then(({team, user}) => {
const requiredMembersCount = 60;
// # Get users not in team and add into the team
cy.apiGetUsersNotInTeam({teamId: team.id, page: 0, perPage: 200}).then(({users}) => {
const usersToAdd = users.
filter((u) => u.delete_at === 0).
slice(0, requiredMembersCount - 3).
map((u) => ({team_id: team.id, user_id: u.id}));
Cypress._.chunk(usersToAdd, 20).forEach((chunk) => {
cy.apiAddUsersToTeam(team.id, chunk);
});
});
// # Check number of team members and add if required.
cy.apiGetTeamMembers(team.id).then(({members}) => {
if (members.length < requiredMembersCount) {
Cypress._.times(requiredMembersCount - members.length, () => {
cy.apiCreateUser().then(({user: newUser}) => {
cy.apiAddUserToTeam(team.id, newUser.id);
});
});
}
});
// # Promote user to team admin
cy.apiUpdateTeamMemberSchemeRole(team.id, user.id, {scheme_admin: true, scheme_user: true});
// # Login as test user and visit town-square
cy.apiLogin(user);
cy.visit(`/${team.name}/channels/town-square`);
});
});
it('MM-T384 Team Admin can use Next button to page through list in Manage Members', () => {
// # Open team menu and click "Manage Members"
cy.uiOpenTeamMenu('Manage Members');
// * Check Manage Members modal dialog
cy.get('#teamMemberModalLabel').should('be.visible');
// * Check teammate total
cy.get('#searchableUserListTotal').should('contain', '1 - 50 members of 60 total');
// # Click Next button
cy.get('#searchableUserListNextBtn').should('be.visible').click();
// * Check teammate list advances by one page
cy.get('#searchableUserListTotal').should('contain', '51 - 60 members of 60 total');
// # Click Prev button
cy.get('#searchableUserListPrevBtn').should('be.visible').click();
// * Check teammate list reverses by one page
cy.get('#searchableUserListTotal').should('contain', '1 - 50 members of 60 total');
});
});

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

@@ -0,0 +1,351 @@
// 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 @team_settings
import * as TIMEOUTS from '../../../fixtures/timeouts';
import {getAdminAccount} from '../../../support/env';
describe('Teams Suite', () => {
let testTeam;
let testUser;
let newUser;
beforeEach(() => {
cy.apiAdminLogin();
cy.apiCreateUser().then(({user}) => {
newUser = user;
});
cy.apiInitSetup().then(({team, user}) => {
testTeam = team;
testUser = user;
});
});
it('MM-T393 Cancel out of leaving team', () => {
// # Login and go to /
cy.apiLogin(testUser);
cy.visit(`/${testTeam.name}/channels/town-square`);
// * Check the team name
cy.uiGetLHSHeader().findByText(testTeam.display_name);
// * Check the initial Url
cy.url().should('include', `/${testTeam.name}/channels/town-square`);
// # Open team menu and click "Manage Members"
cy.uiOpenTeamMenu('Leave Team');
// * Check that the "leave team modal" opened up
cy.get('#leaveTeamModal').should('be.visible');
// # Click on no
cy.get('#leaveTeamNo').click();
// * Check that the "leave team modal" closed
cy.get('#leaveTeamModal').should('not.exist');
// * check the team name
cy.uiGetLHSHeader().findByText(testTeam.display_name);
// * check the final Url
cy.url().should('include', `/${testTeam.name}/channels/town-square`);
});
it('MM-T2340 Team or System Admin searches and adds new team member', () => {
// # Update config
cy.apiUpdateConfig({
GuestAccountsSettings: {
Enable: false,
},
});
let otherUser;
cy.apiCreateUser().then(({user}) => {
otherUser = user;
cy.visit(`/${testTeam.name}/channels/town-square`);
// # Open team menu and click "Invite People"
cy.uiOpenTeamMenu();
cy.uiGetLHSTeamMenu().findByText('Add people to the team');
cy.uiGetLHSTeamMenu().findByText('Invite People').click();
// * Check that the Invitation Modal opened up
cy.findByTestId('invitationModal', {timeout: TIMEOUTS.HALF_SEC}).should('be.visible');
cy.get('.users-emails-input__control').should('be.visible').within(($el) => {
// # Type the first letters of a user
cy.wrap($el).get('input').typeWithForce(otherUser.first_name);
});
// * Verify user is on the list, then select by clicking on it
cy.get('.users-emails-input__menu').
children().should('have.length', 1).
eq(0).should('contain', `@${otherUser.username}`).and('contain', `${otherUser.first_name} ${otherUser.last_name}`).
click();
// # Click "Invite Members" button, then "Done" button
cy.get('#inviteMembersButton').click();
cy.findByTestId('confirm-done').click();
// * As sysadmin, verify system message posts in Town Square and Off-Topic
cy.getLastPost().wait(TIMEOUTS.HALF_SEC).then(($el) => {
cy.wrap($el).get('.user-popover').
should('be.visible').
and('have.text', 'System');
cy.wrap($el).get('.post-message__text-container').
should('be.visible').
and('contain', `You and @${testUser.username} joined the team.`).
and('contain', `@${otherUser.username} added to the team by you.`);
});
cy.get('#sidebarItem_off-topic').should('be.visible').click({force: true});
cy.getLastPost().wait(TIMEOUTS.HALF_SEC).then(($el) => {
cy.wrap($el).get('.user-popover').
should('be.visible').
and('have.text', 'System');
cy.wrap($el).get('.post-message__text-container').
should('be.visible').
and('contain', `You and @${testUser.username} joined the channel.`).
and('contain', `@${otherUser.username} added to the channel by you.`);
});
// # Login as user added to Team and reload
cy.apiLogin(otherUser);
// # Visit the new team and verify that it's in the correct team view
cy.visit(`/${testTeam.name}/channels/town-square`);
cy.uiGetLHSHeader().findByText(testTeam.display_name);
const sysadmin = getAdminAccount();
// * As other user, verify system message posts in Town Square and Off-Topic
cy.getLastPost().wait(TIMEOUTS.HALF_SEC).then(($el) => {
cy.wrap($el).get('.user-popover').
should('be.visible').
and('have.text', 'System');
cy.wrap($el).get('.post-message__text-container').
should('be.visible').
and('contain', `@${sysadmin.username} joined the team.`).
and('contain', `You were added to the team by @${sysadmin.username}.`);
});
cy.get('#sidebarItem_off-topic').should('be.visible').click({force: true});
cy.getLastPost().wait(TIMEOUTS.HALF_SEC).then(($el) => {
cy.wrap($el).get('.user-popover').
should('be.visible').
and('have.text', 'System');
cy.wrap($el).get('.post-message__text-container').
should('be.visible').
and('contain', `@${sysadmin.username} joined the channel.`).
and('contain', `You were added to the channel by @${sysadmin.username}.`);
});
// # Remove user from team
removeTeamMember(testTeam.name, otherUser.username);
});
});
it('MM-T394 Leave team by clicking Yes, leave all teams', () => {
cy.apiUpdateConfig({EmailSettings: {RequireEmailVerification: false}});
// // # Login as test user
cy.apiLogin(testUser);
// # Leave all teams
cy.apiGetTeamsForUser().then(({teams}) => {
teams.forEach((team) => {
cy.visit(`/${team.name}/channels/town-square`);
cy.uiGetLHSHeader().findByText(testTeam.display_name);
cy.leaveTeam();
});
});
// * Check that it redirects into team selection page after leaving all teams
cy.url().should('include', '/select_team');
// # Check that logout is visible and then click to logout
cy.get('#logout').should('be.visible').click();
// * Ensure user is logged out
cy.url({timeout: TIMEOUTS.HALF_MIN}).should('include', 'login');
});
it('MM-T1535 Team setting / Invite code text', () => {
// # visit /
cy.visit(`/${testTeam.name}/channels/town-square`);
// # Open team menu and click "Team Settings"
cy.uiOpenTeamMenu('Team Settings');
// # Open edit settings for invite code
cy.findByText('Invite Code').should('be.visible').click();
// * Verify invite code help text is visible
cy.findByText('The Invite Code is part of the unique team invitation link which is sent to members youre inviting to this team. Regenerating the code creates a new invitation link and invalidates the previous link.').
scrollIntoView().
should('be.visible');
// # Close the team settings
cy.get('body').typeWithForce('{esc}');
});
it('MM-T2312 Team setting / Team name: Change name', () => {
const teamName = 'Test Team';
// # Visit town-square channel
cy.visit(`/${testTeam.name}/channels/town-square`);
// # Open team menu and click "Team Settings"
cy.uiOpenTeamMenu('Team Settings');
// # Click on the team name menu item
cy.findByText('Team Name').should('be.visible').click();
// # Change team name in the input
cy.get('#teamName').should('be.visible').clear().type(teamName);
// Save new team name
cy.findByText(/save/i).click();
// # Close the team settings
cy.get('body').typeWithForce('{esc}');
// Team display name shows as "Testing Team" at top of team menu
cy.uiGetLHSHeader().findByText(teamName);
// Team initials show in the team icon in the sidebar
cy.get(`#${testTeam.name}TeamButton`).scrollIntoView().should('have.attr', 'aria-label', 'test team team');
// # Verify url has original team name
cy.url().should('include', `/${testTeam.name}/channels/town-square`);
});
it('MM-T2317 Team setting / Update team description', () => {
const teamDescription = 'This is the best team';
// # Visit town-square channel
cy.visit(`/${testTeam.name}/channels/town-square`);
// # Open team menu and click "Team Settings"
cy.uiOpenTeamMenu('Team Settings');
// # Click on the team description menu item
cy.findByText('Team Description').should('be.visible').click();
// # Change team description in the input
cy.get('#teamDescription').should('be.visible').clear().type(teamDescription);
cy.get('#teamDescription').should('have.value', teamDescription);
// Save and close
cy.uiSaveAndClose();
// # Open team menu and click "Team Settings"
cy.uiOpenTeamMenu('Team Settings');
// * Verify team description is updated
cy.get('#descriptionDesc').should('have.text', teamDescription);
});
it('MM-T2318 Allow anyone to join this team', () => {
// # Visit town-square channel
cy.visit(`/${testTeam.name}/channels/town-square`);
// # Open team menu and click "Team Settings"
cy.uiOpenTeamMenu('Team Settings');
// # Click on the team description menu item
cy.findByText('Allow any user with an account on this server to join this team').should('be.visible').click();
// # Change team description in the input
cy.get('#teamOpenInvite').click();
// Save new team description
cy.findByText(/save/i).click();
// # Close the team settings
cy.get('body').typeWithForce('{esc}');
// # Login as new user
cy.apiLogin(newUser);
cy.visit('/');
// * Verify if the user is redirected to the Select Team page
cy.url().should('include', '/select_team');
cy.get('#teamsYouCanJoinContent').should('be.visible');
// # Select test team name
cy.findByText(testTeam.display_name, {timeout: TIMEOUTS.HALF_MIN}).should('be.visible').click();
// # Verify Town square is visible
cy.url().should('include', `/${testTeam.name}/channels/town-square`);
cy.findByText('Beginning of Town Square').should('be.visible');
});
it('MM-T2322 Do not allow anyone to join this team', () => {
// # Allow any user with an account on this server to join this new team
cy.apiCreateTeam().then(({team: joinableTeam}) => {
cy.apiPatchTeam(joinableTeam.id, {allow_open_invite: true});
});
// # Visit town-square channel
cy.visit(`/${testTeam.name}/channels/town-square`);
// # Open team menu and click "Team Settings"
cy.uiOpenTeamMenu('Team Settings');
// # Click on the team description menu item
cy.findByText('Allow any user with an account on this server to join this team').should('be.visible').click();
// # Change team description in the input
cy.get('#teamOpenInviteNo').click();
// Save new team description and close team settings
cy.uiSaveAndClose();
// # Login as new user
cy.apiLogin(testUser);
cy.visit(`/${testTeam.name}/channels/town-square`);
// # Open team menu and click "Join Another Team"
cy.uiOpenTeamMenu('Join Another Team');
// # Verify the original test team isn't on the list
cy.get('.signup-team-dir').children().should('not.contain', `#${testTeam.name.charAt(0).toUpperCase() + testTeam.name.slice(1)}`);
});
it('MM-T2328 Member can view and search for members', () => {
cy.apiLogout();
cy.wait(TIMEOUTS.ONE_SEC);
// * Login as test user and join town square
cy.apiLogin(testUser);
cy.visit(`/${testTeam.name}/channels/town-square`);
// # Open team menu and click "View Members"
cy.uiOpenTeamMenu('View Members');
cy.wait(TIMEOUTS.HALF_SEC);
cy.get('#searchUsersInput').should('be.visible').type('sysadmin');
cy.get('.more-modal__list').should('be.visible').children().should('have.length', 1);
});
});
function removeTeamMember(teamName, username) {
cy.apiAdminLogin();
cy.visit(`/${teamName}`);
// # Open team menu and click "Manage Members"
cy.uiOpenTeamMenu('Manage Members');
cy.get(`#teamMembersDropdown_${username}`).should('be.visible').click();
cy.get('#removeFromTeam').should('be.visible').click();
cy.uiClose();
}