@@ -18,71 +18,120 @@ test.describe("Room list filters and sort", () => {
18
18
labsFlags : [ "feature_new_room_list" ] ,
19
19
} ) ;
20
20
21
- /**
22
- * Get the room list
23
- * @param page
24
- */
25
- function getRoomList ( page : Page ) {
26
- return page . getByTestId ( "room-list" ) ;
27
- }
28
-
29
21
function getPrimaryFilters ( page : Page ) {
30
22
return page . getByRole ( "listbox" , { name : "Room list filters" } ) ;
31
23
}
32
24
33
25
test . beforeEach ( async ( { page, app, bot, user } ) => {
34
26
// The notification toast is displayed above the search section
35
27
await app . closeNotificationToast ( ) ;
28
+ } ) ;
29
+
30
+ test . describe ( "Room list" , ( ) => {
31
+ /**
32
+ * Get the room list
33
+ * @param page
34
+ */
35
+ function getRoomList ( page : Page ) {
36
+ return page . getByTestId ( "room-list" ) ;
37
+ }
38
+
39
+ test . beforeEach ( async ( { page, app, bot, user } ) => {
40
+ await app . client . createRoom ( { name : "empty room" } ) ;
36
41
37
- await app . client . createRoom ( { name : "empty room" } ) ;
42
+ const unReadDmId = await bot . createRoom ( {
43
+ name : "unread dm" ,
44
+ invite : [ user . userId ] ,
45
+ is_direct : true ,
46
+ } ) ;
47
+ await bot . sendMessage ( unReadDmId , "I am a robot. Beep." ) ;
38
48
39
- const unReadDmId = await bot . createRoom ( {
40
- name : "unread dm" ,
41
- invite : [ user . userId ] ,
42
- is_direct : true ,
49
+ const unReadRoomId = await app . client . createRoom ( { name : "unread room" } ) ;
50
+ await app . client . inviteUser ( unReadRoomId , bot . credentials . userId ) ;
51
+ await bot . joinRoom ( unReadRoomId ) ;
52
+ await bot . sendMessage ( unReadRoomId , "I am a robot. Beep." ) ;
53
+
54
+ const favouriteId = await app . client . createRoom ( { name : "favourite room" } ) ;
55
+ await app . client . evaluate ( async ( client , favouriteId ) => {
56
+ await client . setRoomTag ( favouriteId , "m.favourite" , { order : 0.5 } ) ;
57
+ } , favouriteId ) ;
43
58
} ) ;
44
- await bot . sendMessage ( unReadDmId , "I am a robot. Beep." ) ;
45
59
46
- const unReadRoomId = await app . client . createRoom ( { name : "unread room" } ) ;
47
- await app . client . inviteUser ( unReadRoomId , bot . credentials . userId ) ;
48
- await bot . joinRoom ( unReadRoomId ) ;
49
- await bot . sendMessage ( unReadRoomId , "I am a robot. Beep." ) ;
60
+ test ( "should filter the list (with primary filters)" , { tag : "@screenshot" } , async ( { page, app, user } ) => {
61
+ const roomList = getRoomList ( page ) ;
62
+ const primaryFilters = getPrimaryFilters ( page ) ;
50
63
51
- const favouriteId = await app . client . createRoom ( { name : "favourite room" } ) ;
52
- await app . client . evaluate ( async ( client , favouriteId ) => {
53
- await client . setRoomTag ( favouriteId , "m.favourite" , { order : 0.5 } ) ;
54
- } , favouriteId ) ;
55
- } ) ;
64
+ const allFilters = await primaryFilters . locator ( "option" ) . all ( ) ;
65
+ for ( const filter of allFilters ) {
66
+ expect ( await filter . getAttribute ( "aria-selected" ) ) . toBe ( "false" ) ;
67
+ }
68
+ await expect ( primaryFilters ) . toMatchScreenshot ( "unselected-primary-filters.png" ) ;
69
+
70
+ await primaryFilters . getByRole ( "option" , { name : "Unread" } ) . click ( ) ;
71
+ // only one room should be visible
72
+ await expect ( roomList . getByRole ( "gridcell" , { name : "unread dm" } ) ) . toBeVisible ( ) ;
73
+ await expect ( roomList . getByRole ( "gridcell" , { name : "unread room" } ) ) . toBeVisible ( ) ;
74
+ expect ( await roomList . locator ( "role=gridcell" ) . count ( ) ) . toBe ( 2 ) ;
75
+ await expect ( primaryFilters ) . toMatchScreenshot ( "unread-primary-filters.png" ) ;
56
76
57
- test ( "should filter the list (with primary filters)" , { tag : "@screenshot" } , async ( { page , app , user } ) => {
58
- const roomList = getRoomList ( page ) ;
59
- const primaryFilters = getPrimaryFilters ( page ) ;
77
+ await primaryFilters . getByRole ( "option" , { name : "Favourite" } ) . click ( ) ;
78
+ await expect ( roomList . getByRole ( "gridcell" , { name : "favourite room" } ) ) . toBeVisible ( ) ;
79
+ expect ( await roomList . locator ( "role=gridcell" ) . count ( ) ) . toBe ( 1 ) ;
60
80
61
- const allFilters = await primaryFilters . locator ( "option" ) . all ( ) ;
62
- for ( const filter of allFilters ) {
63
- expect ( await filter . getAttribute ( "aria-selected" ) ) . toBe ( "false" ) ;
81
+ await primaryFilters . getByRole ( "option" , { name : "People" } ) . click ( ) ;
82
+ await expect ( roomList . getByRole ( "gridcell" , { name : "unread dm" } ) ) . toBeVisible ( ) ;
83
+ expect ( await roomList . locator ( "role=gridcell" ) . count ( ) ) . toBe ( 1 ) ;
84
+
85
+ await primaryFilters . getByRole ( "option" , { name : "Rooms" } ) . click ( ) ;
86
+ await expect ( roomList . getByRole ( "gridcell" , { name : "unread room" } ) ) . toBeVisible ( ) ;
87
+ await expect ( roomList . getByRole ( "gridcell" , { name : "favourite room" } ) ) . toBeVisible ( ) ;
88
+ await expect ( roomList . getByRole ( "gridcell" , { name : "empty room" } ) ) . toBeVisible ( ) ;
89
+ expect ( await roomList . locator ( "role=gridcell" ) . count ( ) ) . toBe ( 3 ) ;
90
+ } ) ;
91
+ } ) ;
92
+
93
+ test . describe ( "Empty room list" , ( ) => {
94
+ /**
95
+ * Get the empty state
96
+ * @param page
97
+ */
98
+ function getEmptyRoomList ( page : Page ) {
99
+ return page . getByTestId ( "empty-room-list" ) ;
64
100
}
65
- await expect ( primaryFilters ) . toMatchScreenshot ( "unselected-primary-filters.png" ) ;
66
-
67
- await primaryFilters . getByRole ( "option" , { name : "Unread" } ) . click ( ) ;
68
- // only one room should be visible
69
- await expect ( roomList . getByRole ( "gridcell" , { name : "unread dm" } ) ) . toBeVisible ( ) ;
70
- await expect ( roomList . getByRole ( "gridcell" , { name : "unread room" } ) ) . toBeVisible ( ) ;
71
- expect ( await roomList . locator ( "role=gridcell" ) . count ( ) ) . toBe ( 2 ) ;
72
- await expect ( primaryFilters ) . toMatchScreenshot ( "unread-primary-filters.png" ) ;
73
-
74
- await primaryFilters . getByRole ( "option" , { name : "Favourite" } ) . click ( ) ;
75
- await expect ( roomList . getByRole ( "gridcell" , { name : "favourite room" } ) ) . toBeVisible ( ) ;
76
- expect ( await roomList . locator ( "role=gridcell" ) . count ( ) ) . toBe ( 1 ) ;
77
-
78
- await primaryFilters . getByRole ( "option" , { name : "People" } ) . click ( ) ;
79
- await expect ( roomList . getByRole ( "gridcell" , { name : "unread dm" } ) ) . toBeVisible ( ) ;
80
- expect ( await roomList . locator ( "role=gridcell" ) . count ( ) ) . toBe ( 1 ) ;
81
-
82
- await primaryFilters . getByRole ( "option" , { name : "Rooms" } ) . click ( ) ;
83
- await expect ( roomList . getByRole ( "gridcell" , { name : "unread room" } ) ) . toBeVisible ( ) ;
84
- await expect ( roomList . getByRole ( "gridcell" , { name : "favourite room" } ) ) . toBeVisible ( ) ;
85
- await expect ( roomList . getByRole ( "gridcell" , { name : "empty room" } ) ) . toBeVisible ( ) ;
86
- expect ( await roomList . locator ( "role=gridcell" ) . count ( ) ) . toBe ( 3 ) ;
101
+
102
+ test (
103
+ "should render the default placeholder when there is no filter" ,
104
+ { tag : "@screenshot" } ,
105
+ async ( { page, app, user } ) => {
106
+ const emptyRoomList = getEmptyRoomList ( page ) ;
107
+ await expect ( emptyRoomList ) . toMatchScreenshot ( "default-empty-room-list.png" ) ;
108
+ await expect ( page . getByTestId ( "room-list-panel" ) ) . toMatchScreenshot ( "room-panel-empty-room-list.png" ) ;
109
+ } ,
110
+ ) ;
111
+
112
+ test ( "should render the placeholder for unread filter" , { tag : "@screenshot" } , async ( { page, app, user } ) => {
113
+ const primaryFilters = getPrimaryFilters ( page ) ;
114
+ await primaryFilters . getByRole ( "option" , { name : "Unread" } ) . click ( ) ;
115
+
116
+ const emptyRoomList = getEmptyRoomList ( page ) ;
117
+ await expect ( emptyRoomList ) . toMatchScreenshot ( "unread-empty-room-list.png" ) ;
118
+
119
+ await emptyRoomList . getByRole ( "button" , { name : "show all chats" } ) . click ( ) ;
120
+ await expect ( primaryFilters . getByRole ( "option" , { name : "Unread" } ) ) . not . toBeChecked ( ) ;
121
+ } ) ;
122
+
123
+ [ "People" , "Rooms" , "Favourite" ] . forEach ( ( filter ) => {
124
+ test (
125
+ `should render the placeholder for ${ filter } filter` ,
126
+ { tag : "@screenshot" } ,
127
+ async ( { page, app, user } ) => {
128
+ const primaryFilters = getPrimaryFilters ( page ) ;
129
+ await primaryFilters . getByRole ( "option" , { name : filter } ) . click ( ) ;
130
+
131
+ const emptyRoomList = getEmptyRoomList ( page ) ;
132
+ await expect ( emptyRoomList ) . toMatchScreenshot ( `${ filter } -empty-room-list.png` ) ;
133
+ } ,
134
+ ) ;
135
+ } ) ;
87
136
} ) ;
88
137
} ) ;
0 commit comments