* Change `feature_group_calls` to default to true. Change state to Beta * Add `enableLegacyCallsVoip` (clarify: Audio settings relate to Legacy) Change `element_call.use_exclusively` to just be the default of `enableLegacyCallsVoip`. Allow disabling in Legacy in the settings. (overwrite `use_exclusivly` via `enableLegacyCallsVoip`) Rename `Voice & Video` to `Legacy Voice & Video` * improvements - settings title update to only show legacy when appropriate - hide menu all together if use_exclusivly is chosen * simplify by removing the feature_group_calls flag * smaller cleanup * fix tests and cleanup * clarify settings (disable) in config.md * add back EC relevant settings in room settings dialog * update screenshots (now default to EC enabled (not disabled) -> show voice and video tab in room settings * update screenshots * always show option to control voice messages input * lint * fix test * disable -> enabled And only have on mic dropdown * update config.md * Back to `disabled` (on by default/no config) * remove element call hint from voice-video settings * Update apps/web/src/i18n/strings/en_EN.json Co-authored-by: Robin <robin@robin.town> * Update apps/web/src/components/views/settings/tabs/user/VoiceUserSettingsTab.tsx Co-authored-by: Robin <robin@robin.town> * review * cleanup element call url setting (its deprecated/not used anymore) * clarify, that also jisti will be enabled/disabled by legacy settings flag * remove double section * remove unn exassary element_call configurations * Update en_EN.json * Update VoiceUserSettingsTab.tsx * Make tests use new defaults (enable element call) * Default events power levels * format * review "Enable Legacy voice/video calls" label * more radical usage of defaults in element_call config.json's * Update config.json * Update en_EN.json * Update RoomSettingsDialog-test.tsx.snap * Update useRoomCall.tsx * fix imports * Update request permission promp to latest designs: https://www.figma.com/design/aOEkaJtaBmPy058V7uoqVr/Element-Call-Updates---2026?node-id=45-12591&t=7takL39icZwt9YjL-0 * Update config.json.d.ts * fix usage of `Element` in i18n * Update General-room-settings-tab-should-be-rendered-properly-1-linux.png --------- Co-authored-by: Robin <robin@robin.town>
189 lines
7.6 KiB
TypeScript
189 lines
7.6 KiB
TypeScript
/*
|
|
Copyright 2024 New Vector Ltd.
|
|
Copyright 2023 The Matrix.org Foundation C.I.C.
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
|
|
Please see LICENSE files in the repository root for full details.
|
|
*/
|
|
|
|
import React from "react";
|
|
import { fireEvent, render, screen, waitFor } from "jest-matrix-react";
|
|
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";
|
|
import MatrixClientContext from "../../../../../src/contexts/MatrixClientContext";
|
|
import SettingsStore from "../../../../../src/settings/SettingsStore";
|
|
import { UIFeature } from "../../../../../src/settings/UIFeature";
|
|
import DMRoomMap from "../../../../../src/utils/DMRoomMap";
|
|
import { TestSDKContext } from "../../../TestSDKContext.ts";
|
|
|
|
describe("<RoomSettingsDialog />", () => {
|
|
const userId = "@alice:server.org";
|
|
const mockClient = getMockClientWithEventEmitter({
|
|
...mockClientMethodsUser(userId),
|
|
isRoomEncrypted: jest.fn().mockReturnValue(false),
|
|
getRoom: jest.fn(),
|
|
getDomain: jest.fn().mockReturnValue("server.org"),
|
|
getLocalAliases: jest.fn().mockResolvedValue({ aliases: [] }),
|
|
getRoomDirectoryVisibility: jest.fn().mockResolvedValue({ visibility: Visibility.Private }),
|
|
getOrCreateFilter: jest.fn(),
|
|
});
|
|
|
|
const roomId = "!room:server.org";
|
|
const room = new Room(roomId, mockClient, userId);
|
|
room.name = "Test Room";
|
|
const room2 = new Room("!room2:server.org", mockClient, userId);
|
|
room2.name = "Another Room";
|
|
|
|
let sdkContext: TestSDKContext;
|
|
|
|
jest.spyOn(SettingsStore, "getValue");
|
|
|
|
beforeEach(() => {
|
|
jest.clearAllMocks();
|
|
|
|
mockClient.getRoom.mockImplementation((roomId) => {
|
|
if (roomId === room.roomId) return room;
|
|
if (roomId === room2.roomId) return room2;
|
|
return null;
|
|
});
|
|
|
|
sdkContext = new TestSDKContext();
|
|
sdkContext._client = mockClient;
|
|
|
|
jest.spyOn(SettingsStore, "getValue").mockReset().mockReturnValue(false);
|
|
|
|
const dmRoomMap = {
|
|
getUserIdForRoomId: jest.fn(),
|
|
} as unknown as DMRoomMap;
|
|
jest.spyOn(DMRoomMap, "shared").mockReturnValue(dmRoomMap);
|
|
});
|
|
|
|
const getComponent = (onFinished = jest.fn(), propRoomId = roomId) =>
|
|
render(<RoomSettingsDialog roomId={propRoomId} onFinished={onFinished} sdkContext={sdkContext} />, {
|
|
wrapper: ({ children }) => (
|
|
<MatrixClientContext.Provider value={mockClient}>{children}</MatrixClientContext.Provider>
|
|
),
|
|
});
|
|
|
|
it("catches errors when room is not found", () => {
|
|
getComponent(undefined, "!room-that-does-not-exist");
|
|
expect(screen.getByText("Something went wrong!")).toBeInTheDocument();
|
|
});
|
|
|
|
it("updates when roomId prop changes", () => {
|
|
const { rerender, getByText } = getComponent(undefined, roomId);
|
|
|
|
expect(getByText(`Room Settings - ${room.name}`)).toBeInTheDocument();
|
|
|
|
rerender(<RoomSettingsDialog roomId={room2.roomId} onFinished={jest.fn()} sdkContext={sdkContext} />);
|
|
|
|
expect(getByText(`Room Settings - ${room2.name}`)).toBeInTheDocument();
|
|
});
|
|
|
|
describe("Settings tabs", () => {
|
|
it("renders default tabs correctly", () => {
|
|
const { container } = getComponent();
|
|
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", async () => {
|
|
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({ content: {}, type: EventType.RoomJoinRules }),
|
|
room.getLiveTimeline().getState(EventTimeline.FORWARDS)!,
|
|
null,
|
|
);
|
|
await waitFor(() =>
|
|
expect(screen.queryByTestId("settings-tab-ROOM_PEOPLE_TAB")).not.toBeInTheDocument(),
|
|
);
|
|
});
|
|
});
|
|
|
|
it("always renders voip settings tab when enabled", () => {
|
|
getComponent();
|
|
expect(screen.getByTestId("settings-tab-ROOM_VOIP_TAB")).toBeInTheDocument();
|
|
});
|
|
|
|
it("renders bridges settings tab when enabled", () => {
|
|
jest.spyOn(SettingsStore, "getValue").mockImplementation(
|
|
(settingName) => settingName === "feature_bridge_state",
|
|
);
|
|
getComponent();
|
|
expect(screen.getByTestId("settings-tab-ROOM_BRIDGES_TAB")).toBeInTheDocument();
|
|
});
|
|
|
|
it("renders advanced settings tab when enabled", () => {
|
|
jest.spyOn(SettingsStore, "getValue").mockImplementation(
|
|
(settingName) => settingName === UIFeature.AdvancedSettings,
|
|
);
|
|
getComponent();
|
|
expect(screen.getByTestId("settings-tab-ROOM_ADVANCED_TAB")).toBeInTheDocument();
|
|
});
|
|
});
|
|
|
|
describe("poll history", () => {
|
|
beforeEach(() => {
|
|
mockClient.getOrCreateFilter.mockResolvedValue("filterId");
|
|
});
|
|
it("renders poll history tab", () => {
|
|
getComponent();
|
|
expect(screen.getByTestId("settings-tab-ROOM_POLL_HISTORY_TAB")).toBeInTheDocument();
|
|
});
|
|
|
|
it("displays poll history when tab clicked", () => {
|
|
const { container } = getComponent();
|
|
|
|
fireEvent.click(screen.getByText("Polls"));
|
|
|
|
expect(container.querySelector(".mx_SettingsTab")).toMatchSnapshot();
|
|
});
|
|
});
|
|
});
|