@@ -78,7 +78,11 @@ TimePicker12HourFormat.play = async () => {
78
78
// Should display 2:30 PM in the input initially
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
- await expect ( inputScope . getAllByText ( 'PM' ) [ 0 ] ) . toBeVisible ( ) ; // PM in input (actual value, not placeholder)
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
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)
82
86
83
87
await userEvent . click ( input ) ;
84
88
await sleep ( 400 ) ;
@@ -112,8 +116,13 @@ TimePicker24HourFormat.play = async () => {
112
116
await expect ( inputScope . queryByText ( '14' ) ) . toBeVisible ( ) ; // 14 hours in input
113
117
await expect ( inputScope . queryByText ( '30' ) ) . toBeVisible ( ) ; // 30 minutes in input
114
118
// AM/PM should not be in input for 24h format
115
- await expect ( inputScope . queryByText ( 'AM' ) ) . not . toBeInTheDocument ( ) ;
116
- await expect ( inputScope . queryByText ( 'PM' ) ) . not . toBeInTheDocument ( ) ;
119
+ // Check that no visible AM/PM elements exist (not just hidden placeholders)
120
+ const amElements = inputScope . queryAllByText ( 'AM' ) ;
121
+ const pmElements = inputScope . queryAllByText ( 'PM' ) ;
122
+ const visibleAmElements = amElements . filter ( ( el ) => el . offsetHeight > 0 ) ;
123
+ const visiblePmElements = pmElements . filter ( ( el ) => el . offsetHeight > 0 ) ;
124
+ expect ( visibleAmElements ) . toHaveLength ( 0 ) ;
125
+ expect ( visiblePmElements ) . toHaveLength ( 0 ) ;
117
126
118
127
await userEvent . click ( input ) ;
119
128
await sleep ( 400 ) ;
@@ -265,7 +274,11 @@ TimePickerControlledState.play = async () => {
265
274
// Should start with 10:30 AM in input
266
275
await expect ( inputScope . queryByText ( '10' ) ) . toBeVisible ( ) ;
267
276
await expect ( inputScope . queryByText ( '30' ) ) . toBeVisible ( ) ;
268
- await expect ( inputScope . getAllByText ( 'AM' ) [ 0 ] ) . toBeVisible ( ) ; // AM in input (actual value, not placeholder)
277
+ // Find the visible AM element (not the hidden placeholder)
278
+ // Use a more specific approach - look for AM text in the time input container
279
+ const timeInputContainer = inputScope . getByRole ( 'combobox' ) ;
280
+ const amElement = within ( timeInputContainer ) . getByText ( 'AM' ) ;
281
+ await expect ( amElement ) . toBeVisible ( ) ; // AM in input (actual value, not placeholder)
269
282
270
283
// Click change time button
271
284
const changeButton = getByRole ( 'button' , { name : 'Change Time' } ) ;
@@ -279,7 +292,11 @@ TimePickerControlledState.play = async () => {
279
292
// Should now show 3:45 PM in input
280
293
await expect ( inputScope2 . queryByText ( '03' ) ) . toBeVisible ( ) ;
281
294
await expect ( inputScope2 . queryByText ( '45' ) ) . toBeVisible ( ) ;
282
- await expect ( inputScope2 . getAllByText ( 'PM' ) [ 0 ] ) . toBeVisible ( ) ; // PM in input (actual value, not placeholder)
295
+ // Find the visible PM element (not the hidden placeholder)
296
+ // Use a more specific approach - look for PM text in the time input container
297
+ const timeInputContainer2 = inputScope2 . getByRole ( 'combobox' ) ;
298
+ const pmElement2 = within ( timeInputContainer2 ) . getByText ( 'PM' ) ;
299
+ await expect ( pmElement2 ) . toBeVisible ( ) ; // PM in input (actual value, not placeholder)
283
300
284
301
// Verify dropdown also shows correct values
285
302
} ;
@@ -300,6 +317,9 @@ TimePickerDisabled.play = async () => {
300
317
const { getByRole } = within ( document . body ) ;
301
318
const input = getByRole ( 'combobox' ) ;
302
319
320
+ // Verify the input is actually disabled
321
+ expect ( input ) . toHaveAttribute ( 'aria-disabled' , 'true' ) ;
322
+
303
323
await userEvent . click ( input ) ;
304
324
await sleep ( 400 ) ;
305
325
0 commit comments