mirror of
https://github.com/element-hq/element-web
synced 2024-11-29 12:58:53 +03:00
Update SecureBackupPanel
to use getCrypto()
(#11322)
`MatrixClient.crypto` is going away, so let's switch over to `getCrypto()`. There doesn't seem to be anything else relying on the `crypto` stub in `mockClientMethodsCrypto()`, so let's get rid of that.
This commit is contained in:
parent
b284fbcc37
commit
ddb8e0aa3a
3 changed files with 10 additions and 14 deletions
|
@ -146,7 +146,7 @@ export default class SecureBackupPanel extends React.PureComponent<{}, IState> {
|
||||||
|
|
||||||
private async getUpdatedDiagnostics(): Promise<void> {
|
private async getUpdatedDiagnostics(): Promise<void> {
|
||||||
const cli = MatrixClientPeg.safeGet();
|
const cli = MatrixClientPeg.safeGet();
|
||||||
const crypto = cli.crypto;
|
const crypto = cli.getCrypto();
|
||||||
if (!crypto) return;
|
if (!crypto) return;
|
||||||
|
|
||||||
const secretStorage = cli.secretStorage;
|
const secretStorage = cli.secretStorage;
|
||||||
|
|
|
@ -18,7 +18,12 @@ import React from "react";
|
||||||
import { fireEvent, render, screen, within } from "@testing-library/react";
|
import { fireEvent, render, screen, within } from "@testing-library/react";
|
||||||
import { mocked } from "jest-mock";
|
import { mocked } from "jest-mock";
|
||||||
|
|
||||||
import { flushPromises, getMockClientWithEventEmitter, mockClientMethodsUser } from "../../../test-utils";
|
import {
|
||||||
|
flushPromises,
|
||||||
|
getMockClientWithEventEmitter,
|
||||||
|
mockClientMethodsCrypto,
|
||||||
|
mockClientMethodsUser,
|
||||||
|
} from "../../../test-utils";
|
||||||
import SecureBackupPanel from "../../../../src/components/views/settings/SecureBackupPanel";
|
import SecureBackupPanel from "../../../../src/components/views/settings/SecureBackupPanel";
|
||||||
import { accessSecretStorage } from "../../../../src/SecurityManager";
|
import { accessSecretStorage } from "../../../../src/SecurityManager";
|
||||||
|
|
||||||
|
@ -30,20 +35,13 @@ describe("<SecureBackupPanel />", () => {
|
||||||
const userId = "@alice:server.org";
|
const userId = "@alice:server.org";
|
||||||
const client = getMockClientWithEventEmitter({
|
const client = getMockClientWithEventEmitter({
|
||||||
...mockClientMethodsUser(userId),
|
...mockClientMethodsUser(userId),
|
||||||
checkKeyBackup: jest.fn(),
|
...mockClientMethodsCrypto(),
|
||||||
isKeyBackupKeyStored: jest.fn(),
|
|
||||||
getKeyBackupEnabled: jest.fn(),
|
getKeyBackupEnabled: jest.fn(),
|
||||||
getKeyBackupVersion: jest.fn().mockReturnValue("1"),
|
getKeyBackupVersion: jest.fn().mockReturnValue("1"),
|
||||||
isKeyBackupTrusted: jest.fn().mockResolvedValue(true),
|
isKeyBackupTrusted: jest.fn().mockResolvedValue(true),
|
||||||
getClientWellKnown: jest.fn(),
|
getClientWellKnown: jest.fn(),
|
||||||
deleteKeyBackupVersion: jest.fn(),
|
deleteKeyBackupVersion: jest.fn(),
|
||||||
secretStorage: { hasKey: jest.fn() },
|
|
||||||
});
|
});
|
||||||
// @ts-ignore allow it
|
|
||||||
client.crypto = {
|
|
||||||
getSessionBackupPrivateKey: jest.fn(),
|
|
||||||
isSecretStorageReady: jest.fn(),
|
|
||||||
} as unknown as Crypto;
|
|
||||||
|
|
||||||
const getComponent = () => render(<SecureBackupPanel />);
|
const getComponent = () => render(<SecureBackupPanel />);
|
||||||
|
|
||||||
|
|
|
@ -155,10 +155,6 @@ export const mockClientMethodsCrypto = (): Partial<
|
||||||
getStoredCrossSigningForUser: jest.fn(),
|
getStoredCrossSigningForUser: jest.fn(),
|
||||||
checkKeyBackup: jest.fn().mockReturnValue({}),
|
checkKeyBackup: jest.fn().mockReturnValue({}),
|
||||||
secretStorage: { hasKey: jest.fn() },
|
secretStorage: { hasKey: jest.fn() },
|
||||||
crypto: {
|
|
||||||
isSecretStorageReady: jest.fn(),
|
|
||||||
getSessionBackupPrivateKey: jest.fn(),
|
|
||||||
},
|
|
||||||
getCrypto: jest.fn().mockReturnValue({
|
getCrypto: jest.fn().mockReturnValue({
|
||||||
getUserDeviceInfo: jest.fn(),
|
getUserDeviceInfo: jest.fn(),
|
||||||
getCrossSigningStatus: jest.fn().mockResolvedValue({
|
getCrossSigningStatus: jest.fn().mockResolvedValue({
|
||||||
|
@ -171,5 +167,7 @@ export const mockClientMethodsCrypto = (): Partial<
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
isCrossSigningReady: jest.fn().mockResolvedValue(true),
|
isCrossSigningReady: jest.fn().mockResolvedValue(true),
|
||||||
|
isSecretStorageReady: jest.fn(),
|
||||||
|
getSessionBackupPrivateKey: jest.fn(),
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue