Replace MatrixClient.isCryptoEnabled
by MatrixClient.getCrypto
(#140)
* Replace `MatrixClient.isCryptoEnabled` by `MatrixClient.getCrypto` * Cast `cryptoEnabled` as `boolean` * Fix `MatrixChat-test` (cherry picked from commit 950ab1940bfcea9443f03284f9175d319c13a44c)
This commit is contained in:
parent
146968da2c
commit
571ada37a7
14 changed files with 11 additions and 36 deletions
|
@ -98,7 +98,6 @@ describe("<MatrixChat />", () => {
|
|||
getThirdpartyProtocols: jest.fn().mockResolvedValue({}),
|
||||
getClientWellKnown: jest.fn().mockReturnValue({}),
|
||||
isVersionSupported: jest.fn().mockResolvedValue(false),
|
||||
isCryptoEnabled: jest.fn().mockReturnValue(false),
|
||||
initRustCrypto: jest.fn(),
|
||||
getRoom: jest.fn(),
|
||||
getMediaHandler: jest.fn().mockReturnValue({
|
||||
|
@ -1012,16 +1011,15 @@ describe("<MatrixChat />", () => {
|
|||
setDeviceIsolationMode: jest.fn(),
|
||||
userHasCrossSigningKeys: jest.fn().mockResolvedValue(false),
|
||||
};
|
||||
loginClient.isCryptoEnabled.mockReturnValue(true);
|
||||
loginClient.getCrypto.mockReturnValue(mockCrypto as any);
|
||||
});
|
||||
|
||||
it("should go straight to logged in view when crypto is not enabled", async () => {
|
||||
loginClient.isCryptoEnabled.mockReturnValue(false);
|
||||
loginClient.getCrypto.mockReturnValue(undefined);
|
||||
|
||||
await getComponentAndLogin(true);
|
||||
|
||||
expect(loginClient.getCrypto()!.userHasCrossSigningKeys).not.toHaveBeenCalled();
|
||||
expect(screen.getByRole("heading", { name: "Welcome Ernie" })).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("should go straight to logged in view when user does not have cross signing keys and server does not support cross signing", async () => {
|
||||
|
|
|
@ -97,6 +97,7 @@ describe("RoomView", () => {
|
|||
stores.rightPanelStore.useUnitTestClient(cli);
|
||||
|
||||
jest.spyOn(VoipUserMapper.sharedInstance(), "getVirtualRoomForRoom").mockResolvedValue(undefined);
|
||||
jest.spyOn(cli, "getCrypto").mockReturnValue(undefined);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
|
@ -230,7 +231,6 @@ describe("RoomView", () => {
|
|||
it("updates url preview visibility on encryption state change", async () => {
|
||||
room.getMyMembership = jest.fn().mockReturnValue(KnownMembership.Join);
|
||||
// we should be starting unencrypted
|
||||
expect(cli.isCryptoEnabled()).toEqual(false);
|
||||
expect(cli.isRoomEncrypted(room.roomId)).toEqual(false);
|
||||
|
||||
const roomViewInstance = await getRoomViewInstance();
|
||||
|
@ -246,7 +246,6 @@ describe("RoomView", () => {
|
|||
expect(roomViewInstance.state.showUrlPreview).toBe(true);
|
||||
|
||||
// now enable encryption
|
||||
cli.isCryptoEnabled.mockReturnValue(true);
|
||||
cli.isRoomEncrypted.mockReturnValue(true);
|
||||
|
||||
// and fake an encryption event into the room to prompt it to re-check
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue