Encryption tab: display correct encryption panel when user cancels the 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
This commit is contained in:
@@ -102,20 +102,12 @@ export function EncryptionUserSettingsTab({ initialState = "loading" }: Encrypti
|
|||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case "reset_identity_compromised":
|
case "reset_identity_compromised":
|
||||||
content = (
|
|
||||||
<ResetIdentityPanel
|
|
||||||
variant="compromised"
|
|
||||||
onCancelClick={() => setState("main")}
|
|
||||||
onFinish={() => setState("main")}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
case "reset_identity_forgot":
|
case "reset_identity_forgot":
|
||||||
content = (
|
content = (
|
||||||
<ResetIdentityPanel
|
<ResetIdentityPanel
|
||||||
variant="forgot"
|
variant={state === "reset_identity_compromised" ? "compromised" : "forgot"}
|
||||||
onCancelClick={() => setState("main")}
|
onCancelClick={checkEncryptionState}
|
||||||
onFinish={() => setState("main")}
|
onFinish={checkEncryptionState}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
|
|||||||
+26
@@ -144,4 +144,30 @@ describe("<EncryptionUserSettingsTab />", () => {
|
|||||||
screen.getByRole("heading", { name: "Forgot your recovery key? You’ll need to reset your identity." }),
|
screen.getByRole("heading", { name: "Forgot your recovery key? You’ll need to reset your identity." }),
|
||||||
).toBeVisible();
|
).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."),
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user