Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit e326526

Browse files
author
Kerry
authored
set correct action for view device list button (#10979)
1 parent d0d9a36 commit e326526

File tree

2 files changed

+39
-2
lines changed

2 files changed

+39
-2
lines changed

src/components/views/rooms/DecryptionFailureBar.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import defaultDispatcher from "../../../dispatcher/dispatcher";
2424
import { Action } from "../../../dispatcher/actions";
2525
import AccessibleButton from "../elements/AccessibleButton";
2626
import { OpenToTabPayload } from "../../../dispatcher/payloads/OpenToTabPayload";
27-
import { UserTab } from "../dialogs/UserTab";
2827
import MatrixClientContext from "../../../contexts/MatrixClientContext";
2928
import SetupEncryptionDialog from "../dialogs/security/SetupEncryptionDialog";
3029
import { SetupEncryptionStore } from "../../../stores/SetupEncryptionStore";
@@ -136,7 +135,7 @@ export const DecryptionFailureBar: React.FC<IProps> = ({ failures }) => {
136135
};
137136

138137
const onDeviceListClick = (): void => {
139-
const payload: OpenToTabPayload = { action: Action.ViewUserSettings, initialTabId: UserTab.Security };
138+
const payload: OpenToTabPayload = { action: Action.ViewUserDeviceSettings };
140139
defaultDispatcher.dispatch(payload);
141140
};
142141

test/components/views/rooms/DecryptionFailureBar-test.tsx

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ import "@testing-library/jest-dom";
2020

2121
import MatrixClientContext from "../../../../src/contexts/MatrixClientContext";
2222
import { DecryptionFailureBar } from "../../../../src/components/views/rooms/DecryptionFailureBar";
23+
import defaultDispatcher from "../../../../src/dispatcher/dispatcher";
24+
import { Action } from "../../../../src/dispatcher/actions";
2325

2426
type MockDevice = { deviceId: string };
2527

@@ -71,6 +73,7 @@ function getBar(wrapper: RenderResult) {
7173
describe("<DecryptionFailureBar />", () => {
7274
beforeEach(() => {
7375
jest.useFakeTimers();
76+
jest.spyOn(defaultDispatcher, "dispatch").mockRestore();
7477
});
7578

7679
afterEach(() => {
@@ -285,6 +288,41 @@ describe("<DecryptionFailureBar />", () => {
285288

286289
bar.unmount();
287290
});
291+
it("Displays button to review device list if we are verified", async () => {
292+
// stub so we dont have to deal with launching modals
293+
jest.spyOn(defaultDispatcher, "dispatch").mockImplementation(() => {});
294+
ourDevice = verifiedDevice1;
295+
allDevices = [verifiedDevice1, verifiedDevice2];
296+
297+
const bar = render(
298+
// @ts-ignore
299+
<MatrixClientContext.Provider value={mockClient}>
300+
<DecryptionFailureBar
301+
failures={[
302+
// @ts-ignore
303+
mockEvent1,
304+
// @ts-ignore
305+
mockEvent2,
306+
// @ts-ignore
307+
mockEvent3,
308+
]}
309+
/>
310+
,
311+
</MatrixClientContext.Provider>,
312+
);
313+
314+
await waitFor(() => expect(mockClient.isSecretStored).toHaveBeenCalled());
315+
316+
act(() => {
317+
jest.advanceTimersByTime(5000);
318+
});
319+
320+
fireEvent.click(screen.getByText("View your device list"));
321+
322+
expect(defaultDispatcher.dispatch).toHaveBeenCalledWith({ action: Action.ViewUserDeviceSettings });
323+
324+
bar.unmount();
325+
});
288326

289327
it("Does not display a button to send key requests if we are unverified", async () => {
290328
ourDevice = unverifiedDevice1;

0 commit comments

Comments
 (0)