Add options to hide right panel in room view (#31252)

* feat: add options to hide right panel in room view

This option is added for the module API.

* test: add test for hideRightPanel=true of room view

* test: update snapshot ids
This commit is contained in:
Florian Duros
2025-11-18 11:05:53 +01:00
committed by GitHub
parent b7acbe65c1
commit 0eff1caab2
3 changed files with 424 additions and 31 deletions

View File

@@ -154,18 +154,21 @@ describe("RoomView", () => {
}
const roomView = render(
<MatrixClientContext.Provider value={cli}>
<SDKContext.Provider value={stores}>
<RoomView
// threepidInvite should be optional on RoomView props
// it is treated as optional in RoomView
threepidInvite={undefined as any}
forceTimeline={false}
ref={ref}
{...props}
/>
</SDKContext.Provider>
</MatrixClientContext.Provider>,
<RoomView
// threepidInvite should be optional on RoomView props
// it is treated as optional in RoomView
threepidInvite={undefined as any}
forceTimeline={false}
ref={ref}
{...props}
/>,
{
wrapper: ({ children }) => (
<MatrixClientContext.Provider value={cli}>
<SDKContext.Provider value={stores}>{children}</SDKContext.Provider>
</MatrixClientContext.Provider>
),
},
);
await flushPromises();
return roomView;
@@ -273,6 +276,28 @@ describe("RoomView", () => {
expect(asFragment()).toMatchSnapshot();
});
it("should hide the right panel when hideRightPanel=true", async () => {
// Join the room
jest.spyOn(room, "getMyMembership").mockReturnValue(KnownMembership.Join);
const { asFragment, rerender } = await mountRoomView(undefined);
defaultDispatcher.dispatch<ViewUserPayload>(
{
action: Action.ViewUser,
member: undefined,
},
true,
);
// Check that the right panel is rendered
await expect(screen.findByTestId("right-panel")).resolves.toBeTruthy();
// Now rerender with hideRightPanel=true
rerender(<RoomView threepidInvite={undefined} forceTimeline={false} hideRightPanel={true} />);
// Check that the right panel is not rendered
await expect(screen.findByTestId("right-panel")).rejects.toThrow();
expect(asFragment()).toMatchSnapshot();
});
describe("invites", () => {
beforeEach(() => {
const member = new RoomMember(room.roomId, cli.getSafeUserId());