Skip to content

Commit

Permalink
Encryption tab: display correct encryption panel when user cancels th…
Browse files Browse the repository at this point in the history
…e reset identity flow (#29216)

* fix(encryption settings): check encryption state when user cancels the reset identity flow

* test(encryption settings): add test to check encryption state when user cancels the reset identity flow
  • Loading branch information
florianduros authored Feb 7, 2025
1 parent 40a6c69 commit 4a8ba81
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,20 +102,12 @@ export function EncryptionUserSettingsTab({ initialState = "loading" }: Encrypti
);
break;
case "reset_identity_compromised":
content = (
<ResetIdentityPanel
variant="compromised"
onCancelClick={() => setState("main")}
onFinish={() => setState("main")}
/>
);
break;
case "reset_identity_forgot":
content = (
<ResetIdentityPanel
variant="forgot"
onCancelClick={() => setState("main")}
onFinish={() => setState("main")}
variant={state === "reset_identity_compromised" ? "compromised" : "forgot"}
onCancelClick={checkEncryptionState}
onFinish={checkEncryptionState}
/>
);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,30 @@ describe("<EncryptionUserSettingsTab />", () => {
screen.getByRole("heading", { name: "Forgot your recovery key? You’ll need to reset your identity." }),
).toBeVisible();
});

it("should re-check the encryption state and displays the correct panel when the user clicks cancel the reset identity flow", async () => {
const user = userEvent.setup();

// Secrets are not cached
jest.spyOn(matrixClient.getCrypto()!, "getCrossSigningStatus").mockResolvedValue({
privateKeysInSecretStorage: true,
publicKeysOnDevice: true,
privateKeysCachedLocally: {
masterKey: false,
selfSigningKey: true,
userSigningKey: true,
},
});

renderComponent({ initialState: "reset_identity_forgot" });

expect(
screen.getByRole("heading", { name: "Forgot your recovery key? You’ll need to reset your identity." }),
).toBeVisible();

await user.click(screen.getByRole("button", { name: "Back" }));
await waitFor(() =>
screen.getByText("Your key storage is out of sync. Click one of the buttons below to fix the problem."),
);
});
});

0 comments on commit 4a8ba81

Please sign in to comment.