Skip to content

test(datetime): migrate tests to playwright #25400

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 53 commits into from
Jun 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
c273d35
test(datetime): migrate basic tests
liamdebeasi Jun 1, 2022
a9f2664
test(datetime): migrate color test
liamdebeasi Jun 1, 2022
c699ba7
test(datetime): migrate disable-dates tests
liamdebeasi Jun 1, 2022
16a8d4d
chore(): lint
liamdebeasi Jun 1, 2022
5e95ed6
test(datetime): migrate display tests
liamdebeasi Jun 2, 2022
f42d3eb
chore(): clean up
liamdebeasi Jun 2, 2022
128e6ca
test(datetime): migrate first day of week test
liamdebeasi Jun 2, 2022
360d9fc
test(datetime): migrate hour cycle tests
liamdebeasi Jun 2, 2022
2622e64
test(datetime): migrate position test
liamdebeasi Jun 2, 2022
d89626a
test(datetime): migrate minmax tests
liamdebeasi Jun 2, 2022
ab7eaa2
test(datetime): migrate set-value tests
liamdebeasi Jun 2, 2022
d2559e5
test(datetime): migrate sub-pixel-width tests
liamdebeasi Jun 2, 2022
4135dc7
chore(): remove old test
liamdebeasi Jun 3, 2022
beb39b8
test(datetime): migrate time-label tests
liamdebeasi Jun 3, 2022
84f7ca2
chore(): remove unneeded values test
liamdebeasi Jun 3, 2022
9e66bed
test(datetime): migrate remaining basic test
liamdebeasi Jun 3, 2022
182b64a
test(datetime): migrate zoom tests
liamdebeasi Jun 3, 2022
22c9906
test(datetime): migrate remaining test
liamdebeasi Jun 3, 2022
4cce9f7
chore: sync with main
liamdebeasi Jun 3, 2022
214b4bb
chore(): fix active day test
liamdebeasi Jun 3, 2022
439c8e6
chore(): wait for datetime to be ready before screenshot
liamdebeasi Jun 3, 2022
69c37c8
chore(): add updated snapshots
Ionitron Jun 3, 2022
4d16314
chore(): improve reliability of month-year-picker tests
liamdebeasi Jun 3, 2022
9554f03
chore(): improve disable dates reliability
liamdebeasi Jun 3, 2022
505387f
Merge branch 'FW-1202' of https://github.com/ionic-team/ionic-framewo…
liamdebeasi Jun 3, 2022
62d2ff2
Merge branch 'main' into FW-1202
liamdebeasi Jun 3, 2022
43a561f
chore(): ensure screenshot datetimes have a value
liamdebeasi Jun 6, 2022
ab1ea9a
Merge branch 'FW-1202' of https://github.com/ionic-team/ionic-framewo…
liamdebeasi Jun 6, 2022
e2417b7
chore(): lint
liamdebeasi Jun 6, 2022
b1a99e0
Update core/src/components/datetime/test/basic/datetime.e2e.ts
liamdebeasi Jun 6, 2022
ad5fe20
chore(): improve reliability of time test
liamdebeasi Jun 6, 2022
44b2938
chore(): improve reliability of screenshot
liamdebeasi Jun 6, 2022
1acba91
test(datetime): add values test
liamdebeasi Jun 6, 2022
50ce736
chore: revert screenshots
liamdebeasi Jun 6, 2022
c699a5a
chore(): improve cover test reliability
liamdebeasi Jun 6, 2022
83c5a2e
chore(): add updated snapshots
Ionitron Jun 6, 2022
e70ad45
chore(): remove test.skip
liamdebeasi Jun 6, 2022
bd499a9
Merge branch 'FW-1202' of https://github.com/ionic-team/ionic-framewo…
liamdebeasi Jun 6, 2022
6e599b3
chore(): improve display tests
liamdebeasi Jun 6, 2022
411bfc3
chore: revert screenshots
liamdebeasi Jun 6, 2022
bb43dd5
chore(): lint
liamdebeasi Jun 6, 2022
468f5ca
chore(): add updated snapshots
Ionitron Jun 6, 2022
086cb06
Merge branch 'FW-1202' of https://github.com/ionic-team/ionic-framewo…
liamdebeasi Jun 6, 2022
42ce41e
chore(): set date to earlier to avoid flaky screenshots
liamdebeasi Jun 6, 2022
004c06f
chore(): add updated snapshots
Ionitron Jun 6, 2022
714c9c4
chore(): clearn screenshots
liamdebeasi Jun 7, 2022
0332b9a
chore(): add updated snapshots
Ionitron Jun 7, 2022
499d81c
Revert "chore(): add updated snapshots"
liamdebeasi Jun 7, 2022
0ee620d
Revert "chore(): clearn screenshots"
liamdebeasi Jun 7, 2022
d743984
Revert "chore(): add updated snapshots"
liamdebeasi Jun 7, 2022
d9d9cb3
Revert "chore(): add updated snapshots"
liamdebeasi Jun 7, 2022
196ebed
chore(): add updated snapshots
Ionitron Jun 7, 2022
c19673b
Merge branch 'main' into FW-1202
liamdebeasi Jun 7, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 108 additions & 0 deletions core/src/components/datetime/test/basic/datetime.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,21 @@ test.describe('datetime: selecting a day', () => {
test('should not highlight a day until one is selected, with default-buttons', async ({ page }) => {
await testHighlight(page, 'custom-datetime');
});
test('should update the active day', async ({ page }) => {
await page.setContent(`
<ion-datetime show-default-buttons="true" value="2021-12-25T12:40:00.000Z"></ion-datetime>
`);

const activeDay = page.locator('ion-datetime .calendar-day-active');

expect(activeDay).toHaveText('25');

const dayBtn = page.locator('ion-datetime .calendar-day[data-day="13"][data-month="12"]');
await dayBtn.click();
await page.waitForChanges();

expect(activeDay).toHaveText('13');
});
});

