Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Room header 'view your device list' does not link to new session manager #10979

Merged
merged 4 commits into from
May 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/components/views/rooms/DecryptionFailureBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -136,7 +135,7 @@ export const DecryptionFailureBar: React.FC<IProps> = ({ failures }) => {
};

const onDeviceListClick = (): void => {
const payload: OpenToTabPayload = { action: Action.ViewUserSettings, initialTabId: UserTab.Security };
const payload: OpenToTabPayload = { action: Action.ViewUserDeviceSettings };
defaultDispatcher.dispatch(payload);
};

Expand Down
38 changes: 38 additions & 0 deletions test/components/views/rooms/DecryptionFailureBar-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 };

Expand Down Expand Up @@ -71,6 +73,7 @@ function getBar(wrapper: RenderResult) {
describe("<DecryptionFailureBar />", () => {
beforeEach(() => {
jest.useFakeTimers();
jest.spyOn(defaultDispatcher, "dispatch").mockRestore();
});

afterEach(() => {
Expand Down Expand Up @@ -285,6 +288,41 @@ describe("<DecryptionFailureBar />", () => {

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
<MatrixClientContext.Provider value={mockClient}>
<DecryptionFailureBar
failures={[
// @ts-ignore
mockEvent1,
// @ts-ignore
mockEvent2,
// @ts-ignore
mockEvent3,
]}
/>
,
</MatrixClientContext.Provider>,
);

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;
Expand Down
Loading