@@ -17,21 +17,28 @@ configs({ modes: ['md'], directions: ['ltr'] }).forEach(({ title, config }) => {
1717 test ( 'should switch the calendar header when moving to a month with a different number of days' , async ( {
1818 page,
1919 } ) => {
20- await page . locator ( '.datetime-ready' ) . waitFor ( ) ;
21-
2220 const monthYearToggle = page . locator ( 'ion-datetime .calendar-month-year' ) ;
2321 const monthColumnItems = page . locator ( 'ion-datetime .month-column ion-picker-column-option' ) ;
2422
2523 await expect ( monthYearToggle ) . toContainText ( 'January 2022' ) ;
2624
25+ // Click to open the picker
2726 await monthYearToggle . click ( ) ;
2827 await page . waitForChanges ( ) ;
2928
30- // Wait for the picker to be fully rendered
31- await page . locator ( 'ion-picker' ) . waitFor ( { state : 'visible' } ) ;
29+ // Wait for the picker to be open
30+ await page . locator ( '.month-year-picker-open' ) . waitFor ( ) ;
31+
32+ // Wait a bit for the picker to fully load
33+ await page . waitForTimeout ( 200 ) ;
34+
35+ const ionChange = await page . spyOnEvent ( 'ionChange' ) ;
36+
37+ // Click on February
38+ await monthColumnItems . filter ( { hasText : 'February' } ) . click ( ) ;
3239
33- // February
34- await monthColumnItems . nth ( 1 ) . click ( ) ;
40+ // Wait for changes
41+ await ionChange . next ( ) ;
3542 await page . waitForChanges ( ) ;
3643
3744 await expect ( monthYearToggle ) . toContainText ( 'February 2022' ) ;
@@ -43,13 +50,23 @@ configs({ modes: ['md'], directions: ['ltr'] }).forEach(({ title, config }) => {
4350 const datetime = page . locator ( 'ion-datetime' ) ;
4451 const ionChange = await page . spyOnEvent ( 'ionChange' ) ;
4552
53+ // Click to open the picker
4654 await monthYearToggle . click ( ) ;
4755 await page . waitForChanges ( ) ;
4856
49- // February
50- await monthColumnItems . nth ( 1 ) . click ( ) ;
57+ // Wait for the picker to be open
58+ await page . locator ( '.month-year-picker-open' ) . waitFor ( ) ;
59+
60+ // Wait a bit for the picker to fully load
61+ await page . waitForTimeout ( 200 ) ;
62+
63+ // Click on February
64+ await monthColumnItems . filter ( { hasText : 'February' } ) . click ( ) ;
5165
66+ // Wait for changes
5267 await ionChange . next ( ) ;
68+ await page . waitForChanges ( ) ;
69+
5370 await expect ( ionChange ) . toHaveReceivedEventTimes ( 1 ) ;
5471 await expect ( datetime ) . toHaveJSProperty ( 'value' , '2022-02-28' ) ;
5572 } ) ;
0 commit comments