@@ -75,7 +75,7 @@ import MatrixClientContext from "../../../../src/contexts/MatrixClientContext";
7575import { type ViewUserPayload } from "../../../../src/dispatcher/payloads/ViewUserPayload.ts" ;
7676import { CallStore } from "../../../../src/stores/CallStore.ts" ;
7777import MediaDeviceHandler , { MediaDeviceKindEnum } from "../../../../src/MediaDeviceHandler.ts" ;
78- import Modal from "../../../../src/Modal.tsx" ;
78+ import Modal , { type ComponentProps } from "../../../../src/Modal.tsx" ;
7979import ErrorDialog from "../../../../src/components/views/dialogs/ErrorDialog.tsx" ;
8080
8181// Used by group calls
@@ -127,7 +127,10 @@ describe("RoomView", () => {
127127 cleanup ( ) ;
128128 } ) ;
129129
130- const mountRoomView = async ( ref ?: RefObject < RoomView | null > ) : Promise < RenderResult > => {
130+ const mountRoomView = async (
131+ ref ?: RefObject < RoomView | null > ,
132+ props ?: Partial < ComponentProps < typeof RoomView > > ,
133+ ) : Promise < RenderResult > => {
131134 if ( stores . roomViewStore . getRoomId ( ) !== room . roomId ) {
132135 const switchedRoom = new Promise < void > ( ( resolve ) => {
133136 const subFn = ( ) => {
@@ -159,6 +162,7 @@ describe("RoomView", () => {
159162 threepidInvite = { undefined as any }
160163 forceTimeline = { false }
161164 ref = { ref }
165+ { ...props }
162166 />
163167 </ SDKContext . Provider >
164168 </ MatrixClientContext . Provider > ,
@@ -250,6 +254,25 @@ describe("RoomView", () => {
250254 expect ( instance . getHiddenHighlightCount ( ) ) . toBe ( 0 ) ;
251255 } ) ;
252256
257+ it ( "should hide the composer when hideComposer=true" , async ( ) => {
258+ // Join the room
259+ jest . spyOn ( room , "getMyMembership" ) . mockReturnValue ( KnownMembership . Join ) ;
260+ const { asFragment } = await mountRoomView ( undefined , { hideComposer : true } ) ;
261+
262+ expect ( screen . queryByRole ( "textbox" , { name : "Message input" } ) ) . not . toBeInTheDocument ( ) ;
263+ expect ( asFragment ( ) ) . toMatchSnapshot ( ) ;
264+ } ) ;
265+
266+ it ( "should hide the header when hideHeader=true" , async ( ) => {
267+ // Join the room
268+ jest . spyOn ( room , "getMyMembership" ) . mockReturnValue ( KnownMembership . Join ) ;
269+ const { asFragment } = await mountRoomView ( undefined , { hideHeader : true } ) ;
270+
271+ // Check that the room name button in the header is not rendered
272+ expect ( screen . queryByRole ( "button" , { name : room . name } ) ) . not . toBeInTheDocument ( ) ;
273+ expect ( asFragment ( ) ) . toMatchSnapshot ( ) ;
274+ } ) ;
275+
253276 describe ( "invites" , ( ) => {
254277 beforeEach ( ( ) => {
255278 const member = new RoomMember ( room . roomId , cli . getSafeUserId ( ) ) ;
0 commit comments