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

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

@@ -0,0 +1,328 @@
// 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
import {getRandomId} from '../../../utils';
describe('Leave an archived channel', () => {
let testTeam;
let offTopicUrl;
before(() => {
cy.apiUpdateConfig({
TeamSettings: {
ExperimentalViewArchivedChannels: true,
},
});
// # Login as test user and visit off-topic
cy.apiInitSetup({loginAfter: true}).then(({team, offTopicUrl: url}) => {
testTeam = team;
offTopicUrl = url;
cy.visit(offTopicUrl);
// # Post a message to the channel
cy.postMessage('hello');
});
});
it('MM-T1680 Open archived channel from search results with permalink view in another channel is open', () => {
// # Visit the test team
cy.visit(`/${testTeam.name}`);
// # Create a new channel
cy.uiCreateChannel({isNewSidebar: true});
// # Make a post
const archivedPostText = `archived${getRandomId()}`;
cy.postMessage(archivedPostText);
cy.getLastPostId().as('archivedPostId');
// # Archive the newly created channel
cy.uiArchiveChannel();
// # Switch away from the archived channel
cy.visit(offTopicUrl);
// # Make a post outside of the archived channel
const otherPostText = `post${getRandomId()}`;
cy.postMessage(otherPostText);
cy.getLastPostId().as('otherPostId');
// # Search for the new post and jump to it from the search results
cy.uiSearchPosts(otherPostText);
cy.get('@otherPostId').then((otherPostId) => cy.uiJumpToSearchResult(otherPostId));
// # Search for a post in the archived channel
cy.uiSearchPosts(archivedPostText);
// # Open it in the RHS
cy.get('@archivedPostId').then((archivedPostId) => {
cy.clickPostCommentIcon(archivedPostId, 'SEARCH');
// * Verify that the RHS has switched from search results to the thread
cy.get('#searchContainer').should('not.exist');
cy.get('#rhsContainer').should('be.visible');
// * Verify that the thread is visible and marked as archived
cy.get(`#rhsPost_${archivedPostId}`).should('be.visible');
cy.get('#rhsContainer .channel-archived-warning__container').should('be.visible');
cy.get('#rhsContainer .channel-archived-warning__content').should('be.visible');
});
});
it('MM-T1697 - Browse Public channels shows archived channels option', () => {
// # Create public channel
cy.apiCreateChannel(testTeam.id, 'channel', 'channel').then(({channel}) => {
// # Visit the channel
cy.visit(`/${testTeam.name}/channels/${channel.name}`);
// # Archive the channel
cy.uiArchiveChannel();
// # Click on add channel button
cy.get('#SidebarContainer .AddChannelDropdown_dropdownButton').click();
// # Click on browse channels
cy.get('#showMoreChannels').click();
// # More channels modal opens
cy.get('#moreChannelsModal').should('be.visible').within(() => {
// # Click on dropdown
cy.findByText('Show: Public Channels').should('be.visible').click();
// # Click archived channels
cy.findByText('Archived Channels').click();
// # Modal should contain created channel
cy.get('#moreChannelsList').should('contain', channel.display_name);
});
cy.get('body').typeWithForce('{esc}');
});
});
it('MM-T1699 - Browse Channels for all channel types shows archived channels option', () => {
let archivedPrivateChannel;
let archivedPublicChannel;
// # Create private channel
cy.uiCreateChannel({isPrivate: true, isNewSidebar: true}).as('channel').then((channel) => {
archivedPrivateChannel = channel;
// # Visit the channel
cy.visit(`/${testTeam.name}/channels/${archivedPrivateChannel.name}`);
// # Archive the channel
cy.uiArchiveChannel();
});
// # Create public channel
cy.apiCreateChannel(testTeam.id, 'channel', 'channel').then(({channel}) => {
archivedPublicChannel = channel;
// # Visit the channel
cy.visit(`/${testTeam.name}/channels/${archivedPublicChannel.name}`);
// # Archive the channel
cy.uiArchiveChannel();
});
// # Click on add channel button
cy.get('#SidebarContainer .AddChannelDropdown_dropdownButton').click();
// # Click on browse channels
cy.get('#showMoreChannels').click();
// # More channels modal opens
cy.get('.more-modal').should('be.visible').within(() => {
// # Public channel list opens by default
cy.findByText('Show: Public Channels').should('be.visible').click();
// # Click on archived channels
cy.findByText('Archived Channels').click();
// # Channel list should contain newly created channels
cy.get('#moreChannelsList').should('contain', archivedPrivateChannel.name);
cy.get('#moreChannelsList').should('contain', archivedPublicChannel.display_name);
});
cy.get('body').typeWithForce('{esc}');
});
it('MM-T1700 - All archived public channels are shown Important', () => {
let archivedPublicChannel1;
let archivedPublicChannel2;
// # Create public channel
cy.apiCreateChannel(testTeam.id, 'channel', 'channel').then(({channel}) => {
archivedPublicChannel1 = channel;
// # Visit the channel
cy.visit(`/${testTeam.name}/channels/${archivedPublicChannel1.name}`);
// # Archive the channel
cy.uiArchiveChannel();
});
// # Create second public channel
cy.apiCreateChannel(testTeam.id, 'channel', 'channel').then(({channel}) => {
archivedPublicChannel2 = channel;
// # Visit the channel
cy.visit(`/${testTeam.name}/channels/${archivedPublicChannel2.name}`);
// # Archive the channel
cy.uiArchiveChannel();
// # Leave channel
cy.uiLeaveChannel();
// # User should be redirected to last viewed channel
cy.url().should('include', `/${testTeam.name}/channels/${archivedPublicChannel1.name}`);
});
// # Click on add channel button
cy.get('#SidebarContainer .AddChannelDropdown_dropdownButton').click();
// # Click on browse channels
cy.get('#showMoreChannels').click();
// # More channels modal opens
cy.get('.more-modal').should('be.visible').within(() => {
// # Public channels are shown by default
cy.findByText('Show: Public Channels').should('be.visible').click();
// # Go to archived channels
cy.findByText('Archived Channels').click();
// # Channel list should contain both archived public channels
cy.get('#moreChannelsList').should('contain', archivedPublicChannel1.display_name);
cy.get('#moreChannelsList').should('contain', archivedPublicChannel2.display_name);
});
cy.get('body').typeWithForce('{esc}');
});
it('MM-T1701 - Only Private channels you are a member of are displayed', () => {
let archivedPrivateChannel1;
let archivedPrivateChannel2;
// # Create private channel
cy.uiCreateChannel({isPrivate: true, isNewSidebar: true}).as('channel').then((channel) => {
archivedPrivateChannel1 = channel;
// # Visit the channel
cy.visit(`/${testTeam.name}/channels/${archivedPrivateChannel1.name}`);
// # Archive the channel
cy.uiArchiveChannel();
});
// # Create another private channel
cy.uiCreateChannel({isPrivate: true, isNewSidebar: true}).as('channel').then((channel) => {
archivedPrivateChannel2 = channel;
// # Visit the channel
cy.visit(`/${testTeam.name}/channels/${archivedPrivateChannel2.name}`);
// # Archive the channel
cy.uiArchiveChannel();
// # Leave the channel
cy.uiLeaveChannel();
});
// # Leave channel modal is visible
cy.get('#confirmModal').should('be.visible');
cy.get('#confirmModalButton').click();
// # Click on add channel button
cy.get('#SidebarContainer .AddChannelDropdown_dropdownButton').click();
// # Click on browse channels
cy.get('#showMoreChannels').click();
// # More channels modal opens
cy.get('.more-modal').should('be.visible').within(() => {
// # Show public channels is visible by default
cy.findByText('Show: Public Channels').should('be.visible').click();
// # Go to archived channels
cy.findByText('Archived Channels').click();
// # Channel list should contain only the private channel user is a member of
cy.get('#moreChannelsList').should('contain', archivedPrivateChannel1.name);
cy.get('#moreChannelsList').should('not.contain', archivedPrivateChannel2.name);
});
cy.get('body').typeWithForce('{esc}');
});
it('MM-T1703 - User can open archived channels', () => {
let archivedChannel;
// # Create a public channel
cy.apiCreateChannel(testTeam.id, 'channel', 'channel').then(({channel}) => {
archivedChannel = channel;
// # Visit the channel
cy.visit(`/${testTeam.name}/channels/${archivedChannel.name}`);
// # Archive the channel
cy.uiArchiveChannel();
});
// # Click on add channel button
cy.get('#SidebarContainer .AddChannelDropdown_dropdownButton').click();
// # Click on browse channels
cy.get('#showMoreChannels').click();
// # More channels modal opens and lands on public channels
cy.get('#moreChannelsModal').should('be.visible').within(() => {
cy.findByText('Show: Public Channels').should('be.visible').click();
// # Go to archived channels
cy.findByText('Archived Channels').click();
// # More channels list should contain the archived channel
cy.get('#moreChannelsList').should('contain', archivedChannel.display_name);
});
cy.get('body').typeWithForce('{esc}');
});
it('MM-T1696 - When clicking Browse Channels no options for archived channels are shown when the feature is disabled', () => {
cy.apiAdminLogin();
cy.apiUpdateConfig({
TeamSettings: {
ExperimentalViewArchivedChannels: false,
},
});
// # Create public channel
cy.apiCreateChannel(testTeam.id, 'channel', 'channel').then(({channel}) => {
// # Visit the channel
cy.visit(`/${testTeam.name}/channels/${channel.name}`);
// # Archive the channel
cy.uiArchiveChannel();
// # Click on add channel button
cy.get('#SidebarContainer .AddChannelDropdown_dropdownButton').click();
// # Click on browse channels
cy.get('#showMoreChannels').click();
// # Modal should not contain the created channel
cy.get('#channelsMoreDropdown').should('not.exist');
cy.get('#moreChannelsList').should('not.contain', channel.name);
});
cy.get('body').typeWithForce('{esc}');
});
});

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

@@ -0,0 +1,110 @@
// 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
import {getAdminAccount} from '../../../support/env';
import {getRandomId} from '../../../utils';
describe('Leave an archived channel', () => {
let testTeam;
let testUser;
before(() => {
cy.apiUpdateConfig({
TeamSettings: {
ExperimentalViewArchivedChannels: true,
},
});
cy.apiInitSetup().then(({team, user}) => {
testTeam = team;
testUser = user;
});
});
beforeEach(() => {
// # Login as test user and visit off-topic
cy.apiLogin(testUser);
cy.visit(`/${testTeam.name}/channels/off-topic`);
});
it('MM-T1687 App does not crash when another user archives a channel', () => {
cy.makeClient({user: getAdminAccount()}).then((client) => {
// # Have another user create a private channel
const channelName = `channel${getRandomId()}`;
cy.wrap(client.createChannel({
display_name: channelName,
name: channelName,
team_id: testTeam.id,
type: 'P',
})).then(async (channel) => {
// # Then invite us to it
await client.addToChannel(testUser.id, channel.id);
cy.wrap(channel);
}).then((channel) => {
// * Verify that the newly created channel is in the sidebar
cy.get(`#sidebarItem_${channel.name}`).should('be.visible');
cy.wrap(channel);
}).then(async (channel) => {
// # Then archive the channel
await client.deleteChannel(channel.id);
// * Verify that the channel is no longer in the sidebar and that the app hasn't crashed
cy.get(`#sidebarItem_${channel.name}`).should('not.exist');
});
});
});
it('MM-T1688 archived channels only appear in search results as long as the user does not leave them', () => {
// # Create a new channel
cy.uiCreateChannel({isNewSidebar: true}).then(({name: channelName}) => {
// # Make a post
const archivedPostText = `archived${getRandomId()}`;
cy.postMessage(archivedPostText);
cy.getLastPostId().then((archivedPostId) => {
// # Archive the newly created channel
cy.uiArchiveChannel();
// # Switch away from the archived channel
cy.get('#sidebarItem_off-topic').click();
// * Verify that the channel is no longer in the sidebar
cy.get(`#sidebarItem_${channelName}`).should('not.exist');
// # Search for the post
cy.uiSearchPosts(archivedPostText);
// * Verify that the post is shown in the search results
cy.get(`#searchResult_${archivedPostId}`).should('be.visible');
// # Switch back to the archived channel through the permalink
cy.uiJumpToSearchResult(archivedPostId);
// * Wait for the permalink URL to disappear
cy.url().should('include', `/${testTeam.name}/channels/${channelName}`);
// # Leave the channel
cy.uiLeaveChannel();
cy.url().should('include', `/${testTeam.name}/channels/off-topic`);
cy.postMessage('hello');
// # Search for the post again
cy.uiSearchPosts(archivedPostText);
// * Verify that the post is no longer shown in the search results
cy.get(`#searchResult_${archivedPostId}`).should('not.exist');
cy.get('#search-items-container .no-results__wrapper').should('be.visible');
});
});
});
});

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

