-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(toggle): migrate tests to Playwright (#25394)
- Loading branch information
1 parent
52ec741
commit a9600a1
Showing
46 changed files
with
125 additions
and
251 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
import { expect } from '@playwright/test'; | ||
import { test } from '@utils/test/playwright'; | ||
|
||
test.describe('toggle: basic', () => { | ||
test.beforeEach(async ({ page }) => { | ||
await page.goto(`/src/components/toggle/test/basic`); | ||
}); | ||
|
||
test('should not have visual regressions', async ({ page }) => { | ||
await page.setIonViewport(); | ||
|
||
expect(await page.screenshot()).toMatchSnapshot(`toggle-diff-${page.getSnapshotSettings()}.png`); | ||
}); | ||
|
||
test('should have proper class and aria role when checked', async ({ page }) => { | ||
const toggle = page.locator('#orange'); | ||
|
||
expect(toggle).not.toHaveClass(/toggle-checked/); | ||
expect(toggle).toHaveAttribute('aria-checked', 'false'); | ||
|
||
await toggle.click(); | ||
await page.waitForChanges(); | ||
|
||
expect(toggle).toHaveClass(/toggle-checked/); | ||
expect(toggle).toHaveAttribute('aria-checked', 'true'); | ||
|
||
await toggle.click(); | ||
await page.waitForChanges(); | ||
|
||
expect(toggle).not.toHaveClass(/toggle-checked/); | ||
expect(toggle).toHaveAttribute('aria-checked', 'false'); | ||
}); | ||
|
||
test('should fire change event with detail', async ({ page }) => { | ||
const toggle = page.locator('#orange'); | ||
const ionChange = await page.spyOnEvent('ionChange'); | ||
|
||
await toggle.click(); | ||
await page.waitForChanges(); | ||
|
||
expect(ionChange).toHaveReceivedEventDetail({ | ||
checked: true, | ||
value: 'on', | ||
}); | ||
|
||
await toggle.click(); | ||
await page.waitForChanges(); | ||
|
||
expect(ionChange).toHaveReceivedEventDetail({ | ||
checked: false, | ||
value: 'on', | ||
}); | ||
}); | ||
|
||
test('should fire change event if checked prop is changed directly', async ({ page }) => { | ||
const toggle = page.locator('#orange'); | ||
const ionChange = await page.spyOnEvent('ionChange'); | ||
|
||
await toggle.evaluate((el: HTMLIonToggleElement) => (el.checked = true)); | ||
await page.waitForChanges(); | ||
|
||
expect(ionChange).toHaveReceivedEvent(); | ||
}); | ||
|
||
test('should pass properties down to hidden input', async ({ page }) => { | ||
const toggle = page.locator('#grapeChecked'); | ||
|
||
expect(toggle).toBeDisabled(); | ||
expect(toggle).toHaveJSProperty('value', 'grape'); | ||
expect(toggle).toHaveJSProperty('name', 'grape'); | ||
|
||
const hiddenInput = page.locator('#grapeChecked input[type=hidden]'); | ||
|
||
expect(hiddenInput).toBeDisabled(); | ||
expect(hiddenInput).toHaveJSProperty('value', 'grape'); | ||
expect(hiddenInput).toHaveJSProperty('name', 'grape'); | ||
|
||
await toggle.evaluate((el: HTMLIonToggleElement) => { | ||
el.disabled = false; | ||
el.checked = false; | ||
el.value = 'new-value'; | ||
el.name = 'new-name'; | ||
}); | ||
|
||
await page.waitForChanges(); | ||
|
||
expect(hiddenInput).not.toBeDisabled(); | ||
expect(hiddenInput).toHaveJSProperty('name', 'new-name'); | ||
|
||
// shouldn't have a value because it's unchecked | ||
// note: using toHaveJSProperty to check empty string triggers error for some reason | ||
const value = await hiddenInput.evaluate((el: HTMLInputElement) => el.value); | ||
expect(value).toBe(''); | ||
}); | ||
}); |
Binary file added
BIN
+225 KB
.../test/basic/toggle.e2e.ts-snapshots/toggle-diff-ios-ltr-Mobile-Chrome-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+65.8 KB
...test/basic/toggle.e2e.ts-snapshots/toggle-diff-ios-ltr-Mobile-Firefox-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+187 KB
.../test/basic/toggle.e2e.ts-snapshots/toggle-diff-ios-ltr-Mobile-Safari-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+225 KB
.../test/basic/toggle.e2e.ts-snapshots/toggle-diff-ios-rtl-Mobile-Chrome-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+66 KB
...test/basic/toggle.e2e.ts-snapshots/toggle-diff-ios-rtl-Mobile-Firefox-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+187 KB
.../test/basic/toggle.e2e.ts-snapshots/toggle-diff-ios-rtl-Mobile-Safari-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+196 KB
...e/test/basic/toggle.e2e.ts-snapshots/toggle-diff-md-ltr-Mobile-Chrome-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+58.6 KB
.../test/basic/toggle.e2e.ts-snapshots/toggle-diff-md-ltr-Mobile-Firefox-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+163 KB
...e/test/basic/toggle.e2e.ts-snapshots/toggle-diff-md-ltr-Mobile-Safari-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+194 KB
...e/test/basic/toggle.e2e.ts-snapshots/toggle-diff-md-rtl-Mobile-Chrome-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+58.4 KB
.../test/basic/toggle.e2e.ts-snapshots/toggle-diff-md-rtl-Mobile-Firefox-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+163 KB
...e/test/basic/toggle.e2e.ts-snapshots/toggle-diff-md-rtl-Mobile-Safari-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { expect } from '@playwright/test'; | ||
import { test } from '@utils/test/playwright'; | ||
|
||
test.describe('toggle: sizes', () => { | ||
test('should not have visual regressions', async ({ page }) => { | ||
await page.goto(`/src/components/toggle/test/sizes`); | ||
|
||
await page.setIonViewport(); | ||
|
||
expect(await page.screenshot()).toMatchSnapshot(`toggle-sizes-diff-${page.getSnapshotSettings()}.png`); | ||
}); | ||
}); |
Binary file added
BIN
+231 KB
...sizes/toggle.e2e.ts-snapshots/toggle-sizes-diff-ios-ltr-Mobile-Chrome-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+71.3 KB
...izes/toggle.e2e.ts-snapshots/toggle-sizes-diff-ios-ltr-Mobile-Firefox-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+203 KB
...sizes/toggle.e2e.ts-snapshots/toggle-sizes-diff-ios-ltr-Mobile-Safari-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+231 KB
...sizes/toggle.e2e.ts-snapshots/toggle-sizes-diff-ios-rtl-Mobile-Chrome-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+70.6 KB
...izes/toggle.e2e.ts-snapshots/toggle-sizes-diff-ios-rtl-Mobile-Firefox-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+202 KB
...sizes/toggle.e2e.ts-snapshots/toggle-sizes-diff-ios-rtl-Mobile-Safari-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+181 KB
.../sizes/toggle.e2e.ts-snapshots/toggle-sizes-diff-md-ltr-Mobile-Chrome-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+55.1 KB
...sizes/toggle.e2e.ts-snapshots/toggle-sizes-diff-md-ltr-Mobile-Firefox-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+155 KB
.../sizes/toggle.e2e.ts-snapshots/toggle-sizes-diff-md-ltr-Mobile-Safari-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+182 KB
.../sizes/toggle.e2e.ts-snapshots/toggle-sizes-diff-md-rtl-Mobile-Chrome-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+54.9 KB
...sizes/toggle.e2e.ts-snapshots/toggle-sizes-diff-md-rtl-Mobile-Firefox-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+155 KB
.../sizes/toggle.e2e.ts-snapshots/toggle-sizes-diff-md-rtl-Mobile-Safari-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { expect } from '@playwright/test'; | ||
import { test } from '@utils/test/playwright'; | ||
|
||
test.describe('toggle: standalone', () => { | ||
test('should not have visual regressions', async ({ page }) => { | ||
await page.goto(`/src/components/toggle/test/standalone`); | ||
|
||
await page.setIonViewport(); | ||
|
||
expect(await page.screenshot()).toMatchSnapshot(`toggle-standalone-diff-${page.getSnapshotSettings()}.png`); | ||
}); | ||
}); |
Binary file added
BIN
+73.1 KB
.../toggle.e2e.ts-snapshots/toggle-standalone-diff-ios-ltr-Mobile-Chrome-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+28.3 KB
...toggle.e2e.ts-snapshots/toggle-standalone-diff-ios-ltr-Mobile-Firefox-linux.png
Oops, something went wrong.
Binary file added
BIN
+70.3 KB
.../toggle.e2e.ts-snapshots/toggle-standalone-diff-ios-ltr-Mobile-Safari-linux.png
Oops, something went wrong.
Binary file added
BIN
+74.8 KB
.../toggle.e2e.ts-snapshots/toggle-standalone-diff-ios-rtl-Mobile-Chrome-linux.png
Oops, something went wrong.
Binary file added
BIN
+28.1 KB
...toggle.e2e.ts-snapshots/toggle-standalone-diff-ios-rtl-Mobile-Firefox-linux.png
Oops, something went wrong.
Binary file added
BIN
+70.2 KB
.../toggle.e2e.ts-snapshots/toggle-standalone-diff-ios-rtl-Mobile-Safari-linux.png
Oops, something went wrong.
Binary file added
BIN
+42.7 KB
...e/toggle.e2e.ts-snapshots/toggle-standalone-diff-md-ltr-Mobile-Chrome-linux.png
Oops, something went wrong.
Binary file added
BIN
+17.9 KB
.../toggle.e2e.ts-snapshots/toggle-standalone-diff-md-ltr-Mobile-Firefox-linux.png
Oops, something went wrong.
Binary file added
BIN
+40 KB
...e/toggle.e2e.ts-snapshots/toggle-standalone-diff-md-ltr-Mobile-Safari-linux.png
Oops, something went wrong.
Binary file added
BIN
+45.2 KB
...e/toggle.e2e.ts-snapshots/toggle-standalone-diff-md-rtl-Mobile-Chrome-linux.png
Oops, something went wrong.
Binary file added
BIN
+18 KB
.../toggle.e2e.ts-snapshots/toggle-standalone-diff-md-rtl-Mobile-Firefox-linux.png
Oops, something went wrong.
Binary file added
BIN
+40.2 KB
...e/toggle.e2e.ts-snapshots/toggle-standalone-diff-md-rtl-Mobile-Safari-linux.png
Oops, something went wrong.