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

Commit 736b083

Browse files
authored
Deflake verification playwright tests (#12669)
Turns out the sleep that got removed in #12667 was useful.
1 parent 5eb5ea8 commit 736b083

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

playwright/e2e/crypto/utils.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,13 @@ export async function checkDeviceIsConnectedKeyBackup(
113113
expectedBackupVersion: string,
114114
checkBackupKeyInCache: boolean,
115115
): Promise<void> {
116+
// Sanity check the given backup version: if it's null, something went wrong earlier in the test.
117+
if (!expectedBackupVersion) {
118+
throw new Error(
119+
`Invalid backup version passed to \`checkDeviceIsConnectedKeyBackup\`: ${expectedBackupVersion}`,
120+
);
121+
}
122+
116123
await page.getByRole("button", { name: "User menu" }).click();
117124
await page.locator(".mx_UserMenu_contextMenu").getByRole("menuitem", { name: "Security & Privacy" }).click();
118125
await expect(page.locator(".mx_Dialog").getByRole("button", { name: "Restore from Backup" })).toBeVisible();

playwright/e2e/crypto/verification.spec.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,17 @@ test.describe("Device verification", () => {
5050
bootstrapSecretStorage: true,
5151
});
5252
aliceBotClient.setCredentials(credentials);
53-
const mxClientHandle = await aliceBotClient.prepareClient();
5453

55-
expectedBackupVersion = await mxClientHandle.evaluate(async (mxClient) => {
56-
return await mxClient.getCrypto()!.getActiveSessionBackupVersion();
57-
});
54+
// Backup is prepared in the background. Poll until it is ready.
55+
const botClientHandle = await aliceBotClient.prepareClient();
56+
await expect
57+
.poll(async () => {
58+
expectedBackupVersion = await botClientHandle.evaluate((cli) =>
59+
cli.getCrypto()!.getActiveSessionBackupVersion(),
60+
);
61+
return expectedBackupVersion;
62+
})
63+
.not.toBe(null);
5864
});
5965

6066
// Click the "Verify with another device" button, and have the bot client auto-accept it.

0 commit comments

Comments
 (0)