snapshot of https://github.com/mattermost/mattermost.git (master, 2026-09-16; blobs > 131072B omitted)
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 1s
Server CI Nightly Race / Build Environment (push) Failing after 1s

This commit is contained in:
upstream-mirror
2026-09-16 00:29:55 +05:00
commit 240db4e2a7
15309 changed files with 2173406 additions and 0 deletions

View File

@@ -0,0 +1,349 @@
// 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 @system_console @group_mentions
import type {Team} from '@mattermost/types/teams';
import type {UserProfile} from '@mattermost/types/users';
import type {Group} from '@mattermost/types/groups';
import {
disablePermission,
enablePermission,
} from '../system_console/channel_moderation/helpers';
import {enableGroupMention} from './helpers';
import ldapUsers from '@/fixtures/ldap_users.json';
import * as TIMEOUTS from '@/fixtures/timeouts';
describe('Group Mentions', () => {
let groupID: string;
let boardUser: Cypress.UserProfile;
let regularUser: UserProfile;
let testTeam: Team;
before(() => {
// * Check if server has license for LDAP Groups
cy.apiRequireLicenseForFeature('LDAPGroups');
// # Enable GuestAccountSettings
cy.apiUpdateConfig({
GuestAccountsSettings: {
Enable: true,
},
});
cy.apiInitSetup().then(({team, user}) => {
regularUser = user;
testTeam = team;
});
// # Test LDAP configuration and server connection
// # Synchronize user attributes
cy.apiLDAPTest();
cy.apiLDAPSync();
// # Link the LDAP Group - board
cy.visit('/admin_console/user_management/groups');
cy.get('#board_group', {timeout: TIMEOUTS.ONE_MIN}).then((el) => {
if (!el.text().includes('Edit')) {
// # Link the Group if its not linked before
if (el.find('.icon.fa-unlink').length > 0) {
el.find('.icon.fa-unlink').click();
}
}
});
// # Get board group id
cy.apiGetGroups().then((res) => {
res.body.forEach((group: Group) => {
if (group.display_name === 'board') {
// # Set groupID to navigate to group page directly
groupID = group.id;
// # Set allow reference false to ensure correct data for test cases
cy.apiPatchGroup(groupID, {allow_reference: false});
}
});
});
// # Login once as board user to ensure the user is created in the system
boardUser = ldapUsers['board-1'] as unknown as Cypress.UserProfile;
cy.apiLogin(boardUser);
// # Login as sysadmin
cy.apiAdminLogin();
// # Add board user to test team to ensure that it exists in the team and set its preferences to skip tutorial step
cy.apiGetUserByEmail(boardUser.email).then(({user}) => {
cy.apiGetChannelByName(testTeam.name, 'town-square').then(({channel}) => {
cy.apiAddUserToTeam(testTeam.id, user.id).then(() => {
cy.apiAddUserToChannel(channel.id, user.id);
});
});
cy.apiSaveTutorialStep(user.id, '999');
});
});
after(() => {
// # Login as sysadmin and navigate to system scheme page
cy.apiAdminLogin();
cy.visit('/admin_console/user_management/permissions/system_scheme');
cy.get('.admin-console__header', {timeout: TIMEOUTS.ONE_MIN}).should('be.visible').and('have.text', 'System Scheme');
// # Click reset to defaults and confirm
cy.findByTestId('resetPermissionsToDefault').click();
cy.get('#confirmModalButton').click();
// # Save
cy.uiSaveConfig();
});
it('MM-T2450 - Group Mentions when user is a Channel Admin', () => {
const groupName = `board_test_case_${Date.now()}`;
// # Login as sysadmin and enable group mention with the group name
cy.apiAdminLogin();
enableGroupMention(groupName, groupID, boardUser.email);
// # Disable Group Mentions for All Users & Channel Admins
cy.visit('/admin_console/user_management/permissions/system_scheme');
cy.get('.admin-console__header', {timeout: TIMEOUTS.ONE_MIN}).should('be.visible').and('have.text', 'System Scheme');
disablePermission('all_users-posts-use_group_mentions-checkbox');
disablePermission('channel_admin-posts-use_group_mentions-checkbox');
cy.uiSaveConfig();
// # Login as a regular user
cy.apiLogin(regularUser);
// # Create a new channel so that regular user can be channel admin
cy.apiCreateChannel(testTeam.id, 'group-mention', 'Group Mentions').then(({channel}) => {
// # Visit the channel
cy.visit(`/${testTeam.name}/channels/${channel.name}`);
// # Type the Group Name
cy.uiGetPostTextBox().clear().type(`@${groupName}`).wait(TIMEOUTS.TWO_SEC);
// * Verify if autocomplete dropdown is not displayed
cy.get('#suggestionList').should('not.exist');
// # Submit a post containing the group mention
cy.postMessage(`@${groupName} hello`);
// * Verify if a system message is not displayed
cy.getLastPostId().then((postId) => {
cy.get(`#postMessageText_${postId}`).should('include.text', `@${groupName}`);
// * Verify that the group mention is not highlighted
cy.get(`#postMessageText_${postId}`).find('.mention--highlight').should('not.exist');
// * Verify that the group mention does not has blue colored text
cy.get(`#postMessageText_${postId}`).find('.group-mention-link').should('not.exist');
});
// # Enable Group Mentions for Channel Admins
cy.apiAdminLogin();
cy.visit('/admin_console/user_management/permissions/system_scheme');
cy.get('.admin-console__header', {timeout: TIMEOUTS.ONE_MIN}).should('be.visible').and('have.text', 'System Scheme');
enablePermission('channel_admin-posts-use_group_mentions-checkbox');
cy.uiSaveConfig();
// # Login as a regular user and visit the channel
cy.apiLogin(regularUser);
cy.visit(`/${testTeam.name}/channels/${channel.name}`);
// # Type the Group Name
cy.uiGetPostTextBox().clear().type(`@${groupName}`).wait(TIMEOUTS.TWO_SEC);
// * Verify if autocomplete dropdown is displayed
cy.get('#suggestionList').should('be.visible').children().within((el) => {
cy.wrap(el).eq(0).should('contain', 'Group Mentions');
cy.wrap(el).eq(1).should('contain', groupName);
});
// # Submit a post containing the group mention
cy.postMessage(`@${groupName} hello`);
// * Verify if a system message is displayed
cy.getLastPostId().then((postId) => {
cy.get(`#postMessageText_${postId}`).should('include.text', `@${boardUser.username} did not get notified by this mention because they are not in the channel. Would you like to add them to the channel? They will have access to all message history.`);
// * Verify if an option should be given to add them to channel
cy.get('a.PostBody_addChannelMemberLink').should('be.visible');
});
});
});
it('MM-T2451 - Group Mentions when user is a Team Admin', () => {
const groupName = `board_test_case_${Date.now()}`;
// # Login as sysadmin and enable group mention with the group name
cy.apiAdminLogin();
enableGroupMention(groupName, groupID, boardUser.email);
// # Disable Group Mentions for All Users & Channel Admins & Team Admins
cy.visit('/admin_console/user_management/permissions/system_scheme');
cy.get('.admin-console__header', {timeout: TIMEOUTS.ONE_MIN}).should('be.visible').and('have.text', 'System Scheme');
disablePermission('all_users-posts-use_group_mentions-checkbox');
disablePermission('channel_admin-posts-use_group_mentions-checkbox');
disablePermission('team_admin-posts-use_group_mentions-checkbox');
cy.uiSaveConfig();
// # Login as a regular user
cy.apiLogin(regularUser);
// # Create a new team and channel so that regular user can be team admin
cy.apiCreateTeam('team', 'Test NoMember').then(({team}) => {
cy.apiCreateChannel(team.id, 'group-mention', 'Group Mentions').then(({channel}) => {
// # Visit the channel
cy.visit(`/${team.name}/channels/${channel.name}`);
// # Type the Group Name
cy.uiGetPostTextBox().clear().type(`@${groupName}`).wait(TIMEOUTS.TWO_SEC);
// * Verify if autocomplete dropdown is not displayed
cy.get('#suggestionList').should('not.exist');
// # Submit a post containing the group mention
cy.postMessage(`@${groupName} hello`);
// * Verify if a system message is not displayed
cy.getLastPostId().then((postId) => {
cy.get(`#postMessageText_${postId}`).should('include.text', `@${groupName}`);
// * Verify that the group mention is not highlighted
cy.get(`#postMessageText_${postId}`).find('.mention--highlight').should('not.exist');
// * Verify that the group mention does not has blue colored text
cy.get(`#postMessageText_${postId}`).find('.group-mention-link').should('not.exist');
});
// # Enable Group Mentions for Team Admins
cy.apiAdminLogin();
cy.visit('/admin_console/user_management/permissions/system_scheme');
cy.get('.admin-console__header', {timeout: TIMEOUTS.ONE_MIN}).should('be.visible').and('have.text', 'System Scheme');
enablePermission('team_admin-posts-use_group_mentions-checkbox');
cy.uiSaveConfig();
// # Login as a regular user and visit the channel
cy.apiLogin(regularUser);
cy.visit(`/${team.name}/channels/${channel.name}`);
// # Type the Group Name
cy.uiGetPostTextBox().clear().type(`@${groupName}`).wait(TIMEOUTS.TWO_SEC);
// * Verify if autocomplete dropdown is displayed
cy.get('#suggestionList').should('be.visible').children().within((el) => {
cy.wrap(el).eq(0).should('contain', 'Group Mentions');
cy.wrap(el).eq(1).should('contain', groupName);
});
// # Submit a post containing the group mention
cy.postMessage(`@${groupName} hello`);
// * Verify if a system message is displayed
cy.getLastPostId().then((postId) => {
cy.get(`#postMessageText_${postId}`).should('include.text', `@${groupName} has no members on this team`);
// * Verify that the group mention is not highlighted
cy.get(`#postMessageText_${postId}`).find('.mention--highlight').should('not.exist');
// * Verify that the group mention has blue colored text
cy.get(`#postMessageText_${postId}`).find('.group-mention-link').should('be.visible');
});
});
});
});
it('MM-T2452 - Group Mentions when user is a Guest User', () => {
const groupName = `board_test_case_${Date.now()}`;
// # Login as sysadmin and enable group mention with the group name
cy.apiAdminLogin();
enableGroupMention(groupName, groupID, boardUser.email);
// # Verify that group mentions for all users & guests are disabled
cy.visit('/admin_console/user_management/permissions/system_scheme');
cy.get('.admin-console__header', {timeout: TIMEOUTS.ONE_MIN}).should('be.visible').and('have.text', 'System Scheme');
cy.findByTestId('all_users-posts-use_group_mentions-checkbox').should('not.have.class', 'checked');
cy.findByTestId('guests-guest_use_group_mentions-checkbox').should('not.have.class', 'checked');
// # Create a new channel as a sysadmin
cy.apiCreateChannel(testTeam.id, 'group-mention', 'Group Mentions').then(({channel}) => {
cy.apiCreateUser().then(({user}) => {
// # Add user to the team and channel
cy.apiAddUserToTeam(testTeam.id, user.id).then(() => {
cy.apiAddUserToChannel(channel.id, user.id);
});
// # Demote the user as a guest user
cy.apiDemoteUserToGuest(user.id);
// # Login as a guest user
cy.apiLogin(user);
// # Visit the channel
cy.visit(`/${testTeam.name}/channels/${channel.name}`);
// # Type the Group Name
cy.uiGetPostTextBox().clear().type(`@${groupName}`).wait(TIMEOUTS.TWO_SEC);
// * Verify if autocomplete dropdown is not displayed
cy.get('#suggestionList').should('not.exist');
// # Submit a post containing the group mention
cy.postMessage(`@${groupName} hello`);
// * Verify if a system message is not displayed
cy.getLastPostId().then((postId) => {
cy.get(`#postMessageText_${postId}`).should('include.text', `@${groupName}`);
// * Verify that the group mention is not highlighted
cy.get(`#postMessageText_${postId}`).find('.mention--highlight').should('not.exist');
// * Verify that the group mention does not has blue colored text
cy.get(`#postMessageText_${postId}`).find('.group-mention-link').should('not.exist');
});
// # Login as sysadmin and enable group mentions permission for guests
cy.apiAdminLogin();
cy.visit('/admin_console/user_management/permissions/system_scheme');
cy.get('.admin-console__header', {timeout: TIMEOUTS.ONE_MIN}).should('be.visible').and('have.text', 'System Scheme');
enablePermission('guests-guest_use_group_mentions-checkbox');
cy.uiSaveConfig();
// # Login as guest user again and visit the channel
cy.apiLogin(user);
cy.visit(`/${testTeam.name}/channels/${channel.name}`);
// # Type the Group Name
cy.uiGetPostTextBox().clear().type(`@${groupName}`).wait(TIMEOUTS.TWO_SEC);
// * Verify if autocomplete dropdown is displayed
cy.get('#suggestionList').should('be.visible').children().within((el) => {
cy.wrap(el).eq(0).should('contain', 'Group Mentions');
cy.wrap(el).eq(1).should('contain', groupName);
});
// # Submit a post containing the group mention
cy.postMessage(`@${groupName} hello`);
// * Verify if a system message is displayed
cy.getLastPostId().then((postId) => {
cy.get(`#postMessageText_${postId}`).should('include.text', `@${boardUser.username} did not get notified by this mention because they are not in the channel.`);
// * Verify that the option to add them to channel is not given
cy.get('a.PostBody_addChannelMemberLink').should('not.exist');
});
});
});
});
});