@@ -0,0 +1,465 @@
// 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 @rhs @channel_info
import {stubClipboard} from '../../../utils';
describe('Channel Info RHS', () => {
let testTeam;
let testChannel;
let groupChannel;
let directChannel;
let directUser;
let admin;
let user;
const otherUsers = [];
before(() => {
cy.apiInitSetup({promoteNewUserAsAdmin: true}).then(({team, user: newAdmin}) => {
testTeam = team;
admin = newAdmin;
cy.apiCreateChannel(testTeam.id, 'channel', 'Public Channel', 'O').then(({channel}) => {
testChannel = channel;
cy.apiAddUserToChannel(channel.id, newAdmin.id);
});
// User we'll use for our permissions tests
cy.apiCreateUser().then(({user: newUser}) => {
cy.apiAddUserToTeam(team.id, newUser.id);
user = newUser;
});
// Users used for GM/DM
cy.apiCreateUser().then(({user: newUser}) => {
otherUsers.push(newUser);
cy.apiPatchUser(newUser.id, {position: 'Upside down'}).then(({user: patchedUser}) => {
cy.apiCreateDirectChannel([newAdmin.id, newUser.id]).then(({channel}) => {
directChannel = channel;
});
directUser = patchedUser;
});
cy.apiAddUserToTeam(team.id, newUser.id);
cy.apiCreateUser().then(({user: newUser2}) => {
otherUsers.push(newUser2);
cy.apiAddUserToTeam(team.id, newUser.id);
cy.apiCreateGroupChannel([newAdmin.id, newUser.id, newUser2.id]).then(({channel}) => {
groupChannel = channel;
});
});
});
// # Change permission so that regular users can't change channels or add members
cy.apiGetRolesByNames(['channel_user']).then(({roles}) => {
const role = roles[0];
const permissions = role.permissions.filter((permission) => {
return !(['manage_public_channel_members', 'manage_private_channel_members', 'manage_public_channel_properties', 'manage_private_channel_properties'].includes(permission));
});
if (permissions.length !== role.permissions) {
cy.apiPatchRole(role.id, {permissions});
}
});
cy.apiLogin(admin);
});
});
it('should be able to open the RHS', () => {
// # Go to test channel
cy.visit(`/${testTeam.name}/channels/${testChannel.name}`);
// # Click on the channel info button
cy.get('#channel-info-btn').click();
// * RHS Container shoud exist
ensureRHSIsOpenOnChannelInfo(testChannel);
});
describe('regular channel', () => {
describe('top buttons', () => {
it('should be able to toggle favorite on a channel', () => {
// # Go to test channel
cy.visit(`/${testTeam.name}/channels/${testChannel.name}`);
// # Click on the channel info button
cy.get('#channel-info-btn').click();
// * Verify that we can toggle the favorite status
cy.uiGetRHS().findByText('Favorite').should('be.visible').click();
cy.uiGetRHS().findByText('Favorited').should('be.visible').click();
cy.uiGetRHS().findByText('Favorite').should('be.visible');
});
it('should be able to toggle mute on a channel', () => {
// # Go to test channel
cy.visit(`/${testTeam.name}/channels/${testChannel.name}`);
// # Click on the channel info button
cy.get('#channel-info-btn').click();
// * Verify that we can toggle the mute status
cy.uiGetRHS().findByText('Mute').should('be.visible').click();
cy.uiGetRHS().findByText('Muted').should('be.visible').click();
cy.uiGetRHS().findByText('Mute').should('be.visible');
});
it('should be able to add people', () => {
// # Go to test channel
cy.visit(`/${testTeam.name}/channels/${testChannel.name}`);
// # Click on the channel info button
cy.get('#channel-info-btn').click();
// * Verify that the modal appears
cy.uiGetRHS().findByText('Add People').should('be.visible').click();
cy.get('.channel-invite').should('be.visible');
});
it('should NOT be able to add people without permission', () => {
// # Login as simple user
cy.apiLogout().then(() => {
cy.apiLogin(user);
// # Go to test channel
cy.visit(`/${testTeam.name}/channels/${testChannel.name}`);
// # Click on the channel info button
cy.get('#channel-info-btn').click();
// * Verify that the modal appears
cy.uiGetRHS().findByText('Add People').should('not.exist');
// # log back in as admin
cy.apiLogout().then(() => {
cy.apiLogin(admin);
});
});
});
it('should be able to copy link', () => {
// # Go to test channel
cy.visit(`/${testTeam.name}/channels/${testChannel.name}`);
stubClipboard().as('clipboard');
// # Click on the channel info button
cy.get('#channel-info-btn').click();
// * Verify initial state
cy.get('@clipboard').its('contents').should('eq', '');
// # Click on "Copy Link"
cy.uiGetRHS().findByText('Copy Link').parent().should('be.visible').trigger('click');
// * Text should change to Copied
cy.uiGetRHS().findByText('Copied').should('be.visible');
// * Verify if it's called with correct link value
cy.get('@clipboard').its('contents').should('eq', `${Cypress.config('baseUrl')}/${testTeam.name}/channels/${testChannel.name}`);
});
});
describe('about area', () => {
it('should display purpose', () => {
// # Go to test channel
cy.visit(`/${testTeam.name}/channels/${testChannel.name}`);
// # Click on the channel info button
cy.get('#channel-info-btn').click();
cy.apiPatchChannel(testChannel.id, {
...testChannel,
purpose: 'purpose for the tests',
}).then(() => {
cy.uiGetRHS().findByText('purpose for the tests').should('be.visible');
});
});
it('should display header', () => {
// # Go to test channel
cy.visit(`/${testTeam.name}/channels/${testChannel.name}`);
// # Click on the channel info button
cy.get('#channel-info-btn').click();
cy.apiPatchChannel(testChannel.id, {
...testChannel,
header: 'header for the tests',
}).then(() => {
cy.uiGetRHS().findByText('header for the tests').should('be.visible');
});
});
});
describe('bottom menu', () => {
it('should be able to manage notifications', () => {
// # Go to test channel
cy.visit(`/${testTeam.name}/channels/${testChannel.name}`);
// # Click on the channel info button
cy.get('#channel-info-btn').click();
// # Click on "Notification Preferences"
cy.uiGetRHS().findByText('Notification Preferences').should('be.visible').click();
// * Ensures the modal is there
cy.get('.settings-modal').should('be.visible');
});
it('should be able to view files and come back', () => {
// # Go to test channel
cy.visit(`/${testTeam.name}/channels/${testChannel.name}`);
// # Click on the channel info button
cy.get('#channel-info-btn').click();
// # Click on "Files"
cy.uiGetRHS().findByTestId('channel_info_rhs-menu').findByText('Files').should('be.visible').click();
// * Ensure we see the files RHS
cy.uiGetRHS().findByText('No files yet').should('be.visible');
// # Click the Back Icon
cy.uiGetRHS().get('[aria-label="Back Icon"]').click();
// * Make sure we are back in the channel info rhs
ensureRHSIsOpenOnChannelInfo(testChannel);
});
it('should be able to view pinned message and come back', () => {
// # Go to test channel
cy.visit(`/${testTeam.name}/channels/${testChannel.name}`);
// # Go to test channel
cy.uiPostMessageQuickly('Hello channel info rhs spec').then(() => {
cy.getNthPostId(-1).then((postId) => {
cy.clickPostDotMenu(postId);
cy.get(`#pin_post_${postId}`).click();
});
});
// # Click on the channel info button
cy.get('#channel-info-btn').click();
// # Click on "Pinned Messages"
cy.uiGetRHS().findByTestId('channel_info_rhs-menu').findByText('Pinned Messages').should('be.visible').click();
// * Ensure we see the Pinned Post RHS
cy.uiGetRHS().findByText('Hello channel info rhs spec').should('be.visible');
// # Click the Back Icon
cy.uiGetRHS().get('[aria-label="Back Icon"]').click();
// * Make sure we are back in the channel info rhs
ensureRHSIsOpenOnChannelInfo(testChannel);
});
it('should be able to view channel members and come back', () => {
// # Go to test channel
cy.visit(`/${testTeam.name}/channels/${testChannel.name}`);
// # Click on the channel info button
cy.get('#channel-info-btn').click();
// # Click on "Members"
cy.uiGetRHS().findByTestId('channel_info_rhs-menu').findByText('Members').should('be.visible').click();
// * Ensure we see the members
cy.uiGetRHS().contains('sysadmin').should('be.visible');
cy.uiGetRHS().contains(`${admin.username}`).should('be.visible');
// # Click the Back Icon
cy.uiGetRHS().get('[aria-label="Back Icon"]').click();
// * Make sure we are back in the channel info rhs
ensureRHSIsOpenOnChannelInfo(testChannel);
});
});
});
describe('group channel', () => {
describe('top buttons', () => {
it('should be able to toggle favorite', () => {
// # Go to test channel
cy.visit(`/${testTeam.name}/messages/${groupChannel.name}`);
// # Click on the channel info button
cy.get('#channel-info-btn').click();
// * Verify that we can toggle the favorite status
cy.uiGetRHS().findByText('Favorite').should('be.visible').click();
cy.uiGetRHS().findByText('Favorited').should('be.visible').click();
cy.uiGetRHS().findByText('Favorite').should('be.visible');
});
it('should be able to toggle mute', () => {
// # Go to test channel
cy.visit(`/${testTeam.name}/messages/${groupChannel.name}`);
// # Click on the channel info button
cy.get('#channel-info-btn').click();
// * Verify that we can toggle the mute status
cy.uiGetRHS().findByText('Mute').should('be.visible').click();
cy.uiGetRHS().findByText('Muted').should('be.visible').click();
cy.uiGetRHS().findByText('Mute').should('be.visible');
});
it('should be able to add people', () => {
// # Go to test channel
cy.visit(`/${testTeam.name}/messages/${groupChannel.name}`);
// # Click on the channel info button
cy.get('#channel-info-btn').click();
// * Verify that the modal appears
cy.uiGetRHS().findByText('Add People').should('be.visible').click();
cy.get('.more-direct-channels').should('be.visible');
});
it('should NOT be able to copy link', () => {
// # Go to test channel
cy.visit(`/${testTeam.name}/messages/${groupChannel.name}`);
// # Click on the channel info button
cy.get('#channel-info-btn').click();
// # Click on "Copy Link"
cy.uiGetRHS().get('Copy Link').should('not.exist');
});
});
describe('about area', () => {
it('should display other users', () => {
// # Go to test channel
cy.visit(`/${testTeam.name}/messages/${groupChannel.name}`);
// # Click on the channel info button
cy.get('#channel-info-btn').click();
otherUsers.forEach((otherUser) => {
cy.uiGetRHS().contains(otherUser.username);
});
});
it('should display header', () => {
// # Go to test channel
cy.visit(`/${testTeam.name}/messages/${groupChannel.name}`);
// # Click on the channel info button
cy.get('#channel-info-btn').click();
cy.apiPatchChannel(groupChannel.id, {
...groupChannel,
header: 'header for the tests',
}).then(() => {
cy.uiGetRHS().findByText('header for the tests').should('be.visible');
});
});
});
describe('bottom menu', () => {
it('should be able to manage notifications', () => {
// # Go to test channel
cy.visit(`/${testTeam.name}/messages/${groupChannel.name}`);
// # Click on the channel info button
cy.get('#channel-info-btn').click();
// # Click on "Notification Preferences"
cy.uiGetRHS().findByText('Notification Preferences').should('be.visible').click();
// * Ensures the modal is there
cy.get('.settings-modal').should('be.visible');
});
});
});
describe('direct channel', () => {
describe('top buttons', () => {
it('should be able to toggle favorite', () => {
// # Go to test channel
cy.visit(`/${testTeam.name}/messages/@${directUser.username}`);
// # Click on the channel info button
cy.get('#channel-info-btn').click();
// * Verify that we can toggle the favorite status
cy.uiGetRHS().findByText('Favorite').should('be.visible').click();
cy.uiGetRHS().findByText('Favorited').should('be.visible').click();
cy.uiGetRHS().findByText('Favorite').should('be.visible');
});
it('should be able to toggle mute', () => {
// # Go to test channel
cy.visit(`/${testTeam.name}/messages/@${directUser.username}`);
// # Click on the channel info button
cy.get('#channel-info-btn').click();
// * Verify that we can toggle the mute status
cy.uiGetRHS().findByText('Mute').should('be.visible').click();
cy.uiGetRHS().findByText('Muted').should('be.visible').click();
cy.uiGetRHS().findByText('Mute').should('be.visible');
});
it('should NOT be able to add people', () => {
// # Go to test channel
cy.visit(`/${testTeam.name}/messages/@${directUser.username}`);
// # Click on the channel info button
cy.get('#channel-info-btn').click();
// * Verify that the modal appears
cy.uiGetRHS().findByText('Add People').should('not.exist');
});
it('should NOT be able to copy link', () => {
// # Go to test channel
cy.visit(`/${testTeam.name}/messages/@${directUser.username}`);
// # Click on the channel info button
cy.get('#channel-info-btn').click();
// # Click on "Copy Link"
cy.uiGetRHS().get('Copy Link').should('not.exist');
});
});
describe('about area', () => {
it('should display other user name and position', () => {
// # Go to test channel
cy.visit(`/${testTeam.name}/messages/@${directUser.username}`);
// # Click on the channel info button
cy.get('#channel-info-btn').click();
cy.uiGetRHS().contains(directUser.username);
cy.uiGetRHS().contains(directUser.position);
});
it('should display header', () => {
// # Go to test channel
cy.visit(`/${testTeam.name}/messages/@${directUser.username}`);
// # Click on the channel info button
cy.get('#channel-info-btn').click();
cy.apiPatchChannel(directChannel.id, {
...directChannel,
header: 'header for the tests',
}).then(() => {
cy.uiGetRHS().findByText('header for the tests').should('be.visible');
});
});
});
});
});
function ensureRHSIsOpenOnChannelInfo(testChannel) {
cy.get('#rhsContainer').then((rhsContainer) => {
cy.wrap(rhsContainer).findByText('Info').should('be.visible');
cy.wrap(rhsContainer).findByText(testChannel.display_name).should('be.visible');
});
}

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

