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

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

@@ -0,0 +1,189 @@
// 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 @channel @channel_settings @smoke
describe('Channel Settings', () => {
let testTeam: Cypress.Team;
let firstUser: Cypress.UserProfile;
let addedUsersChannel: Cypress.Channel;
let username: string;
const usernames: string[] = [];
before(() => {
cy.apiInitSetup().then(({team, user}) => {
testTeam = team;
firstUser = user;
// # Add 4 users
for (let i = 0; i < 4; i++) {
cy.apiCreateUser().then(({user: newUser}) => { // eslint-disable-line
cy.apiAddUserToTeam(testTeam.id, newUser.id);
});
}
cy.apiCreateChannel(testTeam.id, 'channel-test', 'Channel').then(({channel}) => {
addedUsersChannel = channel;
});
cy.apiLogin(firstUser);
});
});
it('MM-T859_1 Single User: Usernames are links, open profile popovers', () => {
// # Create and visit new channel
cy.apiCreateChannel(testTeam.id, 'channel-test', 'Channel').then(({channel}) => {
cy.visit(`/${testTeam.name}/channels/${channel.name}`);
// # Add users to channel
addNumberOfUsersToChannel(1);
cy.getLastPostId().then((id) => {
// * The system message should contain 'added to the channel by you'
cy.get(`#postMessageText_${id}`).should('contain', 'added to the channel by you');
// # Verify username link
verifyMentionedUserAndProfilePopover(id);
});
});
});
it('MM-T859_2 Combined Users: Usernames are links, open profile popovers', () => {
// # Create and visit new channel
cy.apiCreateChannel(testTeam.id, 'channel-test', 'Channel').then(({channel}) => {
cy.visit(`/${testTeam.name}/channels/${channel.name}`);
addNumberOfUsersToChannel(3);
cy.getLastPostId().then((id) => {
cy.get(`#postMessageText_${id}`).should('contain', '2 others were added to the channel by you');
// # Click "2 others" to expand more users
cy.get(`#post_${id}`).find('.markdown__paragraph-inline').siblings('a').first().click().then(() => {
// # Verify each username link
verifyMentionedUserAndProfilePopover(id);
});
});
});
});
it('MM-T856_1 Add existing users to public channel from drop-down > Add Members', () => {
// # Visit the add users channel
cy.visit(`/${testTeam.name}/channels/${addedUsersChannel.name}`);
// # Open channel menu and click 'Add Members'
cy.uiOpenChannelMenu('Add Members');
cy.get('#addUsersToChannelModal').should('be.visible');
// # Type into the input box to search for a user
cy.get('#selectItems input').typeWithForce('u');
// # First add one user in order to see them disappearing from the list
cy.get('#multiSelectList > div').first().then((el) => {
const childNodes = Array.from(el[0].childNodes);
childNodes.map((child: HTMLElement) => usernames.push(child.innerText));
// # Get username from text for comparison
username = usernames.toString().match(/\w+/g)[0];
cy.get('#multiSelectList').should('contain', username);
// # Verify status wrapper is present within the modal list
cy.get(el as unknown as string).children().first().should('have.class', 'status-wrapper');
// # Click to add the first user
cy.wrap(el).click();
// # Verify users list is not visible
cy.get('#multiSelectList').should('not.exist');
// # Click 'Add' button
cy.uiGetButton('Add').click();
cy.get('#addUsersToChannelModal').should('not.exist');
});
// # Verify that the last system post also contains the username
cy.getLastPostId().then((id) => {
cy.get(`#postMessageText_${id}`).should('contain', `${username} added to the channel by you.`);
});
// Add two more users
addNumberOfUsersToChannel(2);
// Verify that the system post reflects the number of added users
cy.getLastPostId().then((id) => {
cy.get(`#postMessageText_${id}`).should('contain', 'added to the channel by you');
});
});
it('MM-T856_2 Existing users cannot be added to public channel from drop-down > Add Members', () => {
cy.apiAdminLogin();
// # Visit the add users channel
cy.visit(`/${testTeam.name}/channels/${addedUsersChannel.name}`);
// # Verify that the system message for adding users displays
cy.getLastPostId().then((id) => {
cy.get(`#postMessageText_${id}`).should('contain', `added to the channel by @${firstUser.username}`);
});
// Visit off topic where all users are added
cy.visit(`/${testTeam.name}/channels/off-topic`);
// # Open channel menu and click 'Add Members'
cy.uiOpenChannelMenu('Add Members');
cy.get('#addUsersToChannelModal').should('be.visible');
// # Type into the input box to search for already added user
cy.get('#selectItems input').typeWithForce(firstUser.username);
// * Verify user list exist
cy.get('#multiSelectList').should('exist').within(() => {
cy.findByText('Already in channel').should('be.visible');
});
cy.get('body').type('{esc}');
});
});
function verifyMentionedUserAndProfilePopover(postId: string) {
cy.get(`#post_${postId}`).find('.mention-link').each(($el) => {
// # Get username from each mentioned link
const userName = $el[0].innerHTML;
// # Click each username link
cy.wrap($el).click();
// * Profile popover should be visible
cy.get('#user-profile-popover').should('be.visible');
// * The username in the popover the same as the username link for each user
cy.get('#userPopoverUsername').should('contain', userName);
// Click anywhere to close profile popover
cy.get('#channelHeaderInfo').click();
});
}
function addNumberOfUsersToChannel(num = 1) {
// # Open channel menu and click 'Add Members'
cy.uiOpenChannelMenu('Add Members');
cy.get('#addUsersToChannelModal').should('be.visible');
// * Assert that modal appears
// # Click the first row for a number of times
Cypress._.times(num, () => {
cy.get('#selectItems input').typeWithForce('u');
cy.get('#multiSelectList').should('be.visible').first().click();
});
// # Click the button "Add" to add user to a channel
cy.uiGetButton('Add').click();
// # Wait for the modal to disappear
cy.get('#addUsersToChannelModal').should('not.exist');
}

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

