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
327 lines
14 KiB
JavaScript
327 lines
14 KiB
JavaScript
// 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 @messaging
|
|
|
|
import * as TIMEOUTS from '@/fixtures/timeouts';
|
|
import {getAdminAccount} from '@/support/env';
|
|
|
|
describe('autocomplete', () => {
|
|
let testTeam;
|
|
let testChannel;
|
|
let testUser;
|
|
let otherUser;
|
|
let otherUser2;
|
|
let notInChannelUser;
|
|
let sysadmin;
|
|
let displayNameTestUser;
|
|
let displayNameOtherUser;
|
|
|
|
before(() => {
|
|
sysadmin = getAdminAccount();
|
|
|
|
// # Login as admin and visit town-square
|
|
cy.apiInitSetup({channelPrefix: {name: 'ask-anything', displayName: 'Ask Anything'}}).then(({team, channel, user}) => {
|
|
testTeam = team;
|
|
testChannel = channel;
|
|
testUser = user;
|
|
displayNameTestUser = `${testUser.first_name} ${testUser.last_name} (${testUser.nickname})`;
|
|
|
|
cy.apiCreateUser({prefix: 'other'}).then(({user: user1}) => {
|
|
otherUser = user1;
|
|
|
|
cy.apiAddUserToTeam(testTeam.id, otherUser.id).then(() => {
|
|
cy.apiAddUserToChannel(testChannel.id, otherUser.id);
|
|
});
|
|
displayNameOtherUser = `${otherUser.first_name} ${otherUser.last_name} (${otherUser.nickname})`;
|
|
});
|
|
|
|
cy.apiCreateUser({prefix: 'other'}).then(({user: user1}) => {
|
|
otherUser2 = user1;
|
|
|
|
cy.apiAddUserToTeam(testTeam.id, otherUser2.id).then(() => {
|
|
cy.apiAddUserToChannel(testChannel.id, otherUser2.id);
|
|
});
|
|
});
|
|
|
|
cy.apiCreateUser({prefix: 'notinchannel'}).then(({user: user1}) => {
|
|
notInChannelUser = user1;
|
|
cy.apiAddUserToTeam(testTeam.id, notInChannelUser.id);
|
|
});
|
|
});
|
|
});
|
|
|
|
it('MM-T2199 @ autocomplete - username', () => {
|
|
cy.visit(`/${testTeam.name}/channels/town-square`);
|
|
|
|
// # Clear then type @ and user name
|
|
cy.uiGetPostTextBox().clear().type(`@${testUser.username}`);
|
|
|
|
// * Verify that the item is displayed or not as expected.
|
|
cy.get('#suggestionList').should('be.visible').within(() => {
|
|
cy.findByText(displayNameTestUser).should('be.visible');
|
|
cy.findByText(displayNameOtherUser).should('not.exist');
|
|
});
|
|
|
|
// # Post user mention
|
|
cy.uiPostMessageQuickly(`@${testUser.username} `);
|
|
cy.uiWaitUntilMessagePostedIncludes(testUser.username);
|
|
|
|
// # Check that the user name has been posted
|
|
cy.getLastPostId().then((postId) => {
|
|
cy.get(`#postMessageText_${postId}`).should('contain', `${testUser.username}`);
|
|
});
|
|
});
|
|
|
|
it('MM-T2200 @ autocomplete - nickname', () => {
|
|
cy.visit(`/${testTeam.name}/channels/town-square`);
|
|
|
|
// # Clear then type @ and user nickname
|
|
cy.uiGetPostTextBox().clear().type(`@${testUser.nickname}`);
|
|
|
|
// * Verify that the item is displayed or not as expected.
|
|
cy.get('#suggestionList').within(() => {
|
|
cy.findByText(displayNameTestUser).should('be.visible');
|
|
cy.findByText(displayNameOtherUser).should('not.exist');
|
|
});
|
|
|
|
// # Post user mention
|
|
cy.uiGetPostTextBox().type('{enter}{enter}');
|
|
cy.uiWaitUntilMessagePostedIncludes(testUser.username);
|
|
|
|
// # Check that the user name has been posted
|
|
cy.getLastPostId().then((postId) => {
|
|
cy.get(`#postMessageText_${postId}`).should('contain', `${testUser.username}`);
|
|
});
|
|
});
|
|
|
|
it('MM-T2201 @ autocomplete - first name', () => {
|
|
cy.visit(`/${testTeam.name}/channels/town-square`);
|
|
|
|
// # Clear then type @ and user first names
|
|
cy.uiGetPostTextBox().clear().type(`@${testUser.first_name}`);
|
|
|
|
// * Verify that the item is displayed or not as expected.
|
|
cy.get('#suggestionList').within(() => {
|
|
cy.findByText(displayNameTestUser).should('be.visible');
|
|
cy.findByText(displayNameOtherUser).should('not.exist');
|
|
});
|
|
|
|
// # Post user mention
|
|
cy.uiGetPostTextBox().type('{enter}{enter}');
|
|
cy.uiWaitUntilMessagePostedIncludes(testUser.username);
|
|
|
|
// # Check that the user name has been posted
|
|
cy.getLastPostId().then((postId) => {
|
|
cy.get(`#postMessageText_${postId}`).should('contain', `${testUser.username}`);
|
|
});
|
|
});
|
|
|
|
it('MM-T2203 @ autocomplete - not email', () => {
|
|
cy.visit(`/${testTeam.name}/channels/town-square`);
|
|
|
|
// # Clear then type @ and user email
|
|
cy.uiGetPostTextBox().clear().type(`@${testUser.email}`);
|
|
|
|
// * Verify that the item is displayed or not as expected.
|
|
cy.get('#suggestionList').should('not.exist');
|
|
});
|
|
|
|
it('MM-T2206 @ autocomplete - not in channel (center), have permission to add (public channel)', () => {
|
|
const message = `@${notInChannelUser.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.`;
|
|
|
|
cy.visit(`/${testTeam.name}/channels/${testChannel.name}`);
|
|
|
|
// # Clear then type @
|
|
cy.uiGetPostTextBox().clear().type('@');
|
|
|
|
// * Verify that the suggestion list is visible
|
|
cy.get('#suggestionList').should('be.visible');
|
|
|
|
// # Type user name
|
|
cy.uiGetPostTextBox().type(notInChannelUser.username);
|
|
|
|
// # Post user mention
|
|
cy.uiGetPostTextBox().type('{enter}{enter}');
|
|
cy.uiWaitUntilMessagePostedIncludes('They will have access to all message history.');
|
|
cy.getLastPostId().then((postId) => {
|
|
// * Verify that the correct system message is displayed or not
|
|
cy.get(`#postMessageText_${postId}`).should('include.text', message);
|
|
|
|
// * Click on the link to add the user to the channel
|
|
cy.get('a.PostBody_addChannelMemberLink').should('be.visible').click();
|
|
cy.uiWaitUntilMessagePostedIncludes('added to the channel by you');
|
|
|
|
// * Verify that the correct system message is displayed or not
|
|
cy.getLastPostId().then((npostId) => {
|
|
cy.get(`#postMessageText_${npostId}`).should('include.text', `@${notInChannelUser.username} added to the channel by you`);
|
|
});
|
|
});
|
|
});
|
|
|
|
it('MM-T2207 Added to channel from autocomplete not in channel', () => {
|
|
let tempUser;
|
|
|
|
// # Create a temporary user
|
|
cy.apiCreateUser({prefix: 'temp'}).then(({user: user1}) => {
|
|
tempUser = user1;
|
|
cy.apiAddUserToTeam(testTeam.id, tempUser.id);
|
|
|
|
cy.apiLogin(testUser).then(() => {
|
|
cy.visit(`/${testTeam.name}/channels/${testChannel.name}`);
|
|
|
|
// # Clear then type @
|
|
cy.uiGetPostTextBox().clear().type('@');
|
|
|
|
// * Verify that the suggestion list is visible
|
|
cy.get('#suggestionList').should('be.visible');
|
|
|
|
// # Type user name
|
|
cy.uiGetPostTextBox().type(tempUser.username);
|
|
|
|
// # Post user name mention
|
|
cy.uiGetPostTextBox().type('{enter}{enter}');
|
|
cy.uiWaitUntilMessagePostedIncludes('They will have access to all message history.');
|
|
|
|
// * Verify that the correct system message is displayed
|
|
cy.getLastPostId().then((postId) => {
|
|
cy.get(`#postMessageText_${postId}`).should('include.text', `@${tempUser.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.`);
|
|
|
|
// * Click on the link to add the user to the channel
|
|
cy.get('a.PostBody_addChannelMemberLink').should('be.visible').click();
|
|
cy.uiWaitUntilMessagePostedIncludes('added to the channel by you');
|
|
});
|
|
|
|
cy.get('#sidebarItem_off-topic', {timeout: TIMEOUTS.HALF_MIN}).should('be.visible').click();
|
|
cy.apiLogout().then(() => {
|
|
cy.apiLogin(tempUser).then(() => {
|
|
cy.visit(`/${testTeam.name}`);
|
|
|
|
// # Verify the mention notification exists
|
|
cy.get(`#sidebarItem_${testChannel.name}`).
|
|
scrollIntoView().
|
|
find('#unreadMentions').
|
|
should('be.visible').
|
|
and('have.text', '1');
|
|
|
|
// * Navigate to the channel the user has been added to
|
|
cy.get(`#sidebarItem_${testChannel.name}`).click();
|
|
cy.uiWaitUntilMessagePostedIncludes('You were added to the channel');
|
|
|
|
// * Verify that the correct system message is displayed or not
|
|
cy.getLastPostId().then((postId) => {
|
|
cy.get(`#postMessageText_${postId}`).should('include.text', `You were added to the channel by @${testUser.username}`);
|
|
});
|
|
|
|
cy.apiLogout().then(() => {
|
|
// # Login as admin to restore the original state
|
|
cy.apiLogin(sysadmin);
|
|
});
|
|
});
|
|
});
|
|
});
|
|
});
|
|
});
|
|
|
|
it('MM-T2209 @ autocomplete - not in DM, GM', () => {
|
|
const userGroupIds = [testUser.id, otherUser.id, otherUser2.id];
|
|
|
|
// # Create a group channel for 3 users
|
|
cy.apiCreateGroupChannel(userGroupIds).then(({channel: gmChannel}) => {
|
|
// # Visit the channel using the name using the channels route
|
|
cy.visit(`/${testTeam.name}/channels/${gmChannel.name}`);
|
|
|
|
// # Clear then type @
|
|
cy.uiGetPostTextBox().clear().type('@');
|
|
|
|
// * Verify that the suggestion list is visible
|
|
cy.get('#suggestionList').should('be.visible');
|
|
|
|
// # Type user name
|
|
cy.uiGetPostTextBox().type(notInChannelUser.username);
|
|
|
|
// # Post user name mention
|
|
cy.uiGetPostTextBox().type('{enter}{enter}');
|
|
cy.uiWaitUntilMessagePostedIncludes(notInChannelUser.username);
|
|
|
|
// # Check that the user name has been posted
|
|
cy.getLastPostId().then((postId) => {
|
|
// * Verify that the correct system message is displayed or not
|
|
cy.get(`#postMessageText_${postId}`).should('not.include.text', `@${notInChannelUser.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.`);
|
|
|
|
// # Check that the user name has been posted
|
|
cy.get(`#postMessageText_${postId}`).should('contain', `${notInChannelUser.username}`);
|
|
|
|
// * Verify that the @ mention is a link
|
|
cy.get(`#postMessageText_${postId}`).find('.mention-link').should('exist');
|
|
});
|
|
});
|
|
|
|
cy.apiCreateDirectChannel([testUser.id, otherUser.id]).then(() => {
|
|
// # Visit the channel using the channel name
|
|
cy.visit(`/${testTeam.name}/channels/${testUser.id}__${otherUser.id}`);
|
|
|
|
// # Clear then type @
|
|
cy.uiGetPostTextBox().clear().type('@');
|
|
|
|
// * Verify that the suggestion list is visible
|
|
cy.get('#suggestionList').should('be.visible');
|
|
|
|
// # Type user name
|
|
cy.uiGetPostTextBox().type(notInChannelUser.username);
|
|
cy.uiGetPostTextBox().type('{enter}{enter}');
|
|
cy.uiWaitUntilMessagePostedIncludes(notInChannelUser.username);
|
|
|
|
cy.getLastPostId().then((postId) => {
|
|
// * Verify that the correct system message is displayed or not
|
|
cy.get(`#postMessageText_${postId}`).should('not.include.text', `@${notInChannelUser.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.`);
|
|
|
|
// # Check that the user name has been posted
|
|
cy.get(`#postMessageText_${postId}`).should('contain', `${notInChannelUser.username}`);
|
|
|
|
// * Verify that the @ mention is a link
|
|
cy.get(`#postMessageText_${postId}`).find('.mention-link').should('exist');
|
|
});
|
|
});
|
|
});
|
|
|
|
it('MM-T2212 @ mention followed by dot or underscore should highlight', () => {
|
|
cy.visit(`/${testTeam.name}/channels/town-square`);
|
|
|
|
// # Type input suffixed with '.'
|
|
cy.uiGetPostTextBox().clear().type(`@${sysadmin.username}.`).type('{enter}{enter}');
|
|
cy.uiWaitUntilMessagePostedIncludes(sysadmin.username);
|
|
|
|
cy.getLastPostId().then((postId) => {
|
|
// # Check that the user name has been posted
|
|
cy.get(`#postMessageText_${postId}`).should('contain', `${sysadmin.username}`);
|
|
|
|
// * Verify that the group mention does have colored text
|
|
cy.get(`#postMessageText_${postId}`).
|
|
findByText(`@${sysadmin.username}`).should('have.class', 'mention-link').
|
|
parent().should('have.class', 'mention--highlight');
|
|
});
|
|
|
|
// # Type input suffixed with '_'
|
|
cy.uiGetPostTextBox().clear().type(`@${sysadmin.username}_`).type('{enter}{enter}');
|
|
cy.uiWaitUntilMessagePostedIncludes(sysadmin.username);
|
|
|
|
cy.getLastPostId().then((postId) => {
|
|
// # Check that the user name has been posted
|
|
cy.get(`#postMessageText_${postId}`).should('contain', `${sysadmin.username}`);
|
|
|
|
// * Verify that the @ mention does have colored text
|
|
cy.get(`#postMessageText_${postId}`).
|
|
findByText(`@${sysadmin.username}`).should('have.class', 'mention-link').
|
|
parent().should('have.class', 'mention--highlight');
|
|
});
|
|
});
|
|
});
|