@@ -37,7 +37,7 @@ describe("Audio player", () => {
37
37
38
38
cy . get ( ".mx_Dialog" ) . within ( ( ) => {
39
39
// Find and click primary "Upload" button
40
- cy . get ( "[data-testid='dialog-primary- button']" ) . findButton ( "Upload" ) . click ( ) ;
40
+ cy . findByRole ( " button" , { name : "Upload" } ) . click ( ) ;
41
41
} ) ;
42
42
43
43
// Wait until the file is sent
@@ -65,7 +65,7 @@ describe("Audio player", () => {
65
65
) ;
66
66
67
67
// Assert that the play button can be found and is visible
68
- cy . findButton ( " Play") . should ( "be.visible" ) ;
68
+ cy . findByRole ( "button" , { name : " Play" } ) . should ( "be.visible" ) ;
69
69
70
70
if ( monospace ) {
71
71
// Assert that the monospace timer is visible
@@ -148,10 +148,9 @@ describe("Audio player", () => {
148
148
cy . createRoom ( { name : "Test Room" } ) . viewRoomByName ( "Test Room" ) ;
149
149
150
150
// Wait until configuration is finished
151
- cy . contains (
152
- ".mx_RoomView_body .mx_GenericEventListSummary[data-layout='group'] .mx_GenericEventListSummary_summary" ,
153
- "created and configured the room." ,
154
- ) . should ( "exist" ) ;
151
+ cy . get ( ".mx_GenericEventListSummary[data-layout='group'] .mx_GenericEventListSummary_summary" ) . within ( ( ) => {
152
+ cy . findByText ( TEST_USER + " created and configured the room." ) . should ( "exist" ) ;
153
+ } ) ;
155
154
} ) ;
156
155
157
156
afterEach ( ( ) => {
@@ -178,20 +177,8 @@ describe("Audio player", () => {
178
177
// Enable high contrast manually
179
178
cy . openUserSettings ( "Appearance" )
180
179
. get ( ".mx_ThemeChoicePanel" )
181
- . within ( ( ) => {
182
- cy . get ( "[data-testid='theme-choice-panel-selectors']" ) . within ( ( ) => {
183
- // Enable light theme
184
- cy . get ( ".mx_ThemeSelector_light" ) . click ( ) ;
185
-
186
- // Assert that the radio button for light theme was checked
187
- cy . get ( ".mx_StyledRadioButton_checked input[value='light']" ) . should ( "exist" ) ;
188
- } ) ;
189
-
190
- cy . get ( "[data-testid='theme-choice-panel-highcontrast']" ) . within ( ( ) => {
191
- // Click the checkbox
192
- cy . get ( "label .mx_Checkbox_background" ) . click ( ) ;
193
- } ) ;
194
- } ) ;
180
+ . findByLabelText ( "Use high contrast" )
181
+ . click ( { force : true } ) ; // force click because the size of the checkbox is zero
195
182
196
183
cy . closeDialog ( ) ;
197
184
@@ -218,24 +205,24 @@ describe("Audio player", () => {
218
205
cy . contains ( ".mx_AudioPlayer_seek [role='timer']" , "00:00" ) . should ( "exist" ) ;
219
206
220
207
// Find and click "Play" button
221
- cy . findButton ( " Play") . click ( ) ;
208
+ cy . findByRole ( "button" , { name : " Play" } ) . click ( ) ;
222
209
223
210
// Assert that "Pause" button can be found
224
- cy . findButton ( " Pause") . should ( "exist" ) ;
211
+ cy . findByRole ( "button" , { name : " Pause" } ) . should ( "exist" ) ;
225
212
226
213
// Assert that the timer is reset when the audio file finished playing
227
214
cy . contains ( ".mx_AudioPlayer_seek [role='timer']" , "00:00" ) . should ( "exist" ) ;
228
215
229
216
// Assert that "Play" button can be found
230
- cy . findButton ( " Play") . should ( "exist" ) ;
217
+ cy . findByRole ( "button" , { name : " Play" } ) . should ( "exist" ) ;
231
218
} ) ;
232
219
} ) ;
233
220
234
221
it ( "should support downloading an audio file" , ( ) => {
235
222
uploadFile ( "cypress/fixtures/1sec.ogg" ) ;
236
223
237
224
// Find and click "Download" button on MessageActionBar
238
- cy . get ( ".mx_EventTile_last" ) . realHover ( ) . findButton ( " Download") . click ( ) ;
225
+ cy . get ( ".mx_EventTile_last" ) . realHover ( ) . findByRole ( "button" , { name : " Download" } ) . click ( ) ;
239
226
240
227
// Assert that the file was downloaded
241
228
cy . readFile ( "cypress/downloads/1sec.ogg" ) . should ( "exist" ) ;
@@ -248,7 +235,7 @@ describe("Audio player", () => {
248
235
cy . get ( ".mx_EventTile_last .mx_AudioPlayer_container" ) . should ( "exist" ) ;
249
236
250
237
// Find and click "Reply" button on MessageActionBar
251
- cy . get ( ".mx_EventTile_last" ) . realHover ( ) . findButton ( " Reply") . click ( ) ;
238
+ cy . get ( ".mx_EventTile_last" ) . realHover ( ) . findByRole ( "button" , { name : " Reply" } ) . click ( ) ;
252
239
253
240
// Reply to the player with another audio file
254
241
uploadFile ( "cypress/fixtures/1sec.ogg" ) ;
@@ -276,7 +263,7 @@ describe("Audio player", () => {
276
263
277
264
// Find and click "Reply" button
278
265
const clickButtonReply = ( ) => {
279
- cy . get ( ".mx_EventTile_last" ) . realHover ( ) . findButton ( " Reply") . click ( ) ;
266
+ cy . get ( ".mx_EventTile_last" ) . realHover ( ) . findByRole ( "button" , { name : " Reply" } ) . click ( ) ;
280
267
} ;
281
268
282
269
uploadFile ( "cypress/fixtures/upload-first.ogg" ) ;
@@ -305,7 +292,9 @@ describe("Audio player", () => {
305
292
cy . get ( ".mx_ReplyChain" ) . should ( "have.length" , 2 ) ;
306
293
307
294
// Assert that one line contains the user name
308
- cy . contains ( ".mx_ReplyChain .mx_ReplyTile_sender" , TEST_USER ) ;
295
+ cy . get ( ".mx_ReplyChain .mx_ReplyTile_sender" ) . within ( ( ) => {
296
+ cy . findByText ( TEST_USER ) ;
297
+ } ) ;
309
298
310
299
// Assert that the other line contains the file button
311
300
cy . get ( ".mx_ReplyChain .mx_MFileBody" ) . should ( "exist" ) ;
@@ -315,7 +304,7 @@ describe("Audio player", () => {
315
304
316
305
cy . get ( "blockquote.mx_ReplyChain:first-of-type" ) . within ( ( ) => {
317
306
// Assert that "In reply to" has disappeared
318
- cy . contains ( "In reply to" ) . should ( "not.exist" ) ;
307
+ cy . findByText ( "In reply to" ) . should ( "not.exist" ) ;
319
308
320
309
// Assert that audio file on the first row is rendered as file button
321
310
cy . get ( ".mx_MFileBody_info[role='button']" ) . within ( ( ) => {
@@ -338,7 +327,7 @@ describe("Audio player", () => {
338
327
cy . get ( ".mx_EventTile_last .mx_AudioPlayer_container" ) . should ( "exist" ) ;
339
328
340
329
// Find and click "Reply in thread" button
341
- cy . get ( ".mx_EventTile_last" ) . realHover ( ) . findButton ( " Reply in thread") . click ( ) ;
330
+ cy . get ( ".mx_EventTile_last" ) . realHover ( ) . findByRole ( "button" , { name : " Reply in thread" } ) . click ( ) ;
342
331
} ) ;
343
332
344
333
// On a thread
@@ -351,20 +340,20 @@ describe("Audio player", () => {
351
340
cy . contains ( ".mx_AudioPlayer_seek [role='timer']" , "00:00" ) . should ( "exist" ) ;
352
341
353
342
// Find and click "Play" button
354
- cy . findButton ( " Play") . click ( ) ;
343
+ cy . findByRole ( "button" , { name : " Play" } ) . click ( ) ;
355
344
356
345
// Assert that "Pause" button can be found
357
- cy . findButton ( " Pause") . should ( "exist" ) ;
346
+ cy . findByRole ( "button" , { name : " Pause" } ) . should ( "exist" ) ;
358
347
359
348
// Assert that the timer is reset when the audio file finished playing
360
349
cy . contains ( ".mx_AudioPlayer_seek [role='timer']" , "00:00" ) . should ( "exist" ) ;
361
350
362
351
// Assert that "Play" button can be found
363
- cy . findButton ( " Play") . should ( "exist" ) ;
352
+ cy . findByRole ( "button" , { name : " Play" } ) . should ( "exist" ) ;
364
353
} ) ;
365
354
} )
366
355
. realHover ( )
367
- . findButton ( " Reply")
356
+ . findByRole ( "button" , { name : " Reply" } )
368
357
. click ( ) ; // Find and click "Reply" button
369
358
370
359
cy . get ( ".mx_MessageComposer--compact" ) . within ( ( ) => {
@@ -375,9 +364,9 @@ describe("Audio player", () => {
375
364
} ) ;
376
365
377
366
// Select :smile: emoji and send it
378
- cy . get ( "[data-testid=' basicmessagecomposer'] ") . type ( ":smile:" ) ;
367
+ cy . findByTestId ( " basicmessagecomposer") . type ( ":smile:" ) ;
379
368
cy . get ( ".mx_Autocomplete_Completion[aria-selected='true']" ) . click ( ) ;
380
- cy . get ( "[data-testid=' basicmessagecomposer'] ") . type ( "{enter}" ) ;
369
+ cy . findByTestId ( " basicmessagecomposer") . type ( "{enter}" ) ;
381
370
} ) ;
382
371
383
372
cy . get ( ".mx_EventTile_last" ) . within ( ( ) => {
0 commit comments