test.describe('datetime: confirm date', () => {
Expand All @@ -45,4 +60,97 @@ test.describe('datetime: confirm date', () => {
const valueAgain = await datetime.evaluate((el: HTMLIonDatetimeElement) => el.value);
expect(valueAgain).toBeUndefined();
});
test('should set the date value based on the selected date', async ({ page }) => {
await page.setContent(`
<button id="bind">Bind datetimeMonthDidChange event</button>
<ion-datetime value="2021-12-25T12:40:00.000Z"></ion-datetime>
<script type="module">
import { InitMonthDidChangeEvent } from '/src/components/datetime/test/utils/month-did-change-event.js';
document.querySelector('button').addEventListener('click', function() {
InitMonthDidChangeEvent();
});
</script>
`);

const datetimeMonthDidChange = await page.spyOnEvent('datetimeMonthDidChange');
const eventButton = page.locator('button#bind');
await eventButton.click();

const buttons = page.locator('ion-datetime .calendar-next-prev ion-button');
await buttons.nth(1).click();

await datetimeMonthDidChange.next();

const datetime = page.locator('ion-datetime');
await datetime.evaluate((el: HTMLIonDatetimeElement) => el.confirm());

// Value may include timezone information so we need to check
// that the value at least includes the correct date/time info.
const value = (await datetime.evaluate((el: HTMLIonDatetimeElement) => el.value))!;
expect(value.includes('2021-12-25T12:40:00')).toBe(true);
});
});

