Fix tests

This commit is contained in:
David Baker
2025-02-05 15:14:10 +01:00
parent 5ac200492c
commit 130458783f
2 changed files with 15 additions and 5 deletions

View File

@@ -71,14 +71,14 @@ const useKeyBackupIsEnabled = (): boolean | undefined => {
const crypto = matrixClient.getCrypto()!;
const info = await crypto.getKeyBackupInfo();
setIsEnabled(Boolean(info?.version));
}, [matrixClient]);
}, [matrixClient, setIsEnabled]);
useEffect(() => {
(async () => {
await checkStatus();
setLoading(false);
})();
}, [checkStatus]);
}, [checkStatus, setLoading]);
useEventEmitter(matrixClient, ClientEvent.AccountData, (event: MatrixEvent): void => {
const type = event.getType();

View File

@@ -145,6 +145,10 @@ describe("<EncryptionUserSettingsTab />", () => {
});
it("should display the reset identity panel when the user clicks on the reset cryptographic identity panel", async () => {
jest.spyOn(matrixClient.getCrypto()!, "getKeyBackupInfo").mockResolvedValue({
version: "1",
} as KeyBackupInfo);
const user = userEvent.setup();
const { asFragment } = renderComponent();
@@ -159,11 +163,17 @@ describe("<EncryptionUserSettingsTab />", () => {
expect(asFragment()).toMatchSnapshot();
});
it("should enter reset flow when showResetIdentity is set", () => {
it("should enter reset flow when showResetIdentity is set", async () => {
jest.spyOn(matrixClient.getCrypto()!, "getKeyBackupInfo").mockResolvedValue({
version: "1",
} as KeyBackupInfo);
renderComponent({ initialState: "reset_identity_forgot" });
expect(
screen.getByRole("heading", { name: "Forgot your recovery key? Youll need to reset your identity." }),
await expect(
await screen.findByRole("heading", {
name: "Forgot your recovery key? Youll need to reset your identity.",
}),
).toBeVisible();
});
});