Skip to content

Commit

Permalink
playwright/dehydration: update check
Browse files Browse the repository at this point in the history
The old "Security & Privacy" tab is going away, so we need a new way to check
for dehydrated device existence.
  • Loading branch information
richvdh committed Feb 14, 2025
1 parent 09db599 commit 28454f4
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions playwright/e2e/crypto/dehydration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { test, expect } from "../../element-web-test";
import { isDendrite } from "../../plugins/homeserver/dendrite";
import { completeCreateSecretStorageDialog, createBot, logIntoElement } from "./utils.ts";
import { type Client } from "../../pages/client.ts";
import { type ElementAppPage } from "../../pages/ElementAppPage.ts";

const NAME = "Alice";

Expand Down Expand Up @@ -49,13 +50,7 @@ test.describe("Dehydration", () => {

await completeCreateSecretStorageDialog(page);

// Open the settings again
await app.settings.openUserSettings("Security & Privacy");

// The Security tab should indicate that there is a dehydrated device present
await expect(securityTab.getByText("Offline device enabled")).toBeVisible();

await app.settings.closeDialog();
await expectDehydratedDeviceEnabled(app);

// the dehydrated device gets created with the name "Dehydrated
// device". We want to make sure that it is not visible as a normal
Expand Down Expand Up @@ -109,3 +104,16 @@ async function getDehydratedDeviceIds(client: Client): Promise<string[]> {
);
});
}

/** Wait for our user to have a dehydrated device */
async function expectDehydratedDeviceEnabled(app: ElementAppPage): Promise<void> {
// It might be nice to do this via the UI, but currently this info is not exposed via the UI.
//
// Note we might have to wait for the device list to be refreshed, so we wrap in `expect.poll`.
await expect
.poll(async () => {
const dehydratedDeviceIds = await getDehydratedDeviceIds(app.client);
return dehydratedDeviceIds.length;
})
.toEqual(1);
}

0 comments on commit 28454f4

Please sign in to comment.