@@ -0,0 +1,100 @@
// 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 @channel_settings
// node run_tests.js --group='@channel_settings'
import {getRandomId} from '../../../utils';
import * as TIMEOUTS from '../../../fixtures/timeouts';
describe('Channel Settings', () => {
let testTeam: Cypress.Team;
let user1: Cypress.UserProfile;
let admin: Cypress.UserProfile;
before(() => {
cy.apiGetMe().then(({user: adminUser}) => {
admin = adminUser;
cy.apiInitSetup().then(({team, user}) => {
testTeam = team;
user1 = user;
cy.visit(`/${testTeam.name}/channels/town-square`);
});
});
});
it('MM-T1808 Hover effect exists to add a channel description / header (when not already present)', () => {
// # Create a new public channel and then private channel
['O', 'P'].forEach((channelType) => {
cy.apiCreateChannel(testTeam.id, `chan${getRandomId()}`, 'chan', channelType).then(({channel}) => {
// # Go to new channel
cy.visit(`/${testTeam.name}/channels/${channel.name}`);
// * Test hovering over the header with public and private channel
hoverOnChannelDescriptionAndVerifyBehavior();
});
});
// # Create DM with admin and user 1
cy.apiCreateDirectChannel([user1.id, user1.id]).then(() => {
// # Go to DM
cy.visit(`/${testTeam.name}/messages/@${user1.username}`);
// * Test hovering over the header with DM
hoverOnChannelDescriptionAndVerifyBehavior();
});
// # Create another user and add to the team
cy.apiCreateUser().then(({user: user2}) => {
cy.apiAddUserToTeam(testTeam.id, user2.id).then(() => {
// # Create a GM with admin, user1 and user 2
cy.apiCreateGroupChannel([user2.id, user1.id, admin.id]).then(({channel}) => {
// # Visit the channel using the name using the channels route
cy.visit(`/${testTeam.name}/channels/${channel.name}`);
// * Test hovering over the header with GM
hoverOnChannelDescriptionAndVerifyBehavior();
});
});
});
});
});
function hoverOnChannelDescriptionAndVerifyBehavior() {
const channelDescriptionText = `test description ${getRandomId()}`;
// # Wait a little for channel to load
cy.wait(TIMEOUTS.FIVE_SEC);
// # Scan within channel header description area
cy.get('#channelHeaderDescription').should('be.visible').within(() => {
// * Verify that empty header text is visible and click it
cy.findByText('Add a channel header').should('be.visible').click();
});
// # Scan inside the channel header modal
cy.get('.a11y__modal.modal-dialog').should('be.visible').within(() => {
// # Enter a channel description
cy.findByTestId('edit_textbox').should('exist').clear().type(channelDescriptionText);
// # Click on save
cy.findByText('Save').should('be.visible').click();
});
cy.get('#channelHeaderDescription').should('be.visible').within(() => {
// * Verify that new channel header is set and click it
cy.findAllByText(channelDescriptionText).should('be.visible').click({multiple: true, force: true});
});
// * Check clicking on it doesn't open the edit modal once again
cy.get('.a11y__modal.modal-dialog').should('not.exist');
}

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

