Add tests when user verification change
This commit is contained in:
parent
ebe8b259c7
commit
8d01c23309
1 changed files with 27 additions and 1 deletions
|
@ -22,7 +22,7 @@ import {
|
||||||
RoomStateEvent,
|
RoomStateEvent,
|
||||||
SearchResult,
|
SearchResult,
|
||||||
} from "matrix-js-sdk/src/matrix";
|
} from "matrix-js-sdk/src/matrix";
|
||||||
import { CryptoApi, UserVerificationStatus } from "matrix-js-sdk/src/crypto-api";
|
import { CryptoApi, UserVerificationStatus, CryptoEvent } from "matrix-js-sdk/src/crypto-api";
|
||||||
import { KnownMembership } from "matrix-js-sdk/src/types";
|
import { KnownMembership } from "matrix-js-sdk/src/types";
|
||||||
import {
|
import {
|
||||||
fireEvent,
|
fireEvent,
|
||||||
|
@ -307,6 +307,32 @@ describe("RoomView", () => {
|
||||||
expect(roomViewInstance.state.liveTimeline).not.toEqual(oldTimeline);
|
expect(roomViewInstance.state.liveTimeline).not.toEqual(oldTimeline);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should update when the e2e status when the user verification changed", async () => {
|
||||||
|
room.currentState.setStateEvents([
|
||||||
|
mkRoomMemberJoinEvent(cli.getSafeUserId(), room.roomId),
|
||||||
|
mkRoomMemberJoinEvent("user@example.com", room.roomId),
|
||||||
|
]);
|
||||||
|
room.getMyMembership = jest.fn().mockReturnValue(KnownMembership.Join);
|
||||||
|
// Not all the calls to cli.isRoomEncrypted are migrated, so we need to mock both.
|
||||||
|
mocked(cli.isRoomEncrypted).mockReturnValue(true);
|
||||||
|
jest.spyOn(cli, "getCrypto").mockReturnValue(crypto);
|
||||||
|
jest.spyOn(cli.getCrypto()!, "isEncryptionEnabledInRoom").mockResolvedValue(true);
|
||||||
|
jest.spyOn(cli.getCrypto()!, "getUserVerificationStatus").mockResolvedValue(
|
||||||
|
new UserVerificationStatus(false, false, false),
|
||||||
|
);
|
||||||
|
jest.spyOn(cli.getCrypto()!, "getUserDeviceInfo").mockResolvedValue(
|
||||||
|
new Map([["user@example.com", new Map<string, any>()]]),
|
||||||
|
);
|
||||||
|
|
||||||
|
const { container } = await renderRoomView();
|
||||||
|
await waitFor(() => expect(container.querySelector(".mx_E2EIcon_normal")).toBeInTheDocument());
|
||||||
|
|
||||||
|
const verificationStatus = new UserVerificationStatus(true, true, false);
|
||||||
|
jest.spyOn(cli.getCrypto()!, "getUserVerificationStatus").mockResolvedValue(verificationStatus);
|
||||||
|
cli.emit(CryptoEvent.UserTrustStatusChanged, cli.getSafeUserId(), verificationStatus);
|
||||||
|
await waitFor(() => expect(container.querySelector(".mx_E2EIcon_verified")).toBeInTheDocument());
|
||||||
|
});
|
||||||
|
|
||||||
describe("with virtual rooms", () => {
|
describe("with virtual rooms", () => {
|
||||||
it("checks for a virtual room on initial load", async () => {
|
it("checks for a virtual room on initial load", async () => {
|
||||||
const { container } = await renderRoomView();
|
const { container } = await renderRoomView();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue