You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-08-09 08:42:50 +03:00
Settings panels: avoid exceptions with rust crypto (#10962)
* Settings panels: avoid exceptions with rust crypto If we are using rust crypto, `client.crypto` is undefined. We'll need to fix these up better in future, but for now, just return early. * Update tests
This commit is contained in:
committed by
GitHub
parent
7c34d66bde
commit
161e19dfb6
@@ -79,7 +79,7 @@ describe("<CrossSigningPanel />", () => {
|
||||
expect(screen.getByTestId("summarised-status").innerHTML).toEqual("✅ Cross-signing is ready for use.");
|
||||
expect(screen.getByText("Cross-signing private keys:").parentElement!).toMatchSnapshot();
|
||||
expect(mockClient.crypto!.crossSigningInfo.isStoredInSecretStorage).toHaveBeenCalledWith(
|
||||
mockClient.crypto!.secretStorage,
|
||||
mockClient.secretStorage,
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -106,7 +106,7 @@ describe("<CrossSigningPanel />", () => {
|
||||
);
|
||||
expect(screen.getByText("Cross-signing private keys:").parentElement!).toMatchSnapshot();
|
||||
expect(mockClient.crypto!.crossSigningInfo.isStoredInSecretStorage).toHaveBeenCalledWith(
|
||||
mockClient.crypto!.secretStorage,
|
||||
mockClient.secretStorage,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
@@ -32,17 +32,17 @@ describe("<SecureBackupPanel />", () => {
|
||||
...mockClientMethodsUser(userId),
|
||||
checkKeyBackup: jest.fn(),
|
||||
isKeyBackupKeyStored: jest.fn(),
|
||||
isSecretStorageReady: jest.fn(),
|
||||
getKeyBackupEnabled: jest.fn(),
|
||||
getKeyBackupVersion: jest.fn().mockReturnValue("1"),
|
||||
isKeyBackupTrusted: jest.fn().mockResolvedValue(true),
|
||||
getClientWellKnown: jest.fn(),
|
||||
deleteKeyBackupVersion: jest.fn(),
|
||||
secretStorage: { hasKey: jest.fn() },
|
||||
});
|
||||
// @ts-ignore allow it
|
||||
client.crypto = {
|
||||
secretStorage: { hasKey: jest.fn() },
|
||||
getSessionBackupPrivateKey: jest.fn(),
|
||||
isSecretStorageReady: jest.fn(),
|
||||
} as unknown as Crypto;
|
||||
|
||||
const getComponent = () => render(<SecureBackupPanel />);
|
||||
@@ -62,7 +62,7 @@ describe("<SecureBackupPanel />", () => {
|
||||
},
|
||||
});
|
||||
|
||||
mocked(client.crypto!.secretStorage.hasKey).mockClear().mockResolvedValue(false);
|
||||
mocked(client.secretStorage.hasKey).mockClear().mockResolvedValue(false);
|
||||
client.deleteKeyBackupVersion.mockClear().mockResolvedValue();
|
||||
client.getKeyBackupVersion.mockClear();
|
||||
client.isKeyBackupTrusted.mockClear();
|
||||
@@ -166,7 +166,7 @@ describe("<SecureBackupPanel />", () => {
|
||||
});
|
||||
|
||||
it("resets secret storage", async () => {
|
||||
mocked(client.crypto!.secretStorage.hasKey).mockClear().mockResolvedValue(true);
|
||||
mocked(client.secretStorage.hasKey).mockClear().mockResolvedValue(true);
|
||||
getComponent();
|
||||
// flush checkKeyBackup promise
|
||||
await flushPromises();
|
||||
|
Reference in New Issue
Block a user