diff --git a/apps/meteor/tests/e2e/emojis.spec.ts b/apps/meteor/tests/e2e/emojis.spec.ts index 6f0c99284c525..b14b0986a720b 100644 --- a/apps/meteor/tests/e2e/emojis.spec.ts +++ b/apps/meteor/tests/e2e/emojis.spec.ts @@ -17,11 +17,10 @@ test.describe.serial('emoji', () => { test.beforeEach(async ({ page }) => { poHomeChannel = new HomeChannel(page); - await page.goto('/home'); + await poHomeChannel.gotoChannel(targetChannel); }); test('should display emoji picker properly', async ({ page }) => { - await poHomeChannel.navbar.openChat(targetChannel); await poHomeChannel.composer.btnEmoji.click(); await test.step('should display scroller', async () => { @@ -37,7 +36,6 @@ test.describe.serial('emoji', () => { }); await test.step('should pick and send grinning emoji', async () => { - await poHomeChannel.navbar.openChat(targetChannel); await poHomeChannel.pickEmoji('grinning'); await page.keyboard.press('Enter'); @@ -46,7 +44,6 @@ test.describe.serial('emoji', () => { }); test('expect send emoji via text', async ({ page }) => { - await poHomeChannel.navbar.openChat(targetChannel); await poHomeChannel.content.sendMessage(':innocent:'); await page.keyboard.press('Enter'); @@ -54,8 +51,6 @@ test.describe.serial('emoji', () => { }); test('expect render special characters and numbers properly', async () => { - await poHomeChannel.navbar.openChat(targetChannel); - await poHomeChannel.content.sendMessage('® © ™ # *'); await expect(poHomeChannel.content.lastUserMessage).toContainText('® © ™ # *'); }); @@ -79,7 +74,7 @@ test.describe.serial('emoji', () => { await poAdminEmoji.addEmojiFlexTab.save(); await poAdminEmoji.sidebar.close(); - await poHomeChannel.navbar.openChat(targetChannel); + await poHomeChannel.gotoChannel(targetChannel); await poHomeChannel.content.sendMessage(`:${emojiName}:`); await page.keyboard.press('Enter'); @@ -94,7 +89,7 @@ test.describe.serial('emoji', () => { await poAdminEmoji.editEmojiFlexTab.save(); await poAdminEmoji.sidebar.close(); - await poHomeChannel.navbar.openChat(targetChannel); + await poHomeChannel.gotoChannel(targetChannel); await poHomeChannel.content.sendMessage(`:${newEmojiName}:`); await page.keyboard.press('Enter'); diff --git a/apps/meteor/tests/e2e/export-messages.spec.ts b/apps/meteor/tests/e2e/export-messages.spec.ts index eb5c5f5fa474b..faf25d830667e 100644 --- a/apps/meteor/tests/e2e/export-messages.spec.ts +++ b/apps/meteor/tests/e2e/export-messages.spec.ts @@ -20,7 +20,7 @@ test.describe('export-messages', () => { test.beforeEach(async ({ page }) => { poHomeChannel = new HomeChannel(page); - await page.goto('/home'); + await poHomeChannel.gotoChannel(targetChannel); }); test.afterAll(async ({ api }) => { @@ -31,7 +31,6 @@ test.describe('export-messages', () => { }); test('should all export methods be available in targetChannel', async () => { - await poHomeChannel.navbar.openChat(targetChannel); await poHomeChannel.roomToolbar.openMoreOptions(); await poHomeChannel.roomToolbar.menuItemExportMessages.click(); @@ -42,7 +41,6 @@ test.describe('export-messages', () => { }); test('should display export output format correctly depending on the selected method', async () => { - await poHomeChannel.navbar.openChat(targetChannel); await poHomeChannel.roomToolbar.openMoreOptions(); await poHomeChannel.roomToolbar.menuItemExportMessages.click(); @@ -71,7 +69,6 @@ test.describe('export-messages', () => { test('when trying to send email without filling to users or to additional emails, should mark both fields as invalid', async () => { const testMessage = uniqueMessage(); - await poHomeChannel.navbar.openChat(targetChannel); await poHomeChannel.content.sendMessage(testMessage); await poHomeChannel.roomToolbar.openMoreOptions(); await poHomeChannel.roomToolbar.menuItemExportMessages.click(); @@ -94,7 +91,6 @@ test.describe('export-messages', () => { }); test('should display an error when trying to send email without selecting any message', async ({ page }) => { - await poHomeChannel.navbar.openChat(targetChannel); await poHomeChannel.roomToolbar.openMoreOptions(); await poHomeChannel.roomToolbar.menuItemExportMessages.click(); @@ -112,7 +108,6 @@ test.describe('export-messages', () => { const message1 = uniqueMessage(); const message2 = uniqueMessage(); - await poHomeChannel.navbar.openChat(targetChannel); await poHomeChannel.content.sendMessage(message1); await poHomeChannel.roomToolbar.openMoreOptions(); await poHomeChannel.roomToolbar.menuItemExportMessages.click(); @@ -128,7 +123,6 @@ test.describe('export-messages', () => { const message1 = uniqueMessage(); const message2 = uniqueMessage(); - await poHomeChannel.navbar.openChat(targetChannel); await poHomeChannel.content.sendMessage(message1); await poHomeChannel.content.sendMessage(message2); @@ -153,7 +147,6 @@ test.describe('export-messages', () => { const message1 = uniqueMessage(); const message2 = uniqueMessage(); - await poHomeChannel.navbar.openChat(targetChannel); await poHomeChannel.content.sendMessage(message1); await poHomeChannel.content.sendMessage(message2); diff --git a/apps/meteor/tests/e2e/files-management.spec.ts b/apps/meteor/tests/e2e/files-management.spec.ts index 55d9e41dcb172..5b37ec4fb061c 100644 --- a/apps/meteor/tests/e2e/files-management.spec.ts +++ b/apps/meteor/tests/e2e/files-management.spec.ts @@ -18,8 +18,7 @@ test.describe.serial('files-management', () => { test.beforeEach(async ({ page }) => { poHomeChannel = new HomeChannel(page); - await page.goto('/home'); - await poHomeChannel.navbar.openChat(targetChannel); + await poHomeChannel.gotoChannel(targetChannel); }); test.afterAll(async ({ api }) => { diff --git a/apps/meteor/tests/e2e/message-actions.spec.ts b/apps/meteor/tests/e2e/message-actions.spec.ts index 0561ba13e136d..26ec840ee0b30 100644 --- a/apps/meteor/tests/e2e/message-actions.spec.ts +++ b/apps/meteor/tests/e2e/message-actions.spec.ts @@ -19,8 +19,7 @@ test.describe.serial('message-actions', () => { }); test.beforeEach(async ({ page }) => { poHomeChannel = new HomeChannel(page); - await page.goto('/home'); - await poHomeChannel.navbar.openChat(targetChannel); + await poHomeChannel.gotoChannel(targetChannel); }); test('expect reply the message', async ({ page }) => { @@ -127,7 +126,7 @@ test.describe.serial('message-actions', () => { await createDiscussionModal.inputName.fill(discussionName); await createButton.click(); await expect(page.locator('header h1')).toHaveText(discussionName); - await poHomeChannel.navbar.openChat(targetChannel); + await poHomeChannel.gotoChannel(targetChannel); // Should fail if more than one discussion has been created await expect(poHomeChannel.content.getMessageByText(discussionName)).toHaveCount(1); }); @@ -203,8 +202,7 @@ test.describe.serial('message-actions', () => { }); test.beforeEach(async ({ page }) => { poHomeChannel = new HomeChannel(page); - await page.goto('/home'); - await poHomeChannel.navbar.openChat(targetChannel); + await poHomeChannel.gotoChannel(targetChannel); }); test('expect reply the message in direct', async ({ page }) => { await poHomeChannel.content.sendMessage('this is a message for reply in direct'); @@ -220,7 +218,7 @@ test.describe.serial('message-actions', () => { await poHomeChannel.content.sendMessage(message); await poHomeChannel.content.forwardMessage(forwardChannel); - await poHomeChannel.navbar.openChat(forwardChannel); + await poHomeChannel.gotoChannel(forwardChannel); await expect(poHomeChannel.content.lastUserMessage).toContainText(message); }); @@ -253,7 +251,7 @@ test.describe.serial('message-actions', () => { await poHomeChannel.content.forwardMessage(forwardChannel); - await poHomeChannel.navbar.openChat(forwardChannel); + await poHomeChannel.gotoChannel(forwardChannel); await expect(poHomeChannel.content.lastUserMessage).toContainText(filename); }); @@ -265,7 +263,7 @@ test.describe.serial('message-actions', () => { await poHomeChannel.content.forwardMessage(forwardChannel); - await poHomeChannel.navbar.openChat(forwardChannel); + await poHomeChannel.gotoChannel(forwardChannel); await expect(poHomeChannel.content.lastUserMessage).toContainText(filename); }); @@ -277,7 +275,7 @@ test.describe.serial('message-actions', () => { await poHomeChannel.content.forwardMessage(forwardChannel); - await poHomeChannel.navbar.openChat(forwardChannel); + await poHomeChannel.gotoChannel(forwardChannel); await expect(poHomeChannel.content.lastUserMessage).toContainText(filename); }); @@ -289,7 +287,7 @@ test.describe.serial('message-actions', () => { await poHomeChannel.content.forwardMessage(forwardChannel); - await poHomeChannel.navbar.openChat(forwardChannel); + await poHomeChannel.gotoChannel(forwardChannel); await expect(poHomeChannel.content.lastUserMessage).toContainText(filename); }); @@ -301,7 +299,7 @@ test.describe.serial('message-actions', () => { await poHomeChannel.content.forwardMessage(forwardChannel); - await poHomeChannel.navbar.openChat(forwardChannel); + await poHomeChannel.gotoChannel(forwardChannel); await expect(poHomeChannel.content.lastUserMessage).toContainText(filename); }); }); diff --git a/apps/meteor/tests/e2e/message-composer.spec.ts b/apps/meteor/tests/e2e/message-composer.spec.ts index a36a6afd7a290..7af3095ed04e4 100644 --- a/apps/meteor/tests/e2e/message-composer.spec.ts +++ b/apps/meteor/tests/e2e/message-composer.spec.ts @@ -18,11 +18,10 @@ test.describe.serial('message-composer', () => { test.beforeEach(async ({ page }) => { poHomeChannel = new HomeChannel(page); - await page.goto('/home'); + await poHomeChannel.gotoChannel(targetChannel); }); test('should have all formatters and the main actions visible on toolbar', async () => { - await poHomeChannel.navbar.openChat(targetChannel); await poHomeChannel.content.sendMessage('hello composer'); await expect(poHomeChannel.composer.allPrimaryActions).toHaveCount(12); @@ -30,14 +29,11 @@ test.describe.serial('message-composer', () => { test('should have only the main formatter and the main action', async ({ page }) => { await page.setViewportSize({ width: 768, height: 600 }); - await poHomeChannel.navbar.openChat(targetChannel); await expect(poHomeChannel.composer.allPrimaryActions).toHaveCount(6); }); test('should navigate on toolbar using arrow keys', async ({ page }) => { - await poHomeChannel.navbar.openChat(targetChannel); - await page.keyboard.press('Tab'); await page.keyboard.press('ArrowRight'); await page.keyboard.press('ArrowRight'); @@ -48,8 +44,6 @@ test.describe.serial('message-composer', () => { }); test('should move the focus away from toolbar using tab key', async ({ page }) => { - await poHomeChannel.navbar.openChat(targetChannel); - await page.keyboard.press('Tab'); await page.keyboard.press('Tab'); @@ -58,7 +52,6 @@ test.describe.serial('message-composer', () => { test('should add a link to the selected text', async ({ page }) => { const url = faker.internet.url(); - await poHomeChannel.navbar.openChat(targetChannel); await page.keyboard.type('hello composer'); await page.keyboard.press('Control+A'); // on Windows and Linux @@ -71,7 +64,6 @@ test.describe.serial('message-composer', () => { }); test('should select popup item and not send the message when pressing enter', async ({ page }) => { - await poHomeChannel.navbar.openChat(targetChannel); await poHomeChannel.content.sendMessage('hello composer'); await test.step('mention popup', async () => { @@ -106,7 +98,6 @@ test.describe.serial('message-composer', () => { }); test('should list popup items correctly', async ({ page }) => { - await poHomeChannel.navbar.openChat(targetChannel); await poHomeChannel.content.sendMessage('hello composer'); await test.step('mention popup', async () => { @@ -117,7 +108,6 @@ test.describe.serial('message-composer', () => { }); test('should close mention popup when canceling a message edit via "Cancel" button', async ({ page }) => { - await poHomeChannel.navbar.openChat(targetChannel); await poHomeChannel.content.sendMessage('hello composer'); await test.step('expect to edit last message', async () => { @@ -145,7 +135,6 @@ test.describe.serial('message-composer', () => { }); test('should close mention popup when canceling a message edit via keyboard', async ({ page }) => { - await poHomeChannel.navbar.openChat(targetChannel); await poHomeChannel.content.sendMessage('hello composer'); await test.step('expect to edit last message', async () => { @@ -174,8 +163,6 @@ test.describe.serial('message-composer', () => { test.describe('audio recorder', () => { test('should open audio recorder', async () => { - await poHomeChannel.navbar.openChat(targetChannel); - await test.step('should be able to record an audio with text content in composer ', async () => { await poHomeChannel.composer.inputMessage.fill('this is a message with audio message'); await expect(poHomeChannel.composer.btnAudioMessage).toBeEnabled(); @@ -186,7 +173,6 @@ test.describe.serial('message-composer', () => { }); test('should stop recording when clicking on cancel', async () => { - await poHomeChannel.navbar.openChat(targetChannel); await poHomeChannel.composer.btnAudioMessage.click(); await expect(poHomeChannel.audioRecorder).toBeVisible(); @@ -195,7 +181,6 @@ test.describe.serial('message-composer', () => { }); test('should attach file to the composer when clicking on "Finish recording"', async ({ page }) => { - await poHomeChannel.navbar.openChat(targetChannel); await poHomeChannel.composer.btnAudioMessage.click(); await expect(poHomeChannel.audioRecorder).toBeVisible(); diff --git a/apps/meteor/tests/e2e/page-objects/home-channel.ts b/apps/meteor/tests/e2e/page-objects/home-channel.ts index 523b7e0996899..bc44a80dba5f7 100644 --- a/apps/meteor/tests/e2e/page-objects/home-channel.ts +++ b/apps/meteor/tests/e2e/page-objects/home-channel.ts @@ -96,6 +96,11 @@ export class HomeChannel { return this.page.goto('/home'); } + async gotoChannel(name: string) { + await this.page.goto(`/channel/${name}`); + await this.content.waitForChannel(); + } + get btnContextualbarClose(): Locator { return this.page.locator('[data-qa="ContextualbarActionClose"]'); } diff --git a/apps/meteor/tests/e2e/read-receipts.spec.ts b/apps/meteor/tests/e2e/read-receipts.spec.ts index fbd091860a98d..583697336676b 100644 --- a/apps/meteor/tests/e2e/read-receipts.spec.ts +++ b/apps/meteor/tests/e2e/read-receipts.spec.ts @@ -22,12 +22,11 @@ test.describe.serial('read-receipts', () => { test.beforeEach(async ({ page }) => { poHomeChannel = new HomeChannel(page); - await page.goto('/home'); + await poHomeChannel.gotoChannel(targetChannel); }); test.describe('read receipt settings disabled', async () => { test('should not show read receipts item menu', async ({ page }) => { - await poHomeChannel.navbar.openChat(targetChannel); await poHomeChannel.content.sendMessage('hello world'); await poHomeChannel.content.openLastMessageMenu(); await expect(page.locator('role=menuitem[name="Read receipts"]')).not.toBeVisible(); @@ -57,19 +56,17 @@ test.describe.serial('read-receipts', () => { test('should show read receipts message sent status in the sent message', async ({ browser }) => { const { page } = await createAuxContext(browser, Users.user1); auxContext = { page, poHomeChannel: new HomeChannel(page) }; - await auxContext.poHomeChannel.navbar.openChat(targetChannel); + await auxContext.poHomeChannel.gotoChannel(targetChannel); await auxContext.poHomeChannel.content.sendMessage('hello admin'); await expect(auxContext.poHomeChannel.content.lastUserMessage.getByRole('status', { name: 'Message sent' })).toBeVisible(); }); test('should show read receipts message viewed status in the sent message', async () => { - await poHomeChannel.navbar.openChat(targetChannel); await expect(poHomeChannel.content.lastUserMessage.getByRole('status', { name: 'Message viewed' })).toBeVisible(); }); test('should show the reads receipt modal with the users who read the message', async ({ page }) => { - await poHomeChannel.navbar.openChat(targetChannel); await poHomeChannel.content.openLastMessageMenu(); await page.locator('role=menuitem[name="Read receipts"]').click(); diff --git a/apps/meteor/tests/e2e/report-message.spec.ts b/apps/meteor/tests/e2e/report-message.spec.ts index 40e0fdfe8dccf..f12b4eff6ec67 100644 --- a/apps/meteor/tests/e2e/report-message.spec.ts +++ b/apps/meteor/tests/e2e/report-message.spec.ts @@ -11,6 +11,7 @@ test.use({ storageState: Users.user1.state }); test.describe.serial('report message', () => { let poHomeChannel: HomeChannel; + let adminHomeChannel: HomeChannel; let targetChannel: string; let adminPage: Page; let reportModal: ReportMessageModal; @@ -33,21 +34,19 @@ test.describe.serial('report message', () => { test.beforeEach(async ({ page }) => { poHomeChannel = new HomeChannel(page); + adminHomeChannel = new HomeChannel(adminPage); - await page.goto('/home'); - await adminPage.goto('/home'); + await poHomeChannel.gotoChannel(targetChannel); + await adminHomeChannel.gotoChannel(targetChannel); }); test('should show report message option in message menu for other users messages', async () => { await test.step('send message as user1', async () => { - await poHomeChannel.navbar.openChat(targetChannel); const testMessage = faker.lorem.sentence(); await poHomeChannel.content.sendMessage(testMessage); }); await test.step('verify report option is visible for the other user', async () => { - const adminHomeChannel = new HomeChannel(adminPage); - await adminHomeChannel.navbar.openChat(targetChannel); await adminHomeChannel.content.openLastMessageMenu(); await expect(adminPage.getByRole('menuitem', { name: 'Report' })).toBeVisible(); }); @@ -55,7 +54,6 @@ test.describe.serial('report message', () => { test('should not show report message option in message menu for own messages', async ({ page }) => { await test.step('send message as user1', async () => { - await poHomeChannel.navbar.openChat(targetChannel); const testMessage = faker.lorem.sentence(); await poHomeChannel.content.sendMessage(testMessage); }); @@ -68,15 +66,11 @@ test.describe.serial('report message', () => { test('should validate empty report description', async () => { await test.step('send message as user1', async () => { - await poHomeChannel.navbar.openChat(targetChannel); const testMessage = faker.lorem.sentence(); await poHomeChannel.content.sendMessage(testMessage); }); await test.step('try to submit empty report', async () => { - const adminHomeChannel = new HomeChannel(adminPage); - await adminHomeChannel.navbar.openChat(targetChannel); - await adminHomeChannel.content.openLastMessageMenu(); await adminPage.getByRole('menuitem', { name: 'Report' }).click(); await reportModal.submitReport(); @@ -85,15 +79,11 @@ test.describe.serial('report message', () => { test('should be able to cancel reporting a message', async () => { await test.step('send message as user1', async () => { - await poHomeChannel.navbar.openChat(targetChannel); const testMessage = faker.lorem.sentence(); await poHomeChannel.content.sendMessage(testMessage); }); await test.step('open and cancel report modal', async () => { - const adminHomeChannel = new HomeChannel(adminPage); - await adminHomeChannel.navbar.openChat(targetChannel); - await adminHomeChannel.content.openLastMessageMenu(); await adminPage.getByRole('menuitem', { name: 'Report' }).click(); await reportModal.cancelReport(); @@ -105,7 +95,6 @@ test.describe.serial('report message', () => { let reportDescription: string; await test.step('send message as user1', async () => { - await poHomeChannel.navbar.openChat(targetChannel); testMessage = faker.lorem.sentence(); await poHomeChannel.content.sendMessage(testMessage); }); @@ -113,9 +102,6 @@ test.describe.serial('report message', () => { await test.step('report message as the other user', async () => { reportDescription = faker.lorem.sentence(); - const adminHomeChannel = new HomeChannel(adminPage); - await adminHomeChannel.navbar.openChat(targetChannel); - await adminHomeChannel.content.openLastMessageMenu(); await adminPage.getByRole('menuitem', { name: 'Report' }).click(); await reportModal.submitReport(reportDescription); diff --git a/apps/meteor/tests/e2e/threads.spec.ts b/apps/meteor/tests/e2e/threads.spec.ts index 88782e0d2b3e1..485afdd38fed5 100644 --- a/apps/meteor/tests/e2e/threads.spec.ts +++ b/apps/meteor/tests/e2e/threads.spec.ts @@ -7,13 +7,13 @@ test.use({ storageState: Users.admin.state }); test.describe.serial('Threads', () => { let poHomeChannel: HomeChannel; let targetChannel: string; + test.beforeAll(async ({ api }) => { targetChannel = await createTargetChannel(api); }); test.beforeEach(async ({ page }) => { poHomeChannel = new HomeChannel(page); - await page.goto('/home'); - await poHomeChannel.navbar.openChat(targetChannel); + await poHomeChannel.gotoChannel(targetChannel); }); test.afterAll(async ({ api }) => deleteChannel(api, targetChannel)); @@ -92,8 +92,7 @@ test.describe.serial('Threads', () => { test.describe('thread message actions', () => { test.beforeEach(async ({ page }) => { poHomeChannel = new HomeChannel(page); - await page.goto('/home'); - await poHomeChannel.navbar.openChat(targetChannel); + await poHomeChannel.gotoChannel(targetChannel); await poHomeChannel.content.sendMessage('this is a message for reply'); await poHomeChannel.content.openReplyInThread(); });