Skip to content

Commit 939501a

Browse files
committed
Fix playwright test that used the e2e icon
1 parent 94ca4e2 commit 939501a

File tree

1 file changed

+14
-17
lines changed

1 file changed

+14
-17
lines changed

playwright/e2e/crypto/event-shields.spec.ts

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -144,26 +144,23 @@ test.describe("Cryptography", function () {
144144
// bob deletes his second device
145145
await bobSecondDevice.evaluate((cli) => cli.logout(true));
146146

147-
// 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.
148-
async function awaitOneDevice(iterations = 1) {
149-
const rightPanel = page.locator(".mx_RightPanel");
150-
await rightPanel.getByTestId("base-card-back-button").click();
151-
await rightPanel.getByText("Bob").click();
152-
const sessionCountText = await rightPanel
153-
.locator(".mx_UserInfo_devices")
154-
.getByText(" session", { exact: false })
155-
.textContent();
156-
// cf https://github.com/vector-im/element-web/issues/26279: Element-R uses the wrong text here
157-
if (sessionCountText != "1 session" && sessionCountText != "1 verified session") {
158-
if (iterations >= 10) {
159-
throw new Error(`Bob still has ${sessionCountText} after 10 iterations`);
147+
// wait for the logout to propagate.
148+
const onlyOneDevice = await app.client.evaluate(
149+
async (cli, { userId }) => {
150+
for (let i = 0; i < 10; ++i) {
151+
const userDeviceMap = await cli.getCrypto()?.getUserDeviceInfo([userId], true);
152+
const deviceMap = userDeviceMap?.get(userId);
153+
if (deviceMap.size === 1) return true;
154+
await new Promise((r) => setTimeout(r, 500));
160155
}
161-
await awaitOneDevice(iterations + 1);
162-
}
156+
return false;
157+
},
158+
{ userId: bob.credentials.userId },
159+
);
160+
if (!onlyOneDevice) {
161+
throw new Error(`Bob still has more than one session after 10 iterations!`);
163162
}
164163

165-
await awaitOneDevice();
166-
167164
// close and reopen the room, to get the shield to update.
168165
await app.viewRoomByName("Bob");
169166
await app.viewRoomByName("TestRoom");

0 commit comments

Comments
 (0)