-
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(toast): migrate tests to playwright (#25751)
- Loading branch information
1 parent
d711658
commit f47c5de
Showing
71 changed files
with
198 additions
and
214 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import AxeBuilder from '@axe-core/playwright'; | ||
import { expect } from '@playwright/test'; | ||
import { test } from '@utils/test/playwright'; | ||
|
||
test.describe('toast: a11y', () => { | ||
test.beforeEach(async ({ page }, testInfo) => { | ||
test.skip(testInfo.project.metadata.rtl === true, 'This test does not check LTR vs RTL layouts'); | ||
await page.goto(`/src/components/toast/test/a11y`); | ||
}); | ||
test('should not have any axe violations with polite toasts', async ({ page }) => { | ||
const ionToastDidPresent = await page.spyOnEvent('ionToastDidPresent'); | ||
|
||
const politeButton = page.locator('#polite'); | ||
await politeButton.click(); | ||
|
||
await ionToastDidPresent.next(); | ||
|
||
/** | ||
* IonToast overlays the entire screen, so | ||
* Axe will be unable to verify color contrast | ||
* on elements under the toast. | ||
*/ | ||
const results = await new AxeBuilder({ page }).disableRules('color-contrast').analyze(); | ||
expect(results.violations).toEqual([]); | ||
}); | ||
test('should not have any axe violations with assertive toasts', async ({ page }) => { | ||
const ionToastDidPresent = await page.spyOnEvent('ionToastDidPresent'); | ||
|
||
const politeButton = page.locator('#assertive'); | ||
await politeButton.click(); | ||
|
||
await ionToastDidPresent.next(); | ||
|
||
/** | ||
* IonToast overlays the entire screen, so | ||
* Axe will be unable to verify color contrast | ||
* on elements under the toast. | ||
*/ | ||
const results = await new AxeBuilder({ page }).disableRules('color-contrast').analyze(); | ||
expect(results.violations).toEqual([]); | ||
}); | ||
}); |
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,136 @@ | ||
import { expect } from '@playwright/test'; | ||
import type { Locator, TestInfo } from '@playwright/test'; | ||
import type { E2EPage, EventSpy } from '@utils/test/playwright'; | ||
import { test } from '@utils/test/playwright'; | ||
|
||
class ToastFixture { | ||
readonly page: E2EPage; | ||
readonly testInfo: TestInfo; | ||
|
||
private ionToastDidPresent!: EventSpy; | ||
|
||
constructor(page: E2EPage, testInfo: TestInfo) { | ||
this.page = page; | ||
this.testInfo = testInfo; | ||
} | ||
|
||
async goto() { | ||
const { page } = this; | ||
await page.goto(`/src/components/toast/test/basic`); | ||
this.ionToastDidPresent = await page.spyOnEvent('ionToastDidPresent'); | ||
} | ||
|
||
async openToast(selector: string) { | ||
const { page, ionToastDidPresent } = this; | ||
const button = page.locator(selector); | ||
await button.click(); | ||
|
||
await ionToastDidPresent.next(); | ||
|
||
return { | ||
toast: page.locator('ion-toast'), | ||
container: page.locator('ion-toast .toast-container'), | ||
}; | ||
} | ||
|
||
async screenshot(screenshotModifier: string, el?: Locator) { | ||
const { page } = this; | ||
|
||
const reference = el !== undefined ? el : page; | ||
expect(await reference.screenshot()).toMatchSnapshot( | ||
`toast-${screenshotModifier}-${page.getSnapshotSettings()}.png` | ||
); | ||
} | ||
|
||
skipRTL(testRef: typeof test, reason = 'This functionality does not have RTL-specific behaviors.') { | ||
const { testInfo } = this; | ||
testRef.skip(testInfo.project.metadata.rtl === true, reason); | ||
} | ||
|
||
skipMode(testRef: typeof test, mode: string, reason: string) { | ||
const { testInfo } = this; | ||
testRef.skip(testInfo.project.metadata.mode === mode, reason); | ||
} | ||
} | ||
|
||
test.describe('toast: rendering', () => { | ||
let toastFixture: ToastFixture; | ||
test.beforeEach(async ({ page }, testInfo) => { | ||
toastFixture = new ToastFixture(page, testInfo); | ||
await toastFixture.goto(); | ||
}); | ||
|
||
test.describe('toast: position', () => { | ||
test.beforeEach(() => { | ||
toastFixture.skipRTL(test); | ||
}); | ||
test('should render toast at the top', async () => { | ||
await toastFixture.openToast('#show-top-toast'); | ||
await toastFixture.screenshot('top'); | ||
}); | ||
test('should render toast at the middle', async () => { | ||
await toastFixture.openToast('#show-middle-toast'); | ||
await toastFixture.screenshot('middle'); | ||
}); | ||
test('should render toast at the bottom', async () => { | ||
await toastFixture.openToast('#show-bottom-toast'); | ||
await toastFixture.screenshot('bottom'); | ||
}); | ||
}); | ||
|
||
test('should set buttons correctly', async () => { | ||
const { container } = await toastFixture.openToast('#custom-action-buttons-toast'); | ||
await toastFixture.screenshot('buttons', container); | ||
}); | ||
|
||
test('should set start/end positioning correctly', async () => { | ||
const { container } = await toastFixture.openToast('#toast-start-and-end'); | ||
await toastFixture.screenshot('start-end', container); | ||
}); | ||
|
||
test('should wrap text correctly', async () => { | ||
toastFixture.skipRTL(test); | ||
const { container } = await toastFixture.openToast('#two-line-toast'); | ||
await toastFixture.screenshot('text', container); | ||
}); | ||
|
||
test('should set color correctly', async () => { | ||
toastFixture.skipRTL(test); | ||
const { container } = await toastFixture.openToast('#color-toast'); | ||
await toastFixture.screenshot('color', container); | ||
}); | ||
|
||
test('should set translucency correctly', async () => { | ||
toastFixture.skipRTL(test); | ||
toastFixture.skipMode(test, 'md', 'Translucency only works on iOS'); | ||
|
||
const { container } = await toastFixture.openToast('#translucent-toast'); | ||
await toastFixture.screenshot('translucent', container); | ||
}); | ||
}); | ||
|
||
test.describe('toast: properties', () => { | ||
let toastFixture: ToastFixture; | ||
test.beforeEach(async ({ page }, testInfo) => { | ||
toastFixture = new ToastFixture(page, testInfo); | ||
|
||
toastFixture.skipMode(test, 'md', 'This functionality has no mode specific logic.'); | ||
toastFixture.skipRTL(test); | ||
|
||
await toastFixture.goto(); | ||
}); | ||
test('should correctly set htmlAttributes', async () => { | ||
const { toast } = await toastFixture.openToast('#show-bottom-toast'); | ||
await expect(toast).toHaveAttribute('data-testid', 'basic-toast'); | ||
}); | ||
|
||
test('should correctly set custom html', async () => { | ||
const { toast } = await toastFixture.openToast('#toast-html'); | ||
await expect(toast.locator('ion-button')).toBeVisible(); | ||
}); | ||
|
||
test('should correctly set custom class', async () => { | ||
const { toast } = await toastFixture.openToast('#custom-class-toast'); | ||
await expect(toast).toHaveClass(/my-custom-class/); | ||
}); | ||
}); |
Binary file added
BIN
+96.4 KB
.../test/basic/toast.e2e.ts-snapshots/toast-bottom-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
+42.4 KB
...test/basic/toast.e2e.ts-snapshots/toast-bottom-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
+84.5 KB
.../test/basic/toast.e2e.ts-snapshots/toast-bottom-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
+111 KB
...t/test/basic/toast.e2e.ts-snapshots/toast-bottom-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
+52.4 KB
.../test/basic/toast.e2e.ts-snapshots/toast-bottom-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
+102 KB
...t/test/basic/toast.e2e.ts-snapshots/toast-bottom-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
+11.9 KB
...test/basic/toast.e2e.ts-snapshots/toast-buttons-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
+4.2 KB
...est/basic/toast.e2e.ts-snapshots/toast-buttons-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
+10.9 KB
...test/basic/toast.e2e.ts-snapshots/toast-buttons-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
+11.8 KB
...test/basic/toast.e2e.ts-snapshots/toast-buttons-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
+4.13 KB
...est/basic/toast.e2e.ts-snapshots/toast-buttons-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
+10.9 KB
...test/basic/toast.e2e.ts-snapshots/toast-buttons-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
+10.7 KB
.../test/basic/toast.e2e.ts-snapshots/toast-buttons-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
+3.21 KB
...test/basic/toast.e2e.ts-snapshots/toast-buttons-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
+9.22 KB
.../test/basic/toast.e2e.ts-snapshots/toast-buttons-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
+10.8 KB
.../test/basic/toast.e2e.ts-snapshots/toast-buttons-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
+3.1 KB
...test/basic/toast.e2e.ts-snapshots/toast-buttons-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
+9.2 KB
.../test/basic/toast.e2e.ts-snapshots/toast-buttons-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.
Binary file added
BIN
+11.4 KB
...t/test/basic/toast.e2e.ts-snapshots/toast-color-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
+4.09 KB
.../test/basic/toast.e2e.ts-snapshots/toast-color-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
+10.8 KB
...t/test/basic/toast.e2e.ts-snapshots/toast-color-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
+10.2 KB
...st/test/basic/toast.e2e.ts-snapshots/toast-color-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
+3.36 KB
...t/test/basic/toast.e2e.ts-snapshots/toast-color-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
+8.69 KB
...st/test/basic/toast.e2e.ts-snapshots/toast-color-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
+96.2 KB
.../test/basic/toast.e2e.ts-snapshots/toast-middle-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
+42.6 KB
...test/basic/toast.e2e.ts-snapshots/toast-middle-ios-ltr-Mobile-Firefox-linux.png
Oops, something went wrong.
Binary file added
BIN
+84.3 KB
.../test/basic/toast.e2e.ts-snapshots/toast-middle-ios-ltr-Mobile-Safari-linux.png
Oops, something went wrong.
Binary file added
BIN
+113 KB
...t/test/basic/toast.e2e.ts-snapshots/toast-middle-md-ltr-Mobile-Chrome-linux.png
Oops, something went wrong.
Binary file added
BIN
+52.7 KB
.../test/basic/toast.e2e.ts-snapshots/toast-middle-md-ltr-Mobile-Firefox-linux.png
Oops, something went wrong.
Binary file added
BIN
+107 KB
...t/test/basic/toast.e2e.ts-snapshots/toast-middle-md-ltr-Mobile-Safari-linux.png
Oops, something went wrong.
Binary file added
BIN
+9.58 KB
...st/basic/toast.e2e.ts-snapshots/toast-start-end-ios-ltr-Mobile-Chrome-linux.png
Oops, something went wrong.
Binary file added
BIN
+3.65 KB
...t/basic/toast.e2e.ts-snapshots/toast-start-end-ios-ltr-Mobile-Firefox-linux.png
Oops, something went wrong.
Binary file added
BIN
+9.23 KB
...st/basic/toast.e2e.ts-snapshots/toast-start-end-ios-ltr-Mobile-Safari-linux.png
Oops, something went wrong.
Binary file added
BIN
+9.58 KB
...st/basic/toast.e2e.ts-snapshots/toast-start-end-ios-rtl-Mobile-Chrome-linux.png
Oops, something went wrong.
Binary file added
BIN
+3.7 KB
...t/basic/toast.e2e.ts-snapshots/toast-start-end-ios-rtl-Mobile-Firefox-linux.png
Oops, something went wrong.
Binary file added
BIN
+9.23 KB
...st/basic/toast.e2e.ts-snapshots/toast-start-end-ios-rtl-Mobile-Safari-linux.png
Oops, something went wrong.
Binary file added
BIN
+9.61 KB
...est/basic/toast.e2e.ts-snapshots/toast-start-end-md-ltr-Mobile-Chrome-linux.png
Oops, something went wrong.
Binary file added
BIN
+3.12 KB
...st/basic/toast.e2e.ts-snapshots/toast-start-end-md-ltr-Mobile-Firefox-linux.png
Oops, something went wrong.
Binary file added
BIN
+8.01 KB
...est/basic/toast.e2e.ts-snapshots/toast-start-end-md-ltr-Mobile-Safari-linux.png
Oops, something went wrong.
Binary file added
BIN
+9.62 KB
...est/basic/toast.e2e.ts-snapshots/toast-start-end-md-rtl-Mobile-Chrome-linux.png
Oops, something went wrong.
Binary file added
BIN
+3.06 KB
...st/basic/toast.e2e.ts-snapshots/toast-start-end-md-rtl-Mobile-Firefox-linux.png
Oops, something went wrong.
Binary file added
BIN
+8.02 KB
...est/basic/toast.e2e.ts-snapshots/toast-start-end-md-rtl-Mobile-Safari-linux.png
Oops, something went wrong.
Binary file added
BIN
+32.9 KB
...st/test/basic/toast.e2e.ts-snapshots/toast-text-ios-ltr-Mobile-Chrome-linux.png
Oops, something went wrong.
Binary file added
BIN
+10.2 KB
...t/test/basic/toast.e2e.ts-snapshots/toast-text-ios-ltr-Mobile-Firefox-linux.png
Oops, something went wrong.
Binary file added
BIN
+32.4 KB
...st/test/basic/toast.e2e.ts-snapshots/toast-text-ios-ltr-Mobile-Safari-linux.png
Oops, something went wrong.
Binary file added
BIN
+30.5 KB
...ast/test/basic/toast.e2e.ts-snapshots/toast-text-md-ltr-Mobile-Chrome-linux.png
Oops, something went wrong.
Binary file added
BIN
+8.63 KB
...st/test/basic/toast.e2e.ts-snapshots/toast-text-md-ltr-Mobile-Firefox-linux.png
Oops, something went wrong.
Binary file added
BIN
+29.5 KB
...ast/test/basic/toast.e2e.ts-snapshots/toast-text-md-ltr-Mobile-Safari-linux.png
Oops, something went wrong.
Binary file added
BIN
+95 KB
...ast/test/basic/toast.e2e.ts-snapshots/toast-top-ios-ltr-Mobile-Chrome-linux.png
Oops, something went wrong.
Binary file added
BIN
+42.3 KB
...st/test/basic/toast.e2e.ts-snapshots/toast-top-ios-ltr-Mobile-Firefox-linux.png
Oops, something went wrong.
Binary file added
BIN
+85 KB
...ast/test/basic/toast.e2e.ts-snapshots/toast-top-ios-ltr-Mobile-Safari-linux.png
Oops, something went wrong.
Binary file added
BIN
+112 KB
...oast/test/basic/toast.e2e.ts-snapshots/toast-top-md-ltr-Mobile-Chrome-linux.png
Oops, something went wrong.
Binary file added
BIN
+53 KB
...ast/test/basic/toast.e2e.ts-snapshots/toast-top-md-ltr-Mobile-Firefox-linux.png
Oops, something went wrong.
Binary file added
BIN
+106 KB
...oast/test/basic/toast.e2e.ts-snapshots/toast-top-md-ltr-Mobile-Safari-linux.png
Oops, something went wrong.
Binary file added
BIN
+26.1 KB
.../basic/toast.e2e.ts-snapshots/toast-translucent-ios-ltr-Mobile-Chrome-linux.png
Oops, something went wrong.
Binary file added
BIN
+3.71 KB
...basic/toast.e2e.ts-snapshots/toast-translucent-ios-ltr-Mobile-Firefox-linux.png
Oops, something went wrong.
Binary file added
BIN
+13.1 KB
.../basic/toast.e2e.ts-snapshots/toast-translucent-ios-ltr-Mobile-Safari-linux.png
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.