wait until we see bob's device, rather than hard-coding a timeout
This commit is contained in:
parent
b8ed73a9ab
commit
4d0ce684f4
1 changed files with 17 additions and 8 deletions
|
@ -8,6 +8,7 @@ Please see LICENSE files in the repository root for full details.
|
||||||
|
|
||||||
import { type Preset, type Visibility } from "matrix-js-sdk/src/matrix";
|
import { type Preset, type Visibility } from "matrix-js-sdk/src/matrix";
|
||||||
|
|
||||||
|
import type { Page } from "@playwright/test";
|
||||||
import { test, expect } from "../../element-web-test";
|
import { test, expect } from "../../element-web-test";
|
||||||
import { doTwoWaySasVerification, awaitVerifier } from "./utils";
|
import { doTwoWaySasVerification, awaitVerifier } from "./utils";
|
||||||
import { Client } from "../../pages/client";
|
import { Client } from "../../pages/client";
|
||||||
|
@ -38,6 +39,8 @@ test.describe("User verification", () => {
|
||||||
toasts,
|
toasts,
|
||||||
room: { roomId: dmRoomId },
|
room: { roomId: dmRoomId },
|
||||||
}) => {
|
}) => {
|
||||||
|
await waitForDeviceKeys(page);
|
||||||
|
|
||||||
// once Alice has joined, Bob starts the verification
|
// once Alice has joined, Bob starts the verification
|
||||||
const bobVerificationRequest = await bob.evaluateHandle(
|
const bobVerificationRequest = await bob.evaluateHandle(
|
||||||
async (client, { dmRoomId, aliceCredentials }) => {
|
async (client, { dmRoomId, aliceCredentials }) => {
|
||||||
|
@ -48,10 +51,6 @@ test.describe("User verification", () => {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait a bit so that Alice can retrieve our device keys.
|
|
||||||
await new Promise((resolve) => {
|
|
||||||
setTimeout(resolve, 500);
|
|
||||||
});
|
|
||||||
return client.getCrypto().requestVerificationDM(aliceCredentials.userId, dmRoomId);
|
return client.getCrypto().requestVerificationDM(aliceCredentials.userId, dmRoomId);
|
||||||
},
|
},
|
||||||
{ dmRoomId, aliceCredentials },
|
{ dmRoomId, aliceCredentials },
|
||||||
|
@ -91,6 +90,8 @@ test.describe("User verification", () => {
|
||||||
toasts,
|
toasts,
|
||||||
room: { roomId: dmRoomId },
|
room: { roomId: dmRoomId },
|
||||||
}) => {
|
}) => {
|
||||||
|
await waitForDeviceKeys(page);
|
||||||
|
|
||||||
// once Alice has joined, Bob starts the verification
|
// once Alice has joined, Bob starts the verification
|
||||||
const bobVerificationRequest = await bob.evaluateHandle(
|
const bobVerificationRequest = await bob.evaluateHandle(
|
||||||
async (client, { dmRoomId, aliceCredentials }) => {
|
async (client, { dmRoomId, aliceCredentials }) => {
|
||||||
|
@ -101,10 +102,6 @@ test.describe("User verification", () => {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait a bit so that Alice can retrieve our device keys.
|
|
||||||
await new Promise((resolve) => {
|
|
||||||
setTimeout(resolve, 500);
|
|
||||||
});
|
|
||||||
return client.getCrypto().requestVerificationDM(aliceCredentials.userId, dmRoomId);
|
return client.getCrypto().requestVerificationDM(aliceCredentials.userId, dmRoomId);
|
||||||
},
|
},
|
||||||
{ dmRoomId, aliceCredentials },
|
{ dmRoomId, aliceCredentials },
|
||||||
|
@ -157,3 +154,15 @@ async function createDMRoom(client: Client, userId: string): Promise<string> {
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Wait until we get the other user's device keys.
|
||||||
|
*
|
||||||
|
* In newer rust-crypto versions, the verification request will be ignored if we
|
||||||
|
* don't have the sender's device keys.
|
||||||
|
*/
|
||||||
|
async function waitForDeviceKeys(page: Page): Promise<void> {
|
||||||
|
await expect(page.getByRole("button", { name: "Avatar" })).toBeVisible();
|
||||||
|
const avatar = await page.getByRole("button", { name: "Avatar" });
|
||||||
|
await avatar.click();
|
||||||
|
await expect(page.getByText("1 session")).toBeVisible();
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue