Skip to content

Commit

Permalink
TCHAP: remove element call in forum room
Browse files Browse the repository at this point in the history
  • Loading branch information
marc.sirisak committed Jan 20, 2025
1 parent dd37a76 commit 9ce0a08
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/components/views/rooms/RoomHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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") &&
Expand Down
20 changes: 20 additions & 0 deletions test/unit-tests/tchap/components/views/rooms/RoomHeaders-test.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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 {
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ exports[`RoomHeader should render as expected 1`] = `
</span>
<div
aria-labelledby=":r0:"
class="mx_DecoratedRoomAvatar_icon mx_DecoratedRoomAvatar_icon_forum"
class="mx_DecoratedRoomAvatar_icon mx_DecoratedRoomAvatar_icon_private"
tabindex="0"
/>
</div>
Expand Down

0 comments on commit 9ce0a08

Please sign in to comment.