diff --git a/src/components/views/rooms/RoomHeader.tsx b/src/components/views/rooms/RoomHeader.tsx index 9edf67d6fb..2fa00a7786 100644 --- a/src/components/views/rooms/RoomHeader.tsx +++ b/src/components/views/rooms/RoomHeader.tsx @@ -53,9 +53,14 @@ import defaultDispatcher from "../../../dispatcher/dispatcher.ts"; import { RoomSettingsTab } from "../dialogs/RoomSettingsDialog.tsx"; import { useScopedRoomContext } from "../../../contexts/ScopedRoomContext.tsx"; +import DecoratedRoomAvatar from "../avatars/DecoratedRoomAvatar"; // :TCHAP: customize-room-header-bar + import TchapUIFeature from "~tchap-web/src/tchap/util/TchapUIFeature"; // :TCHAP: customize-room-header-bar import TchapExternalRoomHeader from "~tchap-web/src/tchap/components/views/rooms/TchapExternalRoomHeader"; // :TCHAP: customize-room-header-bar -import DecoratedRoomAvatar from "../avatars/DecoratedRoomAvatar"; // :TCHAP: customize-room-header-bar +import TchapRoomUtils from "~tchap-web/src/tchap/util/TchapRoomUtils.ts"; +import { TchapRoomType } from "~tchap-web/src/tchap/@types/tchap.ts"; + + export default function RoomHeader({ room, @@ -355,6 +360,7 @@ export default function RoomHeader({ {!isVideoRoom && videoCallButton} */ } {!isDirectMessage && TchapUIFeature.isFeatureActiveForHomeserver("feature_video_group_call") && + TchapRoomUtils.getTchapRoomType(room) !== TchapRoomType.Forum && !isVideoRoom && videoCallButton} {isDirectMessage && TchapUIFeature.isFeatureActiveForHomeserver("feature_video_call") && diff --git a/test/unit-tests/tchap/components/views/rooms/RoomHeaders-test.tsx b/test/unit-tests/tchap/components/views/rooms/RoomHeaders-test.tsx index 310800007f..e611ace940 100644 --- a/test/unit-tests/tchap/components/views/rooms/RoomHeaders-test.tsx +++ b/test/unit-tests/tchap/components/views/rooms/RoomHeaders-test.tsx @@ -1,6 +1,7 @@ import React from "react"; import { KnownMembership, PendingEventOrdering, Room } from "matrix-js-sdk/src/matrix"; import { screen, render, RenderOptions, getByLabelText, queryByLabelText } from "jest-matrix-react"; +import { mocked } from "jest-mock"; import { mkRoomMember, stubClient } from "~tchap-web/test/test-utils"; import RoomHeader from "~tchap-web/src/components/views/rooms/RoomHeader"; @@ -10,6 +11,10 @@ import MatrixClientContext from "~tchap-web/src/contexts/MatrixClientContext"; import SdkConfig from "~tchap-web/src/SdkConfig"; import SettingsStore from "~tchap-web/src/settings/SettingsStore"; import { UIFeature } from "~tchap-web/src/settings/UIFeature"; +import TchapRoomUtils from "~tchap-web/src/tchap/util/TchapRoomUtils"; +import { TchapRoomType } from "~tchap-web/src/tchap/@types/tchap"; + +jest.mock("~tchap-web/src/tchap/util/TchapRoomUtils"); function getWrapper(): RenderOptions { return { @@ -47,6 +52,7 @@ describe("RoomHeader", () => { const featureVideoName: string = "feature_video_call"; const featureVideoGroupName: string = "feature_video_group_call"; const homeserverName: string = "my.home.server"; + const mockedTchapRoomUtils = mocked(TchapRoomUtils); const addHomeserverToMockConfig = (homeservers: string[], feature: string) => { // mock SdkConfig.get("tchap_features") @@ -89,6 +95,8 @@ describe("RoomHeader", () => { (feature) => feature === "feature_group_calls" || feature == UIFeature.Widgets, ); + mockedTchapRoomUtils.getTchapRoomType.mockImplementation(() => TchapRoomType.Private); + DMRoomMap.setShared({ getUserIdForRoomId: jest.fn(), } as unknown as DMRoomMap); @@ -174,4 +182,16 @@ describe("RoomHeader", () => { expect(queryByLabelText(container, "Video call")).toBeNull(); }); + + it("hides the video group when feature is activated but it is a forum", () => { + mockedTchapRoomUtils.getTchapRoomType.mockImplementation(() => TchapRoomType.Forum); + + addHomeserverToMockConfig(["other.homeserver"], featureVideoGroupName); + + mockRoomMembers(room, 4); + + const { container } = getComponent(); + + expect(queryByLabelText(container, "Video call")).toBeNull(); + }); }); diff --git a/test/unit-tests/tchap/components/views/rooms/__snapshots__/RoomHeaders-test.tsx.snap b/test/unit-tests/tchap/components/views/rooms/__snapshots__/RoomHeaders-test.tsx.snap index 82a00c8819..630a4fe8d4 100644 --- a/test/unit-tests/tchap/components/views/rooms/__snapshots__/RoomHeaders-test.tsx.snap +++ b/test/unit-tests/tchap/components/views/rooms/__snapshots__/RoomHeaders-test.tsx.snap @@ -24,7 +24,7 @@ exports[`RoomHeader should render as expected 1`] = `