Files
upstream-mirror 240db4e2a7
Some checks failed
Server CI / Postgres (shard 0) (push) Has been skipped
Server CI / Postgres (shard 3) (push) Has been skipped
BuildEnv Docker Image / build-image (push) Failing after 4s
BuildEnv Docker Image / build-image-fips (push) Failing after 4s
Migration Review & Release Notes / Generate migration review & release notes (push) Failing after 3s
Server CI / Build Environment (push) Failing after 3s
Server CI / Postgres (shard 1) (push) Has been skipped
Tools CI / check-style (mattermost-govet) (push) Failing after 4s
Server CI / Postgres (shard 2) (push) Has been skipped
Tools CI / check-style (mmgotool) (push) Failing after 3s
Server CI / Elasticsearch v8 Compatibility (push) Has been skipped
Server CI / OpenSearch v2 Compatibility (push) Has been skipped
Server CI / Postgres FIPS (shard 0) (push) Has been skipped
Tools CI / Test (mattermost-govet) (push) Failing after 3s
Server CI / Postgres FIPS (shard 1) (push) Has been skipped
Server CI / Postgres FIPS (shard 2) (push) Has been skipped
Tools CI / Test (mmgotool) (push) Failing after 3s
Server CI / Postgres FIPS (shard 3) (push) Has been skipped
Server CI / Run mmctl tests (push) Has been skipped
Server CI / Run mmctl tests (FIPS) (push) Has been skipped
Server CI / Merge Postgres Test Results (push) Has been skipped
Server CI / Merge Postgres FIPS Test Results (push) Has been skipped
Server CI / Check backport migrations (push) Has been skipped
Server CI / Check generated files (push) Has been skipped
Server CI / check-style (push) Has been skipped
Server CI / Vet API (push) Has been skipped
Server CI / Build mattermost server app (push) Has been skipped
Server CI / Server CI Complete (push) Failing after 2s
Server CI / Server CI Artifacts (push) Has been skipped
Server CI / Sentry Upload (push) Has been skipped
Server CI / Server CI Report (push) Failing after 5m1s
Server CI Nightly Race / Race Detector (push) Has been skipped
CodeQL / Analyze (go) (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
Webapp CI Cache Warm / Warm Webapp node_modules Cache (push) Has been cancelled
E2E CI Cache Warm / Warm E2E npm Registry Cache (push) Has been cancelled
API / build (push) Has been cancelled
Web App CI / check-types (push) Has been cancelled
Web App CI / check-lint (push) Has been cancelled
Web App CI / check-i18n (push) Has been cancelled
Web App CI / check-external-links (push) Has been cancelled
Web App CI / test (platform) (push) Has been cancelled
Web App CI / test (mattermost-redux) (push) Has been cancelled
Web App CI / test (channels shard 1/4) (push) Has been cancelled
Web App CI / test (channels shard 2/4) (push) Has been cancelled
Web App CI / test (channels shard 3/4) (push) Has been cancelled
Web App CI / test (channels shard 4/4) (push) Has been cancelled
Web App CI / upload-coverage (push) Has been cancelled
Web App CI / build (push) Has been cancelled
YAML Lint / yamllint (push) Has been cancelled
Push mirrored docker images / cd/Push mirrored docker images (push) Has been cancelled
docs-cd / Build and deploy docs (push) Has been cancelled
Docs CI / build (push) Has been cancelled
E2E Cache Warm: Cypress deps / Warm Cypress deps cache (push) Has been cancelled
Scorecards supply-chain security / Scorecard analysis (push) Has been cancelled
Server CI Weekly / Postgres FIPS (push) Has been skipped
Server CI Weekly / Run mmctl tests (FIPS) (push) Has been skipped
Server CI Weekly / Postgres with binary parameters (push) Has been skipped
Server CI Weekly / Build Environment (push) Failing after 1s
Server CI Cache Warm / Warm Go Module and Build Cache (push) Failing after 2s
Server CI Nightly Race / Build Environment (push) Failing after 1s
snapshot of https://github.com/mattermost/mattermost.git (master, 2026-09-16; blobs > 131072B omitted)
2026-09-16 00:29:55 +05:00

362 lines
14 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// 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().find('div.label-elements > span:nth-child(2)').should('have.text', 'Add or invite people to the team');
cy.uiGetLHSTeamMenu().find("li span:contains('Invite people')").should('have.text', 'Invite people').click().wait(TIMEOUTS.HALF_SEC);
// * 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.findByTestId('inviteButton').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} and @${testUser.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.findAllByTestId('postView').last().scrollIntoView();
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} and @${testUser.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');
// # Go to Access section
cy.get('#accessButton').click();
// # 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 you’re 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 annd close<
saveAndCloseTeamSettings();
// 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');
// # 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
saveAndCloseTeamSettings();
cy.wait(TIMEOUTS.ONE_HUNDRED_MILLIS);
// # Open team menu and click "Team Settings"
cy.uiOpenTeamMenu('Team settings');
// * Verify team description is updated
cy.get('#teamDescription').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');
// # Go to Access section
cy.get('#accessButton').click();
// # Click 'Public Team' card to allow any user to join this team
cy.get('#public-private-selector-button-O').should('exist').and('not.have.class', 'selected').click();
// # Save and close
saveAndCloseTeamSettings();
// # 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.get('h2.channel-intro__title').should('be.visible').should('have.text', 'Town Square');
});
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');
// # Go to Access section
cy.get('#accessButton').click();
// * Verify Private Team card is selected (open joining disabled by default)
cy.get('#public-private-selector-button-P').should('exist').and('have.class', 'selected');
// # Close the modal
cy.uiClose();
// # 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 saveAndCloseTeamSettings() {
// # Save the changes
cy.uiSave();
// * Wait for changes to be saved so the modal can be closed
cy.get('.SaveChangesPanel').should('contain', 'Settings saved');
// # Close the modal
cy.uiClose();
}
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();
}