@@ -40,7 +40,7 @@ test.describe("Audio player", { tag: ["@no-firefox", "@no-webkit"] }, () => {
40
40
// wait for the tile to finish loading
41
41
await expect (
42
42
page
43
- . locator ( ".mx_AudioPlayer_mediaName ")
43
+ . getByTestId ( "audio-player-name ")
44
44
. last ( )
45
45
. filter ( { hasText : file . split ( "/" ) . at ( - 1 ) } ) ,
46
46
) . toBeVisible ( ) ;
@@ -55,12 +55,10 @@ test.describe("Audio player", { tag: ["@no-firefox", "@no-webkit"] }, () => {
55
55
// Check that the audio player is rendered and its button becomes visible
56
56
const checkPlayerVisibility = async ( locator : Locator ) => {
57
57
// Assert that the audio player and media information are visible
58
- const mediaInfo = locator . locator (
59
- ".mx_EventTile_mediaLine .mx_MAudioBody .mx_AudioPlayer_container .mx_AudioPlayer_mediaInfo" ,
60
- ) ;
61
- await expect ( mediaInfo . locator ( ".mx_AudioPlayer_mediaName" , { hasText : ".ogg" } ) ) . toBeVisible ( ) ; // extension
62
- await expect ( mediaInfo . locator ( ".mx_AudioPlayer_byline" , { hasText : "00:01" } ) ) . toBeVisible ( ) ;
63
- await expect ( mediaInfo . locator ( ".mx_AudioPlayer_byline" , { hasText : "(3.56 KB)" } ) ) . toBeVisible ( ) ; // actual size
58
+ const mediaInfo = locator . getByRole ( "region" , { name : "Audio player" } ) ;
59
+ await expect ( mediaInfo . getByText ( ".ogg" ) ) . toBeVisible ( ) ; // extension
60
+ await expect ( mediaInfo . getByRole ( "time" ) ) . toHaveText ( "00:01" ) ; // duration
61
+ await expect ( mediaInfo . getByText ( "(3.56 KB)" ) ) . toBeVisible ( ) ; // actual size;
64
62
65
63
// Assert that the play button can be found and is visible
66
64
await expect ( locator . getByRole ( "button" , { name : "Play" } ) ) . toBeVisible ( ) ;
@@ -79,7 +77,7 @@ test.describe("Audio player", { tag: ["@no-firefox", "@no-webkit"] }, () => {
79
77
}
80
78
81
79
// Check the status of the seek bar
82
- expect ( await page . locator ( ".mx_AudioPlayer_seek input[type='range'] ") . count ( ) ) . toBeGreaterThan ( 0 ) ;
80
+ expect ( await page . getByRole ( "region" , { name : "Audio player" } ) . getByRole ( "slider ") . count ( ) ) . toBeGreaterThan ( 0 ) ;
83
81
84
82
// Enable IRC layout
85
83
await app . settings . setValue ( "layout" , null , SettingLevel . DEVICE , Layout . IRC ) ;
@@ -101,7 +99,7 @@ test.describe("Audio player", { tag: ["@no-firefox", "@no-webkit"] }, () => {
101
99
display: none !important;
102
100
}
103
101
` ,
104
- mask : [ page . locator ( ".mx_AudioPlayer_seek ") ] ,
102
+ mask : [ page . getByTestId ( "audio-player-seek ") ] ,
105
103
} ;
106
104
107
105
// Take a snapshot of mx_EventTile_last on IRC layout
@@ -187,9 +185,9 @@ test.describe("Audio player", { tag: ["@no-firefox", "@no-webkit"] }, () => {
187
185
await uploadFile ( page , "playwright/sample-files/1sec.ogg" ) ;
188
186
189
187
// Assert that the audio player is rendered
190
- const container = page . locator ( ".mx_EventTile_last .mx_AudioPlayer_container" ) ;
188
+ const container = page . locator ( ".mx_EventTile_last" ) . getByRole ( "region" , { name : "Audio player" } ) ;
191
189
// Assert that the counter is zero before clicking the play button
192
- await expect ( container . locator ( ".mx_AudioPlayer_seek [role=' timer']" , { hasText : "00:00" } ) ) . toBeVisible ( ) ;
190
+ await expect ( container . getByRole ( " timer" ) ) . toHaveText ( "00:00" ) ;
193
191
194
192
// Find and click "Play" button, the wait is to make the test less flaky
195
193
await expect ( container . getByRole ( "button" , { name : "Play" } ) ) . toBeVisible ( ) ;
@@ -199,7 +197,7 @@ test.describe("Audio player", { tag: ["@no-firefox", "@no-webkit"] }, () => {
199
197
await expect ( container . getByRole ( "button" , { name : "Pause" } ) ) . toBeVisible ( ) ;
200
198
201
199
// Assert that the timer is reset when the audio file finished playing
202
- await expect ( container . locator ( ".mx_AudioPlayer_seek [role=' timer']" , { hasText : "00:00" } ) ) . toBeVisible ( ) ;
200
+ await expect ( container . getByRole ( " timer" ) ) . toHaveText ( "00:00" ) ;
203
201
204
202
// Assert that "Play" button can be found
205
203
await expect ( container . getByRole ( "button" , { name : "Play" } ) ) . toBeVisible ( ) ;
@@ -227,7 +225,7 @@ test.describe("Audio player", { tag: ["@no-firefox", "@no-webkit"] }, () => {
227
225
await uploadFile ( page , "playwright/sample-files/1sec.ogg" ) ;
228
226
229
227
// Assert the audio player is rendered
230
- await expect ( page . locator ( ".mx_EventTile_last .mx_AudioPlayer_container" ) ) . toBeVisible ( ) ;
228
+ await expect ( page . getByRole ( "region" , { name : "Audio player" } ) ) . toBeVisible ( ) ;
231
229
232
230
// Find and click "Reply" button on MessageActionBar
233
231
const tile = page . locator ( ".mx_EventTile_last" ) ;
@@ -237,7 +235,7 @@ test.describe("Audio player", { tag: ["@no-firefox", "@no-webkit"] }, () => {
237
235
await uploadFile ( page , "playwright/sample-files/1sec.ogg" ) ;
238
236
239
237
// Assert that the audio player is rendered
240
- await expect ( tile . locator ( ".mx_AudioPlayer_container" ) ) . toBeVisible ( ) ;
238
+ await expect ( tile . getByRole ( "region" , { name : "Audio player" } ) ) . toBeVisible ( ) ;
241
239
242
240
// Assert that replied audio file is rendered as file button inside ReplyChain
243
241
const button = tile . locator ( ".mx_ReplyChain_wrapper .mx_MFileBody_info[role='button']" ) ;
@@ -262,23 +260,27 @@ test.describe("Audio player", { tag: ["@no-firefox", "@no-webkit"] }, () => {
262
260
await uploadFile ( page , "playwright/sample-files/upload-first.ogg" ) ;
263
261
264
262
// Assert that the audio player is rendered
265
- await expect ( page . locator ( ".mx_EventTile_last .mx_AudioPlayer_container" ) ) . toBeVisible ( ) ;
263
+ await expect (
264
+ page . locator ( ".mx_EventTile_last" ) . getByRole ( "region" , { name : "Audio player" } ) ,
265
+ ) . toBeVisible ( ) ;
266
266
267
267
await clickButtonReply ( tile ) ;
268
268
269
269
// Reply to the player with another audio file
270
270
await uploadFile ( page , "playwright/sample-files/upload-second.ogg" ) ;
271
271
272
272
// Assert that the audio player is rendered
273
- await expect ( page . locator ( ".mx_EventTile_last .mx_AudioPlayer_container" ) ) . toBeVisible ( ) ;
273
+ await expect (
274
+ page . locator ( ".mx_EventTile_last" ) . getByRole ( "region" , { name : "Audio player" } ) ,
275
+ ) . toBeVisible ( ) ;
274
276
275
277
await clickButtonReply ( tile ) ;
276
278
277
279
// Reply to the player with yet another audio file to create a reply chain
278
280
await uploadFile ( page , "playwright/sample-files/upload-third.ogg" ) ;
279
281
280
282
// Assert that the audio player is rendered
281
- await expect ( tile . locator ( ".mx_AudioPlayer_container" ) ) . toBeVisible ( ) ;
283
+ await expect ( tile . getByRole ( "region" , { name : "Audio player" } ) ) . toBeVisible ( ) ;
282
284
283
285
// Assert that there are two "mx_ReplyChain" elements
284
286
await expect ( tile . locator ( ".mx_ReplyChain" ) ) . toHaveCount ( 2 ) ;
@@ -314,18 +316,20 @@ test.describe("Audio player", { tag: ["@no-firefox", "@no-webkit"] }, () => {
314
316
// On the main timeline
315
317
const messageList = page . locator ( ".mx_RoomView_MessageList" ) ;
316
318
// Assert the audio player is rendered
317
- await expect ( messageList . locator ( ".mx_EventTile_last .mx_AudioPlayer_container" ) ) . toBeVisible ( ) ;
319
+ await expect (
320
+ messageList . locator ( ".mx_EventTile_last" ) . getByRole ( "region" , { name : "Audio player" } ) ,
321
+ ) . toBeVisible ( ) ;
318
322
// Find and click "Reply in thread" button
319
323
await messageList . locator ( ".mx_EventTile_last" ) . hover ( ) ;
320
324
await messageList . locator ( ".mx_EventTile_last" ) . getByRole ( "button" , { name : "Reply in thread" } ) . click ( ) ;
321
325
322
326
// On a thread
323
327
const thread = page . locator ( ".mx_ThreadView" ) ;
324
328
const threadTile = thread . locator ( ".mx_EventTile_last" ) ;
325
- const audioPlayer = threadTile . locator ( ".mx_AudioPlayer_container" ) ;
329
+ const audioPlayer = threadTile . getByRole ( "region" , { name : "Audio player" } ) ;
326
330
327
331
// Assert that the counter is zero before clicking the play button
328
- await expect ( audioPlayer . locator ( ".mx_AudioPlayer_seek [role=' timer']" , { hasText : "00:00" } ) ) . toBeVisible ( ) ;
332
+ await expect ( audioPlayer . getByRole ( " timer" ) ) . toHaveText ( "00:00" ) ;
329
333
330
334
// Find and click "Play" button, the wait is to make the test less flaky
331
335
await expect ( audioPlayer . getByRole ( "button" , { name : "Play" } ) ) . toBeVisible ( ) ;
@@ -335,7 +339,7 @@ test.describe("Audio player", { tag: ["@no-firefox", "@no-webkit"] }, () => {
335
339
await expect ( audioPlayer . getByRole ( "button" , { name : "Pause" } ) ) . toBeVisible ( ) ;
336
340
337
341
// Assert that the timer is reset when the audio file finished playing
338
- await expect ( audioPlayer . locator ( ".mx_AudioPlayer_seek [role=' timer']" , { hasText : "00:00" } ) ) . toBeVisible ( ) ;
342
+ await expect ( audioPlayer . getByRole ( " timer" ) ) . toHaveText ( "00:00" ) ;
339
343
340
344
// Assert that "Play" button can be found
341
345
await expect ( audioPlayer . getByRole ( "button" , { name : "Play" } ) ) . not . toBeDisabled ( ) ;
0 commit comments