Room list: hide the empty/collapse icon when the room list is empty (#33814)

* fix: don't display the empty/collapse icon when the room list is empty

* Fix jest lcov projectRoot config

---------

Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Florian Duros
2026-06-11 13:01:32 +00:00
committed by GitHub
co-authored by Michael Telatynski
parent 2d24778214
commit add7d4c405
3 changed files with 24 additions and 4 deletions
@@ -99,6 +99,7 @@ describe("RoomListViewModel", () => {
expect(viewModel.getSnapshot().sections).toEqual([]);
expect(viewModel.getSnapshot().isRoomListEmpty).toBe(true);
expect(viewModel.getSnapshot().isFlatList).toBe(true);
});
it("should set canCreateRoom based on user rights", () => {
@@ -754,6 +755,22 @@ describe("RoomListViewModel", () => {
expect(viewModel.getSnapshot().sections[0].id).toBe(CHATS_TAG);
});
it("should be a flat list when the room list is empty", () => {
jest.spyOn(RoomListStoreV3.instance, "getSortedRoomsInActiveSpace").mockReturnValue({
spaceId: "home",
sections: [
{ tag: DefaultTagID.Favourite, rooms: [] },
{ tag: CHATS_TAG, rooms: [] },
{ tag: DefaultTagID.LowPriority, rooms: [] },
],
});
viewModel = new RoomListViewModel({ client: matrixClient });
expect(viewModel.getSnapshot().isFlatList).toBe(true);
expect(viewModel.getSnapshot().sections).toHaveLength(0);
});
it("should exclude favourite and low_priority from filter list", () => {
viewModel = new RoomListViewModel({ client: matrixClient });
@@ -1106,12 +1123,15 @@ describe("RoomListViewModel", () => {
});
});
it("should dispatch collapseSection=undefined when it is a flat list", () => {
it.each([
{ label: "flat list", chatsRooms: true },
{ label: "empty room list", chatsRooms: false },
])("should dispatch collapseSection=undefined when it is a $label", ({ chatsRooms }) => {
jest.spyOn(RoomListStoreV3.instance, "getSortedRoomsInActiveSpace").mockReturnValue({
spaceId: "home",
sections: [
{ tag: DefaultTagID.Favourite, rooms: [] },
{ tag: CHATS_TAG, rooms: [regularRoom1] },
{ tag: CHATS_TAG, rooms: chatsRooms ? [regularRoom1] : [] },
{ tag: DefaultTagID.LowPriority, rooms: [] },
],
});