* fix(encryption tab): hide the advanced section when the secrets are not cached locally The secret verification is now made at the level of `EncryptionUserSettingsTab` instead at the `RecoveryPanel` level. In the `EncryptionUserSettingsTab`, we decide to only display `RecoveryPanelOutOfSync` in case of uncached secrets. `RecoveryPanelOutOfSync` is simplified version of `RecoveryPanel` handling only the `secrets_not_cached` case. * refactor(encryption tab): simplify the `RecoveryPanel` without having to handle the missing secrets * test(encryption tab): move test about cached secrets in `EncryptionUserSettingsTab-test.tsx` * test(encryption tab): move e2e test which are testing all the encryption tab in `encryption-tab.spec.ts * refactor(encryption tab): move `RecoveryPanelOutOfSync` in its own file - fix typos - call onFinish after accessSecretStorage - onFinish doesn't need to be asynchronous * doc(encryption tab): improve documentation when the secrets are not cached locally * test(encryption tab): improve test documentation and naming * doc(encryption tab): improve `RecoveryPanelOutOfSync` documentation
89 lines
4.0 KiB
TypeScript
89 lines
4.0 KiB
TypeScript
/*
|
|
* Copyright 2024 New Vector Ltd.
|
|
*
|
|
* SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
|
|
* Please see LICENSE files in the repository root for full details.
|
|
*/
|
|
|
|
import { test, expect } from ".";
|
|
import { checkDeviceIsConnectedKeyBackup, createBot, verifySession } from "../../crypto/utils";
|
|
|
|
test.describe("Recovery section in Encryption tab", () => {
|
|
test.use({
|
|
displayName: "Alice",
|
|
});
|
|
|
|
test.beforeEach(async ({ page, homeserver, credentials }) => {
|
|
// The bot bootstraps cross-signing, creates a key backup and sets up a recovery key
|
|
await createBot(page, homeserver, credentials);
|
|
});
|
|
|
|
test(
|
|
"should change the recovery key",
|
|
{ tag: ["@screenshot", "@no-webkit"] },
|
|
async ({ page, app, homeserver, credentials, util, context }) => {
|
|
await verifySession(app, "new passphrase");
|
|
const dialog = await util.openEncryptionTab();
|
|
|
|
// The user can only change the recovery key
|
|
const changeButton = dialog.getByRole("button", { name: "Change recovery key" });
|
|
await expect(changeButton).toBeVisible();
|
|
await expect(util.getEncryptionRecoverySection()).toMatchScreenshot("default-recovery.png");
|
|
await changeButton.click();
|
|
|
|
// Display the new recovery key and click on the copy button
|
|
await expect(dialog.getByText("Change recovery key?")).toBeVisible();
|
|
await expect(util.getEncryptionTabContent()).toMatchScreenshot("change-key-1-encryption-tab.png", {
|
|
mask: [dialog.getByTestId("recoveryKey")],
|
|
});
|
|
await dialog.getByRole("button", { name: "Copy" }).click();
|
|
await dialog.getByRole("button", { name: "Continue" }).click();
|
|
|
|
// Confirm the recovery key
|
|
await util.confirmRecoveryKey(
|
|
"Enter your new recovery key",
|
|
"Confirm new recovery key",
|
|
"change-key-2-encryption-tab.png",
|
|
);
|
|
},
|
|
);
|
|
|
|
test("should setup the recovery key", { tag: ["@screenshot", "@no-webkit"] }, async ({ page, app, util }) => {
|
|
await verifySession(app, "new passphrase");
|
|
await util.removeSecretStorageDefaultKeyId();
|
|
|
|
// The key backup is deleted and the user needs to set it up
|
|
const dialog = await util.openEncryptionTab();
|
|
const setupButton = dialog.getByRole("button", { name: "Set up recovery" });
|
|
await expect(setupButton).toBeVisible();
|
|
await expect(util.getEncryptionRecoverySection()).toMatchScreenshot("set-up-recovery.png");
|
|
await setupButton.click();
|
|
|
|
// Display an informative panel about the recovery key
|
|
await expect(dialog.getByRole("heading", { name: "Set up recovery" })).toBeVisible();
|
|
await expect(util.getEncryptionTabContent()).toMatchScreenshot("set-up-key-1-encryption-tab.png");
|
|
await dialog.getByRole("button", { name: "Continue" }).click();
|
|
|
|
// Display the new recovery key and click on the copy button
|
|
await expect(dialog.getByText("Save your recovery key somewhere safe")).toBeVisible();
|
|
await expect(util.getEncryptionTabContent()).toMatchScreenshot("set-up-key-2-encryption-tab.png", {
|
|
mask: [dialog.getByTestId("recoveryKey")],
|
|
});
|
|
await dialog.getByRole("button", { name: "Copy" }).click();
|
|
await dialog.getByRole("button", { name: "Continue" }).click();
|
|
|
|
// Confirm the recovery key
|
|
await util.confirmRecoveryKey(
|
|
"Enter your recovery key to confirm",
|
|
"Finish set up",
|
|
"set-up-key-3-encryption-tab.png",
|
|
);
|
|
|
|
// The recovery key is now set up and the user can change it
|
|
await expect(dialog.getByRole("button", { name: "Change recovery key" })).toBeVisible();
|
|
|
|
// Check that the current device is connected to key backup and the backup version is the expected one
|
|
await checkDeviceIsConnectedKeyBackup(app, "1", true);
|
|
});
|
|
});
|