@@ -0,0 +1,329 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
const {generateRandomUser} = require('../../../support/api/user');
// ***************************************************************
// - [#] 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 @rhs @channel_members
function openChannelMembersRhs(testTeam, testChannel) {
// # Go to test channel
cy.visit(`/${testTeam.name}/channels/${testChannel.name}`);
// # Click on the channel info button
cy.get('#channel-info-btn').click();
// # Click on the Members menu
cy.uiGetRHS().findByText('Members').should('be.visible').click();
}
describe('Channel members RHS', () => {
let testTeam;
let testChannel;
let admin;
let user;
before(() => {
cy.apiInitSetup({promoteNewUserAsAdmin: true}).then(({team, user: newAdmin}) => {
testTeam = team;
admin = newAdmin;
// User we'll use for our permissions tests
cy.apiCreateUser().then(({user: newUser}) => {
user = newUser;
cy.apiAddUserToTeam(team.id, newUser.id).then(() => {
cy.apiCreateChannel(testTeam.id, 'channel', 'Public Channel', 'O').then(({channel}) => {
testChannel = channel;
cy.apiAddUserToChannel(channel.id, newAdmin.id);
cy.apiAddUserToChannel(channel.id, newUser.id);
});
});
});
// # Change permission so that regular users can't change channels or add members
cy.apiGetRolesByNames(['channel_user']).then(({roles}) => {
const role = roles[0];
const permissions = role.permissions.filter((permission) => {
return !(['manage_public_channel_members', 'manage_private_channel_members', 'manage_public_channel_properties', 'manage_private_channel_properties'].includes(permission));
});
if (permissions.length !== role.permissions) {
cy.apiPatchRole(role.id, {permissions});
}
});
cy.apiLogin(admin);
});
});
it('should be able to open the RHS from channel info', () => {
// # Open the Channel Members RHS
openChannelMembersRhs(testTeam, testChannel);
// * RHS Container should exist
ensureChannelMembersRHSExists(testChannel);
});
it('should be able to open the RHS from the members icon', () => {
// # Go to test channel
cy.visit(`/${testTeam.name}/channels/${testChannel.name}`);
// # Open the RHS by clicking on the members icon
cy.get('#channelHeaderInfo').within(() => {
cy.get('#member_rhs').should('be.visible').click({force: true});
});
// * RHS Container should exist
ensureChannelMembersRHSExists(testChannel);
});
it('should display the number of members', () => {
// # Open the Channel Members RHS
openChannelMembersRhs(testTeam, testChannel);
// * Verify that we can toggle the favorite status
cy.uiGetRHS().findByText('3 members').should('be.visible');
});
it('should go back to previous RHS when switching from a channel to a DM', () => {
cy.apiCreateUser({}).then(({user: newUser}) => {
cy.apiAddUserToTeam(testTeam.id, newUser.id).then(() => {
// # Open the Channel Members RHS
openChannelMembersRhs(testTeam, testChannel);
// * Ensure we are in the members subpanel
cy.uiGetRHS().get('.sidebar--right__title').findByText('Members').should('be.visible');
// # Visit the DM page
cy.uiGotoDirectMessageWithUser(newUser);
// * We should be in Channel Info RHS now
cy.uiGetRHS().get('.sidebar--right__title').findByText('Info').should('be.visible');
});
});
});
it('should close the RHS when switching from a channel to a DM', () => {
cy.apiCreateUser({}).then(({user: newUser}) => {
cy.apiAddUserToTeam(testTeam.id, newUser.id).then(() => {
// # Open the Channel Members RHS directly from the channel header button
cy.visit(`/${testTeam.name}/channels/${testChannel.name}`);
cy.get('#member_rhs').click();
// * Ensure we are in the members subpanel
cy.uiGetRHS().get('.sidebar--right__title').findByText('Members').should('be.visible');
// # Visit the DM page
cy.uiGotoDirectMessageWithUser(newUser);
// * The RHS must not exist
cy.get('#sidebar-right').should('not.exist');
});
});
});
it('should display search when number of members is 20 or above', () => {
cy.apiCreateChannel(testTeam.id, 'search-test-channel', 'Search Test Channel', 'O').then(({channel}) => {
// # Open the Channel Members RHS
openChannelMembersRhs(testTeam, channel);
// * Ensure the search bar is not there
cy.uiGetRHS().findByPlaceholderText('Search members').should('not.exist');
// # Close RHS
cy.uiCloseRHS();
for (let i = 0; i < 20; i++) {
// eslint-disable-next-line no-loop-func
cy.apiCreateUser().then(({user: newUser}) => {
cy.apiAddUserToTeam(testTeam.id, newUser.id).then(() => {
cy.apiAddUserToChannel(channel.id, newUser.id);
});
});
}
cy.apiGetUsers({in_channel: channel.id}).then(({users}) => {
// # Open the Channel Members RHS
openChannelMembersRhs(testTeam, channel);
// # Search for first user
cy.uiGetRHS().findByTestId('channel-member-rhs-search').should('be.visible').type(users[0].username);
// * we should see them, but nobody else
cy.uiGetRHS().contains(`${users[0].username}`).should('be.visible');
cy.uiGetRHS().findByText(`${users[1].username}`).should('not.exist');
// # erase the field
cy.uiGetRHS().get('[aria-label="cancel members search"]').should('be.visible').click();
cy.uiGetRHS().contains(`${users[0].username}`).should('exist');
});
});
});
it('should hide deactivated members', () => {
cy.apiCreateChannel(testTeam.id, 'hide-test-channel', 'Hide Test Channel', 'O').then(({channel}) => {
let testUser = null;
cy.apiCreateUser().then(({user: newUser}) => {
cy.apiAddUserToTeam(testTeam.id, newUser.id).then(() => {
cy.apiAddUserToChannel(channel.id, newUser.id).then(() => {
testUser = newUser;
// # Open the Channel Members RHS
openChannelMembersRhs(testTeam, channel);
// * Ensure the member is visible
cy.uiGetRHS().contains(`${testUser.username}`).should('be.visible');
// # Deactivate the user
cy.apiDeactivateUser(testUser.id);
// * Ensure the user is not visible anymore
cy.uiGetRHS().findByText(`${testUser.username}`).should('not.exist');
});
});
});
});
});
describe('as an admin', () => {
before(() => {
cy.apiLogout();
cy.apiLogin(admin);
});
it('should be able to open the RHS from the channel menu', () => {
// # Go to test channel
cy.visit(`/${testTeam.name}/channels/${testChannel.name}`);
cy.uiOpenChannelMenu('Manage Members');
// * RHS Container should be open in edit mode
cy.get('#rhsContainer').then((rhsContainer) => {
cy.wrap(rhsContainer).findByText('Members').should('be.visible');
cy.wrap(rhsContainer).findByText(testChannel.display_name).should('be.visible');
// Done button should be visible
cy.wrap(rhsContainer).findByText('Done').should('be.visible');
});
});
it('should be able to invite new members', () => {
// # Open the Channel Members RHS
openChannelMembersRhs(testTeam, testChannel);
// # Click on the Add button
cy.uiGetRHS().findByText('Add').should('be.visible').click();
// * The modal should appear
cy.get('.channel-invite').should('be.visible');
});
it('should be able to manage members', () => {
// # Open the Channel Members RHS
openChannelMembersRhs(testTeam, testChannel);
// # Click on the Manage button
cy.uiGetRHS().findByText('Manage').should('be.visible').click();
// * Can see user with their roles, and change it
cy.uiGetRHS().findByTestId(`memberline-${user.id}`).should('be.visible').within(() => {
cy.contains(`${user.username}`).should('be.visible');
cy.findByText('Member').should('be.visible').click();
cy.findByText('Make Channel Admin').should('be.visible').click();
});
// the user line is going to be removed and re-added in another category,
// cypress struggle to realize this so we have to wait a few ms
// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(500);
// * Can see the user with his new admin role, and change it back
cy.uiGetRHS().findByTestId(`memberline-${user.id}`).should('be.visible').within(() => {
cy.findByText('Admin').should('be.visible').click();
cy.findByText('Make Channel Member').should('be.visible').click();
});
});
});
describe('as an non-admin', () => {
before(() => {
cy.apiLogout();
cy.apiLogin(user);
});
it('should be able to open the RHS from the channel menu', () => {
// # Go to test channel
cy.visit(`/${testTeam.name}/channels/${testChannel.name}`);
cy.uiOpenChannelMenu('View Members');
// * RHS Container should be open in edit mode
ensureChannelMembersRHSExists(testChannel);
});
it('should not be able to invite new members', () => {
// # Open the Channel Members RHS
openChannelMembersRhs(testTeam, testChannel);
// # Click on the Add button
cy.uiGetRHS().findByText('Add').should('not.exist');
});
it('should not be able to manage members', () => {
// # Open the Channel Members RHS
openChannelMembersRhs(testTeam, testChannel);
// # Click on the Manage button
cy.uiGetRHS().findByText('Manage').should('not.exist');
});
});
it('should be able to find users not in the initial list', () => {
cy.apiCreateChannel(testTeam.id, 'big-search-test-channel', 'Big Search Test Channel', 'O').then(({channel}) => {
// # create 100 random users
for (let i = 0; i < 100; i++) {
// eslint-disable-next-line no-loop-func
cy.apiCreateUser().then(({user: newUser}) => {
cy.apiAddUserToTeam(testTeam.id, newUser.id).then(() => {
cy.apiAddUserToChannel(channel.id, newUser.id);
});
});
}
// # create a user that will not be listed by default
const lastUser = generateRandomUser();
lastUser.username = 'zzzzzzz' + Date.now();
cy.apiCreateUser({user: lastUser}).then(({user: newUser}) => {
cy.apiAddUserToTeam(testTeam.id, newUser.id).then(() => {
cy.apiAddUserToChannel(channel.id, newUser.id);
});
});
// # Open the Channel Members RHS
openChannelMembersRhs(testTeam, channel);
// # make sure that last user is not present in the list
cy.uiGetRHS().findByText(`${lastUser.username}`).should('not.exist');
// # Search for the user user
cy.uiGetRHS().findByTestId('channel-member-rhs-search').should('be.visible').type(lastUser.username);
// * the user is now existing
cy.uiGetRHS().contains(`${lastUser.username}`).should('be.visible');
});
});
});
function ensureChannelMembersRHSExists(testChannel) {
cy.get('#rhsContainer').then((rhsContainer) => {
cy.wrap(rhsContainer).findByText('Members').should('be.visible');
cy.wrap(rhsContainer).findByText(testChannel.display_name).should('be.visible');
});
}

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

