Skip to content

Commit 1017729

Browse files
committed
test(datetime): fix flaky tests
1 parent a00a389 commit 1017729

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

core/src/components/datetime/test/custom/datetime.e2e.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ configs({ directions: ['ltr'] }).forEach(({ title, screenshot, config }) => {
3030
test('should allow styling calendar days in grid style datetimes', async ({ page }) => {
3131
const datetime = page.locator('#custom-calendar-days');
3232

33+
await page.locator('.datetime-ready').waitFor();
34+
3335
await expect(datetime).toHaveScreenshot(screenshot(`datetime-custom-calendar-days`));
3436
});
3537
});

core/src/components/datetime/test/custom/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ <h2>Grid Style</h2>
164164
const customDatetime = document.querySelector('#custom-calendar-days');
165165

166166
// Mock the current day to always have the same screenshots
167-
const mockToday = '2023-06-10T16:22';
167+
const mockToday = '2023-06-10T16:22:00.000Z';
168168
Date = class extends Date {
169169
constructor(...args) {
170170
if (args.length === 0) {

core/src/components/datetime/test/datetime.e2e.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ 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+
2022
const monthYearToggle = page.locator('ion-datetime .calendar-month-year');
2123
const monthColumnItems = page.locator('ion-datetime .month-column ion-picker-column-option');
2224

@@ -25,6 +27,9 @@ configs({ modes: ['md'], directions: ['ltr'] }).forEach(({ title, config }) => {
2527
await monthYearToggle.click();
2628
await page.waitForChanges();
2729

30+
// Wait for the picker to be fully rendered
31+
await page.locator('ion-picker').waitFor({ state: 'visible' });
32+
2833
// February
2934
await monthColumnItems.nth(1).click();
3035
await page.waitForChanges();

0 commit comments

Comments
 (0)