View File

@@ -0,0 +1,294 @@
// 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 @system_console @group_mentions
import type {UserProfile} from '@mattermost/types/users';
import type {Team} from '@mattermost/types/teams';
import type {Group} from '@mattermost/types/groups';
import {enableGroupMention} from './helpers';
import ldapUsers from '@/fixtures/ldap_users.json';
import * as TIMEOUTS from '@/fixtures/timeouts';
describe('Group Mentions', () => {
let groupID1: string;
let groupID2: string;
let boardUser;
let regularUser: UserProfile;
let testTeam: Team;
before(() => {
// * Check if server has license for LDAP Groups
cy.apiRequireLicenseForFeature('LDAPGroups');
// # Enable GuestAccountSettings
cy.apiUpdateConfig({
GuestAccountsSettings: {
Enable: true,
},
});
cy.apiInitSetup().then(({team, user}) => {
regularUser = user;
testTeam = team;
});
// # Test LDAP configuration and server connection
// # Synchronize user attributes
cy.apiLDAPTest();
cy.apiLDAPSync();
// # Link the LDAP Group - board
cy.visit('/admin_console/user_management/groups');
cy.get('#board_group', {timeout: TIMEOUTS.ONE_MIN}).then((el) => {
if (!el.text().includes('Edit')) {
// # Link the Group if its not linked before
if (el.find('.icon.fa-unlink').length > 0) {
el.find('.icon.fa-unlink').click();
}
}
});
// # Link the LDAP Group - developers
cy.visit('/admin_console/user_management/groups');
cy.get('#developers_group', {timeout: TIMEOUTS.ONE_MIN}).then((el) => {
if (!el.text().includes('Edit')) {
// # Link the Group if its not linked before
if (el.find('.icon.fa-unlink').length > 0) {
el.find('.icon.fa-unlink').click();
}
}
});
// # Get board group id
cy.apiGetGroups().then((res) => {
res.body.forEach((group: Group) => {
if (group.display_name === 'board') {
// # Set groupID1 to navigate to group page directly
groupID1 = group.id;
// # Set allow reference false to ensure correct data for test cases
cy.apiPatchGroup(group.id, {allow_reference: false});
}
if (group.display_name === 'developers') {
// # Set groupID1 to navigate to group page directly
groupID2 = group.id;
// # Set allow reference false to ensure correct data for test cases
cy.apiPatchGroup(group.id, {allow_reference: false});
}
});
});
// # Login once as board user to ensure the user is created in the system
boardUser = ldapUsers['board-1'];
cy.apiLogin(boardUser);
// # Login as sysadmin
cy.apiAdminLogin();
// # Add board user to test team to ensure that it exists in the team and set its preferences to skip tutorial step
cy.apiGetUserByEmail(boardUser.email).then(({user}) => {
cy.apiGetChannelByName(testTeam.name, 'town-square').then(({channel}) => {
cy.apiAddUserToTeam(testTeam.id, user.id).then(() => {
cy.apiAddUserToChannel(channel.id, user.id);
});
});
cy.apiSaveTutorialStep(user.id, '999');
});
});
beforeEach(() => {
// # Login as sysadmin
cy.apiAdminLogin();
// # Enable Group Mention for the group - board
cy.visit('/admin_console/user_management/groups');
cy.get('#board_group', {timeout: TIMEOUTS.ONE_MIN}).then((el) => {
if (!el.text().includes('Edit')) {
// # Link the Group if its not linked before
if (el.find('.icon.fa-unlink').length > 0) {
el.find('.icon.fa-unlink').click();
}
}
});
});
it('MM-T2447 - Group Mentions when group was unlinked', () => {
const groupName = `board_test_case_${Date.now()}`;
// # Login as sysadmin and enable group mention with the group name
cy.apiAdminLogin();
enableGroupMention(groupName, groupID1);
// # Unlink the group
cy.visit('/admin_console/user_management/groups');
cy.get('#board_group', {timeout: TIMEOUTS.ONE_MIN}).then((el) => {
el.find('.icon.fa-link').click();
});
// # Login as a regular user
cy.apiLogin(regularUser);
// # Create a new channel as a regular user
cy.apiCreateChannel(testTeam.id, 'group-mention', 'Group Mentions').then(({channel}) => {
// # Visit the channel
cy.visit(`/${testTeam.name}/channels/${channel.name}`);
cy.uiGetPostTextBox();
// # Type the Group Name to check if Autocomplete dropdown is not displayed
cy.uiGetPostTextBox().clear().type(`@${groupName}`).wait(TIMEOUTS.TWO_SEC);
// * Verify if autocomplete dropdown is not displayed
cy.get('#suggestionList').should('not.exist');
// # Submit a post containing the group mention
cy.postMessage(`@${groupName} `);
// * Verify if a system message is not displayed
cy.getLastPostId().then((postId) => {
cy.get(`#postMessageText_${postId}`).should('include.text', `@${groupName}`);
// * Verify that the group mention is not highlighted
cy.get(`#postMessageText_${postId}`).find('.mention--highlight').should('not.exist');
});
});
});
it('MM-T2460 - Group Mentions when used in Direct Message', () => {
const groupName = `board_test_case_${Date.now()}`;
// # Login as sysadmin and enable group mention with the group name
cy.apiAdminLogin();
enableGroupMention(groupName, groupID1);
// # Login as a regular user
cy.apiLogin(regularUser);
cy.visit(`/${testTeam.name}/channels/town-square`);
cy.uiGetPostTextBox();
// # Trigger DM with a user
cy.uiAddDirectMessage().click();
cy.get('.more-modal__row.clickable').first().click();
cy.uiGetButton('Go').click();
// # Type the Group Name to check if Autocomplete dropdown is displayed
cy.uiGetPostTextBox().clear().type(`@${groupName}`).wait(TIMEOUTS.TWO_SEC);
// * Verify if autocomplete dropdown is displayed
cy.get('#suggestionList').should('be.visible').children().within((el) => {
cy.wrap(el).eq(0).should('contain', 'Group Mentions');
cy.wrap(el).eq(1).should('contain', groupName);
});
// # Submit a post containing the group mention
cy.postMessage(`@${groupName} `);
// * Verify if a system message is not displayed
cy.getLastPostId().then((postId) => {
cy.get(`#postMessageText_${postId}`).should('include.text', `@${groupName}`);
// * Verify that the group mention is not highlighted
cy.get(`#postMessageText_${postId}`).find('.mention--highlight').should('not.exist');
// * Verify that the group mention has blue colored text
cy.get(`#postMessageText_${postId}`).find('.group-mention-link').should('be.visible');
});
});
it('MM-T2461 - Group Mentions when used in Group Message', () => {
const groupName = `board_test_case_${Date.now()}`;
// # Login as sysadmin and enable group mention with the group name
cy.apiAdminLogin();
enableGroupMention(groupName, groupID1);
// # Login as a regular user
cy.apiLogin(regularUser);
cy.visit(`/${testTeam.name}/channels/town-square`);
cy.uiGetPostTextBox();
// # Trigger DM with couple of users
cy.uiAddDirectMessage().click();
cy.get('.more-modal__row.clickable').first().click();
cy.uiGetButton('Go').click();
// # Type the Group Name to check if Autocomplete dropdown is displayed
cy.uiGetPostTextBox().clear().type(`@${groupName}`).wait(TIMEOUTS.TWO_SEC);
// * Verify if autocomplete dropdown is displayed
cy.get('#suggestionList').should('be.visible').children().within((el) => {
cy.wrap(el).eq(0).should('contain', 'Group Mentions');
cy.wrap(el).eq(1).should('contain', groupName);
});
// # Submit a post containing the group mention
cy.postMessage(`@${groupName} `);
// * Verify if a system message is not displayed
cy.getLastPostId().then((postId) => {
cy.get(`#postMessageText_${postId}`).should('include.text', `@${groupName}`);
// * Verify that the group mention is not highlighted
cy.get(`#postMessageText_${postId}`).find('.mention--highlight').should('not.exist');
// * Verify that the group mention has blue colored text
cy.get(`#postMessageText_${postId}`).find('.group-mention-link').should('be.visible');
});
});
it('MM-T2443 - Group Mentions when Channel is Group Synced', () => {
const groupName = `board_test_case_${Date.now()}`;
const groupName2 = `developers_test_case_${Date.now()}`;
// # Login as sysadmin and enable group mention with the group name
cy.apiAdminLogin();
enableGroupMention(groupName, groupID1);
enableGroupMention(groupName2, groupID2);
// # Create a new channel as a regular user
cy.apiCreateChannel(testTeam.id, 'group-mention-2', 'Group Mentions 2').then(({channel}) => {
// # Link the group and the channel.
cy.apiLinkGroupChannel(groupID1, channel.id);
cy.apiLogin({username: 'board.one', password: 'Password1'}).then((resp) => {
const {user} = resp as {user: UserProfile};
cy.apiAddUserToChannel(channel.id, user.id);
// # Make the channel private and group-synced.
cy.apiPatchChannel(channel.id, {group_constrained: true, type: 'P'});
// # Login to create the dev user
cy.apiLogin({username: 'dev.one', password: 'Password1'}).then((resp2) => {
const {user: devUser} = resp2 as {user: UserProfile};
cy.apiAdminLogin();
cy.apiAddUserToTeam(testTeam.id, devUser.id);
cy.apiLogin({username: 'board.one', password: 'Password1'});
// # Visit the channel
cy.visit(`/${testTeam.name}/channels/${channel.name}`);
cy.uiGetPostTextBox();
cy.postMessage(`@${groupName2} `);
// * Verify if a system message is not displayed
cy.getLastPostId().then((postId) => {
cy.get(`#postMessageText_${postId}`).should('include.text', `@${groupName2}`);
});
});
});
});
});
});

