diff --git a/playwright/e2e/left-panel/room-list-panel/room-list-filter-sort.spec.ts b/playwright/e2e/left-panel/room-list-panel/room-list-filter-sort.spec.ts index bb87f90f19..3ebfb22de1 100644 --- a/playwright/e2e/left-panel/room-list-panel/room-list-filter-sort.spec.ts +++ b/playwright/e2e/left-panel/room-list-panel/room-list-filter-sort.spec.ts @@ -36,17 +36,21 @@ test.describe("Room list filters and sort", () => { return page.getByTestId("room-list"); } + let unReadDmId: string | undefined; + let unReadRoomId: string | undefined; + test.beforeEach(async ({ page, app, bot, user }) => { await app.client.createRoom({ name: "empty room" }); - const unReadDmId = await bot.createRoom({ + unReadDmId = await bot.createRoom({ name: "unread dm", invite: [user.userId], is_direct: true, }); + await app.client.joinRoom(unReadDmId); await bot.sendMessage(unReadDmId, "I am a robot. Beep."); - const unReadRoomId = await app.client.createRoom({ name: "unread room" }); + unReadRoomId = await app.client.createRoom({ name: "unread room" }); await app.client.inviteUser(unReadRoomId, bot.credentials.userId); await bot.joinRoom(unReadRoomId); await bot.sendMessage(unReadRoomId, "I am a robot. Beep."); @@ -88,6 +92,30 @@ test.describe("Room list filters and sort", () => { await expect(roomList.getByRole("gridcell", { name: "empty room" })).toBeVisible(); expect(await roomList.locator("role=gridcell").count()).toBe(3); }); + + test("unread filter should only match unread rooms that have a count", async ({ page, app, bot }) => { + const roomListView = getRoomList(page); + + // Let's configure unread dm room so that we only get notification for mentions and keywords + await app.viewRoomById(unReadDmId); + await app.settings.openRoomSettings("Notifications"); + await page.getByText("@mentions & keywords").click(); + await app.settings.closeDialog(); + + // Let's open a room other than unread room or unread dm + await roomListView.getByRole("gridcell", { name: "Open room favourite room" }).click(); + + // Let's make the bot send a new message in both rooms + await bot.sendMessage(unReadDmId, "Hello!"); + await bot.sendMessage(unReadRoomId, "Hello!"); + + // Let's activate the unread filter now + await page.getByRole("option", { name: "Unread" }).click(); + + // Unread filter should only show unread room and not unread dm! + await expect(roomListView.getByRole("gridcell", { name: "Open room unread room" })).toBeVisible(); + await expect(roomListView.getByRole("gridcell", { name: "Open room unread dm" })).not.toBeVisible(); + }); }); test.describe("Empty room list", () => { diff --git a/playwright/e2e/left-panel/room-list-panel/room-list.spec.ts b/playwright/e2e/left-panel/room-list-panel/room-list.spec.ts index 6f19bf60d1..ed402bc625 100644 --- a/playwright/e2e/left-panel/room-list-panel/room-list.spec.ts +++ b/playwright/e2e/left-panel/room-list-panel/room-list.spec.ts @@ -93,41 +93,4 @@ test.describe("Room list", () => { await filters.getByRole("option", { name: "People" }).click(); await expect(roomListView.getByRole("gridcell", { name: "Open room room0" })).toBeVisible(); }); - - test("unread filter should only match unread rooms that have a count", async ({ page, app, bot }) => { - const roomListView = getRoomList(page); - // Let's create a new room and invite the bot - const room1Id = await app.client.createRoom({ - name: "Unread Room 1", - invite: [bot.credentials?.userId], - }); - await bot.awaitRoomMembership(room1Id); - - // Let's create another room as well - const room2Id = await app.client.createRoom({ - name: "Unread Room 2", - invite: [bot.credentials?.userId], - }); - await bot.awaitRoomMembership(room2Id); - - // Let's configure unread room 1 so that we only get notification for mentions and keywords - await app.viewRoomById(room1Id); - await app.settings.openRoomSettings("Notifications"); - await page.getByText("@mentions & keywords").click(); - await app.settings.closeDialog(); - - // Let's open a room other than room 1 or room 2 - await roomListView.getByRole("gridcell", { name: "Open room room29" }).click(); - - // Let's make the bot send a new message in both room 1 and room 2 - await bot.sendMessage(room1Id, "Hello!"); - await bot.sendMessage(room2Id, "Hello!"); - - // Let's activate the unread filter now - await page.getByRole("option", { name: "Unread" }).click(); - - // Unread filter should only show room 2!! - await expect(roomListView.getByRole("gridcell", { name: "Open room Unread Room 2" })).toBeVisible(); - await expect(roomListView.getByRole("gridcell", { name: "Open room Unread Room 1" })).not.toBeVisible(); - }); }); diff --git a/test/unit-tests/components/viewmodels/roomlist/RoomListViewModel-test.tsx b/test/unit-tests/components/viewmodels/roomlist/RoomListViewModel-test.tsx index 238de4b270..50d0fc4518 100644 --- a/test/unit-tests/components/viewmodels/roomlist/RoomListViewModel-test.tsx +++ b/test/unit-tests/components/viewmodels/roomlist/RoomListViewModel-test.tsx @@ -239,7 +239,9 @@ describe("RoomListViewModel", () => { expect(vm.current.primaryFilters.find((f) => f.name === primaryFilterName)).toBeUndefined(); }); }); + }); + describe("Sorting", () => { it("should change sort order", () => { mockAndCreateRooms(); const { result: vm } = renderHook(() => useRoomListViewModel());