Skip to content

Commit

Permalink
test(backup mas): use checkDeviceIsConnectedKeyBackup instead at lo…
Browse files Browse the repository at this point in the history
…oking at the `Security & Privacy` tab (#29146)

* test(backup mas): use `checkDeviceIsConnectedKeyBackup` instead at looking at the *Security & Privacy* tab

* doc(backup mas): fix comment
  • Loading branch information
florianduros authored Feb 10, 2025
1 parent 047e8e8 commit 426a206
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 6 additions & 2 deletions playwright/e2e/crypto/backups-mas.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { registerAccountMas } from "../oidc";
import { isDendrite } from "../../plugins/homeserver/dendrite";
import { TestClientServerAPI } from "../csAPI";
import { masHomeserver } from "../../plugins/homeserver/synapse/masHomeserver.ts";
import { checkDeviceIsConnectedKeyBackup } from "./utils";

// These tests register an account with MAS because then we go through the "normal" registration flow
// and crypto gets set up. Using the 'user' fixture create a user and synthesizes an existing login,
Expand All @@ -24,8 +25,11 @@ test.describe("Encryption state after registration", () => {
await page.getByRole("button", { name: "Continue" }).click();
await registerAccountMas(page, mailpitClient, `alice_${testInfo.testId}`, "alice@email.com", "Pa$sW0rD!");

await app.settings.openUserSettings("Security & Privacy");
await expect(page.getByText("This session is backing up your keys.")).toBeVisible();
// Wait for the ui to load
await expect(page.locator(".mx_MatrixChat")).toBeVisible();

// Recovery is not set up yet
await checkDeviceIsConnectedKeyBackup(app, "1", true, false);
});

test("user is prompted to set up recovery", async ({ page, mailpitClient, app }, testInfo) => {
Expand Down
4 changes: 3 additions & 1 deletion playwright/e2e/crypto/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,13 @@ export async function checkDeviceIsCrossSigned(app: ElementAppPage): Promise<voi
* @param app -` ElementAppPage` wrapper for the playwright `Page`.
* @param expectedBackupVersion - the version of the backup we expect to be connected to.
* @param checkBackupPrivateKeyInCache - whether to check that the backup decryption key is cached locally
* @param checkBackupKeyIn4S - whether to check that the backup key is stored in 4S
*/
export async function checkDeviceIsConnectedKeyBackup(
app: ElementAppPage,
expectedBackupVersion: string,
checkBackupPrivateKeyInCache: boolean,
checkBackupKeyIn4S: boolean = true,
): Promise<void> {
// Sanity check the given backup version: if it's null, something went wrong earlier in the test.
if (!expectedBackupVersion) {
Expand Down Expand Up @@ -192,7 +194,7 @@ export async function checkDeviceIsConnectedKeyBackup(
// The active backup version is as expected
expect(activeBackupVersion).toBe(expectedBackupVersion);
// The backup key is stored in 4S
expect(backupKeyIn4S).toBe(true);
if (checkBackupKeyIn4S) expect(backupKeyIn4S).toBe(true);

if (checkBackupPrivateKeyInCache) {
// The backup key is available locally
Expand Down

0 comments on commit 426a206

Please sign in to comment.