@@ -0,0 +1,114 @@
// 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
import * as TIMEOUTS from '../../../fixtures/timeouts';
describe('Channel', () => {
let testTeam;
let ownChannel;
let otherChannel;
let testUser;
let offTopicUrl;
const myChannelsDividerText = 'My Channels';
const otherChannelsDividerText = 'Other Channels';
before(() => {
// # Login as new user and visit off-topic
cy.apiInitSetup().then(({team, channel, user, offTopicUrl: url}) => {
testTeam = team;
ownChannel = channel;
testUser = user;
offTopicUrl = url;
cy.apiCreateChannel(testTeam.id, 'delta-test', 'Delta Channel').then((out) => {
otherChannel = out.channel;
});
cy.apiLogin(testUser);
cy.visit(offTopicUrl);
});
});
it('Channel autocomplete should have both lists populated correctly', () => {
// # Type "~"
cy.uiGetPostTextBox().clear().type('~').wait(TIMEOUTS.HALF_SEC);
cy.get('#loadingSpinner').should('not.exist');
// * Should open up suggestion list for channels
// * Should match each channel item
cy.get('#suggestionList').should('be.visible').children().as('suggestionList');
// * Should render "MY CHANNELS" suggestion list divider
cy.get('@suggestionList').eq(0).contains(myChannelsDividerText, {matchCase: false});
cy.get('@suggestionList').eq(1).should('contain', ownChannel.display_name);
cy.get('@suggestionList').eq(2).should('contain', 'Off-Topic');
cy.get('@suggestionList').eq(3).should('contain', 'Town Square');
// * Should render "OTHER CHANNELS" suggestion list divider
cy.get('@suggestionList').eq(4).contains(otherChannelsDividerText, {matchCase: false});
cy.get('@suggestionList').eq(5).should('contain', otherChannel.display_name);
});
it('Joining a channel should alter channel mention autocomplete lists accordingly', () => {
// # Join a channel by /join slash command
cy.uiGetPostTextBox().clear().wait(TIMEOUTS.HALF_SEC).type(`/join ~${otherChannel.name}`).type('{enter}').wait(TIMEOUTS.HALF_SEC);
// * Verify that it redirects into the channel
cy.url().should('include', `/${testTeam.name}/channels/${otherChannel.name}`);
// # Type "~"
cy.uiGetPostTextBox().type('~').wait(TIMEOUTS.HALF_SEC);
cy.get('#loadingSpinner').should('not.exist');
// * Should open up suggestion list for channels
// * Should match each channel
cy.get('#suggestionList').should('be.visible').children().as('suggestionList');
// * Should render "MY CHANNELS" suggestion list divider
cy.get('@suggestionList').eq(0).contains(myChannelsDividerText, {matchCase: false});
cy.get('@suggestionList').eq(1).should('contain', ownChannel.display_name);
cy.get('@suggestionList').eq(2).should('contain', otherChannel.display_name);
cy.get('@suggestionList').eq(3).should('contain', 'Off-Topic');
cy.get('@suggestionList').eq(4).should('contain', 'Town Square');
});
it('Getting removed from a channel should alter channel mention autocomplete lists accordingly', () => {
// # Remove test user from the test channel
cy.apiAdminLogin();
cy.removeUserFromChannel(otherChannel.id, testUser.id).then((res) => {
expect(res.status).to.equal(200);
// # Login as test user and visit the test team
cy.apiLogin(testUser);
cy.visit(offTopicUrl);
// # Type "~"
cy.uiGetPostTextBox().clear().type('~').wait(TIMEOUTS.HALF_SEC);
cy.get('#loadingSpinner').should('not.exist');
// * Should open up suggestion list for channels
// * Should match each channel item
cy.get('#suggestionList').should('be.visible').children().as('suggestionList');
// * Should render "MY CHANNELS" suggestion list divider
cy.get('@suggestionList').eq(0).contains(myChannelsDividerText, {matchCase: false});
cy.get('@suggestionList').eq(1).should('contain', ownChannel.display_name);
cy.get('@suggestionList').eq(2).should('contain', 'Off-Topic');
cy.get('@suggestionList').eq(3).should('contain', 'Town Square');
// * Should render "OTHER CHANNELS" suggestion list divider
cy.get('@suggestionList').eq(4).contains(otherChannelsDividerText, {matchCase: false});
cy.get('@suggestionList').eq(5).should('contain', otherChannel.display_name);
});
});
});

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

@@ -0,0 +1,130 @@
// 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 @not_cloud
import * as TIMEOUTS from '../../../fixtures/timeouts';
const timestamp = Date.now();
function verifyChannel(channel, verifyExistence = true) {
// # Wait for Channel to be created
cy.wait(TIMEOUTS.HALF_SEC);
// # Hover on the channel name
cy.get(`#sidebarItem_${channel.name}`).should('be.visible').trigger('mouseover');
// * Verify that the tooltip is displayed
if (verifyExistence) {
cy.get('div.tooltip-inner').
should('be.visible').
and('contain', channel.display_name);
} else {
cy.get('div.tooltip-inner').should('not.exist');
}
// # Move cursor away from channel
cy.get(`#sidebarItem_${channel.name}`).should('be.visible').trigger('mouseout');
}
describe('channel name tooltips', () => {
let loggedUser;
let longUser;
let testTeam;
before(() => {
cy.shouldNotRunOnCloudEdition();
// # Login as new user and visit off-topic
cy.apiInitSetup().then(({team, user, offTopicUrl}) => {
testTeam = team;
loggedUser = user;
cy.apiCreateUser({prefix: `thisIsALongUsername${timestamp}`}).then(({user: user1}) => {
longUser = user1;
cy.apiAddUserToTeam(testTeam.id, loggedUser.id);
});
cy.apiLogin(loggedUser);
cy.visit(offTopicUrl);
});
});
it('Should show tooltip on hover - open/public channel with long name', () => {
// # Create new test channel
cy.apiCreateChannel(
testTeam.id,
'channel-test',
`Public channel with a long name-${timestamp}`,
).then(({channel}) => {
verifyChannel(channel);
});
});
it('Should show tooltip on hover - private channel with long name', () => {
// # Create new test channel
cy.apiCreateChannel(
testTeam.id,
'channel-test',
`Private channel with a long name-${timestamp}`,
'P',
).then(({channel}) => {
verifyChannel(channel);
});
});
it('Should not show tooltip on hover - open/public channel with short name', () => {
// # Create new test channel
cy.apiCreateChannel(
testTeam.id,
'channel-test',
'Public channel',
).then(({channel}) => {
verifyChannel(channel, false);
});
});
it('Should not show tooltip on hover - private channel with short name', () => {
// # Create new test channel
cy.apiCreateChannel(
testTeam.id,
'channel-test',
'Private channel',
'P',
).then(({channel}) => {
verifyChannel(channel, false);
});
});
it('Should show tooltip on hover - user with a long username', () => {
// # Open a DM with the user
cy.findByRole('button', {name: 'Write a direct message'}).click();
cy.focused().as('searchBox').typeWithForce(longUser.username);
// * Verify that the user is selected in the results list before typing enter
cy.get('div.more-modal__row').
should('have.length', 1).
and('have.class', 'clickable').
and('have.class', 'more-modal__row--selected').
and('contain.text', longUser.username.toLowerCase());
cy.get('@searchBox').typeWithForce('{enter}');
cy.uiGetButton('Go').click();
// # Hover on the channel name
cy.get(`#sidebarItem_${Cypress._.sortBy([loggedUser.id, longUser.id]).join('__')}`).scrollIntoView().should('be.visible').trigger('mouseover');
// * Verify that the tooltip is displayed
cy.get('div.tooltip-inner').should('be.visible');
// # Move cursor away from channel
cy.get(`#sidebarItem_${Cypress._.sortBy([loggedUser.id, longUser.id]).join('__')}`).scrollIntoView().should('be.visible').trigger('mouseout');
});
});

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

