mirror of
https://github.com/vector-im/element-web.git
synced 2025-12-25 19:21:18 +01:00
Test updating
This commit is contained in:
parent
4a3a37323e
commit
e70afdb04f
@ -82,6 +82,7 @@ const useKeyBackupIsEnabled = (): boolean | undefined => {
|
||||
|
||||
useEventEmitter(matrixClient, ClientEvent.AccountData, (event: MatrixEvent): void => {
|
||||
const type = event.getType();
|
||||
// Recheck the status if this account data has been updated as this implies it has changed
|
||||
if (type === "m.org.matrix.custom.backup_disabled") {
|
||||
checkStatus();
|
||||
}
|
||||
|
||||
@ -6,10 +6,11 @@
|
||||
*/
|
||||
|
||||
import React from "react";
|
||||
import { render, screen } from "jest-matrix-react";
|
||||
import { act, render, screen } from "jest-matrix-react";
|
||||
import { type MatrixClient } from "matrix-js-sdk/src/matrix";
|
||||
import { waitFor } from "@testing-library/dom";
|
||||
import userEvent from "@testing-library/user-event";
|
||||
import { ClientEvent, MatrixEvent } from "matrix-js-sdk/src/matrix";
|
||||
|
||||
import type { KeyBackupInfo } from "matrix-js-sdk/src/crypto-api";
|
||||
import {
|
||||
@ -170,4 +171,25 @@ describe("<EncryptionUserSettingsTab />", () => {
|
||||
}),
|
||||
).toBeVisible();
|
||||
});
|
||||
|
||||
it("should update when backup_disabled account data is changed", async () => {
|
||||
jest.spyOn(matrixClient.getCrypto()!, "getKeyBackupInfo").mockResolvedValue({
|
||||
version: "1",
|
||||
} as KeyBackupInfo);
|
||||
|
||||
renderComponent();
|
||||
|
||||
await expect(await screen.findByRole("heading", { name: "Recovery" })).toBeVisible();
|
||||
|
||||
jest.spyOn(matrixClient.getCrypto()!, "getKeyBackupInfo").mockResolvedValue(null);
|
||||
|
||||
act(() => {
|
||||
const accountDataEvent = new MatrixEvent({ type: "m.org.matrix.custom.backup_disabled" });
|
||||
matrixClient.emit(ClientEvent.AccountData, accountDataEvent);
|
||||
});
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.queryByRole("heading", { name: "Recovery" })).toBeNull();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user