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:
Florian Duros
2024-10-15 16:24:58 +02:00
committed by Michael Telatynski
parent 146968da2c
commit 571ada37a7
14 changed files with 11 additions and 36 deletions

View File

@@ -134,8 +134,6 @@ describe("CreateSecretStorageDialog", () => {
});
it("calls bootstrapSecretStorage once keys are restored if the backup is now trusted", async () => {
mockClient.isCryptoEnabled.mockReturnValue(true);
const result = renderComponent();
await result.findByText(/Enter your account password to confirm the upgrade/);
expect(result.container).toMatchSnapshot();

View File

@@ -142,7 +142,6 @@ beforeEach(() => {
isUserIgnored: jest.fn(),
getIgnoredUsers: jest.fn(),
setIgnoredUsers: jest.fn(),
isCryptoEnabled: jest.fn(),
getUserId: jest.fn(),
getSafeUserId: jest.fn(),
getDomain: jest.fn(),
@@ -424,7 +423,6 @@ describe("<UserInfo />", () => {
describe("with crypto enabled", () => {
beforeEach(() => {
mockClient.isCryptoEnabled.mockReturnValue(true);
mockClient.doesServerSupportUnstableFeature.mockResolvedValue(true);
mockCrypto.getUserVerificationStatus.mockResolvedValue(new UserVerificationStatus(false, false, false));
@@ -663,7 +661,6 @@ describe("<UserInfo />", () => {
describe("with an encrypted room", () => {
beforeEach(() => {
mockClient.isCryptoEnabled.mockReturnValue(true);
mockClient.isRoomEncrypted.mockReturnValue(true);
});

View File

@@ -8,15 +8,7 @@ Please see LICENSE files in the repository root for full details.
import React from "react";
import { CallType, MatrixCall } from "matrix-js-sdk/src/webrtc/call";
import {
EventType,
JoinRule,
MatrixClient,
MatrixEvent,
PendingEventOrdering,
Room,
RoomMember,
} from "matrix-js-sdk/src/matrix";
import { EventType, JoinRule, MatrixEvent, PendingEventOrdering, Room, RoomMember } from "matrix-js-sdk/src/matrix";
import { KnownMembership } from "matrix-js-sdk/src/types";
import {
createEvent,
@@ -86,6 +78,7 @@ describe("RoomHeader", () => {
} as unknown as DMRoomMap);
setCardSpy = jest.spyOn(RightPanelStore.instance, "setCard");
jest.spyOn(ShieldUtils, "shieldStatusForRoom").mockResolvedValue(ShieldUtils.E2EStatus.Normal);
});
afterEach(() => {
@@ -595,10 +588,7 @@ describe("RoomHeader", () => {
});
describe("dm", () => {
let client: MatrixClient;
beforeEach(() => {
client = MatrixClientPeg.get()!;
// Make the mocked room a DM
mocked(DMRoomMap.shared().getUserIdForRoomId).mockImplementation((roomId) => {
if (roomId === room.roomId) return "@user:example.com";
@@ -624,8 +614,6 @@ describe("RoomHeader", () => {
getMxcAvatarUrl: () => "mxc://avatar.url/image.png",
},
]);
jest.spyOn(client, "isCryptoEnabled").mockReturnValue(true);
jest.spyOn(ShieldUtils, "shieldStatusForRoom").mockResolvedValue(ShieldUtils.E2EStatus.Normal);
});
it.each([

View File

@@ -571,7 +571,6 @@ describe("<SendMessageComposer/>", () => {
it("should call prepareToEncrypt when the user is typing", async () => {
const cli = stubClient();
cli.isCryptoEnabled = jest.fn().mockReturnValue(true);
cli.isRoomEncrypted = jest.fn().mockReturnValue(true);
const room = mkStubRoom("!roomId:server", "Room", cli);

View File

@@ -38,7 +38,6 @@ function makeClient() {
getUser: jest.fn(),
isGuest: jest.fn().mockReturnValue(false),
isUserIgnored: jest.fn(),
isCryptoEnabled: jest.fn(),
getUserId: jest.fn(),
on: jest.fn(),
isSynapseAdministrator: jest.fn().mockResolvedValue(false),

View File

@@ -25,7 +25,6 @@ function makeClient(wellKnown: IClientWellKnown) {
getUser: jest.fn(),
isGuest: jest.fn().mockReturnValue(false),
isUserIgnored: jest.fn(),
isCryptoEnabled: jest.fn(),
getUserId: jest.fn(),
on: jest.fn(),
isSynapseAdministrator: jest.fn().mockResolvedValue(false),