@@ -0,0 +1,131 @@
// 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 @channel
// Group: @channels @channel_settings
import * as TIMEOUTS from '../../../fixtures/timeouts';
import {getRandomId} from '../../../utils';
describe('Channel routing', () => {
let testTeam: Cypress.Team;
let testUser: Cypress.UserProfile;
let testChannel: Cypress.Channel;
before(() => {
cy.apiInitSetup().then(({team, user, channel}) => {
testTeam = team;
testUser = user;
testChannel = channel;
// # Login as test user and go to town square
cy.apiLogin(testUser);
cy.visit(`/${team.name}/channels/town-square`);
});
});
it('MM-T884_1 Renaming channel name validates against two user IDs being used in URL', () => {
// # Create new test channel
cy.uiCreateChannel({name: 'Test__Channel'});
// # Click on channel menu and press rename channel
cy.get('#channelHeaderDropdownIcon').click();
cy.findByText('Rename Channel').click();
// # Assert if the rename modal present
cy.get('[aria-labelledby="renameChannelModalLabel"').should('be.visible').within(() => {
// # type the two 26 character strings with 2 underscores between them and click on save
cy.get('#channel_name').clear().type('uzsfmtmniifsjgesce4u7yznyh__uzsfmtmniifsjgesce5u7yznyh', {force: true}).wait(TIMEOUTS.HALF_SEC);
cy.get('#save-button').should('be.visible').click();
// # Assert the error occurred with the appropriate message
cy.get('.input__help').should('have.class', 'error');
cy.get('.input__help').should('have.text', 'User IDs are not allowed in channel URLs.');
cy.findByText('Cancel').click();
});
});
it('MM-T884_2 Creating new channel validates against two user IDs being used as channel name', () => {
// # click on create public channel
cy.uiBrowseOrCreateChannel('Create New Channel').click();
// * Verify that the new channel modal is visible
cy.get('#new-channel-modal').should('be.visible').within(() => {
// # Add the new channel name with invalid name and press Create Channel
cy.get('#input_new-channel-modal-name').type('uzsfmtmniifsjgesce4u7yznyh__uzsfmtmniifsjgesce5u7yznyh', {force: true}).wait(TIMEOUTS.HALF_SEC);
cy.findByText('Create channel').should('be.visible').click();
// * Assert the error occurred with the appropriate message
cy.get('.genericModalError').should('be.visible').within(() => {
cy.findByText('Channel names can\'t be in a hexadecimal format. Please enter a different channel name.');
});
// # Close the create channel modal
cy.uiCancelButton().click();
});
});
it('MM-T884_3 Creating a new channel validates against gm-like names being used as channel name', () => {
// # click on create public channel
cy.uiBrowseOrCreateChannel('Create New Channel').click();
// * Verify that the new channel modal is visible
cy.findByRole('dialog', {name: 'Create a new channel'}).within(() => {
// # Add the new channel name with invalid name and press Create Channel
cy.findByPlaceholderText('Enter a name for your new channel').type('71b03afcbb2d503d49f87f057549c43db4e19f92', {force: true}).wait(TIMEOUTS.HALF_SEC);
cy.uiGetButton('Create channel').click();
// * Assert the error occurred with the appropriate message
cy.get('.genericModalError').should('be.visible').within(() => {
cy.findByText('Channel names can\'t be in a hexadecimal format. Please enter a different channel name.');
});
// # Close the create channel modal
cy.uiCancelButton().click();
});
});
it('MM-T883 Channel URL validation for spaces between characters', () => {
const firstWord = getRandomId(26);
const secondWord = getRandomId(26);
// # In a test channel, click the "v" to the right of the channel name in the header
cy.findByText(`${testChannel.display_name}`).click();
cy.get('#channelHeaderDropdownIcon').click();
// # Select "Rename Channel"
cy.findByText('Rename Channel').click();
// # Change the channel name to {26 alphanumeric characters}[insert 2 spaces]{26 alphanumeric characters}
// i.e. a total of 54 characters separated by 2 spaces
cy.get('#display_name').clear().type(`${firstWord}${Cypress._.repeat(' ', 2)}${secondWord}`);
// # Hit Save
cy.findByText('Save').click();
// * The channel name should be updated to the characters you typed with only 1 space between the characters (extra spaces are trimmed)
cy.get('#channelHeaderTitle').contains(`${firstWord} ${secondWord}`);
// # In a test channel, click the "v" to the right of the channel name in the header
cy.get('#channelHeaderDropdownIcon').click();
// # Select "Rename Channel"
cy.findByText('Rename Channel').click();
// # Change the URL to {26 alphanumeric characters}--{26 alphanumeric characters}
cy.get('#channel_name').clear().type(`${firstWord}${Cypress._.repeat('-', 2)}${secondWord}`);
// # Hit Save
cy.findByText('Save').click();
// * The channel URL should be updated to the characters you typed, separated by 2 dashes
cy.url().should('equal', `${Cypress.config('baseUrl')}/${testTeam.name}/channels/${firstWord}${Cypress._.repeat('-', 2)}${secondWord}`);
});
});

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

