@@ -154,18 +154,21 @@ describe("RoomView", () => {
154154 }
155155
156156 const roomView = render (
157- < MatrixClientContext . Provider value = { cli } >
158- < SDKContext . Provider value = { stores } >
159- < RoomView
160- // threepidInvite should be optional on RoomView props
161- // it is treated as optional in RoomView
162- threepidInvite = { undefined as any }
163- forceTimeline = { false }
164- ref = { ref }
165- { ...props }
166- />
167- </ SDKContext . Provider >
168- </ MatrixClientContext . Provider > ,
157+ < RoomView
158+ // threepidInvite should be optional on RoomView props
159+ // it is treated as optional in RoomView
160+ threepidInvite = { undefined as any }
161+ forceTimeline = { false }
162+ ref = { ref }
163+ { ...props }
164+ /> ,
165+ {
166+ wrapper : ( { children } ) => (
167+ < MatrixClientContext . Provider value = { cli } >
168+ < SDKContext . Provider value = { stores } > { children } </ SDKContext . Provider >
169+ </ MatrixClientContext . Provider >
170+ ) ,
171+ } ,
169172 ) ;
170173 await flushPromises ( ) ;
171174 return roomView ;
@@ -273,6 +276,28 @@ describe("RoomView", () => {
273276 expect ( asFragment ( ) ) . toMatchSnapshot ( ) ;
274277 } ) ;
275278
279+ it ( "should hide the right panel when hideRightPanel=true" , async ( ) => {
280+ // Join the room
281+ jest . spyOn ( room , "getMyMembership" ) . mockReturnValue ( KnownMembership . Join ) ;
282+ const { asFragment, rerender } = await mountRoomView ( undefined ) ;
283+
284+ defaultDispatcher . dispatch < ViewUserPayload > (
285+ {
286+ action : Action . ViewUser ,
287+ member : undefined ,
288+ } ,
289+ true ,
290+ ) ;
291+
292+ // Check that the right panel is rendered
293+ await expect ( screen . findByTestId ( "right-panel" ) ) . resolves . toBeTruthy ( ) ;
294+ // Now rerender with hideRightPanel=true
295+ rerender ( < RoomView threepidInvite = { undefined } forceTimeline = { false } hideRightPanel = { true } /> ) ;
296+ // Check that the right panel is not rendered
297+ await expect ( screen . findByTestId ( "right-panel" ) ) . rejects . toThrow ( ) ;
298+ expect ( asFragment ( ) ) . toMatchSnapshot ( ) ;
299+ } ) ;
300+
276301 describe ( "invites" , ( ) => {
277302 beforeEach ( ( ) => {
278303 const member = new RoomMember ( room . roomId , cli . getSafeUserId ( ) ) ;
0 commit comments