diff --git a/apps/meteor/tests/e2e/feature-preview.spec.ts b/apps/meteor/tests/e2e/feature-preview.spec.ts index b477cf664ac2b..72259e8b5665b 100644 --- a/apps/meteor/tests/e2e/feature-preview.spec.ts +++ b/apps/meteor/tests/e2e/feature-preview.spec.ts @@ -45,6 +45,7 @@ test.describe.serial('feature preview', () => { test('should show "Message" and "Navigation" feature sections', async ({ page }) => { await page.goto('/account/feature-preview'); + await page.waitForSelector('.main-content'); await expect(page.getByRole('button', { name: 'Message' })).toBeVisible(); await expect(page.getByRole('button', { name: 'Navigation' })).toBeVisible(); @@ -202,6 +203,9 @@ test.describe.serial('feature preview', () => { await poHomeChannel.content.sendMessage('hello world'); const item = poHomeChannel.sidebar.getSearchRoomByName(targetChannel); + + await expect(item).toBeVisible(); + await poHomeChannel.sidebar.markItemAsUnread(item); await poHomeChannel.sidebar.escSearch(); diff --git a/apps/meteor/tests/e2e/message-mentions.spec.ts b/apps/meteor/tests/e2e/message-mentions.spec.ts index 15abd9c36b400..45f4bd657a643 100644 --- a/apps/meteor/tests/e2e/message-mentions.spec.ts +++ b/apps/meteor/tests/e2e/message-mentions.spec.ts @@ -56,7 +56,7 @@ test.describe.serial('Should not allow to send @all mention if permission to do await expect(page).toHaveURL(`/group/${targetChannel2}`); }); await test.step('receive notify message', async () => { - await adminPage.content.sendMessage('@all '); + await adminPage.content.sendMessage('@all ', false); await expect(adminPage.content.lastUserMessage).toContainText('Notify all in this room is not allowed'); }); }); @@ -98,7 +98,7 @@ test.describe.serial('Should not allow to send @here mention if permission to do await expect(page).toHaveURL(`/group/${targetChannel2}`); }); await test.step('receive notify message', async () => { - await adminPage.content.sendMessage('@here '); + await adminPage.content.sendMessage('@here ', false); await expect(adminPage.content.lastUserMessage).toContainText('Notify all in this room is not allowed'); }); }); diff --git a/apps/meteor/tests/e2e/page-objects/fragments/home-content.ts b/apps/meteor/tests/e2e/page-objects/fragments/home-content.ts index 905be5aa9c530..63e03a71e38aa 100644 --- a/apps/meteor/tests/e2e/page-objects/fragments/home-content.ts +++ b/apps/meteor/tests/e2e/page-objects/fragments/home-content.ts @@ -81,11 +81,25 @@ export class HomeContent { await this.joinRoom(); } - async sendMessage(text: string): Promise { + async sendMessage(text: string, enforce = true): Promise { await this.joinRoomIfNeeded(); await this.page.waitForSelector('[name="msg"]:not([disabled])'); await this.page.locator('[name="msg"]').fill(text); + const responsePromise = this.page.waitForResponse( + (response) => + /api\/v1\/method.call\/sendMessage/.test(response.url()) && response.status() === 200 && response.request().method() === 'POST', + ); await this.page.getByRole('button', { name: 'Send', exact: true }).click(); + + if (enforce) { + const response = await (await responsePromise).json(); + + const mid = JSON.parse(response.message).result._id; + const messageLocator = this.getMessageById(mid); + + await expect(messageLocator).toBeVisible(); + await expect(messageLocator).not.toHaveClass('rcx-message--pending'); + } } async dispatchSlashCommand(text: string): Promise { @@ -432,6 +446,10 @@ export class HomeContent { return this.page.locator('[role="listitem"][aria-roledescription="message"]', { hasText: text }); } + getMessageById(id: string): Locator { + return this.page.locator(`[data-qa-type="message"][id="${id}"]`); + } + async waitForChannel(): Promise { await this.page.locator('role=main').waitFor(); await this.page.locator('role=main >> role=heading[level=1]').waitFor();