@@ -0,0 +1,99 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
// ***************************************************************
// - [#] indicates a test step (e.g. # Go to a page)
// - [*] indicates an assertion (e.g. * Check the title)
// - Use element ID when selecting an element. Create one if none.
// ***************************************************************
// Stage: @prod
// Group: @channels @channel_settings
import * as TIMEOUTS from '../../../fixtures/timeouts';
describe('Channel settings', () => {
let mainUser: Cypress.UserProfile;
let otherUser: Cypress.UserProfile;
let myTeam: Cypress.Team;
// # Ensure a list of channel names that will be alphabetically sorted
const channelNames = new Array(20).fill(1).map((value, index) => `scroll${index}`);
before(() => {
// # Create a user and a team (done by apiInitSetup)
cy.apiInitSetup().then(({team, user: firstUser}) => {
mainUser = firstUser;
myTeam = team;
// # Create another user and add it to the same team
cy.apiCreateUser().then(({user: secondUser}) => {
otherUser = secondUser;
cy.apiAddUserToTeam(team.id, secondUser.id);
});
// # Create 20 channels (based on length of channelNames array) to ensure that the channels list is scrollable
cy.wrap(channelNames).each((name) => {
const displayName = `channel-${name}`;
cy.apiCreateChannel(team.id, name.toString(), displayName, 'O', '', '', false).then(({channel}) => {
// # Add our 2 created users to each channel so they can both post messages
cy.apiAddUserToChannel(channel.id, mainUser.id);
cy.apiAddUserToChannel(channel.id, otherUser.id);
});
});
});
});
it('MM-T888 Channel sidebar: More unreads', () => {
const firstChannelIndex = 0;
const lastChannelIndex = channelNames.length - 1;
// # Navigate to off-topic channel
cy.apiLogin(mainUser);
cy.visit(`/${myTeam.name}/channels/off-topic`);
// # Post message as the second user, in a channel near the top of the list
cy.apiGetChannelByName(myTeam.name, channelNames[firstChannelIndex]).then(({channel}) => {
cy.postMessageAs({
sender: otherUser,
message: 'Bleep bloop I am a robot',
channelId: channel.id,
});
// # Scroll down in channels list until last created channel is visible
cy.get(`#sidebarItem_${channelNames[lastChannelIndex]}`).scrollIntoView({duration: TIMEOUTS.TWO_SEC});
cy.get('.scrollbar--view').scrollTo('bottom');
});
// * After scrolling is complete, "More Unreads" pill should be visible at the top of the channels list
cy.get('#unreadIndicatorBottom').should('not.be.visible');
// * "More Unreads" pill should be visible at the top of the channels list
// # Click on "More Unreads" pill
cy.get('#unreadIndicatorTop').should('be.visible').click();
// # Post as another user in a channel near the bottom of the list, scroll channels list to view it (should be in bold)
cy.apiGetChannelByName(myTeam.name, channelNames[lastChannelIndex]).then(({channel}) => {
cy.postMessageAs({
sender: otherUser,
message: 'Bleep bloop I am a robot',
channelId: channel.id,
});
// # Scroll down in channels list until last created channel is visible
cy.get(`#sidebarItem_${channelNames[firstChannelIndex]}`).scrollIntoView({duration: TIMEOUTS.TWO_SEC});
cy.get('.scrollbar--view').scrollTo('top');
});
// * After scrolling is complete, "More Unreads" pill should not be visible at the top of the channels list
cy.get('#unreadIndicatorTop').should('not.be.visible');
// * "More Unreads" pill should be visible at the bottom of the channels list
// # Click on "More Unreads" pill
cy.get('#unreadIndicatorBottom').should('be.visible').click();
// * "More Unreads" pill should not be visible at the bottom of the channels list & visible at the top
cy.get('#unreadIndicatorBottom').should('not.be.visible');
cy.get('#unreadIndicatorTop').should('be.visible');
});
});