@@ -79,10 +79,12 @@ TimePicker12HourFormat.play = async () => {
79
79
await expect ( inputScope . queryByText ( '02' ) ) . toBeVisible ( ) ; // 2 PM in input
80
80
await expect ( inputScope . queryByText ( '30' ) ) . toBeVisible ( ) ; // 30 minutes in input
81
81
// Find the visible PM element (not the hidden placeholder)
82
- // Use a more specific approach - look for PM text in the time input container
82
+ // Use getAllByText since there are multiple PM elements (placeholder + value)
83
83
const timeInputContainer = inputScope . getByRole ( 'combobox' ) ;
84
- const pmElement = within ( timeInputContainer ) . getByText ( 'PM' ) ;
85
- await expect ( pmElement ) . toBeVisible ( ) ; // PM in input (actual value, not placeholder)
84
+ const pmElements = within ( timeInputContainer ) . getAllByText ( 'PM' ) ;
85
+ const visiblePmElement = pmElements . find ( ( el ) => el . style . pointerEvents !== 'none' ) ;
86
+ expect ( visiblePmElement ) . toBeDefined ( ) ; // Ensure we found a visible element
87
+ await expect ( visiblePmElement ) . toBeVisible ( ) ; // PM in input (actual value, not placeholder)
86
88
87
89
await userEvent . click ( input ) ;
88
90
await sleep ( 400 ) ;
@@ -121,8 +123,8 @@ TimePicker24HourFormat.play = async () => {
121
123
const pmElements = inputScope . queryAllByText ( 'PM' ) ;
122
124
const visibleAmElements = amElements . filter ( ( el ) => el . offsetHeight > 0 ) ;
123
125
const visiblePmElements = pmElements . filter ( ( el ) => el . offsetHeight > 0 ) ;
124
- expect ( visibleAmElements ) . toHaveLength ( 0 ) ;
125
- expect ( visiblePmElements ) . toHaveLength ( 0 ) ;
126
+ await expect ( visibleAmElements ) . toHaveLength ( 0 ) ;
127
+ await expect ( visiblePmElements ) . toHaveLength ( 0 ) ;
126
128
127
129
await userEvent . click ( input ) ;
128
130
await sleep ( 400 ) ;
@@ -275,10 +277,12 @@ TimePickerControlledState.play = async () => {
275
277
await expect ( inputScope . queryByText ( '10' ) ) . toBeVisible ( ) ;
276
278
await expect ( inputScope . queryByText ( '30' ) ) . toBeVisible ( ) ;
277
279
// Find the visible AM element (not the hidden placeholder)
278
- // Use a more specific approach - look for AM text in the time input container
280
+ // Use getAllByText since there are multiple AM elements (placeholder + value)
279
281
const timeInputContainer = inputScope . getByRole ( 'combobox' ) ;
280
- const amElement = within ( timeInputContainer ) . getByText ( 'AM' ) ;
281
- await expect ( amElement ) . toBeVisible ( ) ; // AM in input (actual value, not placeholder)
282
+ const amElements = within ( timeInputContainer ) . getAllByText ( 'AM' ) ;
283
+ const visibleAmElement = amElements . find ( ( el ) => el . style . pointerEvents !== 'none' ) ;
284
+ expect ( visibleAmElement ) . toBeDefined ( ) ; // Ensure we found a visible element
285
+ await expect ( visibleAmElement ) . toBeVisible ( ) ; // AM in input (actual value, not placeholder)
282
286
283
287
// Click change time button
284
288
const changeButton = getByRole ( 'button' , { name : 'Change Time' } ) ;
@@ -293,10 +297,12 @@ TimePickerControlledState.play = async () => {
293
297
await expect ( inputScope2 . queryByText ( '03' ) ) . toBeVisible ( ) ;
294
298
await expect ( inputScope2 . queryByText ( '45' ) ) . toBeVisible ( ) ;
295
299
// Find the visible PM element (not the hidden placeholder)
296
- // Use a more specific approach - look for PM text in the time input container
300
+ // Use getAllByText since there are multiple PM elements (placeholder + value)
297
301
const timeInputContainer2 = inputScope2 . getByRole ( 'combobox' ) ;
298
- const pmElement2 = within ( timeInputContainer2 ) . getByText ( 'PM' ) ;
299
- await expect ( pmElement2 ) . toBeVisible ( ) ; // PM in input (actual value, not placeholder)
302
+ const pmElements2 = within ( timeInputContainer2 ) . getAllByText ( 'PM' ) ;
303
+ const visiblePmElement2 = pmElements2 . find ( ( el ) => el . style . pointerEvents !== 'none' ) ;
304
+ expect ( visiblePmElement2 ) . toBeDefined ( ) ; // Ensure we found a visible element
305
+ await expect ( visiblePmElement2 ) . toBeVisible ( ) ; // PM in input (actual value, not placeholder)
300
306
301
307
// Verify dropdown also shows correct values
302
308
} ;
@@ -318,7 +324,7 @@ TimePickerDisabled.play = async () => {
318
324
const input = getByRole ( 'combobox' ) ;
319
325
320
326
// Verify the input is actually disabled
321
- expect ( input ) . toHaveAttribute ( 'aria-disabled' , 'true' ) ;
327
+ await expect ( input ) . toHaveAttribute ( 'aria-disabled' , 'true' ) ;
322
328
323
329
await userEvent . click ( input ) ;
324
330
await sleep ( 400 ) ;
0 commit comments