Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Playwright: deflake verification tests #28289

Merged
merged 1 commit into from
Oct 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions playwright/e2e/crypto/user-verification.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ test.describe("User verification", () => {
// Accept
await toast.getByRole("button", { name: "Verify User" }).click();

// Wait for the QR code to be rendered. If we don't do this, then the QR code can be rendered just as
// Playwright tries to click the "Verify by emoji" button, which seems to make it miss the button.
// (richvdh: I thought Playwright was supposed to be resilient to such things, but empirically not.)
await expect(page.getByAltText("QR Code")).toBeVisible();

// request verification by emoji
await page.locator("#mx_RightPanel").getByRole("button", { name: "Verify by emoji" }).click();

Expand Down Expand Up @@ -101,20 +106,29 @@ test.describe("User verification", () => {
const toast = await toasts.getToast("Verification requested");
await toast.getByRole("button", { name: "Verify User" }).click();

// Wait for the QR code to be rendered. If we don't do this, then the QR code can be rendered just as
// Playwright tries to click the "Verify by emoji" button, which seems to make it miss the button.
// (richvdh: I thought Playwright was supposed to be resilient to such things, but empirically not.)
await expect(page.getByAltText("QR Code")).toBeVisible();

// request verification by emoji
await page.locator("#mx_RightPanel").getByRole("button", { name: "Verify by emoji" }).click();

/* on the bot side, wait for the verifier to exist ... */
const botVerifier = await awaitVerifier(bobVerificationRequest);
// ... confirm ...
botVerifier.evaluate((verifier) => verifier.verify()).catch(() => {});
// ... and confirm. We expect the verification to fail; we catch the error on the DOM side
// to stop playwright marking the evaluate as failing in the UI.
const botVerification = botVerifier.evaluate((verifier) => verifier.verify().catch(() => {}));
Comment on lines +119 to +121
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a driveby cleanup, not really related to the deflaking.


// ... and abort the verification
await page.getByRole("button", { name: "They don't match" }).click();

const dialog = page.locator(".mx_Dialog");
await expect(dialog.getByText("Your messages are not secure")).toBeVisible();
await dialog.getByRole("button", { name: "OK" }).click();
await expect(dialog).not.toBeVisible();

await botVerification;
});
});

Expand Down
Loading