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
Don't start key backups when opening settings (#11640)
* SecureBackupPanel: stop calling `checkKeyBackup` `checkKeyBackup` will start key backups if they aren't already running. In my not-so-humble opinion, the mere act of opening a settings panel shouldn't change anything. * fix SecurityUserSettingsTab test
This commit is contained in:
committed by
GitHub
parent
c6fec9b95b
commit
c879882558
@@ -46,19 +46,17 @@ describe("<SecureBackupPanel />", () => {
|
||||
const getComponent = () => render(<SecureBackupPanel />);
|
||||
|
||||
beforeEach(() => {
|
||||
client.checkKeyBackup.mockResolvedValue({
|
||||
backupInfo: {
|
||||
version: "1",
|
||||
algorithm: "test",
|
||||
auth_data: {
|
||||
public_key: "1234",
|
||||
},
|
||||
},
|
||||
trustInfo: {
|
||||
usable: false,
|
||||
sigs: [],
|
||||
client.getKeyBackupVersion.mockResolvedValue({
|
||||
version: "1",
|
||||
algorithm: "test",
|
||||
auth_data: {
|
||||
public_key: "1234",
|
||||
},
|
||||
});
|
||||
client.isKeyBackupTrusted.mockResolvedValue({
|
||||
usable: false,
|
||||
sigs: [],
|
||||
});
|
||||
|
||||
mocked(client.secretStorage.hasKey).mockClear().mockResolvedValue(false);
|
||||
client.deleteKeyBackupVersion.mockClear().mockResolvedValue();
|
||||
@@ -75,14 +73,21 @@ describe("<SecureBackupPanel />", () => {
|
||||
expect(screen.queryByRole("progressbar")).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("handles null backup info", async () => {
|
||||
// checkKeyBackup can fail and return null for various reasons
|
||||
client.checkKeyBackup.mockResolvedValue(null);
|
||||
getComponent();
|
||||
// flush checkKeyBackup promise
|
||||
await flushPromises();
|
||||
it("handles error fetching backup", async () => {
|
||||
// getKeyBackupVersion can fail for various reasons
|
||||
client.getKeyBackupVersion.mockImplementation(async () => {
|
||||
throw new Error("beep beep");
|
||||
});
|
||||
const renderResult = getComponent();
|
||||
await renderResult.findByText("Unable to load key backup status");
|
||||
expect(renderResult.container).toMatchSnapshot();
|
||||
});
|
||||
|
||||
// no backup info
|
||||
it("handles absence of backup", async () => {
|
||||
client.getKeyBackupVersion.mockResolvedValue(null);
|
||||
getComponent();
|
||||
// flush getKeyBackupVersion promise
|
||||
await flushPromises();
|
||||
expect(screen.getByText("Back up your keys before signing out to avoid losing them.")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
@@ -124,18 +129,12 @@ describe("<SecureBackupPanel />", () => {
|
||||
});
|
||||
|
||||
it("deletes backup after confirmation", async () => {
|
||||
client.checkKeyBackup
|
||||
client.getKeyBackupVersion
|
||||
.mockResolvedValueOnce({
|
||||
backupInfo: {
|
||||
version: "1",
|
||||
algorithm: "test",
|
||||
auth_data: {
|
||||
public_key: "1234",
|
||||
},
|
||||
},
|
||||
trustInfo: {
|
||||
usable: false,
|
||||
sigs: [],
|
||||
version: "1",
|
||||
algorithm: "test",
|
||||
auth_data: {
|
||||
public_key: "1234",
|
||||
},
|
||||
})
|
||||
.mockResolvedValue(null);
|
||||
|
Reference in New Issue
Block a user