MM-47288 refactor: convert channels/channel/ files to ts (#28483)

* refactor: convert channels/channel/ files to ts

- convert js files to typescript
- update types
- fix lint issues

Fixes: 21299

* fix: solve lint issues channels/channel

- fix lint issues
- udpate types

* fix: adjustment to test case MM-T1687

- code reorganization for test case MM-T1687

* fix: update types on function apiCreateCustomAdmin

- update types for apiCreateCustomAdmin on  user.d.ts so that
lint issue is solved
Этот коммит содержится в:
Angel Mendez
2024-10-09 05:22:45 -06:00
коммит произвёл GitHub
родитель 429c41747c
Коммит 23623fc9c9
22 изменённых файлов: 168 добавлений и 103 удалений

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

@@ -10,11 +10,13 @@
// Stage: @prod // Stage: @prod
// Group: @channels @channel // Group: @channels @channel
import {Channel} from '@mattermost/types/channels';
import {Team} from '@mattermost/types/teams';
import {getRandomId} from '../../../utils'; import {getRandomId} from '../../../utils';
describe('Leave an archived channel', () => { describe('Leave an archived channel', () => {
let testTeam; let testTeam: Team;
let offTopicUrl; let offTopicUrl: string;
const channelType = { const channelType = {
all: 'Channel Type: All', all: 'Channel Type: All',
public: 'Channel Type: Public', public: 'Channel Type: Public',
@@ -63,13 +65,13 @@ describe('Leave an archived channel', () => {
// # Search for the new post and jump to it from the search results // # Search for the new post and jump to it from the search results
cy.uiSearchPosts(otherPostText); cy.uiSearchPosts(otherPostText);
cy.get('@otherPostId').then((otherPostId) => cy.uiJumpToSearchResult(otherPostId)); cy.get<string>('@otherPostId').then((otherPostId) => cy.uiJumpToSearchResult(otherPostId));
// # Search for a post in the archived channel // # Search for a post in the archived channel
cy.uiSearchPosts(archivedPostText); cy.uiSearchPosts(archivedPostText);
// # Open it in the RHS // # Open it in the RHS
cy.get('@archivedPostId').then((archivedPostId) => { cy.get<string>('@archivedPostId').then((archivedPostId) => {
cy.clickPostCommentIcon(archivedPostId, 'SEARCH'); cy.clickPostCommentIcon(archivedPostId, 'SEARCH');
// * Verify that the RHS has switched from search results to the thread // * Verify that the RHS has switched from search results to the thread
@@ -114,8 +116,8 @@ describe('Leave an archived channel', () => {
}); });
it('MM-T1699 - Browse Channels for all channel types shows archived channels option', () => { it('MM-T1699 - Browse Channels for all channel types shows archived channels option', () => {
let archivedPrivateChannel; let archivedPrivateChannel: Channel;
let archivedPublicChannel; let archivedPublicChannel: Channel;
// # Create private channel // # Create private channel
cy.uiCreateChannel({isPrivate: true, isNewSidebar: true}).as('channel').then((channel) => { cy.uiCreateChannel({isPrivate: true, isNewSidebar: true}).as('channel').then((channel) => {
@@ -161,8 +163,8 @@ describe('Leave an archived channel', () => {
}); });
it('MM-T1700 - All archived public channels are shown Important', () => { it('MM-T1700 - All archived public channels are shown Important', () => {
let archivedPublicChannel1; let archivedPublicChannel1: Channel;
let archivedPublicChannel2; let archivedPublicChannel2: Channel;
// # Create public channel // # Create public channel
cy.apiCreateChannel(testTeam.id, 'channel', 'channel').then(({channel}) => { cy.apiCreateChannel(testTeam.id, 'channel', 'channel').then(({channel}) => {
@@ -214,8 +216,8 @@ describe('Leave an archived channel', () => {
}); });
it('MM-T1701 - Only Private channels you are a member of are displayed', () => { it('MM-T1701 - Only Private channels you are a member of are displayed', () => {
let archivedPrivateChannel1; let archivedPrivateChannel1: Channel;
let archivedPrivateChannel2; let archivedPrivateChannel2: Channel;
// # Create private channel // # Create private channel
cy.uiCreateChannel({isPrivate: true, isNewSidebar: true}).as('channel').then((channel) => { cy.uiCreateChannel({isPrivate: true, isNewSidebar: true}).as('channel').then((channel) => {
@@ -268,7 +270,7 @@ describe('Leave an archived channel', () => {
}); });
it('MM-T1703 - User can open archived channels', () => { it('MM-T1703 - User can open archived channels', () => {
let archivedChannel; let archivedChannel: Channel;
// # Create a public channel // # Create a public channel
cy.apiCreateChannel(testTeam.id, 'channel', 'channel').then(({channel}) => { cy.apiCreateChannel(testTeam.id, 'channel', 'channel').then(({channel}) => {

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

@@ -10,12 +10,15 @@
// Stage: @prod // Stage: @prod
// Group: @channels @channel // Group: @channels @channel
import {Channel, ServerChannel} from '@mattermost/types/channels';
import {Team} from '@mattermost/types/teams';
import {UserProfile} from '@mattermost/types/users';
import {getAdminAccount} from '../../../support/env'; import {getAdminAccount} from '../../../support/env';
import {getRandomId} from '../../../utils'; import {getRandomId} from '../../../utils';
describe('Leave an archived channel', () => { describe('Leave an archived channel', () => {
let testTeam; let testTeam: Team;
let testUser; let testUser: UserProfile;
before(() => { before(() => {
cy.apiUpdateConfig({ cy.apiUpdateConfig({
@@ -37,19 +40,21 @@ describe('Leave an archived channel', () => {
}); });
it('MM-T1687 App does not crash when another user archives a channel', () => { it('MM-T1687 App does not crash when another user archives a channel', () => {
cy.makeClient({user: getAdminAccount()}).then((client) => { cy.makeClient({user: getAdminAccount()}).then(async (client) => {
// # Have another user create a private channel // # Have another user create a private channel
const channelName = `channel${getRandomId()}`; const channelName = `channel${getRandomId()}`;
cy.wrap(client.createChannel({ const channelTest = {
display_name: channelName, display_name: channelName,
name: channelName, name: channelName,
team_id: testTeam.id, team_id: testTeam.id,
type: 'P', type: 'P',
})).then(async (channel) => { } as Channel;
cy.wrap(client.createChannel(channelTest)).then(async (channel: ServerChannel) => {
// # Then invite us to it // # Then invite us to it
await client.addToChannel(testUser.id, channel.id); await client.addToChannel(testUser.id, channel.id);
cy.wrap(channel); return channel;
}).then((channel) => { }).then((channel) => {
// * Verify that the newly created channel is in the sidebar // * Verify that the newly created channel is in the sidebar
cy.get(`#sidebarItem_${channel.name}`).should('be.visible'); cy.get(`#sidebarItem_${channel.name}`).should('be.visible');

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

@@ -10,6 +10,9 @@
// Stage: @prod // Stage: @prod
// Group: @channels @channel // Group: @channels @channel
import {Channel} from '@mattermost/types/channels';
import {Team} from '@mattermost/types/teams';
import {UserProfile} from '@mattermost/types/users';
import * as TIMEOUTS from '../../../fixtures/timeouts'; import * as TIMEOUTS from '../../../fixtures/timeouts';
import {createPrivateChannel} from '../enterprise/elasticsearch_autocomplete/helpers'; import {createPrivateChannel} from '../enterprise/elasticsearch_autocomplete/helpers';
@@ -21,10 +24,10 @@ const channelType = {
}; };
describe('Channels', () => { describe('Channels', () => {
let testUser; let testUser: UserProfile;
let otherUser; let otherUser: UserProfile;
let testTeam; let testTeam: Team;
let testChannel; let testChannel: Channel;
before(() => { before(() => {
cy.apiInitSetup().then(({team, user}) => { cy.apiInitSetup().then(({team, user}) => {
@@ -151,7 +154,7 @@ describe('Channels', () => {
cy.apiLogin(otherUser); cy.apiLogin(otherUser);
cy.visit(`/${testTeam.name}/channels/town-square`); cy.visit(`/${testTeam.name}/channels/town-square`);
let newChannel; let newChannel: Channel;
cy.apiCreateChannel(testTeam.id, 'channel-to-leave', 'Channel to leave').then(({channel}) => { cy.apiCreateChannel(testTeam.id, 'channel-to-leave', 'Channel to leave').then(({channel}) => {
newChannel = channel; newChannel = channel;
cy.visit(`/${testTeam.name}/channels/${newChannel.name}`); cy.visit(`/${testTeam.name}/channels/${newChannel.name}`);
@@ -185,9 +188,9 @@ describe('Channels', () => {
ExperimentalViewArchivedChannels: true, ExperimentalViewArchivedChannels: true,
}, },
}); });
let newChannel; let newChannel: Channel;
let testArchivedChannel; let testArchivedChannel: Channel;
let testPrivateArchivedChannel; let testPrivateArchivedChannel: Channel;
cy.apiCreateTeam('team', 'Test NoMember').then(({team}) => { cy.apiCreateTeam('team', 'Test NoMember').then(({team}) => {
cy.apiCreateChannel(team.id, 'not-archived-channel', 'Not Archived Channel').then(({channel}) => { cy.apiCreateChannel(team.id, 'not-archived-channel', 'Not Archived Channel').then(({channel}) => {

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

@@ -1,6 +1,9 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
import {Team} from '@mattermost/types/teams';
import {UserProfile} from '@mattermost/types/users';
// *************************************************************** // ***************************************************************
// - [#] indicates a test step (e.g. # Go to a page) // - [#] indicates a test step (e.g. # Go to a page)
// - [*] indicates an assertion (e.g. * Check the title) // - [*] indicates an assertion (e.g. * Check the title)
@@ -15,9 +18,9 @@ function verifyNoChannelToJoinMessage(isVisible) {
} }
describe('browse public channels', () => { describe('browse public channels', () => {
let testUser; let testUser: UserProfile;
let otherUser; let otherUser: UserProfile;
let testTeam; let testTeam: Team;
before(() => { before(() => {
cy.apiInitSetup().then(({team, user}) => { cy.apiInitSetup().then(({team, user}) => {

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

@@ -10,6 +10,9 @@
// Group: @channels @channel @channel_bookmarks // Group: @channels @channel @channel_bookmarks
// node run_tests.js --group='@channel' // node run_tests.js --group='@channel'
import {Channel} from '@mattermost/types/channels';
import {Team} from '@mattermost/types/teams';
import {UserProfile} from '@mattermost/types/users';
import {getRandomId} from '../../../utils'; import {getRandomId} from '../../../utils';
import * as TIMEOUTS from '../../../fixtures/timeouts'; import * as TIMEOUTS from '../../../fixtures/timeouts';
@@ -17,14 +20,12 @@ describe('Channel Bookmarks', () => {
const SpaceKeyCode = 32; const SpaceKeyCode = 32;
const RightArrowKeyCode = 39; const RightArrowKeyCode = 39;
let testTeam: Cypress.Team; let testTeam: Team;
// eslint-disable-next-line @typescript-eslint/no-unused-vars // eslint-disable-next-line @typescript-eslint/no-unused-vars
let user1: Cypress.UserProfile; let user1: UserProfile;
// eslint-disable-next-line @typescript-eslint/no-unused-vars let admin: UserProfile;
let admin: Cypress.UserProfile; let channel: Channel;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
let channel: Cypress.Channel;
before(() => { before(() => {
cy.apiGetMe().then(({user: adminUser}) => { cy.apiGetMe().then(({user: adminUser}) => {

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

@@ -10,17 +10,20 @@
// Stage: @prod // Stage: @prod
// Group: @channels @channel @rhs @channel_info // Group: @channels @channel @rhs @channel_info
import {Channel} from '@mattermost/types/channels';
import {Team} from '@mattermost/types/teams';
import {UserProfile} from '@mattermost/types/users';
import {stubClipboard} from '../../../utils'; import {stubClipboard} from '../../../utils';
describe('Channel Info RHS', () => { describe('Channel Info RHS', () => {
let testTeam; let testTeam: Team;
let testChannel; let testChannel: Channel;
let groupChannel; let groupChannel: Channel;
let directChannel; let directChannel: Channel;
let directUser; let directUser: UserProfile;
let admin; let admin: UserProfile;
let user; let user: UserProfile;
const otherUsers = []; const otherUsers: UserProfile[] = [];
before(() => { before(() => {
cy.apiInitSetup({promoteNewUserAsAdmin: true}).then(({team, user: newAdmin}) => { cy.apiInitSetup({promoteNewUserAsAdmin: true}).then(({team, user: newAdmin}) => {
@@ -41,7 +44,7 @@ describe('Channel Info RHS', () => {
// Users used for GM/DM // Users used for GM/DM
cy.apiCreateUser().then(({user: newUser}) => { cy.apiCreateUser().then(({user: newUser}) => {
otherUsers.push(newUser); otherUsers.push(newUser);
cy.apiPatchUser(newUser.id, {position: 'Upside down'}).then(({user: patchedUser}) => { cy.apiPatchUser(newUser.id, {position: 'Upside down'} as UserProfile).then(({user: patchedUser}) => {
cy.apiCreateDirectChannel([newAdmin.id, newUser.id]).then(({channel}) => { cy.apiCreateDirectChannel([newAdmin.id, newUser.id]).then(({channel}) => {
directChannel = channel; directChannel = channel;
}); });
@@ -66,7 +69,7 @@ describe('Channel Info RHS', () => {
return !(['manage_public_channel_members', 'manage_private_channel_members', 'manage_public_channel_properties', 'manage_private_channel_properties'].includes(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) { if (permissions.length !== role.permissions.length) {
cy.apiPatchRole(role.id, {permissions}); cy.apiPatchRole(role.id, {permissions});
} }
}); });

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

@@ -1,6 +1,10 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
import {Channel} from '@mattermost/types/channels';
import {Team} from '@mattermost/types/teams';
import {UserProfile} from '@mattermost/types/users';
const {generateRandomUser} = require('../../../support/api/user'); const {generateRandomUser} = require('../../../support/api/user');
// *************************************************************** // ***************************************************************
@@ -12,7 +16,7 @@ const {generateRandomUser} = require('../../../support/api/user');
// Stage: @prod // Stage: @prod
// Group: @channels @channel @rhs @channel_members // Group: @channels @channel @rhs @channel_members
function openChannelMembersRhs(testTeam, testChannel) { function openChannelMembersRhs(testTeam: Team, testChannel: Channel) {
// # Go to test channel // # Go to test channel
cy.visit(`/${testTeam.name}/channels/${testChannel.name}`); cy.visit(`/${testTeam.name}/channels/${testChannel.name}`);
@@ -24,10 +28,10 @@ function openChannelMembersRhs(testTeam, testChannel) {
} }
describe('Channel members RHS', () => { describe('Channel members RHS', () => {
let testTeam; let testTeam: Team;
let testChannel; let testChannel: Channel;
let admin; let admin: UserProfile;
let user; let user: UserProfile;
before(() => { before(() => {
cy.apiInitSetup({promoteNewUserAsAdmin: true}).then(({team, user: newAdmin}) => { cy.apiInitSetup({promoteNewUserAsAdmin: true}).then(({team, user: newAdmin}) => {
@@ -53,7 +57,7 @@ describe('Channel members RHS', () => {
return !(['manage_public_channel_members', 'manage_private_channel_members', 'manage_public_channel_properties', 'manage_private_channel_properties'].includes(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) { if (permissions.length !== role.permissions.length) {
cy.apiPatchRole(role.id, {permissions}); cy.apiPatchRole(role.id, {permissions});
} }
}); });
@@ -168,7 +172,7 @@ describe('Channel members RHS', () => {
it('should hide deactivated members', () => { it('should hide deactivated members', () => {
cy.apiCreateChannel(testTeam.id, 'hide-test-channel', 'Hide Test Channel', 'O').then(({channel}) => { cy.apiCreateChannel(testTeam.id, 'hide-test-channel', 'Hide Test Channel', 'O').then(({channel}) => {
let testUser = null; let testUser: UserProfile;
cy.apiCreateUser().then(({user: newUser}) => { cy.apiCreateUser().then(({user: newUser}) => {
cy.apiAddUserToTeam(testTeam.id, newUser.id).then(() => { cy.apiAddUserToTeam(testTeam.id, newUser.id).then(() => {
cy.apiAddUserToChannel(channel.id, newUser.id).then(() => { cy.apiAddUserToChannel(channel.id, newUser.id).then(() => {

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

@@ -10,14 +10,17 @@
// Stage: @prod // Stage: @prod
// Group: @channels @channel // Group: @channels @channel
import {Channel} from '@mattermost/types/channels';
import {Team} from '@mattermost/types/teams';
import {UserProfile} from '@mattermost/types/users';
import * as TIMEOUTS from '../../../fixtures/timeouts'; import * as TIMEOUTS from '../../../fixtures/timeouts';
describe('Channel', () => { describe('Channel', () => {
let testTeam; let testTeam: Team;
let ownChannel; let ownChannel: Channel;
let otherChannel; let otherChannel: Channel;
let testUser; let testUser: UserProfile;
let offTopicUrl; let offTopicUrl: string;
const myChannelsDividerText = 'My Channels'; const myChannelsDividerText = 'My Channels';
const otherChannelsDividerText = 'Other Channels'; const otherChannelsDividerText = 'Other Channels';

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

@@ -10,11 +10,14 @@
// Stage: @prod // Stage: @prod
// Group: @channels @channel @not_cloud // Group: @channels @channel @not_cloud
import {Channel} from '@mattermost/types/channels';
import {Team} from '@mattermost/types/teams';
import {UserProfile} from '@mattermost/types/users';
import * as TIMEOUTS from '../../../fixtures/timeouts'; import * as TIMEOUTS from '../../../fixtures/timeouts';
const timestamp = Date.now(); const timestamp = Date.now();
function verifyChannel(channel, verifyExistence = true) { function verifyChannel(channel: Channel, verifyExistence = true) {
// # Wait for Channel to be created // # Wait for Channel to be created
cy.wait(TIMEOUTS.HALF_SEC); cy.wait(TIMEOUTS.HALF_SEC);
@@ -35,9 +38,9 @@ function verifyChannel(channel, verifyExistence = true) {
} }
describe('channel name tooltips', () => { describe('channel name tooltips', () => {
let loggedUser; let loggedUser: UserProfile;
let longUser; let longUser: UserProfile;
let testTeam; let testTeam: Team;
before(() => { before(() => {
cy.shouldNotRunOnCloudEdition(); cy.shouldNotRunOnCloudEdition();

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

@@ -1,6 +1,9 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
import {Team} from '@mattermost/types/teams';
import {UserProfile} from '@mattermost/types/users';
// *************************************************************** // ***************************************************************
// - [#] indicates a test step (e.g. # Go to a page) // - [#] indicates a test step (e.g. # Go to a page)
// - [*] indicates an assertion (e.g. * Check the title) // - [*] indicates an assertion (e.g. * Check the title)
@@ -11,10 +14,10 @@
// Group: @channels @channel // Group: @channels @channel
describe('Channel routing', () => { describe('Channel routing', () => {
let testUser; let testUser: UserProfile;
let otherUser1; let otherUser1: UserProfile;
let otherUser2; let otherUser2: UserProfile;
let testTeam; let testTeam: Team;
before(() => { before(() => {
cy.apiInitSetup().then(({team, user}) => { cy.apiInitSetup().then(({team, user}) => {

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

@@ -10,13 +10,14 @@
// Stage: @prod // Stage: @prod
// Group: @channels @channel @channel_settings // Group: @channels @channel @channel_settings
import {Team} from '@mattermost/types/teams';
import { import {
beMuted, beMuted,
beUnmuted, beUnmuted,
} from '../../../support/assertions'; } from '../../../support/assertions';
describe('Channel Settings', () => { describe('Channel Settings', () => {
let testTeam; let testTeam: Team;
before(() => { before(() => {
cy.apiInitSetup().then(({team, user}) => { cy.apiInitSetup().then(({team, user}) => {
testTeam = team; testTeam = team;

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

@@ -1,6 +1,8 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
import {Team} from '@mattermost/types/teams';
// *************************************************************** // ***************************************************************
// - [#] indicates a test step (e.g. # Go to a page) // - [#] indicates a test step (e.g. # Go to a page)
// - [*] indicates an assertion (e.g. * Check the title) // - [*] indicates an assertion (e.g. * Check the title)
@@ -11,9 +13,9 @@
// Group: @channels @channel @smoke // Group: @channels @channel @smoke
describe('Channel Switcher', () => { describe('Channel Switcher', () => {
let testTeam; let testTeam: Team;
let testChannelName; let testChannelName: string;
let offTopicUrl; let offTopicUrl: string;
const channelNamePrefix = 'aswitchchannel'; const channelNamePrefix = 'aswitchchannel';
const channelDisplayNamePrefix = 'ASwitchChannel'; const channelDisplayNamePrefix = 'ASwitchChannel';

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

@@ -1,6 +1,11 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
import {Channel} from '@mattermost/types/channels';
import {Team} from '@mattermost/types/teams';
import {UserProfile} from '@mattermost/types/users';
import {ChainableT} from '../../../types';
// *************************************************************** // ***************************************************************
// - [#] indicates a test step (e.g. # Go to a page) // - [#] indicates a test step (e.g. # Go to a page)
// - [*] indicates an assertion (e.g. * Check the title) // - [*] indicates an assertion (e.g. * Check the title)
@@ -13,7 +18,7 @@
// Make sure that the current channel is Town Square and that the // Make sure that the current channel is Town Square and that the
// channel identified by the passed name is no longer in the channel // channel identified by the passed name is no longer in the channel
// sidebar // sidebar
function verifyChannelWasProperlyClosed(channelName) { function verifyChannelWasProperlyClosed(channelName: string) {
// * Make sure that we have switched channels // * Make sure that we have switched channels
cy.get('#channelHeaderTitle').should('contain', 'Town Square'); cy.get('#channelHeaderTitle').should('contain', 'Town Square');
@@ -22,9 +27,9 @@ function verifyChannelWasProperlyClosed(channelName) {
} }
describe('Close direct messages', () => { describe('Close direct messages', () => {
let testUser; let testUser: UserProfile;
let otherUser; let otherUser: UserProfile;
let testTeam; let testTeam: Team;
before(() => { before(() => {
cy.shouldNotRunOnCloudEdition(); cy.shouldNotRunOnCloudEdition();
@@ -54,7 +59,7 @@ describe('Close direct messages', () => {
}); });
}); });
function createAndVisitDMChannel(userIds) { function createAndVisitDMChannel(userIds: string[]): ChainableT<Channel> {
return cy.apiCreateDirectChannel(userIds).then(({channel}) => { return cy.apiCreateDirectChannel(userIds).then(({channel}) => {
// # Visit the new channel // # Visit the new channel
cy.visit(`/${testTeam.name}/channels/${channel.name}`); cy.visit(`/${testTeam.name}/channels/${channel.name}`);
@@ -68,10 +73,10 @@ describe('Close direct messages', () => {
}); });
describe('Close group messages', () => { describe('Close group messages', () => {
let testUser; let testUser: UserProfile;
let otherUser1; let otherUser1: UserProfile;
let otherUser2; let otherUser2: UserProfile;
let testTeam; let testTeam: Team;
before(() => { before(() => {
cy.apiAdminLogin(); cy.apiAdminLogin();

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

@@ -1,6 +1,9 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
import {Team} from '@mattermost/types/teams';
import {UserProfile} from '@mattermost/types/users';
// *************************************************************** // ***************************************************************
// - [#] indicates a test step (e.g. # Go to a page) // - [#] indicates a test step (e.g. # Go to a page)
// - [*] indicates an assertion (e.g. * Check the title) // - [*] indicates an assertion (e.g. * Check the title)
@@ -11,8 +14,8 @@
// Group: @channels @channel // Group: @channels @channel
describe('Channels', () => { describe('Channels', () => {
let testUser; let testUser: UserProfile;
let testTeam; let testTeam: Team;
before(() => { before(() => {
cy.apiInitSetup().then(({team, user}) => { cy.apiInitSetup().then(({team, user}) => {

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

@@ -1,6 +1,10 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
import {Channel} from '@mattermost/types/channels';
import {Team, TeamMembership} from '@mattermost/types/teams';
import {UserProfile} from '@mattermost/types/users';
// *************************************************************** // ***************************************************************
// - [#] indicates a test step (e.g. # Go to a page) // - [#] indicates a test step (e.g. # Go to a page)
// - [*] indicates an assertion (e.g. * Check the title) // - [*] indicates an assertion (e.g. * Check the title)
@@ -11,14 +15,14 @@
// Group: @channels @channel // Group: @channels @channel
describe('Group Message Conversion To Private Channel', () => { describe('Group Message Conversion To Private Channel', () => {
let testTeam1; let testTeam1: Team;
let testTeam2; let testTeam2: Team;
let testUser1; let testUser1: UserProfile;
let testUser2; let testUser2: UserProfile;
let testUser3; let testUser3: UserProfile;
let gm; let gm: Channel;
before(() => { before(() => {
// we need two teams, and a set of users belonging to both teams // we need two teams, and a set of users belonging to both teams
@@ -36,9 +40,9 @@ describe('Group Message Conversion To Private Channel', () => {
testUser3 = user3; testUser3 = user3;
const teamMembers1 = [testUser1, testUser2, testUser3].map((u) => ({team_id: testTeam1.id, user_id: u.id})); const teamMembers1 = [testUser1, testUser2, testUser3].map((u) => ({team_id: testTeam1.id, user_id: u.id}));
cy.apiAddUsersToTeam(testTeam1.id, teamMembers1).then(() => { cy.apiAddUsersToTeam(testTeam1.id, teamMembers1 as TeamMembership[]).then(() => {
const teamMembers2 = [testUser1, testUser2, testUser3].map((u) => ({team_id: testTeam2.id, user_id: u.id})); const teamMembers2 = [testUser1, testUser2, testUser3].map((u) => ({team_id: testTeam2.id, user_id: u.id}));
cy.apiAddUsersToTeam(testTeam2.id, teamMembers2).then(() => { cy.apiAddUsersToTeam(testTeam2.id, teamMembers2 as TeamMembership[]).then(() => {
cy.apiCreateGroupChannel([testUser1.id, testUser2.id, testUser3.id]).then(({channel}) => { cy.apiCreateGroupChannel([testUser1.id, testUser2.id, testUser3.id]).then(({channel}) => {
gm = channel; gm = channel;
}); });
@@ -91,7 +95,7 @@ describe('Group Message Conversion To Private Channel', () => {
user_id: u.id, user_id: u.id,
})); }));
cy.apiAddUsersToTeam(testTeam2.id, teamMembers).then(() => { cy.apiAddUsersToTeam(testTeam2.id, teamMembers as TeamMembership[]).then(() => {
cy.apiCreateGroupChannel([testUser1.id, testUser2.id, testUser3.id, testUser4.id]).then(({channel}) => { cy.apiCreateGroupChannel([testUser1.id, testUser2.id, testUser3.id, testUser4.id]).then(({channel}) => {
gm2 = channel; gm2 = channel;
@@ -130,7 +134,7 @@ describe('Group Message Conversion To Private Channel', () => {
user_id: testUser5.id, user_id: testUser5.id,
}]; }];
cy.apiAddUsersToTeam(testTeam3.id, teamMembers).then(() => { cy.apiAddUsersToTeam(testTeam3.id, teamMembers as TeamMembership[]).then(() => {
cy.apiCreateGroupChannel([testUser1.id, testUser2.id, testUser3.id, testUser5.id]).then(({channel}) => { cy.apiCreateGroupChannel([testUser1.id, testUser2.id, testUser3.id, testUser5.id]).then(({channel}) => {
gm3 = channel; gm3 = channel;

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

@@ -10,12 +10,15 @@
// Stage: @prod // Stage: @prod
// Group: @channels @channel // Group: @channels @channel
import {Channel} from '@mattermost/types/channels';
import {Team} from '@mattermost/types/teams';
import {UserProfile} from '@mattermost/types/users';
import * as TIMEOUTS from '../../../fixtures/timeouts'; import * as TIMEOUTS from '../../../fixtures/timeouts';
describe('Leave channel', () => { describe('Leave channel', () => {
let testTeam; let testTeam: Team;
let testUser; let testUser: UserProfile;
let testChannel; let testChannel: Channel;
before(() => { before(() => {
cy.apiUpdateConfig({ cy.apiUpdateConfig({

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

@@ -9,6 +9,7 @@
// Group: @channels @channel // Group: @channels @channel
import {UserProfile} from '@mattermost/types/users';
import {getAdminAccount} from '../../../support/env'; import {getAdminAccount} from '../../../support/env';
const demoteToChannelMember = (user, channelId, admin) => { const demoteToChannelMember = (user, channelId, admin) => {
@@ -37,8 +38,8 @@ const promoteToChannelAdmin = (user, channelId, admin) => {
describe('Change Roles', () => { describe('Change Roles', () => {
const admin = getAdminAccount(); const admin = getAdminAccount();
let testUser; let testUser: UserProfile;
let testChannelId; let testChannelId: string;
beforeEach(() => { beforeEach(() => {
// # Login as test user and visit test channel // # Login as test user and visit test channel
@@ -57,7 +58,7 @@ describe('Change Roles', () => {
return !(['manage_public_channel_members', 'manage_private_channel_members', 'manage_public_channel_properties', 'manage_private_channel_properties'].includes(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) { if (permissions.length !== role.permissions.length) {
cy.apiPatchRole(role.id, {permissions}); cy.apiPatchRole(role.id, {permissions});
} }
}); });

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

@@ -42,7 +42,7 @@ declare namespace Cypress {
* // do something with roles * // do something with roles
* }); * });
*/ */
apiGetRolesByNames(names: string[]): Chainable<Role[]>; apiGetRolesByNames(names: string[]): Chainable<{roles: Role[]}>;
/** /**
* Patch a role by ID. * Patch a role by ID.

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

@@ -193,7 +193,7 @@ declare namespace Cypress {
* *
* @returns {UserProfile} `out.sysadmin` as `UserProfile` object * @returns {UserProfile} `out.sysadmin` as `UserProfile` object
*/ */
apiCreateCustomAdmin(options: {loginAfter: boolean; hideAdminTrialModal?: boolean}): Chainable<{sysadmin: UserProfile}>; apiCreateCustomAdmin({loginAfter = false, hideAdminTrialModal = true} = {}): Chainable<{sysadmin: UserProfile}>;
/** /**
* Create a new user with an options to set name prefix and be able to bypass tutorial steps. * Create a new user with an options to set name prefix and be able to bypass tutorial steps.
@@ -248,7 +248,7 @@ declare namespace Cypress {
* // do something with users * // do something with users
* }); * });
*/ */
apiGetUsers(queryParams: Record<string, any>): Chainable<UserProfile[]>; apiGetUsers(queryParams: Record<string, any>): Chainable<{users: UserProfile[]}>;
/** /**
* Get list of users that are not team members. * Get list of users that are not team members.

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

@@ -1,16 +1,20 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
Cypress.Commands.add('uiSearchPosts', (searchTerm) => { import {ChainableT} from 'tests/types';
function uiSearchPosts(searchTerm: string) {
// # Enter the search terms and hit enter to start the search // # Enter the search terms and hit enter to start the search
cy.get('#searchBox').clear().type(searchTerm).type('{enter}'); cy.get('#searchBox').clear().type(searchTerm).type('{enter}');
// * Wait for the RHS to open and the search results to appear // * Wait for the RHS to open and the search results to appear
cy.contains('.sidebar--right__header', 'Search Results').should('be.visible'); cy.contains('.sidebar--right__header', 'Search Results').should('be.visible');
cy.get('#searchContainer .LoadingSpinner').should('not.exist'); cy.get('#searchContainer .LoadingSpinner').should('not.exist');
}); }
Cypress.Commands.add('uiJumpToSearchResult', (postId) => { Cypress.Commands.add('uiSearchPosts', uiSearchPosts);
function uiJumpToSearchResult(postId: string) {
// # Find the post in the search results and click Jump // # Find the post in the search results and click Jump
cy.get(`#searchResult_${postId}`).contains('a', 'Jump').click(); cy.get(`#searchResult_${postId}`).contains('a', 'Jump').click();
@@ -19,4 +23,16 @@ Cypress.Commands.add('uiJumpToSearchResult', (postId) => {
// * Verify that the permalinked post is highlighted in the center channel // * Verify that the permalinked post is highlighted in the center channel
cy.get(`#post_${postId}.post--highlight`).should('be.visible'); cy.get(`#post_${postId}.post--highlight`).should('be.visible');
}); }
Cypress.Commands.add('uiJumpToSearchResult', uiJumpToSearchResult);
declare global {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace Cypress {
interface Chainable {
uiSearchPosts(searchTerm: string): ChainableT;
uiJumpToSearchResult(postId: string): ChainableT;
}
}
}

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

@@ -638,7 +638,7 @@ declare global {
* @example * @example
* cy.uiPostMessageQuickly('Hello world') * cy.uiPostMessageQuickly('Hello world')
*/ */
uiPostMessageQuickly(message: string): void; uiPostMessageQuickly(message: string): ChainableT<void>;
/** /**
* Clicks on a visible emoji in the emoji picker. * Clicks on a visible emoji in the emoji picker.