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

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

@@ -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,7 +13,7 @@
// Group: @channels @collapsed_reply_threads // Group: @channels @collapsed_reply_threads
describe('Collapsed Reply Threads', () => { describe('Collapsed Reply Threads', () => {
let testTeam; let testTeam: Team;
before(() => { before(() => {
cy.apiUpdateConfig({ cy.apiUpdateConfig({

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

@@ -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 {PostMessageResp} from 'tests/support/task_commands';
// *************************************************************** // ***************************************************************
// - [#] 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 +16,10 @@
// Group: @channels @collapsed_reply_threads // Group: @channels @collapsed_reply_threads
describe('Collapsed Reply Threads', () => { describe('Collapsed Reply Threads', () => {
let testTeam; let testTeam: Team;
let otherUser; let otherUser: UserProfile;
let testChannel; let testChannel: Channel;
let rootPost; let rootPost: PostMessageResp;
beforeEach(() => { beforeEach(() => {
cy.apiUpdateConfig({ cy.apiUpdateConfig({

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

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

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

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

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

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

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

@@ -10,15 +10,20 @@
// Stage: @prod // Stage: @prod
// Group: @channels @collapsed_reply_threads // 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', () => { describe('Collapsed Reply Threads', () => {
let testTeam; let testTeam: Team;
let testChannel; let testChannel: Channel;
let user1; let user1: UserProfile;
let user2; let user2: UserProfile;
let user3; let user3: UserProfile;
let rootPost; let rootPost: PostMessageResp;
let replyPost1; let replyPost1: PostMessageResp;
let replyPost2; let replyPost2: PostMessageResp;
const messages = { const messages = {
ROOT: 'ROOT POST', ROOT: 'ROOT POST',

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

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

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

@@ -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,9 +14,9 @@
// Group: @channels @collapsed_reply_threads // Group: @channels @collapsed_reply_threads
describe('Collapsed Reply Threads', () => { describe('Collapsed Reply Threads', () => {
let testTeam; let testTeam: Team;
let testUser; let testUser: UserProfile;
let otherUser; let otherUser: UserProfile;
before(() => { before(() => {
cy.apiUpdateConfig({ cy.apiUpdateConfig({

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

@@ -10,15 +10,19 @@
// Stage: @prod // Stage: @prod
// Group: @channels @collapsed_reply_threads // 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'; import * as TIMEOUTS from '../../../fixtures/timeouts';
describe('Collapsed Reply Threads', () => { describe('Collapsed Reply Threads', () => {
let testTeam; let testTeam: Team;
let testUser; let testUser: UserProfile;
let otherUser; let otherUser: UserProfile;
let testChannel; let testChannel: Channel;
let rootPost; let rootPost: PostMessageResp;
let postForAvatar; let postForAvatar: PostMessageResp;
before(() => { before(() => {
cy.apiUpdateConfig({ cy.apiUpdateConfig({

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

@@ -10,13 +10,16 @@
// Stage: @prod // Stage: @prod
// Group: @channels @collapsed_reply_threads // 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 * as TIMEOUTS from '../../../fixtures/timeouts';
describe('Collapsed Reply Threads', () => { describe('Collapsed Reply Threads', () => {
let testTeam; let testTeam: Team;
let testUser; let testUser: UserProfile;
let otherUser; let otherUser: UserProfile;
let testChannel; let testChannel: Channel;
before(() => { before(() => {
cy.apiUpdateConfig({ cy.apiUpdateConfig({

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

@@ -55,7 +55,8 @@ describe('Verify Guest User Identification in different screens', () => {
}); });
// # Deactivate Guest user // # 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 // # Switch channels away and back to reload the header
cy.get('.SidebarChannel:contains(Town Square)').click(); cy.get('.SidebarChannel:contains(Town Square)').click();

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

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

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

@@ -70,6 +70,7 @@ export const matterpollPlugin = {
id: 'com.github.matterpoll.matterpoll', id: 'com.github.matterpoll.matterpoll',
version: '1.5.0', version: '1.5.0',
url: 'https://github.com/matterpoll/matterpoll/releases/download/v1.5.0/com.github.matterpoll.matterpoll-1.5.0.tar.gz', 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 = { export const testPlugin = {