Skip to content

Commit 02b00d1

Browse files
authored
test: Flaky expect star the thread message (RocketChat#39615)
1 parent f960b38 commit 02b00d1

7 files changed

Lines changed: 31 additions & 31 deletions

File tree

apps/meteor/tests/e2e/e2e-encryption/e2ee-encrypted-channels.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ test.describe('E2EE Encrypted Channels', () => {
102102
await poHomeChannel.content.toggleAlsoSendThreadToChannel(true);
103103
await page.getByRole('dialog').locator('[name="msg"]').last().fill('This is an encrypted thread message also sent in channel');
104104
await page.keyboard.press('Enter');
105-
await expect(poHomeChannel.content.lastThreadMessageText).toContainText('This is an encrypted thread message also sent in channel');
106-
await expect(poHomeChannel.content.lastThreadMessageText.locator('.rcx-icon--name-key')).toBeVisible();
105+
await expect(poHomeChannel.content.lastUserThreadMessage).toContainText('This is an encrypted thread message also sent in channel');
106+
await expect(poHomeChannel.content.lastUserThreadMessage.locator('.rcx-icon--name-key')).toBeVisible();
107107
await expect(poHomeChannel.content.lastThreadMessagePreview).toContainText('This is an encrypted thread message also sent in channel');
108108
await expect(poHomeChannel.content.mainThreadMessageText).toContainText('This is the thread main message.');
109109
await expect(poHomeChannel.content.mainThreadMessageText.locator('.rcx-icon--name-key')).toBeVisible();

apps/meteor/tests/e2e/message-actions.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ test.describe.serial('message-actions', () => {
3838
await page.locator('.rcx-vertical-bar').locator(`role=textbox[name="Message #${targetChannel}"]`).type('this is a reply message');
3939
await page.keyboard.press('Enter');
4040

41-
await expect(poHomeChannel.content.lastThreadMessageText).toHaveText('this is a reply message');
41+
await expect(poHomeChannel.content.lastUserThreadMessage).toHaveText('this is a reply message');
4242
});
4343

4444
// with thread open we listen to the subscription and update the collection from there
@@ -48,7 +48,7 @@ test.describe.serial('message-actions', () => {
4848
await poHomeChannel.content.openReplyInThread();
4949
await page.getByRole('dialog').locator(`role=textbox[name="Message #${targetChannel}"]`).fill('this is a reply message');
5050
await page.keyboard.press('Enter');
51-
await expect(poHomeChannel.content.lastThreadMessageText).toHaveText('this is a reply message');
51+
await expect(poHomeChannel.content.lastUserThreadMessage).toHaveText('this is a reply message');
5252
});
5353

5454
await test.step('unfollow thread', async () => {
@@ -73,7 +73,7 @@ test.describe.serial('message-actions', () => {
7373
await poHomeChannel.content.openReplyInThread();
7474
await page.locator('.rcx-vertical-bar').locator(`role=textbox[name="Message #${targetChannel}"]`).fill('this is a reply message');
7575
await page.keyboard.press('Enter');
76-
await expect(poHomeChannel.content.lastThreadMessageText).toHaveText('this is a reply message');
76+
await expect(poHomeChannel.content.lastUserThreadMessage).toHaveText('this is a reply message');
7777
});
7878

7979
// close thread before testing because the behavior changes

apps/meteor/tests/e2e/page-objects/fragments/home-content.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ export class HomeContent {
6565
return this.messageListItems.last();
6666
}
6767

68+
get lastUserThreadMessage(): Locator {
69+
return this.threadMessageListItems.last();
70+
}
71+
6872
get lastThreadMessagePreview(): Locator {
6973
return this.page.getByRole('listitem').locator('[role="link"][aria-roledescription="thread message preview"]').last();
7074
}
@@ -269,10 +273,6 @@ export class HomeContent {
269273
return this.threadMessageListItems.first();
270274
}
271275

272-
get lastThreadMessageText(): Locator {
273-
return this.threadMessageListItems.last();
274-
}
275-
276276
get lastThreadMessagePreviewText(): Locator {
277277
return this.page.locator('div.messages-box ul.messages-list [role=link]').last();
278278
}
@@ -417,9 +417,9 @@ export class HomeContent {
417417
}
418418

419419
async openLastThreadMessageMenu(): Promise<void> {
420-
await this.threadMessageList.last().hover();
421-
await this.threadMessageList.last().getByRole('button', { name: 'More', exact: true }).waitFor();
422-
await this.threadMessageList.last().getByRole('button', { name: 'More', exact: true }).click();
420+
await this.lastUserThreadMessage.hover();
421+
await this.lastUserThreadMessage.getByRole('button', { name: 'More', exact: true }).waitFor();
422+
await this.lastUserThreadMessage.getByRole('button', { name: 'More', exact: true }).click();
423423
}
424424

425425
async toggleAlsoSendThreadToChannel(isChecked: boolean): Promise<void> {

apps/meteor/tests/e2e/quote-attachment.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ test.describe.parallel('Quote Attachment', () => {
8080
});
8181

8282
await test.step('Quote the message with attachment in thread', async () => {
83-
await poHomeChannel.content.lastThreadMessageText.hover();
83+
await poHomeChannel.content.lastUserThreadMessage.hover();
8484
await poHomeChannel.content.btnQuoteMessage.click();
8585

8686
// Verify the quote preview shows both file and description
@@ -94,10 +94,10 @@ test.describe.parallel('Quote Attachment', () => {
9494
});
9595

9696
await test.step('Verify the quoted message appears correctly in thread', async () => {
97-
await expect(poHomeChannel.content.lastThreadMessageText).toBeVisible();
97+
await expect(poHomeChannel.content.lastUserThreadMessage).toBeVisible();
9898
await expect(poHomeChannel.content.threadMessageQuotedFileDescription(fileDescription)).toBeVisible();
9999
await expect(poHomeChannel.content.threadMessageQuotedFileName(textFileName)).toBeVisible();
100-
await expect(poHomeChannel.content.lastThreadMessageText).toContainText(threadQuoteMessage);
100+
await expect(poHomeChannel.content.lastUserThreadMessage).toContainText(threadQuoteMessage);
101101
});
102102
});
103103

apps/meteor/tests/e2e/quote-messages.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -216,21 +216,21 @@ test.describe.serial('Quote Messages', () => {
216216
await poHomeChannel.content.openReplyInThread();
217217
await expect(page).toHaveURL(/.*thread/);
218218
await poHomeChannel.content.sendMessageInThread(threadMessage);
219-
await expect(poHomeChannel.content.lastThreadMessageText).toContainText(threadMessage);
219+
await expect(poHomeChannel.content.lastUserThreadMessage).toContainText(threadMessage);
220220
});
221221

222222
await test.step('Quote message in DM thread', async () => {
223-
await poHomeChannel.content.lastThreadMessageText.hover();
223+
await poHomeChannel.content.lastUserThreadMessage.hover();
224224
await poHomeChannel.content.btnQuoteMessage.click();
225225
await expect(poHomeChannel.content.threadQuotePreview).toBeVisible();
226226
await expect(poHomeChannel.content.threadQuotePreview).toContainText(threadMessage);
227227
await poHomeChannel.content.sendMessageInThread(quoteText);
228228
});
229229

230230
await test.step('Verify quoted message appears in DM thread', async () => {
231-
await expect(poHomeChannel.content.lastThreadMessageText).toBeVisible();
232-
await expect(poHomeChannel.content.lastThreadMessageText.locator('blockquote')).toBeVisible();
233-
await expect(poHomeChannel.content.lastThreadMessageText).toContainText(quoteText);
231+
await expect(poHomeChannel.content.lastUserThreadMessage).toBeVisible();
232+
await expect(poHomeChannel.content.lastUserThreadMessage.locator('blockquote')).toBeVisible();
233+
await expect(poHomeChannel.content.lastUserThreadMessage).toContainText(quoteText);
234234
});
235235
});
236236
});

apps/meteor/tests/e2e/team-management.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ test.describe.serial('teams-management', () => {
149149
await poHomeTeam.content.openReplyInThread();
150150
await page.locator('.rcx-vertical-bar').locator(`role=textbox[name="Message #${targetTeam}"]`).type('any-reply-message');
151151
await page.keyboard.press('Enter');
152-
await expect(poHomeTeam.content.lastThreadMessageText).toHaveText('any-reply-message');
152+
await expect(poHomeTeam.content.lastUserThreadMessage).toHaveText('any-reply-message');
153153
});
154154

155155
test('should set targetTeam as readonly', async () => {

apps/meteor/tests/e2e/threads.spec.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ test.describe.serial('Threads', () => {
3636
await poHomeChannel.content.toggleAlsoSendThreadToChannel(true);
3737
await page.getByRole('dialog').locator('[name="msg"]').last().fill('This is a thread message also sent in channel');
3838
await page.keyboard.press('Enter');
39-
await expect(poHomeChannel.content.lastThreadMessageText).toContainText('This is a thread message also sent in channel');
39+
await expect(poHomeChannel.content.lastUserThreadMessage).toContainText('This is a thread message also sent in channel');
4040
await expect(poHomeChannel.content.lastThreadMessagePreview).toContainText('This is a thread message also sent in channel');
4141
});
4242
test('expect open threads contextual bar when clicked on thread preview', async ({ page }) => {
4343
await poHomeChannel.content.lastThreadMessagePreviewText.click();
4444
await expect(page).toHaveURL(/.*thread/);
45-
await expect(poHomeChannel.content.lastThreadMessageText).toContainText('This is a thread message also sent in channel');
45+
await expect(poHomeChannel.content.lastUserThreadMessage).toContainText('This is a thread message also sent in channel');
4646
});
4747
test.describe('hideFlexTab Preference enabled for threads', () => {
4848
test.beforeAll(async ({ api }) => {
@@ -64,18 +64,18 @@ test.describe.serial('Threads', () => {
6464
test('expect open threads contextual bar when clicked on thread preview', async ({ page }) => {
6565
await poHomeChannel.content.lastThreadMessagePreviewText.click();
6666
await expect(page).toHaveURL(/.*thread/);
67-
await expect(poHomeChannel.content.lastThreadMessageText).toContainText('This is a thread message also sent in channel');
67+
await expect(poHomeChannel.content.lastUserThreadMessage).toContainText('This is a thread message also sent in channel');
6868
});
6969
test('expect not to close thread contextual bar when performing some action', async ({ page }) => {
7070
await poHomeChannel.content.lastThreadMessagePreviewText.click();
7171
await expect(page).toHaveURL(/.*thread/);
72-
await expect(poHomeChannel.content.lastThreadMessageText).toContainText('This is a thread message also sent in channel');
72+
await expect(poHomeChannel.content.lastUserThreadMessage).toContainText('This is a thread message also sent in channel');
7373

7474
await poHomeChannel.content.openLastThreadMessageMenu();
7575
await page.locator('role=menuitem[name="Copy text"]').click();
7676

7777
await expect(page).toHaveURL(/.*thread/);
78-
await expect(poHomeChannel.content.lastThreadMessageText).toContainText('This is a thread message also sent in channel');
78+
await expect(poHomeChannel.content.lastUserThreadMessage).toContainText('This is a thread message also sent in channel');
7979
});
8080
});
8181
test('expect upload a file attachment in thread with description', async ({ page }) => {
@@ -131,8 +131,8 @@ test.describe.serial('Threads', () => {
131131
});
132132

133133
test('expect quote the thread message', async ({ page }) => {
134-
await poHomeChannel.content.lastThreadMessageText.hover();
135-
await poHomeChannel.content.lastThreadMessageText.getByRole('button', { name: 'Quote' }).click();
134+
await poHomeChannel.content.lastUserThreadMessage.hover();
135+
await poHomeChannel.content.lastUserThreadMessage.getByRole('button', { name: 'Quote' }).click();
136136
await page.locator('[name="msg"]').last().fill('this is a quote message');
137137
await page.keyboard.press('Enter');
138138

@@ -168,15 +168,15 @@ test.describe.serial('Threads', () => {
168168

169169
test('expect close thread if has only one message and user press escape', async ({ page }) => {
170170
await expect(page).toHaveURL(/.*thread/);
171-
await expect(poHomeChannel.content.lastThreadMessageText).toBeVisible();
171+
await expect(poHomeChannel.content.lastUserThreadMessage).toBeVisible();
172172
await expect(page.locator('[name="msg"]').last()).toBeFocused();
173173
await page.keyboard.press('Escape');
174174
await expect(page).not.toHaveURL(/.*thread/);
175175
});
176176

177177
test('expect reset the thread composer to original message if user presses escape', async ({ page }) => {
178178
await expect(page).toHaveURL(/.*thread/);
179-
await expect(poHomeChannel.content.lastThreadMessageText).toBeVisible();
179+
await expect(poHomeChannel.content.lastUserThreadMessage).toBeVisible();
180180

181181
await expect(page.locator('[name="msg"]').last()).toBeFocused();
182182
await page.locator('[name="msg"]').last().fill('message to be edited');
@@ -193,7 +193,7 @@ test.describe.serial('Threads', () => {
193193

194194
test('expect clean composer and keep the thread open if user is editing message and presses escape', async ({ page }) => {
195195
await expect(page).toHaveURL(/.*thread/);
196-
await expect(poHomeChannel.content.lastThreadMessageText).toBeVisible();
196+
await expect(poHomeChannel.content.lastUserThreadMessage).toBeVisible();
197197
await expect(page.locator('[name="msg"]').last()).toBeFocused();
198198

199199
await page.locator('[name="msg"]').last().fill('message to be edited');

0 commit comments

Comments
 (0)