Skip to content

Commit

Permalink
Fix playwright test that used the e2e icon
Browse files Browse the repository at this point in the history
  • Loading branch information
MidhunSureshR committed Feb 5, 2025
1 parent 94ca4e2 commit 939501a
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions playwright/e2e/crypto/event-shields.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,26 +144,23 @@ test.describe("Cryptography", function () {
// bob deletes his second device
await bobSecondDevice.evaluate((cli) => cli.logout(true));

// wait for the logout to propagate. Workaround for https://github.com/vector-im/element-web/issues/26263 by repeatedly closing and reopening Bob's user info.
async function awaitOneDevice(iterations = 1) {
const rightPanel = page.locator(".mx_RightPanel");
await rightPanel.getByTestId("base-card-back-button").click();
await rightPanel.getByText("Bob").click();
const sessionCountText = await rightPanel
.locator(".mx_UserInfo_devices")
.getByText(" session", { exact: false })
.textContent();
// cf https://github.com/vector-im/element-web/issues/26279: Element-R uses the wrong text here
if (sessionCountText != "1 session" && sessionCountText != "1 verified session") {
if (iterations >= 10) {
throw new Error(`Bob still has ${sessionCountText} after 10 iterations`);
// wait for the logout to propagate.
const onlyOneDevice = await app.client.evaluate(
async (cli, { userId }) => {
for (let i = 0; i < 10; ++i) {
const userDeviceMap = await cli.getCrypto()?.getUserDeviceInfo([userId], true);
const deviceMap = userDeviceMap?.get(userId);
if (deviceMap.size === 1) return true;
await new Promise((r) => setTimeout(r, 500));
}
await awaitOneDevice(iterations + 1);
}
return false;
},
{ userId: bob.credentials.userId },
);
if (!onlyOneDevice) {
throw new Error(`Bob still has more than one session after 10 iterations!`);
}

await awaitOneDevice();

// close and reopen the room, to get the shield to update.
await app.viewRoomByName("Bob");
await app.viewRoomByName("TestRoom");
Expand Down

0 comments on commit 939501a

Please sign in to comment.