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 15:01:32 +02:00
committed by GitHub
parent 2d24778214
commit add7d4c405
3 changed files with 24 additions and 4 deletions
+1 -1
View File
@@ -59,7 +59,7 @@ const config: Config = {
// Coverage chokes on type definition files
"!<rootDir>/src/**/*.d.ts",
],
coverageReporters: ["text-summary", "lcov"],
coverageReporters: ["text-summary", ["lcov", { projectRoot: "../../" }]],
prettierPath: null,
moduleDirectories: ["node_modules", "test/test-utils"],
};
@@ -699,7 +699,7 @@ function computeSections(
...section,
rooms: isSectionExpanded(section.tag) ? section.rooms : [],
}));
const isFlatList = sections.length === 1 && sections[0].tag === CHATS_TAG;
const isFlatList = sections.length === 0 || (sections.length === 1 && sections[0].tag === CHATS_TAG);
return { sections, isFlatList };
}
@@ -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: [] },
],
});