Fix flaky crypto playwright tests (#143)

* Playwright: wait for sync to arrive after joining rooms

Fix a couple of flaky tests which were not waiting for the /sync to complete
after joining a room.

* Playwright: add a comment about a broken helper

* playwright: fix more flakiness in the shields test

This bit can take a while as well.

* Update playwright/pages/client.ts

Co-authored-by: R Midhun Suresh <hi@midhun.dev>

* Add a timeout to `awaitRoomMembership`

---------

Co-authored-by: R Midhun Suresh <hi@midhun.dev>
This commit is contained in:
Richard van der Hoff 2024-10-11 12:48:46 +01:00 committed by GitHub
parent c71dc6b0f8
commit 771d4a8417
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 68 additions and 4 deletions

View file

@ -33,7 +33,7 @@ test.describe("Cryptography", function () {
await app.client.bootstrapCrossSigning(aliceCredentials);
await autoJoin(bob);
// create an encrypted room
// create an encrypted room, and wait for Bob to join it.
testRoomId = await createSharedRoomWithUser(app, bob.credentials.userId, {
name: "TestRoom",
initial_state: [
@ -46,6 +46,9 @@ test.describe("Cryptography", function () {
},
],
});
// Even though Alice has seen Bob's join event, Bob may not have done so yet. Wait for the sync to arrive.
await bob.awaitRoomMembership(testRoomId);
});
test("should show the correct shield on e2e events", async ({
@ -287,9 +290,9 @@ test.describe("Cryptography", function () {
// Let our app start syncing again
await app.client.network.goOnline();
// Wait for the messages to arrive
// Wait for the messages to arrive. It can take quite a while for the sync to wake up.
const last = page.locator(".mx_EventTile_last");
await expect(last).toContainText("test encrypted from unverified");
await expect(last).toContainText("test encrypted from unverified", { timeout: 20000 });
const lastE2eIcon = last.locator(".mx_EventTile_e2eIcon");
await expect(lastE2eIcon).toHaveClass(/mx_EventTile_e2eIcon_warning/);
await lastE2eIcon.focus();