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
4 changed files with 68 additions and 4 deletions

View File

@@ -43,6 +43,7 @@ const testMessages = async (page: Page, bob: Bot, bobRoomId: string) => {
};
const bobJoin = async (page: Page, bob: Bot) => {
// Wait for Bob to get the invite
await bob.evaluate(async (cli) => {
const bobRooms = cli.getRooms();
if (!bobRooms.length) {
@@ -55,9 +56,13 @@ const bobJoin = async (page: Page, bob: Bot) => {
});
}
});
const roomId = await bob.joinRoomByName("Alice");
const roomId = await bob.joinRoomByName("Alice");
await expect(page.getByText("Bob joined the room")).toBeVisible();
// 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(roomId);
return roomId;
};