test: flaky feature preview tests (#35891)

Co-authored-by: juliajforesti <juliajforesti@gmail.com>
pull/35915/merge
Guilherme Gazzo 9 months ago committed by Guilherme Gazzo
parent 05c57beb60
commit 166e669d5d
  1. 4
      apps/meteor/tests/e2e/feature-preview.spec.ts
  2. 4
      apps/meteor/tests/e2e/message-mentions.spec.ts
  3. 20
      apps/meteor/tests/e2e/page-objects/fragments/home-content.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();

@ -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');
});
});

@ -81,11 +81,25 @@ export class HomeContent {
await this.joinRoom();
}
async sendMessage(text: string): Promise<void> {
async sendMessage(text: string, enforce = true): Promise<void> {
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<void> {
@ -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<void> {
await this.page.locator('role=main').waitFor();
await this.page.locator('role=main >> role=heading[level=1]').waitFor();

Loading…
Cancel
Save