New room list: fix compose menu action in space (#29500)

* fix(room list header): in view model, can create room in space if user has the right. Display the compose menu if the user can create room or video room

* fix(room list header): can create directly chat if compose menu is disabled

* test(room list header): add tests for view model

* test(room list header): update tests of view

* test(room list header): update list test
This commit is contained in:
Florian Duros
2025-03-14 17:12:30 +01:00
committed by GitHub
parent 9fb52e984c
commit ceba762caf
6 changed files with 111 additions and 7 deletions
@@ -51,12 +51,16 @@ describe("<RoomListHeaderView />", () => {
expect(asFragment()).toMatchSnapshot();
});
it("should not display the compose menu", () => {
it("should not display the compose menu", async () => {
const user = userEvent.setup();
mocked(useRoomListHeaderViewModel).mockReturnValue({ ...defaultValue, displayComposeMenu: false });
const { asFragment } = render(<RoomListHeaderView />);
expect(screen.queryByRole("button", { name: "Add" })).toBeNull();
expect(asFragment()).toMatchSnapshot();
await user.click(screen.getByRole("button", { name: "New message" }));
expect(defaultValue.createChatRoom).toHaveBeenCalled();
});
it("should display all the buttons when the menu is opened", async () => {