Skip to content

Commit 3d0b533

Browse files
test: fix channel flaky navigation (#40390)
1 parent 378e214 commit 3d0b533

9 files changed

Lines changed: 29 additions & 72 deletions

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

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,10 @@ test.describe.serial('emoji', () => {
1717
test.beforeEach(async ({ page }) => {
1818
poHomeChannel = new HomeChannel(page);
1919

20-
await page.goto('/home');
20+
await poHomeChannel.gotoChannel(targetChannel);
2121
});
2222

2323
test('should display emoji picker properly', async ({ page }) => {
24-
await poHomeChannel.navbar.openChat(targetChannel);
2524
await poHomeChannel.composer.btnEmoji.click();
2625

2726
await test.step('should display scroller', async () => {
@@ -37,7 +36,6 @@ test.describe.serial('emoji', () => {
3736
});
3837

3938
await test.step('should pick and send grinning emoji', async () => {
40-
await poHomeChannel.navbar.openChat(targetChannel);
4139
await poHomeChannel.pickEmoji('grinning');
4240
await page.keyboard.press('Enter');
4341

@@ -46,16 +44,13 @@ test.describe.serial('emoji', () => {
4644
});
4745

4846
test('expect send emoji via text', async ({ page }) => {
49-
await poHomeChannel.navbar.openChat(targetChannel);
5047
await poHomeChannel.content.sendMessage(':innocent:');
5148
await page.keyboard.press('Enter');
5249

5350
await expect(poHomeChannel.content.lastUserMessage).toContainText('😇');
5451
});
5552

5653
test('expect render special characters and numbers properly', async () => {
57-
await poHomeChannel.navbar.openChat(targetChannel);
58-
5954
await poHomeChannel.content.sendMessage('® © ™ # *');
6055
await expect(poHomeChannel.content.lastUserMessage).toContainText('® © ™ # *');
6156
});
@@ -79,7 +74,7 @@ test.describe.serial('emoji', () => {
7974
await poAdminEmoji.addEmojiFlexTab.save();
8075
await poAdminEmoji.sidebar.close();
8176

82-
await poHomeChannel.navbar.openChat(targetChannel);
77+
await poHomeChannel.gotoChannel(targetChannel);
8378

8479
await poHomeChannel.content.sendMessage(`:${emojiName}:`);
8580
await page.keyboard.press('Enter');
@@ -94,7 +89,7 @@ test.describe.serial('emoji', () => {
9489
await poAdminEmoji.editEmojiFlexTab.save();
9590
await poAdminEmoji.sidebar.close();
9691

97-
await poHomeChannel.navbar.openChat(targetChannel);
92+
await poHomeChannel.gotoChannel(targetChannel);
9893

9994
await poHomeChannel.content.sendMessage(`:${newEmojiName}:`);
10095
await page.keyboard.press('Enter');

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

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ test.describe('export-messages', () => {
2020
test.beforeEach(async ({ page }) => {
2121
poHomeChannel = new HomeChannel(page);
2222

23-
await page.goto('/home');
23+
await poHomeChannel.gotoChannel(targetChannel);
2424
});
2525

2626
test.afterAll(async ({ api }) => {
@@ -31,7 +31,6 @@ test.describe('export-messages', () => {
3131
});
3232

3333
test('should all export methods be available in targetChannel', async () => {
34-
await poHomeChannel.navbar.openChat(targetChannel);
3534
await poHomeChannel.roomToolbar.openMoreOptions();
3635
await poHomeChannel.roomToolbar.menuItemExportMessages.click();
3736

@@ -42,7 +41,6 @@ test.describe('export-messages', () => {
4241
});
4342

4443
test('should display export output format correctly depending on the selected method', async () => {
45-
await poHomeChannel.navbar.openChat(targetChannel);
4644
await poHomeChannel.roomToolbar.openMoreOptions();
4745
await poHomeChannel.roomToolbar.menuItemExportMessages.click();
4846

@@ -71,7 +69,6 @@ test.describe('export-messages', () => {
7169
test('when trying to send email without filling to users or to additional emails, should mark both fields as invalid', async () => {
7270
const testMessage = uniqueMessage();
7371

74-
await poHomeChannel.navbar.openChat(targetChannel);
7572
await poHomeChannel.content.sendMessage(testMessage);
7673
await poHomeChannel.roomToolbar.openMoreOptions();
7774
await poHomeChannel.roomToolbar.menuItemExportMessages.click();
@@ -94,7 +91,6 @@ test.describe('export-messages', () => {
9491
});
9592

9693
test('should display an error when trying to send email without selecting any message', async ({ page }) => {
97-
await poHomeChannel.navbar.openChat(targetChannel);
9894
await poHomeChannel.roomToolbar.openMoreOptions();
9995
await poHomeChannel.roomToolbar.menuItemExportMessages.click();
10096

@@ -112,7 +108,6 @@ test.describe('export-messages', () => {
112108
const message1 = uniqueMessage();
113109
const message2 = uniqueMessage();
114110

115-
await poHomeChannel.navbar.openChat(targetChannel);
116111
await poHomeChannel.content.sendMessage(message1);
117112
await poHomeChannel.roomToolbar.openMoreOptions();
118113
await poHomeChannel.roomToolbar.menuItemExportMessages.click();
@@ -128,7 +123,6 @@ test.describe('export-messages', () => {
128123
const message1 = uniqueMessage();
129124
const message2 = uniqueMessage();
130125

131-
await poHomeChannel.navbar.openChat(targetChannel);
132126
await poHomeChannel.content.sendMessage(message1);
133127
await poHomeChannel.content.sendMessage(message2);
134128

@@ -153,7 +147,6 @@ test.describe('export-messages', () => {
153147
const message1 = uniqueMessage();
154148
const message2 = uniqueMessage();
155149

156-
await poHomeChannel.navbar.openChat(targetChannel);
157150
await poHomeChannel.content.sendMessage(message1);
158151
await poHomeChannel.content.sendMessage(message2);
159152

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ test.describe.serial('files-management', () => {
1818
test.beforeEach(async ({ page }) => {
1919
poHomeChannel = new HomeChannel(page);
2020

21-
await page.goto('/home');
22-
await poHomeChannel.navbar.openChat(targetChannel);
21+
await poHomeChannel.gotoChannel(targetChannel);
2322
});
2423

2524
test.afterAll(async ({ api }) => {

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

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ test.describe.serial('message-actions', () => {
1919
});
2020
test.beforeEach(async ({ page }) => {
2121
poHomeChannel = new HomeChannel(page);
22-
await page.goto('/home');
23-
await poHomeChannel.navbar.openChat(targetChannel);
22+
await poHomeChannel.gotoChannel(targetChannel);
2423
});
2524

2625
test('expect reply the message', async ({ page }) => {
@@ -127,7 +126,7 @@ test.describe.serial('message-actions', () => {
127126
await createDiscussionModal.inputName.fill(discussionName);
128127
await createButton.click();
129128
await expect(page.locator('header h1')).toHaveText(discussionName);
130-
await poHomeChannel.navbar.openChat(targetChannel);
129+
await poHomeChannel.gotoChannel(targetChannel);
131130
// Should fail if more than one discussion has been created
132131
await expect(poHomeChannel.content.getMessageByText(discussionName)).toHaveCount(1);
133132
});
@@ -203,8 +202,7 @@ test.describe.serial('message-actions', () => {
203202
});
204203
test.beforeEach(async ({ page }) => {
205204
poHomeChannel = new HomeChannel(page);
206-
await page.goto('/home');
207-
await poHomeChannel.navbar.openChat(targetChannel);
205+
await poHomeChannel.gotoChannel(targetChannel);
208206
});
209207
test('expect reply the message in direct', async ({ page }) => {
210208
await poHomeChannel.content.sendMessage('this is a message for reply in direct');
@@ -220,7 +218,7 @@ test.describe.serial('message-actions', () => {
220218
await poHomeChannel.content.sendMessage(message);
221219
await poHomeChannel.content.forwardMessage(forwardChannel);
222220

223-
await poHomeChannel.navbar.openChat(forwardChannel);
221+
await poHomeChannel.gotoChannel(forwardChannel);
224222
await expect(poHomeChannel.content.lastUserMessage).toContainText(message);
225223
});
226224

@@ -253,7 +251,7 @@ test.describe.serial('message-actions', () => {
253251

254252
await poHomeChannel.content.forwardMessage(forwardChannel);
255253

256-
await poHomeChannel.navbar.openChat(forwardChannel);
254+
await poHomeChannel.gotoChannel(forwardChannel);
257255
await expect(poHomeChannel.content.lastUserMessage).toContainText(filename);
258256
});
259257

@@ -265,7 +263,7 @@ test.describe.serial('message-actions', () => {
265263

266264
await poHomeChannel.content.forwardMessage(forwardChannel);
267265

268-
await poHomeChannel.navbar.openChat(forwardChannel);
266+
await poHomeChannel.gotoChannel(forwardChannel);
269267
await expect(poHomeChannel.content.lastUserMessage).toContainText(filename);
270268
});
271269

@@ -277,7 +275,7 @@ test.describe.serial('message-actions', () => {
277275

278276
await poHomeChannel.content.forwardMessage(forwardChannel);
279277

280-
await poHomeChannel.navbar.openChat(forwardChannel);
278+
await poHomeChannel.gotoChannel(forwardChannel);
281279
await expect(poHomeChannel.content.lastUserMessage).toContainText(filename);
282280
});
283281

@@ -289,7 +287,7 @@ test.describe.serial('message-actions', () => {
289287

290288
await poHomeChannel.content.forwardMessage(forwardChannel);
291289

292-
await poHomeChannel.navbar.openChat(forwardChannel);
290+
await poHomeChannel.gotoChannel(forwardChannel);
293291
await expect(poHomeChannel.content.lastUserMessage).toContainText(filename);
294292
});
295293

@@ -301,7 +299,7 @@ test.describe.serial('message-actions', () => {
301299

302300
await poHomeChannel.content.forwardMessage(forwardChannel);
303301

304-
await poHomeChannel.navbar.openChat(forwardChannel);
302+
await poHomeChannel.gotoChannel(forwardChannel);
305303
await expect(poHomeChannel.content.lastUserMessage).toContainText(filename);
306304
});
307305
});

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

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,22 @@ test.describe.serial('message-composer', () => {
1818
test.beforeEach(async ({ page }) => {
1919
poHomeChannel = new HomeChannel(page);
2020

21-
await page.goto('/home');
21+
await poHomeChannel.gotoChannel(targetChannel);
2222
});
2323

2424
test('should have all formatters and the main actions visible on toolbar', async () => {
25-
await poHomeChannel.navbar.openChat(targetChannel);
2625
await poHomeChannel.content.sendMessage('hello composer');
2726

2827
await expect(poHomeChannel.composer.allPrimaryActions).toHaveCount(12);
2928
});
3029

3130
test('should have only the main formatter and the main action', async ({ page }) => {
3231
await page.setViewportSize({ width: 768, height: 600 });
33-
await poHomeChannel.navbar.openChat(targetChannel);
3432

3533
await expect(poHomeChannel.composer.allPrimaryActions).toHaveCount(6);
3634
});
3735

3836
test('should navigate on toolbar using arrow keys', async ({ page }) => {
39-
await poHomeChannel.navbar.openChat(targetChannel);
40-
4137
await page.keyboard.press('Tab');
4238
await page.keyboard.press('ArrowRight');
4339
await page.keyboard.press('ArrowRight');
@@ -48,8 +44,6 @@ test.describe.serial('message-composer', () => {
4844
});
4945

5046
test('should move the focus away from toolbar using tab key', async ({ page }) => {
51-
await poHomeChannel.navbar.openChat(targetChannel);
52-
5347
await page.keyboard.press('Tab');
5448
await page.keyboard.press('Tab');
5549

@@ -58,7 +52,6 @@ test.describe.serial('message-composer', () => {
5852

5953
test('should add a link to the selected text', async ({ page }) => {
6054
const url = faker.internet.url();
61-
await poHomeChannel.navbar.openChat(targetChannel);
6255

6356
await page.keyboard.type('hello composer');
6457
await page.keyboard.press('Control+A'); // on Windows and Linux
@@ -71,7 +64,6 @@ test.describe.serial('message-composer', () => {
7164
});
7265

7366
test('should select popup item and not send the message when pressing enter', async ({ page }) => {
74-
await poHomeChannel.navbar.openChat(targetChannel);
7567
await poHomeChannel.content.sendMessage('hello composer');
7668

7769
await test.step('mention popup', async () => {
@@ -106,7 +98,6 @@ test.describe.serial('message-composer', () => {
10698
});
10799

108100
test('should list popup items correctly', async ({ page }) => {
109-
await poHomeChannel.navbar.openChat(targetChannel);
110101
await poHomeChannel.content.sendMessage('hello composer');
111102

112103
await test.step('mention popup', async () => {
@@ -117,7 +108,6 @@ test.describe.serial('message-composer', () => {
117108
});
118109

119110
test('should close mention popup when canceling a message edit via "Cancel" button', async ({ page }) => {
120-
await poHomeChannel.navbar.openChat(targetChannel);
121111
await poHomeChannel.content.sendMessage('hello composer');
122112

123113
await test.step('expect to edit last message', async () => {
@@ -145,7 +135,6 @@ test.describe.serial('message-composer', () => {
145135
});
146136

147137
test('should close mention popup when canceling a message edit via keyboard', async ({ page }) => {
148-
await poHomeChannel.navbar.openChat(targetChannel);
149138
await poHomeChannel.content.sendMessage('hello composer');
150139

151140
await test.step('expect to edit last message', async () => {
@@ -174,8 +163,6 @@ test.describe.serial('message-composer', () => {
174163

175164
test.describe('audio recorder', () => {
176165
test('should open audio recorder', async () => {
177-
await poHomeChannel.navbar.openChat(targetChannel);
178-
179166
await test.step('should be able to record an audio with text content in composer ', async () => {
180167
await poHomeChannel.composer.inputMessage.fill('this is a message with audio message');
181168
await expect(poHomeChannel.composer.btnAudioMessage).toBeEnabled();
@@ -186,7 +173,6 @@ test.describe.serial('message-composer', () => {
186173
});
187174

188175
test('should stop recording when clicking on cancel', async () => {
189-
await poHomeChannel.navbar.openChat(targetChannel);
190176
await poHomeChannel.composer.btnAudioMessage.click();
191177
await expect(poHomeChannel.audioRecorder).toBeVisible();
192178

@@ -195,7 +181,6 @@ test.describe.serial('message-composer', () => {
195181
});
196182

197183
test('should attach file to the composer when clicking on "Finish recording"', async ({ page }) => {
198-
await poHomeChannel.navbar.openChat(targetChannel);
199184
await poHomeChannel.composer.btnAudioMessage.click();
200185
await expect(poHomeChannel.audioRecorder).toBeVisible();
201186

apps/meteor/tests/e2e/page-objects/home-channel.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,11 @@ export class HomeChannel {
9696
return this.page.goto('/home');
9797
}
9898

99+
async gotoChannel(name: string) {
100+
await this.page.goto(`/channel/${name}`);
101+
await this.content.waitForChannel();
102+
}
103+
99104
get btnContextualbarClose(): Locator {
100105
return this.page.locator('[data-qa="ContextualbarActionClose"]');
101106
}

apps/meteor/tests/e2e/read-receipts.spec.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,11 @@ test.describe.serial('read-receipts', () => {
2222
test.beforeEach(async ({ page }) => {
2323
poHomeChannel = new HomeChannel(page);
2424

25-
await page.goto('/home');
25+
await poHomeChannel.gotoChannel(targetChannel);
2626
});
2727

2828
test.describe('read receipt settings disabled', async () => {
2929
test('should not show read receipts item menu', async ({ page }) => {
30-
await poHomeChannel.navbar.openChat(targetChannel);
3130
await poHomeChannel.content.sendMessage('hello world');
3231
await poHomeChannel.content.openLastMessageMenu();
3332
await expect(page.locator('role=menuitem[name="Read receipts"]')).not.toBeVisible();
@@ -57,19 +56,17 @@ test.describe.serial('read-receipts', () => {
5756
test('should show read receipts message sent status in the sent message', async ({ browser }) => {
5857
const { page } = await createAuxContext(browser, Users.user1);
5958
auxContext = { page, poHomeChannel: new HomeChannel(page) };
60-
await auxContext.poHomeChannel.navbar.openChat(targetChannel);
59+
await auxContext.poHomeChannel.gotoChannel(targetChannel);
6160
await auxContext.poHomeChannel.content.sendMessage('hello admin');
6261

6362
await expect(auxContext.poHomeChannel.content.lastUserMessage.getByRole('status', { name: 'Message sent' })).toBeVisible();
6463
});
6564

6665
test('should show read receipts message viewed status in the sent message', async () => {
67-
await poHomeChannel.navbar.openChat(targetChannel);
6866
await expect(poHomeChannel.content.lastUserMessage.getByRole('status', { name: 'Message viewed' })).toBeVisible();
6967
});
7068

7169
test('should show the reads receipt modal with the users who read the message', async ({ page }) => {
72-
await poHomeChannel.navbar.openChat(targetChannel);
7370
await poHomeChannel.content.openLastMessageMenu();
7471
await page.locator('role=menuitem[name="Read receipts"]').click();
7572

0 commit comments

Comments
 (0)