Fix display of devices without encryption support in Settings dialog (#10977)

* Update tests to demonstrate broken behaviour

* Fixes and comments

* Remove exception swallowing

This seems like it causes more problems than it solves.
This commit is contained in:
Richard van der Hoff 2023-05-25 17:12:01 +01:00 committed by GitHub
parent 796ed35e75
commit 5593872b7a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 193 additions and 79 deletions

View file

@ -232,27 +232,6 @@ describe("<SessionManagerTab />", () => {
expect(container.getElementsByClassName("mx_Spinner").length).toBeFalsy();
});
it("does not fail when checking device verification fails", async () => {
const logSpy = jest.spyOn(console, "error").mockImplementation((e) => {});
mockClient.getDevices.mockResolvedValue({
devices: [alicesDevice, alicesMobileDevice],
});
const failError = new Error("non-specific failure");
mockCrypto.getDeviceVerificationStatus.mockImplementation(() => {
throw failError;
});
render(getComponent());
await act(async () => {
await flushPromises();
});
// called for each device despite error
expect(mockCrypto.getDeviceVerificationStatus).toHaveBeenCalledWith(aliceId, alicesDevice.device_id);
expect(mockCrypto.getDeviceVerificationStatus).toHaveBeenCalledWith(aliceId, alicesMobileDevice.device_id);
expect(logSpy).toHaveBeenCalledWith("Error getting device cross-signing info", failError);
});
it("sets device verification status correctly", async () => {
mockClient.getDevices.mockResolvedValue({
devices: [alicesDevice, alicesMobileDevice, alicesOlderMobileDevice],
@ -268,7 +247,7 @@ describe("<SessionManagerTab />", () => {
return new DeviceVerificationStatus({});
}
// alicesOlderMobileDevice does not support encryption
throw new Error("encryption not supported");
return null;
});
const { getByTestId } = render(getComponent());
@ -567,8 +546,7 @@ describe("<SessionManagerTab />", () => {
return new DeviceVerificationStatus({ crossSigningVerified: true, localVerified: true });
}
// but alicesMobileDevice doesn't support encryption
// XXX this is not what happens if a device doesn't support encryption.
throw new Error("encryption not supported");
return null;
});
const { getByTestId, queryByTestId } = render(getComponent());