1
0
mirror of https://github.com/matrix-org/matrix-react-sdk.git synced 2025-08-07 21:23:00 +03:00

Allow managing room knocks (#11404)

* Allow managing room knocks

Signed-off-by: Charly Nguyen <charly.nguyen@nordeck.net>

* Apply PR feedback

Signed-off-by: Charly Nguyen <charly.nguyen@nordeck.net>

* Apply Sonar feedback

Signed-off-by: Charly Nguyen <charly.nguyen@nordeck.net>

---------

Signed-off-by: Charly Nguyen <charly.nguyen@nordeck.net>
This commit is contained in:
Charly Nguyen
2023-08-16 10:16:19 +02:00
committed by GitHub
parent 4f138ed041
commit d569ba0cfe
13 changed files with 711 additions and 7 deletions

View File

@@ -16,7 +16,16 @@ limitations under the License.
import React from "react";
import { fireEvent, render, screen } from "@testing-library/react";
import { Room, Visibility } from "matrix-js-sdk/src/matrix";
import { mkEvent } from "matrix-js-sdk/spec/test-utils/test-utils";
import {
EventTimeline,
EventType,
JoinRule,
MatrixEvent,
Room,
RoomStateEvent,
Visibility,
} from "matrix-js-sdk/src/matrix";
import { getMockClientWithEventEmitter, mockClientMethodsUser } from "../../../test-utils";
import RoomSettingsDialog from "../../../../src/components/views/dialogs/RoomSettingsDialog";
@@ -84,6 +93,54 @@ describe("<RoomSettingsDialog />", () => {
expect(container.querySelectorAll(".mx_TabbedView_tabLabel")).toMatchSnapshot();
});
describe("people settings tab", () => {
it("does not render when disabled and room join rule is not knock", () => {
jest.spyOn(room, "getJoinRule").mockReturnValue(JoinRule.Invite);
getComponent();
expect(screen.queryByTestId("settings-tab-ROOM_PEOPLE_TAB")).not.toBeInTheDocument();
});
it("does not render when disabled and room join rule is knock", () => {
jest.spyOn(room, "getJoinRule").mockReturnValue(JoinRule.Knock);
getComponent();
expect(screen.queryByTestId("settings-tab-ROOM_PEOPLE_TAB")).not.toBeInTheDocument();
});
it("does not render when enabled and room join rule is not knock", () => {
jest.spyOn(SettingsStore, "getValue").mockImplementation(
(setting) => setting === "feature_ask_to_join",
);
jest.spyOn(room, "getJoinRule").mockReturnValue(JoinRule.Invite);
getComponent();
expect(screen.queryByTestId("settings-tab-ROOM_PEOPLE_TAB")).not.toBeInTheDocument();
});
it("renders when enabled and room join rule is knock", () => {
jest.spyOn(SettingsStore, "getValue").mockImplementation(
(setting) => setting === "feature_ask_to_join",
);
jest.spyOn(room, "getJoinRule").mockReturnValue(JoinRule.Knock);
getComponent();
expect(screen.getByTestId("settings-tab-ROOM_PEOPLE_TAB")).toBeInTheDocument();
});
it("re-renders on room join rule changes", () => {
jest.spyOn(SettingsStore, "getValue").mockImplementation(
(setting) => setting === "feature_ask_to_join",
);
jest.spyOn(room, "getJoinRule").mockReturnValue(JoinRule.Knock);
getComponent();
jest.spyOn(room, "getJoinRule").mockReturnValue(JoinRule.Invite);
mockClient.emit(
RoomStateEvent.Events,
new MatrixEvent(mkEvent({ content: {}, type: EventType.RoomJoinRules })),
room.getLiveTimeline().getState(EventTimeline.FORWARDS)!,
null,
);
expect(screen.queryByTestId("settings-tab-ROOM_PEOPLE_TAB")).not.toBeInTheDocument();
});
});
it("renders voip settings tab when enabled", () => {
jest.spyOn(SettingsStore, "getValue").mockImplementation(
(settingName) => settingName === "feature_group_calls",