MM-47291 refactor: migrate collapsed_reply_threads to ts (#27808)

* refactor: migrate collapsed_reply_threads to ts

- migrate collapsed_reply_threads e2e tests to typescript
- update matterpollPlugin plugin constant so that it matches
with apiUploadAndEnablePlugin argument

Fixes: #21296

* refactor: use PostMessageResp on channel_notifications_spec

- use type PostMessageResp
- convert cy.wrap to regular for loop

* refactor: update types on collapsed_reply_threads

- add missing types to variables
- update types on current variables
- remove unnecessary commands on following_spec.ts

* fix: solve issue with non callable function

- move wait call to next line

* refactor: remove functions from global scope

- keep functions as helper functions
- fix lint issue
Этот коммит содержится в:
Angel Mendez
2024-10-08 15:15:43 -06:00
коммит произвёл GitHub
родитель 33af22b2d3
Коммит 3d38d239ff
15 изменённых файлов: 101 добавлений и 60 удалений

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

@@ -10,15 +10,18 @@
// Stage: @prod
// Group: @channels @collapsed_reply_threads
import {Team} from '@mattermost/types/teams';
import {UserProfile} from '@mattermost/types/users';
import {PostMessageResp} from '../../../support/task_commands';
import {spyNotificationAs} from '../../../support/notification';
describe('CRT Desktop notifications', () => {
let testTeam;
let testChannelUrl;
let testChannelId;
let testChannelName;
let receiver;
let sender;
let testTeam: Team;
let testChannelUrl: string;
let testChannelId: string;
let testChannelName: string;
let receiver: UserProfile;
let sender: UserProfile;
before(() => {
cy.apiUpdateConfig({
@@ -265,11 +268,12 @@ describe('CRT Desktop notifications', () => {
cy.get('#sidebarItem_threads #unreadMentions').should('exist').and('have.text', '1');
// # Delete the replies
cy.wrap(['@reply', '@replyMention']).each((reply) => {
cy.get(reply).then(({id}) => {
const replies = ['@reply', '@replyMention'];
for (const reply of replies) {
cy.get<PostMessageResp>(reply).then(({id}) => {
cy.apiDeletePost(id);
});
});
}
// * Verify there is no notification
cy.get('#sidebarItem_threads #unreadMentions').should('not.exist');
@@ -288,7 +292,7 @@ describe('CRT Desktop notifications', () => {
cy.postMessageAs({sender, message: 'a thread', channelId: dmChannel.id, rootId: ''}).as('rootPost');
// # Get post id of message
cy.get('@rootPost').then(({id: rootId}) => {
cy.get<PostMessageResp>('@rootPost').then(({id: rootId}) => {
// # Post a reply to the thread, which will trigger a follow
cy.postMessageAs({sender: receiver, message: 'following the thread', channelId: dmChannel.id, rootId});
@@ -303,11 +307,12 @@ describe('CRT Desktop notifications', () => {
cy.get('#sidebarItem_threads #unreadMentions').should('exist');
// # Delete the replies
cy.wrap(['@reply', '@replyMention']).each((reply) => {
cy.get(reply).then(({id}) => {
const replies = ['@reply', '@replyMention'];
for (const reply of replies) {
cy.get<PostMessageResp>(reply).then(({id}) => {
cy.apiDeletePost(id);
});
});
}
// * Verify there is no notification
cy.get('#sidebarItem_threads #unreadMentions').should('not.exist');

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

@@ -1,6 +1,8 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {Team} from '@mattermost/types/teams';
// ***************************************************************
// - [#] indicates a test step (e.g. # Go to a page)
// - [*] indicates an assertion (e.g. * Check the title)
@@ -11,7 +13,7 @@
// Group: @channels @collapsed_reply_threads
describe('Collapsed Reply Threads', () => {
let testTeam;
let testTeam: Team;
before(() => {
cy.apiUpdateConfig({

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

@@ -1,6 +1,11 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// 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 {PostMessageResp} from 'tests/support/task_commands';
// ***************************************************************
// - [#] indicates a test step (e.g. # Go to a page)
// - [*] indicates an assertion (e.g. * Check the title)
@@ -11,10 +16,10 @@
// Group: @channels @collapsed_reply_threads
describe('Collapsed Reply Threads', () => {
let testTeam;
let otherUser;
let testChannel;
let rootPost;
let testTeam: Team;
let otherUser: UserProfile;
let testChannel: Channel;
let rootPost: PostMessageResp;
beforeEach(() => {
cy.apiUpdateConfig({

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

@@ -10,14 +10,17 @@
// Stage: @prod
// Group: @channels @collapsed_reply_threads @not_cloud
import {Channel} from '@mattermost/types/channels';
import {Team} from '@mattermost/types/teams';
import {UserProfile} from '@mattermost/types/users';
import * as MESSAGES from '../../../fixtures/messages';
import {matterpollPlugin} from '../../../utils/plugins';
import {interceptFileUpload} from '../files_and_attachments/helpers';
describe('Collapsed Reply Threads', () => {
let testTeam;
let testChannel;
let user1;
let testTeam: Team;
let testChannel: Channel;
let user1: UserProfile;
before(() => {
cy.apiUpdateConfig({

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

@@ -10,13 +10,16 @@
// Stage: @prod
// Group: @channels @collapsed_reply_threads
import {Channel} from '@mattermost/types/channels';
import {Team} from '@mattermost/types/teams';
import {UserProfile} from '@mattermost/types/users';
import * as MESSAGES from '../../../fixtures/messages';
import {waitUntilUploadComplete, interceptFileUpload} from '../files_and_attachments/helpers';
describe('Collapsed Reply Threads', () => {
let testTeam;
let testChannel;
let user1;
let testTeam: Team;
let testChannel: Channel;
let user1: UserProfile;
const files = [
{

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

@@ -9,14 +9,18 @@
// Group: @channels @collapsed_reply_threads
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 {isMac} from '../../../utils';
import {ChainableT} from '../../../types';
describe('Collapsed Reply Threads', () => {
let testTeam;
let testUser;
let otherUser;
let testChannel;
let testTeam: Team;
let testUser: UserProfile;
let otherUser: UserProfile;
let testChannel: Channel;
before(() => {
cy.apiUpdateConfig({
@@ -239,7 +243,7 @@ describe('Collapsed Reply Threads', () => {
});
});
function postMessageWithReply(channelId, postSender, postMessage, replySender, replyMessage) {
function postMessageWithReply(channelId, postSender, postMessage, replySender, replyMessage): ChainableT {
return cy.postMessageAs({
sender: postSender,
message: postMessage || 'Another interesting post.',
@@ -254,7 +258,7 @@ function postMessageWithReply(channelId, postSender, postMessage, replySender, r
});
}
function scrollThreadsListToEnd(maxScrolls = 1, scrolls = 0) {
function scrollThreadsListToEnd(maxScrolls = 1, scrolls = 0): ChainableT<void> {
if (scrolls === maxScrolls) {
return;
}
@@ -271,4 +275,3 @@ function scrollThreadsListToEnd(maxScrolls = 1, scrolls = 0) {
}
});
}

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

@@ -10,15 +10,20 @@
// Stage: @prod
// Group: @channels @collapsed_reply_threads
import {Channel} from '@mattermost/types/channels';
import {Team} from '@mattermost/types/teams';
import {UserProfile} from '@mattermost/types/users';
import {PostMessageResp} from 'tests/support/task_commands';
describe('Collapsed Reply Threads', () => {
let testTeam;
let testChannel;
let user1;
let user2;
let user3;
let rootPost;
let replyPost1;
let replyPost2;
let testTeam: Team;
let testChannel: Channel;
let user1: UserProfile;
let user2: UserProfile;
let user3: UserProfile;
let rootPost: PostMessageResp;
let replyPost1: PostMessageResp;
let replyPost2: PostMessageResp;
const messages = {
ROOT: 'ROOT POST',

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

@@ -1,6 +1,9 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// 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 * as TIMEOUTS from '../../../fixtures/timeouts';
// ***************************************************************
@@ -13,11 +16,11 @@ import * as TIMEOUTS from '../../../fixtures/timeouts';
// Group: @channels @collapsed_reply_threads
describe('Collapsed Reply Threads', () => {
let userA; // Member of team A and B
let teamA;
let teamB;
let offTopicUrlA;
let testChannel;
let userA: UserProfile; // Member of team A and B
let teamA: Team;
let teamB: Team;
let offTopicUrlA: string;
let testChannel: Channel;
before(() => {
cy.apiUpdateConfig({

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

@@ -1,6 +1,9 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// 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 an assertion (e.g. * Check the title)
@@ -11,9 +14,9 @@
// Group: @channels @collapsed_reply_threads
describe('Collapsed Reply Threads', () => {
let testTeam;
let testUser;
let otherUser;
let testTeam: Team;
let testUser: UserProfile;
let otherUser: UserProfile;
before(() => {
cy.apiUpdateConfig({

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

@@ -10,15 +10,19 @@
// Stage: @prod
// Group: @channels @collapsed_reply_threads
import {Channel} from '@mattermost/types/channels';
import {Team} from '@mattermost/types/teams';
import {UserProfile} from '@mattermost/types/users';
import {PostMessageResp} from 'tests/support/task_commands';
import * as TIMEOUTS from '../../../fixtures/timeouts';
describe('Collapsed Reply Threads', () => {
let testTeam;
let testUser;
let otherUser;
let testChannel;
let rootPost;
let postForAvatar;
let testTeam: Team;
let testUser: UserProfile;
let otherUser: UserProfile;
let testChannel: Channel;
let rootPost: PostMessageResp;
let postForAvatar: PostMessageResp;
before(() => {
cy.apiUpdateConfig({

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

@@ -10,13 +10,16 @@
// Stage: @prod
// Group: @channels @collapsed_reply_threads
import {Channel} from '@mattermost/types/channels';
import {Team} from '@mattermost/types/teams';
import {UserProfile} from '@mattermost/types/users';
import * as TIMEOUTS from '../../../fixtures/timeouts';
describe('Collapsed Reply Threads', () => {
let testTeam;
let testUser;
let otherUser;
let testChannel;
let testTeam: Team;
let testUser: UserProfile;
let otherUser: UserProfile;
let testChannel: Channel;
before(() => {
cy.apiUpdateConfig({

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

@@ -137,7 +137,7 @@ describe('Verify Accessibility Support in Modals & Dialogs', () => {
it('MM-T1468 Accessibility Support in Add people to Channel Dialog screen', () => {
// # Add atleast 5 users
for (let i = 0; i < 5; i++) {
cy.apiCreateUser().then(({user}) => { // eslint-disable-line
cy.apiCreateUser().then(({user}) => { // eslint-disable-line
cy.apiAddUserToTeam(testTeam.id, user.id);
});
}

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

@@ -55,7 +55,8 @@ describe('Verify Guest User Identification in different screens', () => {
});
// # Deactivate Guest user
cy.externalActivateUser(guestUser.id, false).wait(TIMEOUTS.FIVE_SEC);
cy.externalActivateUser(guestUser.id, false);
cy.wait(TIMEOUTS.FIVE_SEC);
// # Switch channels away and back to reload the header
cy.get('.SidebarChannel:contains(Town Square)').click();

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

@@ -13,7 +13,7 @@ import {ChainableT} from '../types';
* @param {Object} channelId - where a post will be posted
*/
interface PostMessageResp {
export interface PostMessageResp {
id: string;
status: number;
data: any;

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

@@ -70,6 +70,7 @@ export const matterpollPlugin = {
id: 'com.github.matterpoll.matterpoll',
version: '1.5.0',
url: 'https://github.com/matterpoll/matterpoll/releases/download/v1.5.0/com.github.matterpoll.matterpoll-1.5.0.tar.gz',
filename: 'com.github.matterpoll.matterpoll-1.5.0.tar.gz',
};
export const testPlugin = {