-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Expand file tree
/
Copy pathdatetime.e2e.ts
More file actions
57 lines (44 loc) · 2.03 KB
/
datetime.e2e.ts
File metadata and controls
57 lines (44 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import { expect } from '@playwright/test';
import { configs, test } from '@utils/test/playwright';
configs({ modes: ['md'], directions: ['ltr'] }).forEach(({ title, config }) => {
test.describe(title('datetime: switching months with different number of days'), () => {
test.beforeEach(async ({ page }) => {
await page.setContent(
`
<ion-datetime locale="en-US" presentation="date" value="2022-01-31"></ion-datetime>
`,
config
);
await page.locator('.datetime-ready').waitFor();
});
test('should switch the calendar header when moving to a month with a different number of days', async ({
page,
}) => {
await page.locator('.datetime-ready').waitFor();
const monthYearToggle = page.locator('ion-datetime .calendar-month-year');
const monthColumnItems = page.locator('ion-datetime .month-column ion-picker-column-option');
await expect(monthYearToggle).toContainText('January 2022');
await monthYearToggle.click();
await page.waitForChanges();
// Wait for the picker to be fully rendered
await page.locator('ion-picker').waitFor({ state: 'visible' });
// February
await monthColumnItems.nth(1).click();
await page.waitForChanges();
await expect(monthYearToggle).toContainText('February 2022');
});
test('should adjust the selected day when moving to a month with a different number of days', async ({ page }) => {
const monthYearToggle = page.locator('ion-datetime .calendar-month-year');
const monthColumnItems = page.locator('ion-datetime .month-column ion-picker-column-option');
const datetime = page.locator('ion-datetime');
const ionChange = await page.spyOnEvent('ionChange');
await monthYearToggle.click();
await page.waitForChanges();
// February
await monthColumnItems.nth(1).click();
await ionChange.next();
await expect(ionChange).toHaveReceivedEventTimes(1);
await expect(datetime).toHaveJSProperty('value', '2022-02-28');
});
});
});