View File

@@ -0,0 +1,250 @@
// 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 @system_console @group_mentions
import type {Team} from '@mattermost/types/teams';
import type {UserProfile} from '@mattermost/types/users';
import type {Group} from '@mattermost/types/groups';
import {
disablePermission,
enablePermission,
saveConfigForChannel,
visitChannelConfigPage,
} from '../system_console/channel_moderation/helpers';
import {checkboxesTitleToIdMap} from '../system_console/channel_moderation/constants';
import {enableGroupMention} from './helpers';
import * as TIMEOUTS from '@/fixtures/timeouts';
import ldapUsers from '@/fixtures/ldap_users.json';
describe('Group Mentions', () => {
let groupID: string;
let boardUser: Cypress.UserProfile;
let regularUser: UserProfile;
let testTeam: Team;
before(() => {
// * Check if server has license for LDAP Groups
cy.apiRequireLicenseForFeature('LDAPGroups');
// # Enable GuestAccountSettings
cy.apiUpdateConfig({
GuestAccountsSettings: {
Enable: true,
},
});
cy.apiInitSetup().then(({team, user}) => {
regularUser = user;
testTeam = team;
});
// # Test LDAP configuration and server connection
// # Synchronize user attributes
cy.apiLDAPTest();
cy.apiLDAPSync();
// # Link the group - board
cy.visit('/admin_console/user_management/groups');
cy.get('#board_group', {timeout: TIMEOUTS.ONE_MIN}).then((el) => {
if (!el.text().includes('Edit')) {
// # Link the Group if its not linked before
if (el.find('.icon.fa-unlink').length > 0) {
el.find('.icon.fa-unlink').click();
}
}
});
// # Get board group id
cy.apiGetGroups().then((res) => {
res.body.forEach((group: Group) => {
if (group.display_name === 'board') {
// # Set groupID to navigate to group page directly
groupID = group.id;
// # Set allow reference false to ensure correct data for test cases
cy.apiPatchGroup(groupID, {allow_reference: false});
}
});
});
// # Login once as board user to ensure the user is created in the system
boardUser = ldapUsers['board-1'] as unknown as Cypress.UserProfile;
cy.apiLogin(boardUser);
// # Login as sysadmin
cy.apiAdminLogin();
// # Add board user to test team to ensure that it exists in the team and set its preferences to skip tutorial step
cy.apiGetUserByEmail(boardUser.email).then(({user}) => {
cy.apiGetChannelByName(testTeam.name, 'town-square').then(({channel}) => {
cy.apiAddUserToTeam(testTeam.id, user.id).then(() => {
cy.apiAddUserToChannel(channel.id, user.id);
});
});
cy.apiSaveTutorialStep(user.id, '999');
});
});
it('MM-T2456 - Group Mentions when group members are in the team but not in the channel', () => {
const groupName = `board_test_case_${Date.now()}`;
// # Login as sysadmin and enable group mention with the group name
cy.apiAdminLogin();
enableGroupMention(groupName, groupID, boardUser.email);
// # Login as a regular user
cy.apiLogin(regularUser);
// # Create a new channel as a regular user
cy.apiCreateChannel(testTeam.id, 'group-mention', 'Group Mentions').then(({channel}) => {
// # Visit the channel
cy.visit(`/${testTeam.name}/channels/${channel.name}`);
cy.uiGetPostTextBox();
// # Submit a post containing the group mention
cy.postMessage(`@${groupName} `);
// * Verify if a system message is displayed indicating that list of members were not notified
cy.getLastPostId().then((postId) => {
cy.get(`#postMessageText_${postId}`).should('include.text', `@${boardUser.username} did not get notified by this mention because they are not in the channel. Would you like to add them to the channel? They will have access to all message history.`);
// * Verify if an option should be given to add them to channel
cy.get('a.PostBody_addChannelMemberLink').should('be.visible');
});
});
});
it('MM-T2457 - Group Mentions when group members are not in the team and the channel', () => {
const groupName = `board_test_case_${Date.now()}`;
// # Login as sysadmin and enable group mention with the group name
cy.apiAdminLogin();
enableGroupMention(groupName, groupID, boardUser.email);
// # Create a new team and channel as a sysadmin
cy.apiCreateTeam('team', 'Test NoMember').then(({team}) => {
cy.apiCreateChannel(team.id, 'group-mention', 'Group Mentions').then(({channel}) => {
cy.apiCreateUser().then(({user}) => {
// # Add user to the team and channel
cy.apiAddUserToTeam(team.id, user.id).then(() => {
cy.apiAddUserToChannel(channel.id, user.id);
});
// # Login as a regular user
cy.apiLogin(user);
// # Visit the channel
cy.visit(`/${team.name}/channels/${channel.name}`);
cy.uiGetPostTextBox();
// # Submit a post containing the group mention
cy.postMessage(`@${groupName} `);
// * Verify if a system message is displayed indicating that there are no members in this team
cy.getLastPostId().then((postId) => {
cy.get(`#postMessageText_${postId}`).
should('include.text', `@${groupName} has no members on this team`);
// * Verify that the group mention is not highlighted
cy.get(`#postMessageText_${postId}`).find('.mention--highlight').should('not.exist');
});
});
});
});
});
it('MM-T2458 - Group Mentions when group members are not in the channel as a Guest User', () => {
const groupName = `board_test_case_${Date.now()}`;
// # Login as sysadmin and enable group mention with the group name
cy.apiAdminLogin();
enableGroupMention(groupName, groupID, boardUser.email);
// # Enable Group Mentions for Guest Users
cy.visit('/admin_console/user_management/permissions/system_scheme');
cy.get('.admin-console__header', {timeout: TIMEOUTS.ONE_MIN}).should('be.visible').and('have.text', 'System Scheme');
enablePermission('guests-guest_use_group_mentions-checkbox');
cy.uiSaveConfig();
// # Create a new channel as a sysadmin
cy.apiCreateChannel(testTeam.id, 'group-mention', 'Group Mentions').then(({channel}) => {
cy.apiCreateUser().then(({user}) => {
// # Add user to the team and channel
cy.apiAddUserToTeam(testTeam.id, user.id).then(() => {
cy.apiAddUserToChannel(channel.id, user.id);
});
// # Demote the user as a guest user
cy.apiDemoteUserToGuest(user.id);
// # Login as a guest user
cy.apiLogin(user);
// # Visit the channel
cy.visit(`/${testTeam.name}/channels/${channel.name}`);
cy.uiGetPostTextBox();
// # Submit a post containing the group mention
cy.postMessage(`@${groupName} `);
// * Verify if a system message is displayed indicating that list of members were not notified
cy.getLastPostId().then((postId) => {
cy.get(`#postMessageText_${postId}`).
should('include.text', `@${boardUser.username} did not get notified by this mention because they are not in the channel.`);
// * Verify that the option to add them to channel is not given
cy.get('a.PostBody_addChannelMemberLink').should('not.exist');
});
});
});
});
it('MM-T2459 - Group Mentions when group members are not in the channel when Manage Members is disabled', () => {
const groupName = `board_test_case_${Date.now()}`;
// # Login as sysadmin and enable group mention with the group name
cy.apiAdminLogin();
enableGroupMention(groupName, groupID, boardUser.email);
// # Create a new channel as a sysadmin
cy.apiCreateChannel(testTeam.id, 'group-mention', 'Group Mentions').then(({channel}) => {
// # Disable Manage Members permission for the channel
visitChannelConfigPage(channel);
disablePermission(checkboxesTitleToIdMap.MANAGE_MEMBERS_MEMBERS);
saveConfigForChannel();
// # Add regular user to the channel
cy.apiAddUserToChannel(channel.id, regularUser.id);
// # Login as a regular user
cy.apiLogin(regularUser);
// # Visit the channel
cy.visit(`/${testTeam.name}/channels/${channel.name}`);
cy.uiGetPostTextBox();
// # Submit a post containing the group mention
cy.postMessage(`@${groupName} `);
// * Verify if a system message is displayed indicating that list of members were not notified
cy.getLastPostId().then((postId) => {
cy.get(`#postMessageText_${postId}`).
should('include.text', `@${boardUser.username} did not get notified by this mention because they are not in the channel.`);
// * Verify that the option to add them to channel is not given
cy.get('a.PostBody_addChannelMemberLink').should('not.exist');
});
});
});
});

View File

@@ -0,0 +1,31 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import * as TIMEOUTS from '@/fixtures/timeouts';
export function enableGroupMention(groupName: string, groupID: string, userEmail?: string): void {
// # Visit Group Configurations page
cy.visit(`/admin_console/user_management/groups/${groupID}`);
// # Scroll users list into view and then make sure it has loaded before scrolling back to the top
cy.get('#group_users', {timeout: TIMEOUTS.ONE_MIN}).scrollIntoView();
if (userEmail) {
cy.findByText(userEmail).should('be.visible');
}
cy.get('#group_profile').scrollIntoView().wait(TIMEOUTS.TWO_SEC);
// # Click the allow reference button
cy.findByTestId('allowReferenceSwitch').then((el) => {
const button = el.find('button');
const classAttribute = button[0]?.getAttribute('class') ?? '';
if (!classAttribute.includes('active')) {
button[0].click();
}
});
// # Give the group a custom name different from its DisplayName attribute
cy.get('#groupMention').find('input').clear().type(groupName);
// # Click save button
cy.uiSaveConfig();
}