|
| 1 | +/* |
| 2 | +Copyright 2023 The Matrix.org Foundation C.I.C. |
| 3 | +
|
| 4 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +you may not use this file except in compliance with the License. |
| 6 | +You may obtain a copy of the License at |
| 7 | +
|
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +
|
| 10 | +Unless required by applicable law or agreed to in writing, software |
| 11 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +See the License for the specific language governing permissions and |
| 14 | +limitations under the License. |
| 15 | +*/ |
| 16 | + |
| 17 | +import { test, expect } from "../../element-web-test"; |
| 18 | + |
| 19 | +test.describe("Backups", () => { |
| 20 | + test.use({ |
| 21 | + displayName: "Hanako", |
| 22 | + }); |
| 23 | + |
| 24 | + test("Create, delete and recreate a keys backup", async ({ page, user, app }, workerInfo) => { |
| 25 | + // skipIfLegacyCrypto |
| 26 | + test.skip( |
| 27 | + workerInfo.project.name === "Legacy Crypto", |
| 28 | + "This test only works with Rust crypto. Deleting the backup seems to fail with legacy crypto.", |
| 29 | + ); |
| 30 | + |
| 31 | + // Create a backup |
| 32 | + const tab = await app.settings.openUserSettings("Security & Privacy"); |
| 33 | + await expect(tab.getByRole("heading", { name: "Secure Backup" })).toBeVisible(); |
| 34 | + await tab.getByRole("button", { name: "Set up", exact: true }).click(); |
| 35 | + const dialog = await app.getDialogByTitle("Set up Secure Backup", 60000); |
| 36 | + await dialog.getByRole("button", { name: "Continue", exact: true }).click(); |
| 37 | + await expect(dialog.getByRole("heading", { name: "Save your Security Key" })).toBeVisible(); |
| 38 | + await dialog.getByRole("button", { name: "Copy", exact: true }).click(); |
| 39 | + const securityKey = await app.getClipboard(); |
| 40 | + await dialog.getByRole("button", { name: "Continue", exact: true }).click(); |
| 41 | + await expect(dialog.getByRole("heading", { name: "Secure Backup successful" })).toBeVisible(); |
| 42 | + await dialog.getByRole("button", { name: "Done", exact: true }).click(); |
| 43 | + |
| 44 | + // Delete it |
| 45 | + await app.settings.openUserSettings("Security & Privacy"); |
| 46 | + await expect(tab.getByRole("heading", { name: "Secure Backup" })).toBeVisible(); |
| 47 | + await tab.getByRole("button", { name: "Delete Backup", exact: true }).click(); |
| 48 | + await dialog.getByTestId("dialog-primary-button").click(); // Click "Delete Backup" |
| 49 | + |
| 50 | + // Create another |
| 51 | + await tab.getByRole("button", { name: "Set up", exact: true }).click(); |
| 52 | + dialog.getByLabel("Security Key").fill(securityKey); |
| 53 | + await dialog.getByRole("button", { name: "Continue", exact: true }).click(); |
| 54 | + await expect(dialog.getByRole("heading", { name: "Success!" })).toBeVisible(); |
| 55 | + await dialog.getByRole("button", { name: "OK", exact: true }).click(); |
| 56 | + }); |
| 57 | +}); |
0 commit comments