@@ -0,0 +1,138 @@
// 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
describe('Channel routing', () => {
let testUser;
let otherUser1;
let otherUser2;
let testTeam;
before(() => {
cy.apiInitSetup().then(({team, user}) => {
testTeam = team;
testUser = user;
cy.apiCreateUser({prefix: 'otherA'}).then(({user: newUser}) => {
otherUser1 = newUser;
cy.apiAddUserToTeam(team.id, newUser.id);
});
cy.apiCreateUser({prefix: 'otherB'}).then(({user: newUser}) => {
otherUser2 = newUser;
cy.apiAddUserToTeam(team.id, newUser.id);
});
// # Login as test user and go to town square
cy.apiLogin(testUser);
cy.visit(`/${team.name}/channels/town-square`);
});
});
it('should go to town square channel view', () => {
// * Check if the channel is loaded correctly
cy.get('#channelHeaderTitle').should('be.visible').should('contain', 'Town Square');
});
it('should go to private channel view', () => {
// # Create a private channel
cy.apiCreateChannel(testTeam.id, 'private-channel', 'Private channel', 'P').then(({channel}) => {
// # Go to the newly created channel
cy.visit(`/${testTeam.name}/channels/${channel.name}`);
// * Check you can go to the channel without problem
cy.get('#channelHeaderTitle').should('be.visible').should('contain', 'Private channel');
// # Remove the created channel
cy.apiDeleteChannel(channel.id);
});
});
it('should go to self direct channel using the multiple ways to go', () => {
// # Create a self direct channel
cy.apiCreateDirectChannel([testUser.id, testUser.id]).then(({channel: ownDMChannel}) => {
// # Visit the channel using the channel name
cy.visit(`/${testTeam.name}/channels/${testUser.id}__${testUser.id}`);
// * Check you can go to the channel without problem
cy.get('#channelHeaderTitle').should('be.visible').should('contain', `${testUser.username} (you)`);
// # Visit the channel using the channel id
cy.visit(`/${testTeam.name}/channels/${ownDMChannel.id}`);
// * Check you can go to the channel without problem
cy.get('#channelHeaderTitle').should('be.visible').should('contain', `${testUser.username} (you)`);
// # Visit the channel using the username
cy.visit(`/${testTeam.name}/messages/@${testUser.username}`);
// * Check you can go to the channel without problem
cy.get('#channelHeaderTitle').should('be.visible').should('contain', `${testUser.username} (you)`);
// # Visit the channel using the user email
cy.visit(`/${testTeam.name}/messages/${testUser.email}`);
// * Check you can go to the channel without problem
cy.get('#channelHeaderTitle').should('be.visible').should('contain', `${testUser.username} (you)`);
});
});
it('should go to other user direct channel using multiple ways to go', () => {
// # Create a direct channel between two users
cy.apiCreateDirectChannel([testUser.id, otherUser1.id]).then(({channel: dmChannel}) => {
// # Visit the channel using the channel name
cy.visit(`/${testTeam.name}/channels/${testUser.id}__${otherUser1.id}`);
// * Check you can go to the channel without problem
cy.get('#channelHeaderTitle').should('be.visible').should('contain', otherUser1.username);
// # Visit the channel using the channel id
cy.visit(`/${testTeam.name}/channels/${dmChannel.id}`);
// * Check you can go to the channel without problem
cy.get('#channelHeaderTitle').should('be.visible').should('contain', otherUser1.username);
// # Visit the channel using the target username
cy.visit(`/${testTeam.name}/messages/@${otherUser1.username}`);
// * Check you can go to the channel without problem
cy.get('#channelHeaderTitle').should('be.visible').should('contain', otherUser1.username);
// # Visit the channel using the target user email
cy.visit(`/${testTeam.name}/messages/${otherUser1.email}`);
// * Check you can go to the channel without problem
cy.get('#channelHeaderTitle').should('be.visible').should('contain', otherUser1.username);
});
});
it('should go group channel using group id', () => {
const userGroupIds = [testUser.id, otherUser1.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}`);
// * Check you can go to the channel without problem
const displayName = gmChannel.display_name.split(', ').filter(((username) => username !== testUser.username)).join(', ');
cy.get('#channelHeaderTitle').should('be.visible').should('contain', displayName);
// # Visit the channel using the name using the messages route
cy.visit(`/${testTeam.name}/messages/${gmChannel.name}`);
// * Check you can go to the channel without problem
cy.get('#channelHeaderTitle').should('be.visible').should('contain', displayName);
});
});
});

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

@@ -0,0 +1,95 @@
// 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
import {
beMuted,
beUnmuted,
} from '../../../support/assertions';
describe('Channel Settings', () => {
let testTeam;
before(() => {
cy.apiInitSetup().then(({team, user}) => {
testTeam = team;
cy.apiCreateChannel(testTeam.id, 'channel', 'Private Channel', 'P').then(({channel}) => {
cy.apiAddUserToChannel(channel.id, user.id);
});
cy.apiLogin(user);
// # Visit town-square channel
cy.visit(`/${testTeam.name}/channels/town-square`);
});
});
it('MM-T882 Channel URL validation works properly', () => {
cy.apiCreateChannel(testTeam.id, 'channel-test', 'Channel').then(({channel}) => {
// # Go to test channel
cy.visit(`/${testTeam.name}/channels/${channel.name}`);
// # Go to channel dropdown > Rename channel
cy.get('#channelHeaderDropdownIcon').click();
cy.findByText('Rename Channel').click();
// # Try to enter existing URL and save
cy.get('#channel_name').clear().type('town-square');
cy.get('#save-button').click();
// # Error is displayed and URL is unchanged
cy.get('.has-error').should('be.visible').and('contain', 'Unable to update the channel');
cy.url().should('include', `/${testTeam.name}/channels/${channel.name}`);
// # Enter a new URL and save
cy.get('#channel_name').clear().type('another-town-square');
cy.get('#save-button').click();
// * URL is updated and no errors are displayed
cy.url().should('include', `/${testTeam.name}/channels/another-town-square`);
});
});
it('MM-T887 Channel dropdown menu - Mute / Unmute', () => {
// # Visit off-topic
cy.visit(`/${testTeam.name}/channels/off-topic`);
// # Go to channel dropdown > Mute channel
cy.get('#channelHeaderDropdownIcon').click();
cy.get('#channelHeaderDropdownMenu').should('exist').
findByText('Mute Channel').should('be.visible').click();
// # Verify channel is muted
cy.get('#sidebarItem_off-topic').should(beMuted);
// # Verify mute bell icon is visible
cy.get('#toggleMute').should('be.visible');
// # Verify that off topic is last in the list of channels
cy.uiGetLhsSection('CHANNELS').find('.SidebarChannel').
last().should('contain', 'Off-Topic').
get('a').should('have.class', 'muted');
// # Click Unmute channel while menu is open
cy.get('#channelHeaderDropdownIcon').click();
cy.get('#channelHeaderDropdownMenu').should('exist').
findByText('Unmute Channel').should('be.visible').click();
// # Verify channel is unmuted
cy.get('#sidebarItem_off-topic').should(beUnmuted);
// # Verify mute bell icon is not visible
cy.get('#toggleMute').should('not.exist');
// # Verify that off topic is not last in the list of channels
cy.uiGetLhsSection('CHANNELS').find('.SidebarChannel').
last().should('not.contain', 'Off-Topic');
});
});

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

@@ -0,0 +1,112 @@
// 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 @smoke
describe('Channel Switcher', () => {
let testTeam;
let testChannelName;
let offTopicUrl;
const channelNamePrefix = 'aswitchchannel';
const channelDisplayNamePrefix = 'ASwitchChannel';
before(() => {
cy.apiInitSetup({channelPrefix: {name: `${channelNamePrefix}-a`, displayName: `${channelDisplayNamePrefix} A`}}).then(({team, channel, user, offTopicUrl: url}) => {
testTeam = team;
testChannelName = channel.display_name;
offTopicUrl = url;
// # Add some channels
cy.apiCreateChannel(testTeam.id, `${channelNamePrefix}-b`, `${channelDisplayNamePrefix} B`, 'O');
cy.apiCreateChannel(testTeam.id, `${channelNamePrefix}-c`, `${channelDisplayNamePrefix} C`, 'O');
// # Login as test user and go to off-topic
cy.apiLogin(user);
cy.visit(offTopicUrl);
});
});
it('MM-T2031_1 - should switch channels by keyboard', () => {
// # Press CTRL+K (Windows) or CMD+K(Mac)
cy.typeCmdOrCtrl().type('K', {release: true});
// # Start typing channel name in the "Switch Channels" modal message box
// # Use up/down arrow keys to highlight second channel
// # Press ENTER
cy.findByRole('textbox', {name: 'quick switch input'}).
type(`${channelDisplayNamePrefix} `).
type('{downarrow}{downarrow}{enter}');
// * Expect channel title to match title
cy.get('#channelHeaderTitle').
should('be.visible').
and('contain.text', testChannelName);
// * Expect url to match url
cy.url().should('contain', `${testChannelName.replace(/ /g, '-').toLowerCase()}`);
});
it('MM-T2031_2 - should switch channels by mouse', () => {
// # Press CTRL+K (Windows) or CMD+K(Mac)
cy.typeCmdOrCtrl().type('K', {release: true});
// # Start typing channel name in the "Switch Channels" modal message box
cy.findByRole('textbox', {name: 'quick switch input'}).type(`${channelDisplayNamePrefix} `);
cy.get(`[data-testid^=${channelNamePrefix}-c] > span`).click();
// * Expect channel title to match title
cy.get('#channelHeaderTitle').
should('be.visible').
and('contain.text', `${channelDisplayNamePrefix} C`);
// * Expect url to match url
cy.url().should('contain', `${channelNamePrefix}-c`);
});
it('MM-T2031_3 - should show empty result', () => {
// # Press CTRL+K (Windows) or CMD+K(Mac)
cy.typeCmdOrCtrl().type('K', {release: true});
// # Type invalid channel name in the "Switch Channels" modal message box
cy.findByRole('textbox', {name: 'quick switch input'}).type('there-is-no-spoon');
// * Expect 'nothing found' message
cy.get('.no-results__title > span').should('be.visible');
});
it('MM-T2031_4 - should close on esc and outside click', () => {
cy.visit(offTopicUrl);
// # Press CTRL+K (Windows) or CMD+K(Mac)
cy.typeCmdOrCtrl().type('K', {release: true});
// # Press ESC
cy.findByRole('textbox', {name: 'quick switch input'}).type('{esc}');
// * Expect the dialog to be closed
cy.findByRole('textbox', {name: 'quick switch input'}).should('not.exist');
// * Expect staying in the same channel
cy.url().should('contain', 'off-topic');
// # Press CTRL+K (Windows) or CMD+K(Mac)
cy.typeCmdOrCtrl().type('K', {release: true});
// # Click outside of the modal
cy.get('.modal').click({force: true});
// * Expect the dialog to be closed
cy.findByRole('textbox', {name: 'quick switch input'}).should('not.exist');
// * Expect staying in the same channel
cy.url().should('contain', 'off-topic');
});
});

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

@@ -0,0 +1,125 @@
// 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 @not_cloud
// Make sure that the current channel is Town Square and that the
// channel identified by the passed name is no longer in the channel
// sidebar
function verifyChannelWasProperlyClosed(channelName) {
// * Make sure that we have switched channels
cy.get('#channelHeaderTitle').should('contain', 'Town Square');
// * Make sure the old DM no longer exists
cy.get('#sidebarItem_' + channelName).should('not.exist');
}
describe('Close direct messages', () => {
let testUser;
let otherUser;
let testTeam;
before(() => {
cy.shouldNotRunOnCloudEdition();
cy.apiInitSetup().then(({team, user}) => {
testUser = user;
testTeam = team;
cy.apiCreateUser().then(({user: newUser}) => {
otherUser = newUser;
cy.apiAddUserToTeam(team.id, newUser.id);
});
// # Login as test user and go to town square
cy.apiLogin(testUser);
cy.visit(`/${testTeam.name}/channels/town-square`);
});
});
it('Through channel header dropdown menu', () => {
createAndVisitDMChannel([testUser.id, otherUser.id]).then((channel) => {
// # Open channel header dropdown menu and click on Close Direct Message
cy.get('#channelHeaderDropdownIcon').click();
cy.findByText('Close Direct Message').click();
verifyChannelWasProperlyClosed(channel.name);
});
});
function createAndVisitDMChannel(userIds) {
return cy.apiCreateDirectChannel(userIds).then(({channel}) => {
// # Visit the new channel
cy.visit(`/${testTeam.name}/channels/${channel.name}`);
// * Verify channel's display name
cy.get('#channelHeaderTitle').should('contain', channel.display_name);
return cy.wrap(channel);
});
}
});
describe('Close group messages', () => {
let testUser;
let otherUser1;
let otherUser2;
let testTeam;
before(() => {
cy.apiAdminLogin();
cy.shouldNotRunOnCloudEdition();
cy.apiInitSetup().then(({team, user}) => {
testUser = user;
testTeam = team;
cy.apiCreateUser({prefix: 'aaa'}).then(({user: newUser}) => {
otherUser1 = newUser;
cy.apiAddUserToTeam(team.id, newUser.id);
});
cy.apiCreateUser({prefix: 'bbb'}).then(({user: newUser}) => {
otherUser2 = newUser;
cy.apiAddUserToTeam(team.id, newUser.id);
});
// # Login as test user and go to town square
cy.apiLogin(testUser);
cy.visit(`/${team.name}/channels/town-square`);
});
});
it('Through channel header dropdown menu', () => {
createAndVisitGMChannel([otherUser1, otherUser2]).then((channel) => {
// # Open channel header dropdown menu and click on Close Direct Message
cy.get('#channelHeaderDropdownIcon').click();
cy.findByText('Close Group Message').click();
verifyChannelWasProperlyClosed(channel.name);
});
});
function createAndVisitGMChannel(users = []) {
const userIds = users.map((user) => user.id);
return cy.apiCreateGroupChannel(userIds).then(({channel}) => {
// # Visit the new channel
cy.visit(`/${testTeam.name}/channels/${channel.name}`);
// * Verify channel's display name
const displayName = users.
map((member) => member.username).
sort((a, b) => a.localeCompare(b, 'en', {numeric: true})).
join(', ');
cy.get('#channelHeaderTitle').should('contain', displayName);
return cy.wrap(channel);
});
}
});

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

@@ -0,0 +1,158 @@
// 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
describe('Channels', () => {
let testUser;
let testTeam;
before(() => {
cy.apiInitSetup().then(({team, user}) => {
testUser = user;
testTeam = team;
});
});
it('MM-T3348 - Convert to private channel should only be shown to users with permission', () => {
// # Reset permissions to default
resetPermissionsToDefault();
// # Enable convert public channels to private for all users
enablePermission('all_users-public_channel-convert_public_channel_to_private-checkbox');
saveConfig();
// # Login as a regular user
cy.apiLogin(testUser);
// # Create new test channel
cy.apiCreateChannel(testTeam.id, 'channel-test', 'Channel').then(({channel}) => {
// # Go to test channel
cy.visit(`/${testTeam.name}/channels/${channel.name}`);
// # Click the channel header dropdown
cy.get('#channelHeaderDropdownIcon').click();
// * Channel convert to private should be visible and confirm
cy.get('#channelConvertToPrivate').should('be.visible').click();
cy.findByTestId('convertChannelConfirm').should('be.visible').click();
// # Click the channel header dropdown
cy.get('#channelHeaderDropdownIcon').click();
// * Channel convert to private should no longer be visible
cy.get('#channelConvertToPrivate').should('not.exist');
});
// # Reset permissions to default
resetPermissionsToDefault();
// # Login as a regular user
cy.apiLogin(testUser);
// # Create new test channel
cy.apiCreateChannel(testTeam.id, 'channel-test', 'Channel').then(({channel}) => {
// # Go to test channel
cy.visit(`/${testTeam.name}/channels/${channel.name}`);
// # Click the channel header dropdown
cy.get('#channelHeaderDropdownIcon').click();
// * Channel convert to private should no longer be visible
cy.get('#channelConvertToPrivate').should('not.exist');
});
// # Reset permissions to default
resetPermissionsToDefault();
// # Remove permission from team admins
removePermission('team_admin-public_channel-convert_public_channel_to_private-checkbox');
saveConfig();
// # Promote user to team admin
cy.apiUpdateTeamMemberSchemeRole(testTeam.id, testUser.id, {scheme_admin: true, scheme_user: true});
// # Login as the now team admin user
cy.apiLogin(testUser);
// # Create new test channel
cy.apiCreateChannel(testTeam.id, 'channel-test', 'Channel').then(({channel}) => {
// # Go to test channel
cy.visit(`/${testTeam.name}/channels/${channel.name}`);
// # Click the channel header dropdown
cy.get('#channelHeaderDropdownIcon').click();
// * Channel convert to private should not be visible
cy.get('#channelConvertToPrivate').should('not.exist');
});
// # Reset permissions to default
resetPermissionsToDefault();
// # Login as the team admin user
cy.apiLogin(testUser);
// # Create new test channel
cy.apiCreateChannel(testTeam.id, 'channel-test', 'Channel').then(({channel}) => {
// # Go to test channel
cy.visit(`/${testTeam.name}/channels/${channel.name}`);
// # Click the channel header dropdown
cy.get('#channelHeaderDropdownIcon').click();
// * Channel convert to private should be visible and confirm
cy.get('#channelConvertToPrivate').should('be.visible').click();
cy.findByTestId('convertChannelConfirm').should('be.visible').click();
// # Click the channel header dropdown
cy.get('#channelHeaderDropdownIcon').click();
// * Channel convert to private should no longer be visible
cy.get('#channelConvertToPrivate').should('not.exist');
});
});
});
const saveConfig = () => {
cy.get('#saveSetting').click();
cy.waitUntil(() => cy.get('#saveSetting').then((el) => {
return el[0].innerText === 'Save';
}));
};
const enablePermission = (permissionCheckBoxTestId) => {
cy.findByTestId(permissionCheckBoxTestId).then((el) => {
if (!el.hasClass('checked')) {
el.click();
}
});
};
const removePermission = (permissionCheckBoxTestId) => {
cy.findByTestId(permissionCheckBoxTestId).then((el) => {
if (el.hasClass('checked')) {
el.click();
}
});
};
const resetPermissionsToDefault = () => {
// # Login as sysadmin and navigate to system scheme page
cy.apiAdminLogin();
cy.visit('/admin_console/user_management/permissions/system_scheme');
// # Click reset to defaults and confirm
cy.findByTestId('resetPermissionsToDefault').click();
cy.get('#confirmModalButton').click();
// # Save
saveConfig();
};

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

@@ -0,0 +1,100 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {UserProfile} from 'mattermost-redux/types/users';
// ***************************************************************
// - [#] 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
describe('Leave and Archive channel actions display as destructive', () => {
let testUser: UserProfile;
let offTopicUrl: string;
before(() => {
// # Login as test user and visit off-topic channel
cy.apiInitSetup().then(({user, offTopicUrl: url}) => {
testUser = user;
offTopicUrl = url;
cy.apiLogin(testUser);
cy.visit(offTopicUrl);
});
});
beforeEach(() => {
cy.reload();
});
it('MM-T4943_1 Leave and Archive channel actions display as destructive in the channel dropdown menu', () => {
// # click on channel drop-down menu
cy.get('#channelHeaderTitle').should('be.visible').click();
// * View Info menu option should be visible
cy.findByText('View Info').should('be.visible');
// * Move to... menu option should be visible
cy.findByText('Move to...').should('be.visible').children().trigger('mouseover');
// * Favorites Sub-menu option should be visible
cy.findByText('Favorites').should('be.visible');
// * New Category Sub-menu option should be visible
cy.findByText('New Category').should('be.visible');
// * Notification Preferences menu option should be visible
cy.get('#channelNotificationPreferences').should('be.visible');
// * Mute Channel menu option should be visible
cy.get('#channelToggleMuteChannel').should('be.visible');
// * Add Members menu option should be visible
cy.get('#channelAddMembers').should('be.visible');
// * Manage Members menu option should be visible
cy.get('#channelManageMembers').should('be.visible');
// * Edit Channel Header menu option should be visible
cy.get('#channelEditHeader').should('be.visible');
// * Edit Channel Purpose menu option should be visible
cy.get('#channelEditPurpose').should('be.visible');
// * Rename Channel menu option should be visible
cy.get('#channelRename').should('be.visible');
// * Archive Channel menu option should be visible and have a background-color (destructive)
cy.get('#channelArchiveChannel').should('be.visible').children().focus().should('have.css', 'background-color', 'rgb(210, 75, 78)');
// * Leave Channel menu option should be visible and hav a background-color (destructive)
cy.get('#channelLeaveChannel').should('be.visible').children().focus().should('have.css', 'background-color', 'rgb(210, 75, 78)');
});
it('MM-T4943_2 Leave channel actions display as destructive in the Edit Channel Menu ', () => {
// # Open Edit Channel Menu and verify menu optin
cy.uiGetChannelSidebarMenu('Off-Topic').within(() => {
// * Favorite menu option should be visible
cy.findByText('Favorite').should('be.visible').should('not.have.css', 'color', 'rgb(210, 75, 78)');
// * Mute Channel menu option should be visible
cy.findByText('Mute Channel').should('be.visible').should('not.have.css', 'color', 'rgb(210, 75, 78)');
// * Copy Link menu option should be visible
cy.findByText('Copy Link').should('be.visible').should('not.have.css', 'color', 'rgb(210, 75, 78)');
// * Add Members menu option should be visible
cy.findByText('Add Members').should('be.visible').should('not.have.css', 'color', 'rgb(210, 75, 78)');
// * Move to... menu option should be visible and is not destructive
cy.findByText('Move to...').should('be.visible').should('not.have.css', 'color', 'rgb(210, 75, 78)');
// * Leave Channel menu option should be visible and have a color (destructive)
cy.findByText('Leave Channel').should('be.visible').should('have.css', 'color', 'rgb(210, 75, 78)');
});
});
});

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

@@ -0,0 +1,110 @@
// 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
import * as TIMEOUTS from '../../../fixtures/timeouts';
describe('Leave channel', () => {
let testTeam;
let testUser;
let testChannel;
before(() => {
cy.apiUpdateConfig({
ServiceSettings: {
ThreadAutoFollow: true,
CollapsedThreads: 'default_off',
},
});
// # Login as test user and visit created channel
cy.apiInitSetup().then(({team, user}) => {
testUser = user;
testTeam = team;
cy.apiLogin(testUser);
cy.apiCreateChannel(testTeam.id, 'channel', 'channel').then(({channel}) => {
testChannel = channel;
});
});
});
beforeEach(() => {
cy.visit(`/${testTeam.name}/channels/${testChannel.name}`);
});
it('MM-T4429_1 Leave a channel while RHS is open', () => {
// # Post a message in the channel
cy.postMessage('Test leave channel while RHS open');
cy.getLastPostId().then((id) => {
// # Open RHS
cy.clickPostCommentIcon(id);
// # Post a reply message
cy.postMessageAs({sender: testUser, message: 'another reply!', channelId: testChannel.id, rootId: id});
// * RHS should be visible
cy.get('#rhsContainer').should('be.visible');
// * RHS text box should be visible
cy.uiGetReplyTextBox();
// # Archive the channel
cy.uiLeaveChannel();
cy.wait(TIMEOUTS.TWO_SEC); // eslint-disable-line cypress/no-unnecessary-waiting
// * RHS should not be visible
cy.get('#rhsContainer').should('not.exist');
// * Assert that user is redirected to townsquare
cy.url().should('include', '/channels/town-square');
cy.get('#channelHeaderTitle').should('be.visible').and('contain', 'Town Square');
});
});
it('MM-T4429_2 Leave a channel while RHS is open and CRT on', () => {
// * Post text box should be visible
cy.uiGetPostTextBox();
// # Set CRT to on
cy.uiChangeCRTDisplaySetting('ON');
// # Post a message in the channel
cy.postMessage('Test leave channel while RHS open');
cy.getLastPostId().then((id) => {
// # Open RHS
cy.clickPostCommentIcon(id);
// # Post a reply message
cy.postMessageAs({sender: testUser, message: 'another reply!', channelId: testChannel.id, rootId: id});
// * RHS should be visible
cy.get('#rhsContainer').should('be.visible');
// * RHS text box should be visible
cy.uiGetReplyTextBox();
// * Close tour tip
cy.get('#tipNextButton').should('be.visible').click();
// # Archive the channel
cy.uiLeaveChannel();
cy.wait(TIMEOUTS.TWO_SEC); // eslint-disable-line cypress/no-unnecessary-waiting
// * RHS should not be visible
cy.get('#rhsContainer').should('not.exist');
// * Assert that user is redirected to townsquare
cy.url().should('include', '/channels/town-square');
cy.get('#channelHeaderTitle').should('be.visible').and('contain', 'Town Square');
});
});
});

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

@@ -0,0 +1,258 @@
// 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
import * as TIMEOUTS from '../../../fixtures/timeouts';
import {createPrivateChannel} from '../enterprise/elasticsearch_autocomplete/helpers';
describe('Channels', () => {
let testUser;
let otherUser;
let testTeam;
let testChannel;
before(() => {
cy.apiInitSetup().then(({team, user}) => {
testUser = user;
testTeam = team;
cy.apiCreateUser().then(({user: user1}) => {
otherUser = user1;
cy.apiAddUserToTeam(testTeam.id, otherUser.id);
});
cy.apiLogin(testUser).then(() => {
// # Create new test channel
cy.apiCreateChannel(testTeam.id, 'channel-test', 'Channel').then(({channel}) => {
testChannel = channel;
});
// # Go to town square
cy.visit(`/${team.name}/channels/town-square`);
});
});
});
it('MM-19337 Verify UI of More channels modal with archived selection', () => {
verifyMoreChannelsModalWithArchivedSelection(false, testUser, testTeam);
verifyMoreChannelsModalWithArchivedSelection(true, testUser, testTeam);
});
it('MM-19337 Enable users to view archived channels', () => {
cy.apiAdminLogin();
cy.apiUpdateConfig({
TeamSettings: {
ExperimentalViewArchivedChannels: true,
},
});
// # Login as new user and go to "/"
cy.apiLogin(otherUser);
cy.visit(`/${testTeam.name}/channels/town-square`);
// # Go to LHS and click 'Browse Channels'
cy.uiBrowseOrCreateChannel('Browse Channels').click();
cy.get('#moreChannelsModal').should('be.visible').within(() => {
// * Dropdown should be visible, defaulting to "Public Channels"
cy.get('#channelsMoreDropdown').should('be.visible').and('contain', 'Show: Public Channels').wait(TIMEOUTS.HALF_SEC);
cy.get('#searchChannelsTextbox').should('be.visible').type(testChannel.display_name).wait(TIMEOUTS.HALF_SEC);
cy.get('#moreChannelsList').should('be.visible').children().should('have.length', 1).within(() => {
cy.findByText(testChannel.display_name).should('be.visible');
});
cy.get('#searchChannelsTextbox').clear();
// * Channel test should be visible as a public channel in the list
cy.get('#moreChannelsList').should('be.visible').within(() => {
// # Click to join the channel
cy.findByText(testChannel.display_name).scrollIntoView().should('be.visible').click();
});
});
// # Verify that the modal is closed and it's redirected to the selected channel
cy.get('#moreChannelsModal').should('not.exist');
cy.url().should('include', `/${testTeam.name}/channels/${testChannel.name}`);
// # Login as channel admin and go directly to the channel
cy.apiLogin(testUser);
cy.visit(`/${testTeam.name}/channels/${testChannel.name}`);
// # Click channel header to open channel menu
cy.get('#channelHeaderTitle').should('contain', testChannel.display_name).click();
// * Verify that the menu is opened
cy.get('.Menu__content').should('be.visible').within(() => {
// # Archive the channel
cy.findByText('Archive Channel').should('be.visible').click();
});
// * Verify that the delete/archive channel modal is opened
cy.get('#deleteChannelModal').should('be.visible').within(() => {
// # Confirm archive
cy.findByText('Archive').should('be.visible').click();
});
// # Go to LHS and click 'Browse Channels'
cy.uiBrowseOrCreateChannel('Browse Channels').click();
cy.get('#moreChannelsModal').should('be.visible').within(() => {
// # CLick dropdown to open selection
cy.get('#channelsMoreDropdown').should('be.visible').click().within((el) => {
// # Click on archived channels item
cy.findByText('Archived Channels').should('be.visible').click();
// * Channel test should be visible as an archived channel in the list
cy.wrap(el).should('contain', 'Show: Archived Channels');
});
cy.get('#searchChannelsTextbox').should('be.visible').type(testChannel.display_name).wait(TIMEOUTS.HALF_SEC);
cy.get('#moreChannelsList').children().should('have.length', 1).within(() => {
cy.findByText(testChannel.display_name).should('be.visible');
});
cy.get('#searchChannelsTextbox').clear();
// * Test channel should be visible as a archived channel in the list
cy.get('#moreChannelsList').should('be.visible').within(() => {
// # Click to view archived channel
cy.findByText(testChannel.display_name).scrollIntoView().should('be.visible').click();
});
});
// * Assert that channel is archived and new messages can't be posted.
cy.get('#channelArchivedMessage').should('contain', 'You are viewing an archived channel. New messages cannot be posted.');
cy.uiGetPostTextBox({exist: false});
// # Switch to another channel
cy.get('#sidebarItem_town-square').click();
// * Assert that archived channel doesn't show up in LHS list
cy.get('#sidebar-left').should('not.contain', testChannel.display_name);
});
it('MM-T1702 Search works when changing public/archived options in the dropdown', () => {
cy.apiAdminLogin();
cy.apiUpdateConfig({
TeamSettings: {
ExperimentalViewArchivedChannels: true,
},
});
let newChannel;
let testArchivedChannel;
let testPrivateArchivedChannel;
cy.apiCreateTeam('team', 'Test NoMember').then(({team}) => {
cy.apiCreateChannel(team.id, 'not-archived-channel', 'Not Archived Channel').then(({channel}) => {
newChannel = channel;
cy.visit(`/${team.name}/channels/${newChannel.name}`);
// # Leave the channel
cy.uiLeaveChannel();
// * Verify that we've switched to Town Square
cy.url().should('include', '/channels/town-square');
});
cy.apiCreateChannel(team.id, 'archived-channel', 'Archived Channel').then(({channel}) => {
testArchivedChannel = channel;
// # Visit the channel
cy.visit(`/${team.name}/channels/${testArchivedChannel.name}`);
// # Archive the channel
cy.uiArchiveChannel();
// # Leave the channel
cy.uiLeaveChannel();
// * Verify that we've switched to Town Square
cy.url().should('include', '/channels/town-square');
});
createPrivateChannel(team.id).then((channel) => {
testPrivateArchivedChannel = channel;
// # Visit the channel
cy.visit(`/${team.name}/channels/${testPrivateArchivedChannel.name}`);
// # Archive the channel
cy.uiArchiveChannel();
cy.visit(`/${team.name}/channels/town-square`);
});
});
// # Go to LHS and click 'Browse Channels'
cy.uiBrowseOrCreateChannel('Browse Channels').click();
// * Dropdown should be visible, defaulting to "Public Channels"
cy.get('#channelsMoreDropdown').should('be.visible').within((el) => {
cy.wrap(el).should('contain', 'Show: Public Channels');
});
// * Users should be able to type and search
cy.get('#searchChannelsTextbox').should('be.visible').type('iv').wait(TIMEOUTS.HALF_SEC);
cy.get('#moreChannelsList').should('be.visible').children().should('have.length', 1).within(() => {
cy.findByText(newChannel.display_name).should('be.visible');
});
cy.get('#moreChannelsModal').should('be.visible').within(() => {
// * Users should be able to switch to "Archived Channels" list
cy.get('#channelsMoreDropdown').should('be.visible').and('contain', 'Show: Public Channels').click().within((el) => {
// # Click on archived channels item
cy.findByText('Archived Channels').should('be.visible').click();
// * Modal should show the archived channels list
cy.wrap(el).should('contain', 'Show: Archived Channels');
}).wait(TIMEOUTS.HALF_SEC);
cy.get('#searchChannelsTextbox').clear();
cy.get('#moreChannelsList').should('be.visible').children().should('have.length', 2);
cy.get('#moreChannelsList').within(() => {
cy.findByText(testArchivedChannel.display_name).should('be.visible');
cy.findByText(testPrivateArchivedChannel.display_name).should('be.visible');
});
});
});
});
function verifyMoreChannelsModalWithArchivedSelection(isEnabled, testUser, testTeam) {
// # Login as sysadmin and Update config to enable/disable viewing of archived channels
cy.apiAdminLogin();
cy.apiUpdateConfig({
TeamSettings: {
ExperimentalViewArchivedChannels: isEnabled,
},
});
// * Verify more channels modal
cy.visit(`/${testTeam.name}/channels/town-square`);
verifyMoreChannelsModal(isEnabled);
// # Login as regular user and verify more channels modal
cy.apiLogin(testUser);
cy.visit(`/${testTeam.name}/channels/town-square`);
verifyMoreChannelsModal(isEnabled);
}
function verifyMoreChannelsModal(isEnabled) {
// # Go to LHS and click 'Browse Channels'
cy.uiBrowseOrCreateChannel('Browse Channels').click();
// * Verify that the more channels modal is open and with or without option to view archived channels
cy.get('#moreChannelsModal').should('be.visible').within(() => {
if (isEnabled) {
cy.get('#channelsMoreDropdown').should('be.visible').and('have.text', 'Show: Public Channels');
} else {
cy.get('#channelsMoreDropdown').should('not.exist');
}
});
}

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

@@ -0,0 +1,97 @@
// 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
function verifyNoChannelToJoinMessage(isVisible) {
cy.findByText('No more channels to join').should(isVisible ? 'be.visible' : 'not.exist');
cy.findByText('Click \'Create New Channel\' to make a new one').should(isVisible ? 'be.visible' : 'not.exist');
}
describe('more public channels', () => {
let testUser;
let otherUser;
let testTeam;
before(() => {
cy.apiInitSetup().then(({team, user}) => {
testUser = user;
testTeam = team;
cy.apiCreateUser().then(({user: user1}) => {
otherUser = user1;
cy.apiAddUserToTeam(testTeam.id, otherUser.id);
});
cy.apiLogin(testUser).then(() => {
// # create 30 channels
for (let i = 0; i < 30; i++) {
cy.apiCreateChannel(testTeam.id, 'public-channel', 'public-channel');
}
// # Go to town square
cy.visit(`/${team.name}/channels/town-square`);
});
});
});
it('MM-T1664 Channels do not disappear from More Channels modal', () => {
// # Login as other user
cy.apiLogin(otherUser);
// # Go to town square
cy.visit(`/${testTeam.name}/channels/town-square`);
// # Go to LHS and click 'Browse Channels'
cy.uiBrowseOrCreateChannel('Browse Channels').click();
// * Assert that the moreChannelsModel is visible
cy.findByRole('dialog', {name: 'More Channels'}).should('be.visible').within(() => {
// * Assert that the moreChannelsList is visible and the number of channels is 31
cy.get('#moreChannelsList').should('be.visible').children().should('have.length', 31);
// # scroll to the middle channel
cy.get('#moreChannelsList .more-modal__row').eq(15).scrollIntoView();
// * Assert that the "No more channels to join" message does not exist
verifyNoChannelToJoinMessage(false);
// # scroll to the last channel
cy.get('#moreChannelsList .more-modal__row').last().scrollIntoView();
// * Assert that the "No more channels to join" message does not exist
verifyNoChannelToJoinMessage(false);
// # scroll to the first channel
cy.get('#moreChannelsList .more-modal__row').first().scrollIntoView();
// * Assert that the "No more channels to join" message does not exist
verifyNoChannelToJoinMessage(false);
});
// # Login as testUser
cy.apiLogin(testUser);
// # Go to town square
cy.visit(`/${testTeam.name}/channels/town-square`);
// # Go to LHS and click 'Browse Channels'
cy.uiBrowseOrCreateChannel('Browse Channels').click();
// * Assert the moreChannelsModel is visible
cy.findByRole('dialog', {name: 'More Channels'}).should('be.visible').within(() => {
// * Assert the moreChannelsList does have one child
cy.get('#moreChannelsList').should('be.visible').children().should('have.length', 1);
// * Assert that the "No more channels to join" message is visible
verifyNoChannelToJoinMessage(true);
});
});
});

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

@@ -0,0 +1,51 @@
// 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
describe('New Channel modal with Boards enabled', () => {
let testTeam;
before(() => {
cy.apiInitSetup().then(({team}) => {
testTeam = team;
});
cy.apiCreateCustomAdmin().then(({sysadmin}) => {
cy.apiLogin(sysadmin);
cy.visit(`/${testTeam.name}/channels/town-square`);
});
cy.shouldHaveFeatureFlag('BoardsProduct', true);
});
it('MM-T5141 New Channel is created with an associated Board', () => {
// # Create new channel with board
const channelName = 'Test Channel With Board';
cy.uiCreateChannel({
prefix: 'channel-',
isPrivate: false,
purpose: '',
name: channelName,
createBoard: true,
}).then(() => {
// * Verify that new channel is in the sidebar and is active
cy.url().should('include', `/${testTeam.name}/channels/test-channel`);
cy.get('#channelHeaderTitle').should('contain', channelName);
cy.get(`.SidebarChannel.active:contains(${channelName})`).should('be.visible');
// * Verify the board is created - check the message sent
cy.waitUntil(() => cy.getLastPost().then((el) => {
const postedMessageEl = el.find('.post-message__text > p')[0];
return Boolean(postedMessageEl && postedMessageEl.textContent.includes('created the board'));
}));
});
});
});

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

@@ -0,0 +1,207 @@
// 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 @rhs
import * as TIMEOUTS from '../../../fixtures/timeouts';
import * as MESSAGES from '../../../fixtures/messages';
describe('Channel RHS', () => {
let testAdmin: Cypress.UserProfile;
let testTeam: Cypress.Team;
let testChannel: Cypress.Channel;
before(() => {
cy.apiCreateCustomAdmin({loginAfter: true}).then(({sysadmin}) => {
testAdmin = sysadmin;
cy.apiCreateTeam('team1', 'team1').then(({team}) => {
testTeam = team;
cy.apiAddUserToTeam(testTeam.id, testAdmin.id);
cy.apiCreateChannel(testTeam.id, 'channel', 'channel', 'O').then(({channel}) => {
testChannel = channel;
cy.apiAddUserToChannel(channel.id, testAdmin.id);
cy.apiSaveCRTPreference(testAdmin.id, 'off');
cy.apiLogin(testAdmin);
});
});
});
});
beforeEach(() => {
// # Go to test channel
cy.visit(`/${testTeam.name}/channels/${testChannel.name}`);
});
it('MM-44435 - should be able to open channel info, visit the system console and come back without issues -- KNOWN ISSUE: MM-47226', () => {
// # Click on the channel info button
cy.uiGetChannelInfoButton().click();
// * Verify that the channel info is opened in RHS
verifyRHSisOpenAndHasTitle('Info');
// # visit the system console and leave it
openSystemConsoleAndLeave();
// * Verify that the channel info is still opened in RHS
verifyRHSisOpenAndHasTitle('Info');
});
it('MM-T5311 - should be able to open recent mentions, visit the system console and come back without issues', () => {
// # Click on the recent mentions button
cy.uiGetRecentMentionButton().click();
// * Verify that the recent mentions is opened in RHS
verifyRHSisOpenAndHasTitle('Recent Mentions');
// # visit the system console and leave it
openSystemConsoleAndLeave();
// * Verify that the recent mentions is still opened in RHS
verifyRHSisOpenAndHasTitle('Recent Mentions');
});
it('MM-T5312 - should be able to open saved posts, visit the system console and come back without issues', () => {
// # Click on the saved posts button
cy.uiGetSavedPostButton().click();
// * Verify that the saved posts is opened in RHS
verifyRHSisOpenAndHasTitle('Saved Posts');
// # visit the system console and leave it
openSystemConsoleAndLeave();
// * Verify that the saved posts is still opened in RHS
verifyRHSisOpenAndHasTitle('Saved Posts');
});
it('MM-T5313 - should be able to open pinned posts, visit the system console and come back without issues', () => {
// # Click on the pinned posts button
cy.uiGetChannelPinButton().click();
// * Verify that the pinned posts is opened in RHS
verifyRHSisOpenAndHasTitle('Pinned Posts');
// # visit the system console and leave it
openSystemConsoleAndLeave();
// * Verify that the pinned posts is still opened in RHS
verifyRHSisOpenAndHasTitle('Pinned Posts');
});
it('MM-T5314 - should be able to open channel members, visit the system console and come back without issues', () => {
// # Click on the channel members button
cy.uiGetChannelMemberButton().click();
// * Verify that the channel members is opened in RHS
verifyRHSisOpenAndHasTitle('Members');
// # visit the system console and leave it
openSystemConsoleAndLeave();
// * Verify that the channel members is still opened in RHS
verifyRHSisOpenAndHasTitle('Members');
});
it('MM-T5315 - should be able to open channel files, visit the system console and come back without issues', () => {
// # Click on the channel files button
cy.uiGetChannelFileButton().click();
// * Verify that the channel files is opened in RHS
verifyRHSisOpenAndHasTitle('Recent files');
// # visit the system console and leave it
openSystemConsoleAndLeave();
// * Verify that the channel files is still opened in RHS
verifyRHSisOpenAndHasTitle('Recent files');
});
it('MM-T5316 - should be able to open search results, visit the system console and come back without issues', () => {
// # Post a message
cy.postMessage(MESSAGES.SMALL);
// # Enter the search terms and hit enter to start the search
cy.get('#searchBox').clear().type(MESSAGES.TINY).type('{enter}');
// * Verify that the search results is opened in RHS
verifyRHSisOpenAndHasTitle('Search Results');
// # visit the system console and leave it
openSystemConsoleAndLeave();
// * Verify that the search results is still opened in RHS
verifyRHSisOpenAndHasTitle('Search Results');
});
it('MM-T5317 - should be able to open thread reply, visit the system console and come back without issues', () => {
// # Post a message
cy.postMessage(MESSAGES.SMALL);
// # Click on the reply button
cy.getLastPostId().then((postId) => {
cy.clickPostCommentIcon(postId);
});
// * Verify that the thread reply is opened in RHS
verifyRHSisOpenAndHasTitle('Thread');
// # visit the system console and leave it
openSystemConsoleAndLeave();
// * Verify that the thread reply is still opened in RHS
verifyRHSisOpenAndHasTitle('Thread');
});
it('MM-T5318 - should be able to open thread reply with CRT, visit the system console and come back without issues', () => {
// # Enable CRT
cy.apiSaveCRTPreference(testAdmin.id, 'on');
// # Refresh the page
cy.reload();
// # Post a message
cy.postMessage(MESSAGES.SMALL);
// # Click on the reply button
cy.getLastPostId().then((postId) => {
cy.clickPostCommentIcon(postId);
});
// * Verify that the thread reply is opened in RHS
verifyRHSisOpenAndHasTitle('Thread');
// # visit the system console and leave it
openSystemConsoleAndLeave();
// * Verify that the thread reply is still opened in RHS
verifyRHSisOpenAndHasTitle('Thread');
});
});
function openSystemConsoleAndLeave() {
// # visit the system console...
cy.uiOpenProductMenu('System Console');
cy.wait(TIMEOUTS.THREE_SEC);
// # ...and leave it
cy.get('.backstage-navbar__back').click();
}
function verifyRHSisOpenAndHasTitle(title: string) {
cy.get('#sidebar-right').should('exist').within(() => {
cy.findByText(title).should('exist').and('be.visible');
});
}

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

@@ -0,0 +1,63 @@
// 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
import {getAdminAccount} from '../../../support/env';
describe('View Members modal', () => {
const sysadmin = getAdminAccount();
it('MM-20164 - Going from a Member to an Admin should update the modal', () => {
cy.apiInitSetup().then(({team, user}) => {
cy.apiCreateUser().then(({user: user1}) => {
cy.apiAddUserToTeam(team.id, user1.id);
});
// # Promote user as a system admin
// # Visit default channel and verify members modal
cy.apiLogin(user);
promoteToSysAdmin(user, sysadmin);
cy.visit(`/${team.name}/channels/town-square`);
verifyMemberDropdownAction(true);
// # Make user a regular member
// # Reload and verify members modal
demoteToMember(user, sysadmin);
cy.reload();
verifyMemberDropdownAction(false);
});
});
});
const demoteToMember = (user, sysadmin) => {
cy.externalRequest({user: sysadmin, method: 'put', path: `users/${user.id}/roles`, data: {roles: 'system_user'}});
};
const promoteToSysAdmin = (user, sysadmin) => {
cy.externalRequest({user: sysadmin, method: 'put', path: `users/${user.id}/roles`, data: {roles: 'system_user system_admin'}});
};
function verifyMemberDropdownAction(hasActionItem) {
// # Click member count to open member rhs
cy.get('#member_rhs').click();
cy.uiGetRHS().should('be.visible').within(() => {
// # Click "Manage"
cy.findByText('Manage').click();
});
// * Check to see any user has dropdown menu
if (hasActionItem) {
cy.uiGetRHS().findAllByText('Member').should('exist');
} else {
cy.uiGetRHS().findByText('Member').should('not.exist');
}
}

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

@@ -0,0 +1,92 @@
// 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 @channel
import {getAdminAccount} from '../../../support/env';
const demoteToMember = (user, admin) => {
cy.externalRequest({user: admin, method: 'put', path: `users/${user.id}/roles`, data: {roles: 'system_user'}});
};
const demoteToChannelMember = (user, channelId, admin) => {
cy.externalRequest({
user: admin,
method: 'put',
path: `channels/${channelId}/members/${user.id}/schemeRoles`,
data: {
scheme_user: true,
scheme_admin: false,
},
});
};
const promoteToChannelAdmin = (user, channelId, admin) => {
cy.externalRequest({
user: admin,
method: 'put',
path: `channels/${channelId}/members/${user.id}/schemeRoles`,
data: {
scheme_user: true,
scheme_admin: true,
},
});
};
describe('Change Roles', () => {
const admin = getAdminAccount();
let testUser;
let testChannelId;
beforeEach(() => {
// # Login as test user and visit test channel
cy.apiInitSetup().then(({team, user, channel}) => {
testUser = user;
testChannelId = channel.id;
cy.apiCreateUser().then(({user: otherUser}) => {
cy.apiAddUserToTeam(team.id, otherUser.id);
});
// # Change permission so that regular users can't change channels or add members
cy.apiGetRolesByNames(['channel_user']).then(({roles}) => {
const role = roles[0];
const permissions = role.permissions.filter((permission) => {
return !(['manage_public_channel_members', 'manage_private_channel_members', 'manage_public_channel_properties', 'manage_private_channel_properties'].includes(permission));
});
if (permissions.length !== role.permissions) {
cy.apiPatchRole(role.id, {permissions});
}
});
cy.apiLogin(testUser);
cy.visit(`/${team.name}/channels/${channel.name}`);
// # Make user a regular member for channel and system
demoteToMember(testUser, admin);
demoteToChannelMember(testUser, testChannelId, admin);
// # Reload page to ensure no cache or saved information
cy.reload(true);
});
});
it('MM-T4174 User role to channel admin/member updates channel member modal immediately without refresh', () => {
// # Go to member modal
cy.uiGetChannelMemberButton().click();
cy.uiGetRHS().findByText('Manage').should('not.exist');
// Promote user to a channel admin
promoteToChannelAdmin(testUser, testChannelId, admin);
// * Check to see if a dropdown exists now
cy.uiGetRHS().findByText('Manage').should('be.visible');
});
});