From 02d631de01117b408b28ca745a2923b20c7eb933 Mon Sep 17 00:00:00 2001 From: Kerry Archibald Date: Thu, 25 May 2023 15:58:40 +1200 Subject: [PATCH] set correct action for view device list button --- .../views/rooms/DecryptionFailureBar.tsx | 3 +- .../views/rooms/DecryptionFailureBar-test.tsx | 38 +++++++++++++++++++ 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/src/components/views/rooms/DecryptionFailureBar.tsx b/src/components/views/rooms/DecryptionFailureBar.tsx index 94cf02d8a65..74631688676 100644 --- a/src/components/views/rooms/DecryptionFailureBar.tsx +++ b/src/components/views/rooms/DecryptionFailureBar.tsx @@ -24,7 +24,6 @@ import defaultDispatcher from "../../../dispatcher/dispatcher"; import { Action } from "../../../dispatcher/actions"; import AccessibleButton from "../elements/AccessibleButton"; import { OpenToTabPayload } from "../../../dispatcher/payloads/OpenToTabPayload"; -import { UserTab } from "../dialogs/UserTab"; import MatrixClientContext from "../../../contexts/MatrixClientContext"; import SetupEncryptionDialog from "../dialogs/security/SetupEncryptionDialog"; import { SetupEncryptionStore } from "../../../stores/SetupEncryptionStore"; @@ -136,7 +135,7 @@ export const DecryptionFailureBar: React.FC = ({ failures }) => { }; const onDeviceListClick = (): void => { - const payload: OpenToTabPayload = { action: Action.ViewUserSettings, initialTabId: UserTab.Security }; + const payload: OpenToTabPayload = { action: Action.ViewUserDeviceSettings }; defaultDispatcher.dispatch(payload); }; diff --git a/test/components/views/rooms/DecryptionFailureBar-test.tsx b/test/components/views/rooms/DecryptionFailureBar-test.tsx index a716d38c265..25b028d7da9 100644 --- a/test/components/views/rooms/DecryptionFailureBar-test.tsx +++ b/test/components/views/rooms/DecryptionFailureBar-test.tsx @@ -20,6 +20,8 @@ import "@testing-library/jest-dom"; import MatrixClientContext from "../../../../src/contexts/MatrixClientContext"; import { DecryptionFailureBar } from "../../../../src/components/views/rooms/DecryptionFailureBar"; +import defaultDispatcher from "../../../../src/dispatcher/dispatcher"; +import { Action } from "../../../../src/dispatcher/actions"; type MockDevice = { deviceId: string }; @@ -71,6 +73,7 @@ function getBar(wrapper: RenderResult) { describe("", () => { beforeEach(() => { jest.useFakeTimers(); + jest.spyOn(defaultDispatcher, "dispatch").mockRestore(); }); afterEach(() => { @@ -285,6 +288,41 @@ describe("", () => { bar.unmount(); }); + it("Displays button to review device list if we are verified", async () => { + // stub so we dont have to deal with launching modals + jest.spyOn(defaultDispatcher, "dispatch").mockImplementation(() => {}); + ourDevice = verifiedDevice1; + allDevices = [verifiedDevice1, verifiedDevice2]; + + const bar = render( + // @ts-ignore + + + , + , + ); + + await waitFor(() => expect(mockClient.isSecretStored).toHaveBeenCalled()); + + act(() => { + jest.advanceTimersByTime(5000); + }); + + fireEvent.click(screen.getByText("View your device list")); + + expect(defaultDispatcher.dispatch).toHaveBeenCalledWith({ action: Action.ViewUserDeviceSettings }); + + bar.unmount(); + }); it("Does not display a button to send key requests if we are unverified", async () => { ourDevice = unverifiedDevice1;