@@ -69,17 +69,17 @@ describe('files: Filter in files list', { testIsolation: true }, () => {
6969 getRowForFile ( 'file.txt' ) . should ( 'be.visible' )
7070 getRowForFile ( 'spreadsheet.csv' ) . should ( 'be.visible' )
7171
72- filesFilters . filterContainter ( )
73- . findByRole ( 'button' , { name : 'Type' } )
74- . should ( 'be.visible' )
75- . click ( )
76- cy . findByRole ( 'menuitemcheckbox' , { name : 'Spreadsheets' } )
77- . should ( 'be.visible' )
78- . click ( )
79- filesFilters . filterContainter ( )
80- . findByRole ( 'button' , { name : 'Type' } )
72+ filesFilters . triggerFilter ( 'Type' )
73+
74+ cy . findByRole ( 'button' , { name : 'Spreadsheets' } )
8175 . should ( 'be.visible' )
76+ . and ( 'have.attr' , 'aria-pressed' , 'false' )
77+ . as ( 'spreadsheetsFilterButton' )
8278 . click ( )
79+ cy . get ( '@spreadsheetsFilterButton' )
80+ . should ( 'have.attr' , 'aria-pressed' , 'true' )
81+
82+ filesFilters . closeFilterMenu ( )
8383
8484 // See that only the spreadsheet is visible
8585 getRowForFile ( 'spreadsheet.csv' ) . should ( 'be.visible' )
@@ -91,33 +91,32 @@ describe('files: Filter in files list', { testIsolation: true }, () => {
9191 // All are visible by default
9292 getRowForFile ( 'folder' ) . should ( 'be.visible' )
9393
94- filesFilters . filterContainter ( )
95- . findByRole ( 'button' , { name : 'Type' } )
96- . should ( 'be.visible' )
97- . click ( )
98- cy . findByRole ( 'menuitemcheckbox' , { name : 'Spreadsheets' } )
99- . should ( 'be.visible' )
100- . click ( )
101- filesFilters . filterContainter ( )
102- . findByRole ( 'button' , { name : 'Type' } )
94+ filesFilters . triggerFilter ( 'Type' )
95+
96+ cy . findByRole ( 'button' , { name : 'Spreadsheets' } )
10397 . should ( 'be.visible' )
98+ . as ( 'spreadsheetsFilterButton' )
10499 . click ( )
100+ cy . get ( '@spreadsheetsFilterButton' )
101+ . should ( 'have.attr' , 'aria-pressed' , 'true' )
102+
103+ filesFilters . closeFilterMenu ( )
105104
106105 // See folder is not visible
107106 getRowForFile ( 'folder' ) . should ( 'not.exist' )
108107
109108 // clear filter
110- filesFilters . filterContainter ( )
111- . findByRole ( 'button' , { name : 'Type' } )
112- . should ( 'be.visible' )
113- . click ( )
114- cy . findByRole ( 'menuitem' , { name : / c l e a r f i l t e r / i } )
115- . should ( 'be.visible' )
116- . click ( )
117- filesFilters . filterContainter ( )
118- . findByRole ( 'button' , { name : 'Type' } )
109+ filesFilters . triggerFilter ( 'Type' )
110+
111+ cy . findByRole ( 'button' , { name : 'Spreadsheets' } )
119112 . should ( 'be.visible' )
113+ . and ( 'have.attr' , 'aria-pressed' , 'true' )
114+ . as ( 'spreadsheetsFilterButton' )
120115 . click ( )
116+ cy . get ( '@spreadsheetsFilterButton' )
117+ . should ( 'have.attr' , 'aria-pressed' , 'false' )
118+
119+ filesFilters . closeFilterMenu ( )
121120
122121 // See folder is visible again
123122 getRowForFile ( 'folder' ) . should ( 'be.visible' )
@@ -127,17 +126,16 @@ describe('files: Filter in files list', { testIsolation: true }, () => {
127126 // All are visible by default
128127 getRowForFile ( 'folder' ) . should ( 'be.visible' )
129128
130- filesFilters . filterContainter ( )
131- . findByRole ( 'button' , { name : 'Type' } )
132- . should ( 'be.visible' )
133- . click ( )
134- cy . findByRole ( 'menuitemcheckbox' , { name : 'Spreadsheets' } )
135- . should ( 'be.visible' )
136- . click ( )
137- filesFilters . filterContainter ( )
138- . findByRole ( 'button' , { name : 'Type' } )
129+ filesFilters . triggerFilter ( 'Type' )
130+
131+ cy . findByRole ( 'button' , { name : 'Spreadsheets' } )
139132 . should ( 'be.visible' )
133+ . as ( 'spreadsheetsFilterButton' )
140134 . click ( )
135+ cy . get ( '@spreadsheetsFilterButton' )
136+ . should ( 'have.attr' , 'aria-pressed' , 'true' )
137+
138+ filesFilters . closeFilterMenu ( )
141139
142140 // See folder is not visible
143141 getRowForFile ( 'folder' ) . should ( 'not.exist' )
@@ -154,16 +152,16 @@ describe('files: Filter in files list', { testIsolation: true }, () => {
154152 getRowForFile ( 'folder' ) . should ( 'be.visible' )
155153 getRowForFile ( 'file.txt' ) . should ( 'be.visible' )
156154
157- filesFilters . filterContainter ( )
158- . findByRole ( 'button' , { name : 'Type' } )
159- . should ( 'be.visible' )
160- . click ( )
161- cy . findByRole ( 'menuitemcheckbox' , { name : 'Folders' } )
155+ filesFilters . triggerFilter ( 'Type' )
156+
157+ cy . findByRole ( 'button' , { name : 'Folders' } )
162158 . should ( 'be.visible' )
159+ . as ( 'spreadsheetsFilterButton' )
163160 . click ( )
164- filesFilters . filterContainter ( )
165- . findByRole ( 'button' , { name : 'Type' } )
166- . click ( )
161+ cy . get ( '@spreadsheetsFilterButton' )
162+ . should ( 'have.attr' , 'aria-pressed' , 'true' )
163+
164+ filesFilters . closeFilterMenu ( )
167165
168166 // See that only the folder is visible
169167 getRowForFile ( 'folder' ) . should ( 'be.visible' )
@@ -189,20 +187,16 @@ describe('files: Filter in files list', { testIsolation: true }, () => {
189187 getRowForFile ( 'file.txt' ) . should ( 'be.visible' )
190188
191189 // enable type filter for folders
192- filesFilters . filterContainter ( )
193- . findByRole ( 'button' , { name : 'Type' } )
194- . should ( 'be.visible' )
195- . click ( )
196- cy . findByRole ( 'menuitemcheckbox' , { name : 'Folders' } )
190+ filesFilters . triggerFilter ( 'Type' )
191+
192+ cy . findByRole ( 'button' , { name : 'Folders' } )
197193 . should ( 'be.visible' )
194+ . as ( 'spreadsheetsFilterButton' )
198195 . click ( )
199- // assert the button is checked
200- cy . findByRole ( 'menuitemcheckbox' , { name : 'Folders' } )
201- . should ( 'have.attr' , 'aria-checked' , 'true' )
202- // close the menu
203- filesFilters . filterContainter ( )
204- . findByRole ( 'button' , { name : 'Type' } )
205- . click ( )
196+ cy . get ( '@spreadsheetsFilterButton' )
197+ . should ( 'have.attr' , 'aria-pressed' , 'true' )
198+
199+ filesFilters . closeFilterMenu ( )
206200
207201 // See the chips are active
208202 filesFilters . activeFilters ( )
@@ -222,13 +216,13 @@ describe('files: Filter in files list', { testIsolation: true }, () => {
222216 . should ( 'have.length' , 1 )
223217 . contains ( / F o l d e r / ) . should ( 'be.visible' )
224218 // And also the button should be active
225- filesFilters . filterContainter ( )
226- . findByRole ( 'button' , { name : 'Type' } )
227- . should ( 'be.visible' )
228- . click ( )
229- cy . findByRole ( 'menuitemcheckbox' , { name : 'Folders' } )
219+ filesFilters . triggerFilter ( 'Type' )
220+
221+ cy . findByRole ( 'button' , { name : 'Folders' } )
230222 . should ( 'be.visible' )
231- . and ( 'have.attr' , 'aria-checked' , 'true' )
223+ . should ( 'have.attr' , 'aria-pressed' , 'true' )
224+
225+ filesFilters . closeFilterMenu ( )
232226 } )
233227
234228 /** Regression test of https://github.com/nextcloud/server/issues/53038 */
0 commit comments