@@ -2,11 +2,11 @@ import { test, expect } from '@playwright/test'
22
33/**
44 * Sound functionality tests
5- *
5+ *
66 * These tests verify that:
77 * 1. Preview buttons in sound selector trigger audio playback
88 * 2. Timer completion triggers the selected sound to play
9- *
9+ *
1010 * Note: Actual audio playback cannot be verified in headless mode,
1111 * but we can verify that the audio files are requested from the server.
1212 */
@@ -35,21 +35,24 @@ test.describe('Sound Functionality', () => {
3535 // Set up network request monitoring before clicking preview
3636 // We're monitoring for any MP3 file request
3737 const soundRequestPromise = page . waitForRequest (
38- ( request ) => request . url ( ) . includes ( '/sounds/' ) && request . url ( ) . endsWith ( '.mp3' ) ,
39- { timeout : 3000 }
38+ ( request ) =>
39+ request . url ( ) . includes ( '/sounds/' ) && request . url ( ) . endsWith ( '.mp3' ) ,
40+ { timeout : 3000 } ,
4041 )
4142
42- // Click the preview button for "Chime"
43- const previewButton = page . getByRole ( 'button' , { name : / p r e v i e w c h i m e / i } )
43+ // Click the preview button for "Ascending Chime"
44+ const previewButton = page . getByRole ( 'button' , {
45+ name : / p r e v i e w a s c e n d i n g c h i m e / i,
46+ } )
4447 await previewButton . click ( )
4548
4649 // Verify that a sound file was requested
4750 const soundRequest = await soundRequestPromise
48- expect ( soundRequest . url ( ) ) . toContain ( '/sounds/chime.mp3' )
51+ expect ( soundRequest . url ( ) ) . toContain ( '/sounds/ascending- chime.mp3' )
4952
50- // Verify the request was successful
53+ // Verify the request was successful (200 or 206 for audio streaming)
5154 const response = await soundRequest . response ( )
52- expect ( response ?. status ( ) ) . toBe ( 200 ) // OK response for audio files
55+ expect ( [ 200 , 206 ] ) . toContain ( response ?. status ( ) )
5356 } )
5457
5558 test ( 'all preview buttons trigger sound requests' , async ( { page } ) => {
@@ -64,23 +67,28 @@ test.describe('Sound Functionality', () => {
6467 const soundSelector = page . getByRole ( 'combobox' , { name : / s e l e c t s o u n d / i } )
6568 await soundSelector . click ( )
6669
67- // Test each sound preset
68- const soundPresets = [ 'Gentle Bell ' , 'Soft Alarm ' , 'Digital Beep ' ]
70+ // Test each sound preset (using valid remaining sounds)
71+ const soundPresets = [ 'Bright Ding ' , 'Alert Beep ' , 'Service Bell ' ]
6972
7073 for ( const presetName of soundPresets ) {
7174 // Set up network request monitoring
7275 const soundRequestPromise = page . waitForRequest (
73- ( request ) => request . url ( ) . includes ( '/sounds/' ) && request . url ( ) . endsWith ( '.mp3' ) ,
74- { timeout : 3000 }
76+ ( request ) =>
77+ request . url ( ) . includes ( '/sounds/' ) && request . url ( ) . endsWith ( '.mp3' ) ,
78+ { timeout : 3000 } ,
7579 )
7680
7781 // Click the preview button
78- const previewButton = page . getByRole ( 'button' , { name : new RegExp ( `preview ${ presetName } ` , 'i' ) } )
82+ const previewButton = page . getByRole ( 'button' , {
83+ name : new RegExp ( `preview ${ presetName } ` , 'i' ) ,
84+ } )
7985 await previewButton . click ( )
8086
8187 // Verify sound request was made
8288 const soundRequest = await soundRequestPromise
83- expect ( soundRequest . url ( ) ) . toMatch ( / \/ s o u n d s \/ ( g e n t l e - b e l l | c h i m e | s o f t - a l a r m | d i g i t a l - b e e p ) \. m p 3 / )
89+ expect ( soundRequest . url ( ) ) . toMatch (
90+ / \/ s o u n d s \/ ( a s c e n d i n g - c h i m e | b r i g h t - d i n g | a l e r t - b e e p | s e r v i c e - b e l l ) \. m p 3 / ,
91+ )
8492
8593 // Wait a bit before testing next sound
8694 await page . waitForTimeout ( 500 )
@@ -118,7 +126,7 @@ test.describe('Sound Functionality', () => {
118126 const url = request . url ( )
119127 return url . includes ( '/sounds/' ) && url . endsWith ( '.mp3' )
120128 } ,
121- { timeout : 6000 } // 3 seconds for timer + 3 seconds buffer
129+ { timeout : 6000 } , // 3 seconds for timer + 3 seconds buffer
122130 )
123131
124132 // Start the timer
@@ -127,14 +135,14 @@ test.describe('Sound Functionality', () => {
127135
128136 // Verify timer started
129137 await expect ( page . getByRole ( 'button' , { name : / p a u s e / i } ) ) . toBeVisible ( {
130- timeout : 1000
138+ timeout : 1000 ,
131139 } )
132140
133141 // Wait for sound request when timer completes
134142 const soundRequest = await soundRequestPromise
135143
136- // Verify the correct sound file was requested (default is gentle-bell )
137- expect ( soundRequest . url ( ) ) . toContain ( '/sounds/gentle-bell .mp3' )
144+ // Verify the correct sound file was requested (default is ascending-chime )
145+ expect ( soundRequest . url ( ) ) . toContain ( '/sounds/ascending-chime .mp3' )
138146
139147 // Verify the request was successful (206 for partial content/streaming)
140148 const response = await soundRequest . response ( )
@@ -145,7 +153,9 @@ test.describe('Sound Functionality', () => {
145153 } )
146154
147155 // TODO: Fix timer completion sound test - same issue as above
148- test . skip ( 'timer completion respects selected sound preset' , async ( { page } ) => {
156+ test . skip ( 'timer completion respects selected sound preset' , async ( {
157+ page,
158+ } ) => {
149159 await page . goto ( '/en' )
150160 await page . waitForLoadState ( 'domcontentloaded' )
151161
@@ -160,7 +170,9 @@ test.describe('Sound Functionality', () => {
160170 const soundSelector = page . getByRole ( 'combobox' , { name : / s e l e c t s o u n d / i } )
161171 await soundSelector . click ( )
162172
163- const digitalBeepOption = page . getByRole ( 'option' , { name : / d i g i t a l b e e p / i } )
173+ const digitalBeepOption = page . getByRole ( 'option' , {
174+ name : / d i g i t a l b e e p / i,
175+ } )
164176 await digitalBeepOption . click ( )
165177
166178 // Close settings
@@ -181,8 +193,8 @@ test.describe('Sound Functionality', () => {
181193
182194 // Set up network request monitoring BEFORE starting timer
183195 const soundRequestPromise = page . waitForRequest (
184- ( request ) => request . url ( ) . includes ( '/sounds/digital-beep .mp3' ) ,
185- { timeout : 6000 }
196+ ( request ) => request . url ( ) . includes ( '/sounds/ascending-chime .mp3' ) ,
197+ { timeout : 6000 } ,
186198 )
187199
188200 // Start the timer
@@ -191,12 +203,12 @@ test.describe('Sound Functionality', () => {
191203
192204 // Verify timer started
193205 await expect ( page . getByRole ( 'button' , { name : / p a u s e / i } ) ) . toBeVisible ( {
194- timeout : 1000
206+ timeout : 1000 ,
195207 } )
196208
197209 // Wait for timer to complete and verify correct sound was requested
198210 const soundRequest = await soundRequestPromise
199- expect ( soundRequest . url ( ) ) . toContain ( '/sounds/digital-beep .mp3' )
211+ expect ( soundRequest . url ( ) ) . toContain ( '/sounds/ascending-chime .mp3' )
200212
201213 // Verify the request was successful
202214 const response = await soundRequest . response ( )
@@ -223,7 +235,9 @@ test.describe('Sound Functionality', () => {
223235 // Use JavaScript to find and click the None option by text content
224236 await page . evaluate ( ( ) => {
225237 const options = Array . from ( document . querySelectorAll ( '[role="option"]' ) )
226- const noneOption = options . find ( option => option . textContent ?. trim ( ) === 'None' ) as HTMLElement
238+ const noneOption = options . find (
239+ ( option ) => option . textContent ?. trim ( ) === 'None' ,
240+ ) as HTMLElement
227241 if ( noneOption ) {
228242 // Ensure the element is visible and clickable
229243 noneOption . style . display = 'block'
@@ -252,7 +266,10 @@ test.describe('Sound Functionality', () => {
252266 // Track all network requests
253267 const soundRequests : string [ ] = [ ]
254268 page . on ( 'request' , ( request ) => {
255- if ( request . url ( ) . includes ( '/sounds/' ) && request . url ( ) . endsWith ( '.mp3' ) ) {
269+ if (
270+ request . url ( ) . includes ( '/sounds/' ) &&
271+ request . url ( ) . endsWith ( '.mp3' )
272+ ) {
256273 soundRequests . push ( request . url ( ) )
257274 }
258275 } )
@@ -288,12 +305,15 @@ test.describe('Sound Functionality', () => {
288305
289306 // Set up network monitoring
290307 const soundRequestPromise = page . waitForRequest (
291- ( request ) => request . url ( ) . includes ( '/sounds/' ) && request . url ( ) . endsWith ( '.mp3' ) ,
292- { timeout : 3000 }
308+ ( request ) =>
309+ request . url ( ) . includes ( '/sounds/' ) && request . url ( ) . endsWith ( '.mp3' ) ,
310+ { timeout : 3000 } ,
293311 )
294312
295- // Click the preview button directly
296- const previewButton = page . getByRole ( 'button' , { name : / p r e v i e w g e n t l e b e l l / i } )
313+ // Click the preview button directly (using valid remaining sound)
314+ const previewButton = page . getByRole ( 'button' , {
315+ name : / p r e v i e w a s c e n d i n g c h i m e / i,
316+ } )
297317 await expect ( previewButton ) . toBeVisible ( )
298318 await previewButton . click ( )
299319
@@ -306,4 +326,3 @@ test.describe('Sound Functionality', () => {
306326 expect ( ariaLabel ) . toContain ( 'Preview' )
307327 } )
308328} )
309-
0 commit comments