Prompt users to set up recovery (#30075)
* Show indicator in settings dialog when user doesn't have recovery set up * Update settings headers to use red dot for recommended settings * update recovery setup toast and remember if the user dismisses it * update playwright snapshots * use typed event emitters * reverse logic for the account data flag * fix comment and type
This commit is contained in:
@@ -7,9 +7,9 @@ Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
|
||||
import React, { type ReactElement } from "react";
|
||||
import { render, screen } from "jest-matrix-react";
|
||||
import { render, screen, waitFor } from "jest-matrix-react";
|
||||
import { mocked, type MockedObject } from "jest-mock";
|
||||
import { type MatrixClient } from "matrix-js-sdk/src/matrix";
|
||||
import { ClientEvent, MatrixEvent, type MatrixClient } from "matrix-js-sdk/src/matrix";
|
||||
|
||||
import SettingsStore, { type CallbackFn } from "../../../../../src/settings/SettingsStore";
|
||||
import SdkConfig from "../../../../../src/SdkConfig";
|
||||
@@ -250,4 +250,28 @@ describe("<UserSettingsDialog />", () => {
|
||||
// unwatches settings on unmount
|
||||
expect(mockSettingsStore.unwatchSetting).toHaveBeenCalledWith("mock-watcher-id-feature_mjolnir");
|
||||
});
|
||||
|
||||
it("displays an indicator when user needs to set up recovery", async () => {
|
||||
// Initially, the user doesn't have secret storage, so it should display
|
||||
// an indicator.
|
||||
mockClient.secretStorage.getDefaultKeyId.mockResolvedValue(null);
|
||||
|
||||
const { container } = render(getComponent());
|
||||
|
||||
await waitFor(() => {
|
||||
expect(container.querySelector(".mx_SettingsDialog_tabLabelsAlert")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
// Test that the handler ignores unknown account data
|
||||
mockClient.emit(ClientEvent.AccountData, new MatrixEvent({ type: "bar" }));
|
||||
|
||||
// The user now has secret storage. Trigger an update and check that
|
||||
// the indicator disappears.
|
||||
mockClient.secretStorage.getDefaultKeyId.mockResolvedValue("foo");
|
||||
mockClient.emit(ClientEvent.AccountData, new MatrixEvent({ type: "m.secret_storage.default_key" }));
|
||||
|
||||
await waitFor(() => {
|
||||
expect(container.querySelector(".mx_SettingsDialog_tabLabelsAlert")).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user