test.describe('datetime: footer', () => {
test('should render default buttons', async ({ page }) => {
await page.setContent('<ion-datetime value="2022-05-03" show-default-buttons="true"></ion-datetime>');

const cancelButton = page.locator('ion-datetime #cancel-button');
expect(cancelButton).toHaveText('Cancel');

const confirmButton = page.locator('ion-datetime #confirm-button');
expect(confirmButton).toHaveText('Done');

const datetime = page.locator('ion-datetime');
expect(await datetime.screenshot()).toMatchSnapshot(
`datetime-footer-default-buttons-${page.getSnapshotSettings()}.png`
);
});
test('should render clear button', async ({ page }) => {
await page.setContent('<ion-datetime value="2022-05-03" show-clear-button="true"></ion-datetime>');

const clearButton = page.locator('ion-datetime #clear-button');
expect(clearButton).toHaveText('Clear');

const datetime = page.locator('ion-datetime');
expect(await datetime.screenshot()).toMatchSnapshot(
`datetime-footer-clear-button-${page.getSnapshotSettings()}.png`
);
});
test('should render default and clear buttons', async ({ page }) => {
await page.setContent(
'<ion-datetime value="2022-05-03" show-default-buttons="true" show-clear-button="true"></ion-datetime>'
);

const cancelButton = page.locator('ion-datetime #cancel-button');
expect(cancelButton).toHaveText('Cancel');

const confirmButton = page.locator('ion-datetime #confirm-button');
expect(confirmButton).toHaveText('Done');

const clearButton = page.locator('ion-datetime #clear-button');
expect(clearButton).toHaveText('Clear');

const datetime = page.locator('ion-datetime');
expect(await datetime.screenshot()).toMatchSnapshot(
`datetime-footer-default-clear-buttons-${page.getSnapshotSettings()}.png`
);
});
test('should render custom buttons', async ({ page }) => {
await page.setContent(`
<ion-datetime value="2022-05-03">
<ion-buttons slot="buttons">
<ion-button id="custom-button" color="primary">Hello!</ion-button>
</ion-buttons>
</ion-datetime>
`);

const customButton = page.locator('ion-datetime #custom-button');
expect(customButton).toBeVisible();

const datetime = page.locator('ion-datetime');
expect(await datetime.screenshot()).toMatchSnapshot(
`datetime-footer-custom-buttons-${page.getSnapshotSettings()}.png`
);
});
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
144 changes: 0 additions & 144 deletions core/src/components/datetime/test/basic/e2e.ts

This file was deleted.

43 changes: 43 additions & 0 deletions core/src/components/datetime/test/color/datetime.e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { expect } from '@playwright/test';
import { test } from '@utils/test/playwright';

test.describe('datetime: color', () => {
test('should not have visual regressions', async ({ page }) => {
await page.goto('/src/components/datetime/test/color');

const colorSelect = page.locator('ion-select');
const darkModeToggle = page.locator('ion-checkbox');
const datetime = page.locator('ion-datetime');

await darkModeToggle.evaluate((el: HTMLIonCheckboxElement) => (el.checked = true));
await page.waitForChanges();

expect(await datetime.first().screenshot()).toMatchSnapshot(
`datetime-color-default-dark-${page.getSnapshotSettings()}.png`
);
expect(await datetime.last().screenshot()).toMatchSnapshot(
`datetime-color-custom-dark-${page.getSnapshotSettings()}.png`
);

await darkModeToggle.evaluate((el: HTMLIonCheckboxElement) => (el.checked = false));
await colorSelect.evaluate((el: HTMLIonSelectElement) => (el.value = 'danger'));
await page.waitForChanges();

expect(await datetime.first().screenshot()).toMatchSnapshot(
`datetime-color-default-light-color-${page.getSnapshotSettings()}.png`
);
expect(await datetime.last().screenshot()).toMatchSnapshot(
`datetime-color-custom-light-color-${page.getSnapshotSettings()}.png`
);

await darkModeToggle.evaluate((el: HTMLIonCheckboxElement) => (el.checked = true));
await page.waitForChanges();

expect(await datetime.first().screenshot()).toMatchSnapshot(
`datetime-color-default-dark-color-${page.getSnapshotSettings()}.png`
);
expect(await datetime.last().screenshot()).toMatchSnapshot(
`datetime-color-custom-dark-color-${page.getSnapshotSettings()}.png`
);
});
});
33 changes: 0 additions & 33 deletions core/src/components/datetime/test/color/e2e.ts

This file was deleted.

4 changes: 2 additions & 2 deletions core/src/components/datetime/test/color/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,12 @@
<div class="grid">
<div class="grid-item">
<h2>Default</h2>
<ion-datetime show-default-title="true" show-default-buttons="true"></ion-datetime>
<ion-datetime value="2022-05-03" show-default-title="true" show-default-buttons="true"></ion-datetime>
</div>

<div class="grid-item">
<h2>Custom</h2>
<ion-datetime show-default-title="true" show-default-buttons="true">
<ion-datetime value="2022-05-03" show-default-title="true" show-default-buttons="true">
<ion-buttons slot="buttons">
<ion-button color="danger">Reset</ion-button>
<ion-button color="primary">Confirm</ion-button>
Expand Down
Loading