Skip to content

Commit

Permalink
Fix some flaky playwright tests (#28855)
Browse files Browse the repository at this point in the history
* Fix some flaky playwright tests

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Fix more flaky tests

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Iterate

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Reuse existing assertion

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

---------

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
  • Loading branch information
t3chguy authored Jan 6, 2025
1 parent 69ee8fd commit d8f6c12
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 9 deletions.
1 change: 0 additions & 1 deletion playwright/e2e/audio-player/audio-player.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,6 @@ test.describe("Audio player", { tag: ["@no-firefox", "@no-webkit"] }, () => {

// Find and click "Reply" button
const clickButtonReply = async () => {
await tile.scrollIntoViewIfNeeded();
await tile.hover();
await tile.getByRole("button", { name: "Reply", exact: true }).click();
};
Expand Down
5 changes: 2 additions & 3 deletions playwright/e2e/composer/RTE.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,8 @@ test.describe("Composer", () => {
// Enter some more text, then send the message
await page.getByRole("textbox").pressSequentially("this is the spoiler text ");
await page.getByRole("button", { name: "Send message" }).click();
// Check that a spoiler item has appeared in the timeline and locator the spoiler command text
await expect(page.locator("button.mx_EventTile_spoiler")).toBeVisible();
await expect(page.getByText("this is the spoiler text")).toBeVisible();
// Check that a spoiler item has appeared in the timeline and contains the spoiler text
await expect(page.locator("button.mx_EventTile_spoiler")).toHaveText("this is the spoiler text");
});
});
});
Expand Down
4 changes: 3 additions & 1 deletion playwright/e2e/login/soft_logout.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ test.describe("Soft logout", () => {

// back to the welcome page
await expect(page).toHaveURL(/\/#\/home/);
await expect(page.getByRole("heading", { name: `Welcome ${user.userId}`, exact: true })).toBeVisible();
await expect(
page.getByRole("heading", { name: "Now, let's help you get started", exact: true }),
).toBeVisible();
});

test("still shows the soft-logout page when the page is reloaded after a soft-logout", async ({
Expand Down
2 changes: 2 additions & 0 deletions playwright/e2e/read-receipts/high-level.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Please see LICENSE files in the repository root for full details.
import { customEvent, many, test } from ".";

test.describe("Read receipts", { tag: "@mergequeue" }, () => {
test.slow();

test.describe("Ignored events", () => {
test("If all events after receipt are unimportant, the room is read", async ({
roomAlpha: room1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ test.describe("Roles & Permissions room settings tab", () => {
// Change the role of Alice to Moderator (50)
await combobox.selectOption("Moderator");
await expect(combobox).toHaveValue("50");
const respPromise = page.waitForRequest("**/state/**");
await applyButton.click();
await respPromise;

// Reload and check Alice is still Moderator (50)
await page.reload();
Expand Down
8 changes: 4 additions & 4 deletions playwright/e2e/spotlight/spotlight.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ test.describe("Spotlight", () => {
await expect(resultLocator).toHaveCount(1);
await expect(resultLocator.first()).toContainText(room1Name);
await resultLocator.first().click();
expect(page.url()).toContain(room1Id);
await expect(page).toHaveURL(new RegExp(`#/room/${room1Id}`));
await expect(roomHeaderName(page)).toContainText(room1Name);
});

Expand All @@ -139,7 +139,7 @@ test.describe("Spotlight", () => {
await expect(resultLocator.first()).toContainText(room1Name);
await expect(resultLocator.first()).toContainText("View");
await resultLocator.first().click();
expect(page.url()).toContain(room1Id);
await expect(page).toHaveURL(new RegExp(`#/room/${room1Id}`));
await expect(roomHeaderName(page)).toContainText(room1Name);
});

Expand All @@ -153,7 +153,7 @@ test.describe("Spotlight", () => {
await expect(resultLocator.first()).toContainText(room2Name);
await expect(resultLocator.first()).toContainText("Join");
await resultLocator.first().click();
expect(page.url()).toContain(room2Id);
await expect(page).toHaveURL(new RegExp(`#/room/${room2Id}`));
await expect(page.locator(".mx_RoomView_MessageList")).toHaveCount(1);
await expect(roomHeaderName(page)).toContainText(room2Name);
});
Expand All @@ -168,7 +168,7 @@ test.describe("Spotlight", () => {
await expect(resultLocator.first()).toContainText(room3Name);
await expect(resultLocator.first()).toContainText("View");
await resultLocator.first().click();
expect(page.url()).toContain(room3Id);
await expect(page).toHaveURL(new RegExp(`#/room/${room3Id}`));
await page.getByRole("button", { name: "Join the discussion" }).click();
await expect(roomHeaderName(page)).toHaveText(room3Name);
});
Expand Down

0 comments on commit d8f6c12

Please sign in to comment.