Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit b283b18

Browse files
authored
Fix flakiness in playwright tests (#12512)
* Remove redundant option Signed-off-by: Michael Telatynski <[email protected]> * Stabilise app download dialog screenshot test Signed-off-by: Michael Telatynski <[email protected]> * Try to stabilise user menu opening in playwright tests Signed-off-by: Michael Telatynski <[email protected]> * Stabilise one-to-one-chat.spec.ts Signed-off-by: Michael Telatynski <[email protected]> * Stabilise kick.spec.ts Signed-off-by: Michael Telatynski <[email protected]> * Iterate Signed-off-by: Michael Telatynski <[email protected]> * Discard changes to playwright/element-web-test.ts --------- Signed-off-by: Michael Telatynski <[email protected]>
1 parent cc69589 commit b283b18

File tree

5 files changed

+15
-4
lines changed

5 files changed

+15
-4
lines changed

playwright/e2e/login/overwrite_login.spec.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ test.describe("Overwrite login action", () => {
4747
}, clientCredentials);
4848

4949
// It should be now another user!!
50-
const newUserMenu = await app.openUserMenu();
51-
await expect(newUserMenu.getByText(bobRegister.userId)).toBeVisible();
50+
await expect(page.getByText("Welcome BOB")).toBeVisible();
5251
});
5352
});

playwright/e2e/one-to-one-chat/one-to-one-chat.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ test.describe("1:1 chat room", () => {
4545
await expect(
4646
page.getByRole("group", { name: "Rooms" }).locator(".mx_RoomTile").getByText(user2.displayName),
4747
).not.toBeVisible();
48+
await page.waitForTimeout(500); // avoid race condition with routing
4849

4950
// open new 1:1 chat room
5051
await page.goto(`/#/user/${user2.userId}?action=chat`);

playwright/e2e/user-onboarding/user-onboarding-new.spec.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,17 @@ test.describe("User Onboarding (new user)", () => {
4545
await expect(
4646
page.getByRole("dialog").getByRole("heading", { level: 1, name: "Download Element" }),
4747
).toBeVisible();
48-
await expect(page.locator(".mx_Dialog")).toMatchScreenshot();
48+
await expect(page.locator(".mx_Dialog")).toMatchScreenshot(
49+
"User-Onboarding-new-user-app-download-dialog-1.png",
50+
{
51+
// Set a constant bg behind the modal to ensure screenshot stability
52+
css: `
53+
.mx_AppDownloadDialog_wrapper {
54+
background: black;
55+
}
56+
`,
57+
},
58+
);
4959
});
5060

5161
test("using find friends action should increase progress", async ({ page, homeserver }) => {

playwright/pages/settings.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ export class Settings {
2525
* Open the top left user menu, returning a Locator to the resulting context menu.
2626
*/
2727
public async openUserMenu(): Promise<Locator> {
28-
await this.page.getByRole("button", { name: "User menu" }).click();
2928
const locator = this.page.locator(".mx_ContextualMenu");
29+
if (await locator.locator(".mx_UserMenu_contextMenu_header").isVisible()) return locator;
30+
await this.page.getByRole("button", { name: "User menu" }).click();
3031
await locator.waitFor();
3132
return locator;
3233
}
17 Bytes
Loading

0 commit comments

Comments
 (0)