-
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(action-sheet): migrate to playwright (#25523)
- Loading branch information
1 parent
ab63623
commit f5eec13
Showing
71 changed files
with
178 additions
and
335 deletions.
There are no files selected for viewing
151 changes: 151 additions & 0 deletions
151
core/src/components/action-sheet/test/basic/action-sheet.e2e.ts
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,151 @@ | ||
import { expect } from '@playwright/test'; | ||
import type { Locator } from '@playwright/test'; | ||
import { test } from '@utils/test/playwright'; | ||
import type { E2EPage } from '@utils/test/playwright'; | ||
|
||
test.describe('action sheet: basic', () => { | ||
let actionSheetFixture: ActionSheetFixture; | ||
test.beforeEach(async ({ page }) => { | ||
await page.goto(`/src/components/action-sheet/test/basic`); | ||
actionSheetFixture = new ActionSheetFixture(page); | ||
}); | ||
test.describe('action sheet: data', () => { | ||
test('should return data', async ({ page }, testInfo) => { | ||
test.skip(testInfo.project.metadata.rtl === true, 'This does not test LTR vs. RTL layout.'); | ||
const ionActionSheetDidDismiss = await page.spyOnEvent('ionActionSheetDidDismiss'); | ||
|
||
await actionSheetFixture.open('#buttonData'); | ||
|
||
const buttonOption = page.locator('ion-action-sheet button#option'); | ||
await buttonOption.click(); | ||
|
||
await ionActionSheetDidDismiss.next(); | ||
expect(ionActionSheetDidDismiss).toHaveReceivedEventDetail({ data: { type: '1' } }); | ||
}); | ||
test('should return cancel button data', async ({ page }, testInfo) => { | ||
test.skip(testInfo.project.metadata.rtl === true, 'This does not test LTR vs. RTL layout.'); | ||
const ionActionSheetDidDismiss = await page.spyOnEvent('ionActionSheetDidDismiss'); | ||
|
||
await actionSheetFixture.open('#buttonData'); | ||
|
||
const buttonOption = page.locator('ion-action-sheet button.action-sheet-cancel'); | ||
await buttonOption.click(); | ||
|
||
await ionActionSheetDidDismiss.next(); | ||
expect(ionActionSheetDidDismiss).toHaveReceivedEventDetail({ data: { type: 'cancel' }, role: 'cancel' }); | ||
}); | ||
}); | ||
test.describe('action sheet: attributes', () => { | ||
test('should set htmlAttributes', async ({ page }, testInfo) => { | ||
test.skip(testInfo.project.metadata.rtl === true, 'This does not test LTR vs. RTL layout.'); | ||
await actionSheetFixture.open('#basic'); | ||
|
||
const actionSheet = page.locator('ion-action-sheet'); | ||
expect(actionSheet).toHaveAttribute('data-testid', 'basic-action-sheet'); | ||
}); | ||
}); | ||
test.describe('action sheet: variants', () => { | ||
test('should open basic action sheet', async () => { | ||
await actionSheetFixture.open('#basic'); | ||
await actionSheetFixture.screenshot('basic'); | ||
|
||
/** | ||
* We want to test that the dismiss method | ||
* actually works, but we do not need to test | ||
* it every time. As a result, we only | ||
* call dismiss in this test. | ||
*/ | ||
await actionSheetFixture.dismiss(); | ||
}); | ||
test('should open cancel only action sheet', async () => { | ||
await actionSheetFixture.open('#cancelOnly'); | ||
await actionSheetFixture.screenshot('cancel-only'); | ||
}); | ||
test('should open custom action sheet', async () => { | ||
await actionSheetFixture.open('#custom'); | ||
await actionSheetFixture.screenshot('custom'); | ||
}); | ||
test('should open scrollable action sheet', async () => { | ||
await actionSheetFixture.open('#scrollableOptions'); | ||
await actionSheetFixture.screenshot('scrollable-options'); | ||
}); | ||
test('should open scrollable action sheet without cancel', async () => { | ||
await actionSheetFixture.open('#scrollWithoutCancel'); | ||
await actionSheetFixture.screenshot('scroll-without-cancel'); | ||
}); | ||
test('should open custom backdrop action sheet', async ({ page }, testInfo) => { | ||
test.skip(testInfo.project.metadata.rtl === true, 'This does not test LTR vs. RTL layout.'); | ||
await actionSheetFixture.open('#customBackdrop'); | ||
|
||
const backdrop = page.locator('ion-action-sheet ion-backdrop'); | ||
expect(backdrop).toHaveCSS('opacity', '1'); | ||
}); | ||
test('should open alert from action sheet', async ({ page }, testInfo) => { | ||
test.skip(testInfo.project.metadata.rtl === true, 'This does not test LTR vs. RTL layout.'); | ||
const ionAlertDidPresent = await page.spyOnEvent('ionAlertDidPresent'); | ||
await actionSheetFixture.open('#alertFromActionSheet'); | ||
|
||
await page.locator('#open-alert').click(); | ||
|
||
await ionAlertDidPresent.next(); | ||
}); | ||
test('should not dismiss action sheet when backdropDismiss: false', async ({ page }, testInfo) => { | ||
test.skip(testInfo.project.metadata.rtl === true, 'This does not test LTR vs. RTL layout.'); | ||
await actionSheetFixture.open('#noBackdropDismiss'); | ||
|
||
const actionSheet = page.locator('ion-action-sheet'); | ||
await actionSheet.locator('ion-backdrop').click(); | ||
|
||
expect(actionSheet).toBeVisible(); | ||
}); | ||
}); | ||
test.describe('action sheet: focus trap', () => { | ||
test('it should trap focus in action sheet', async ({ page, browserName }, testInfo) => { | ||
test.skip(testInfo.project.metadata.rtl === true, 'This does not test LTR vs. RTL layout.'); | ||
const tabKey = browserName === 'webkit' ? 'Alt+Tab' : 'Tab'; | ||
|
||
await actionSheetFixture.open('#basic'); | ||
const buttons = page.locator('ion-action-sheet button'); | ||
|
||
await page.keyboard.press(tabKey); | ||
await expect(buttons.nth(0)).toBeFocused(); | ||
|
||
await page.keyboard.press(`Shift+${tabKey}`); | ||
await expect(buttons.nth(4)).toBeFocused(); | ||
|
||
await page.keyboard.press(tabKey); | ||
await expect(buttons.nth(0)).toBeFocused(); | ||
}); | ||
}); | ||
}); | ||
|
||
class ActionSheetFixture { | ||
readonly page: E2EPage; | ||
|
||
private actionSheet!: Locator; | ||
|
||
constructor(page: E2EPage) { | ||
this.page = page; | ||
} | ||
|
||
async open(selector: string) { | ||
const ionActionSheetDidPresent = await this.page.spyOnEvent('ionActionSheetDidPresent'); | ||
await this.page.locator(selector).click(); | ||
await ionActionSheetDidPresent.next(); | ||
this.actionSheet = this.page.locator('ion-action-sheet'); | ||
expect(this.actionSheet).toBeVisible(); | ||
} | ||
|
||
async dismiss() { | ||
const ionActionSheetDidDismiss = await this.page.spyOnEvent('ionActionSheetDidDismiss'); | ||
await this.actionSheet.evaluate((el: HTMLIonActionSheetElement) => el.dismiss()); | ||
await ionActionSheetDidDismiss.next(); | ||
expect(this.actionSheet).not.toBeVisible(); | ||
} | ||
|
||
async screenshot(modifier: string) { | ||
expect(await this.actionSheet.screenshot()).toMatchSnapshot( | ||
`action-sheet-${modifier}-diff-${this.page.getSnapshotSettings()}.png` | ||
); | ||
} | ||
} |
Binary file added
BIN
+109 KB
...-sheet.e2e.ts-snapshots/action-sheet-basic-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
+39.8 KB
...sheet.e2e.ts-snapshots/action-sheet-basic-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
+87.4 KB
...-sheet.e2e.ts-snapshots/action-sheet-basic-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
+109 KB
...-sheet.e2e.ts-snapshots/action-sheet-basic-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
+40.3 KB
...sheet.e2e.ts-snapshots/action-sheet-basic-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
+87.3 KB
...-sheet.e2e.ts-snapshots/action-sheet-basic-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
+116 KB
...n-sheet.e2e.ts-snapshots/action-sheet-basic-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
+43 KB
...-sheet.e2e.ts-snapshots/action-sheet-basic-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
+90.9 KB
...n-sheet.e2e.ts-snapshots/action-sheet-basic-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
+116 KB
...n-sheet.e2e.ts-snapshots/action-sheet-basic-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
+43.1 KB
...-sheet.e2e.ts-snapshots/action-sheet-basic-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
+90.7 KB
...n-sheet.e2e.ts-snapshots/action-sheet-basic-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.
Binary file added
BIN
+99 KB
....e2e.ts-snapshots/action-sheet-cancel-only-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
+37.1 KB
...e2e.ts-snapshots/action-sheet-cancel-only-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
+90.6 KB
....e2e.ts-snapshots/action-sheet-cancel-only-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
+98.9 KB
....e2e.ts-snapshots/action-sheet-cancel-only-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
+37.2 KB
...e2e.ts-snapshots/action-sheet-cancel-only-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
+90.6 KB
....e2e.ts-snapshots/action-sheet-cancel-only-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
+91.8 KB
...t.e2e.ts-snapshots/action-sheet-cancel-only-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
+38.1 KB
....e2e.ts-snapshots/action-sheet-cancel-only-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
+84.4 KB
...t.e2e.ts-snapshots/action-sheet-cancel-only-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
+92.3 KB
...t.e2e.ts-snapshots/action-sheet-cancel-only-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
+38.1 KB
....e2e.ts-snapshots/action-sheet-cancel-only-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
+84.3 KB
...t.e2e.ts-snapshots/action-sheet-cancel-only-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.
Binary file added
BIN
+111 KB
...sheet.e2e.ts-snapshots/action-sheet-custom-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
+39.9 KB
...heet.e2e.ts-snapshots/action-sheet-custom-diff-ios-ltr-Mobile-Firefox-linux.png
Oops, something went wrong.
Binary file added
BIN
+93.4 KB
...sheet.e2e.ts-snapshots/action-sheet-custom-diff-ios-ltr-Mobile-Safari-linux.png
Oops, something went wrong.
Binary file added
BIN
+111 KB
...sheet.e2e.ts-snapshots/action-sheet-custom-diff-ios-rtl-Mobile-Chrome-linux.png
Oops, something went wrong.
Binary file added
BIN
+40.2 KB
...heet.e2e.ts-snapshots/action-sheet-custom-diff-ios-rtl-Mobile-Firefox-linux.png
Oops, something went wrong.
Binary file added
BIN
+93.4 KB
...sheet.e2e.ts-snapshots/action-sheet-custom-diff-ios-rtl-Mobile-Safari-linux.png
Oops, something went wrong.
Binary file added
BIN
+111 KB
...-sheet.e2e.ts-snapshots/action-sheet-custom-diff-md-ltr-Mobile-Chrome-linux.png
Oops, something went wrong.
Binary file added
BIN
+42.7 KB
...sheet.e2e.ts-snapshots/action-sheet-custom-diff-md-ltr-Mobile-Firefox-linux.png
Oops, something went wrong.
Binary file added
BIN
+94.8 KB
...-sheet.e2e.ts-snapshots/action-sheet-custom-diff-md-ltr-Mobile-Safari-linux.png
Oops, something went wrong.
Binary file added
BIN
+112 KB
...-sheet.e2e.ts-snapshots/action-sheet-custom-diff-md-rtl-Mobile-Chrome-linux.png
Oops, something went wrong.
Binary file added
BIN
+42.7 KB
...sheet.e2e.ts-snapshots/action-sheet-custom-diff-md-rtl-Mobile-Firefox-linux.png
Oops, something went wrong.
Binary file added
BIN
+94.7 KB
...-sheet.e2e.ts-snapshots/action-sheet-custom-diff-md-rtl-Mobile-Safari-linux.png
Oops, something went wrong.
Binary file added
BIN
+96.4 KB
...apshots/action-sheet-scroll-without-cancel-diff-ios-ltr-Mobile-Chrome-linux.png
Oops, something went wrong.
Binary file added
BIN
+38.1 KB
...pshots/action-sheet-scroll-without-cancel-diff-ios-ltr-Mobile-Firefox-linux.png
Oops, something went wrong.
Binary file added
BIN
+78.8 KB
...apshots/action-sheet-scroll-without-cancel-diff-ios-ltr-Mobile-Safari-linux.png
Oops, something went wrong.
Binary file added
BIN
+96.4 KB
...apshots/action-sheet-scroll-without-cancel-diff-ios-rtl-Mobile-Chrome-linux.png
Oops, something went wrong.
Binary file added
BIN
+38.1 KB
...pshots/action-sheet-scroll-without-cancel-diff-ios-rtl-Mobile-Firefox-linux.png
Oops, something went wrong.
Binary file added
BIN
+78.8 KB
...apshots/action-sheet-scroll-without-cancel-diff-ios-rtl-Mobile-Safari-linux.png
Oops, something went wrong.
Binary file added
BIN
+87.9 KB
...napshots/action-sheet-scroll-without-cancel-diff-md-ltr-Mobile-Chrome-linux.png
Oops, something went wrong.
Binary file added
BIN
+29.6 KB
...apshots/action-sheet-scroll-without-cancel-diff-md-ltr-Mobile-Firefox-linux.png
Oops, something went wrong.
Binary file added
BIN
+75.2 KB
...napshots/action-sheet-scroll-without-cancel-diff-md-ltr-Mobile-Safari-linux.png
Oops, something went wrong.
Binary file added
BIN
+87.8 KB
...napshots/action-sheet-scroll-without-cancel-diff-md-rtl-Mobile-Chrome-linux.png
Oops, something went wrong.
Binary file added
BIN
+29.8 KB
...apshots/action-sheet-scroll-without-cancel-diff-md-rtl-Mobile-Firefox-linux.png
Oops, something went wrong.
Binary file added
BIN
+75 KB
...napshots/action-sheet-scroll-without-cancel-diff-md-rtl-Mobile-Safari-linux.png
Oops, something went wrong.
Binary file added
BIN
+87.2 KB
...-snapshots/action-sheet-scrollable-options-diff-ios-ltr-Mobile-Chrome-linux.png
Oops, something went wrong.
Binary file added
BIN
+35.8 KB
...snapshots/action-sheet-scrollable-options-diff-ios-ltr-Mobile-Firefox-linux.png
Oops, something went wrong.
Binary file added
BIN
+74.9 KB
...-snapshots/action-sheet-scrollable-options-diff-ios-ltr-Mobile-Safari-linux.png
Oops, something went wrong.
Binary file added
BIN
+87.2 KB
...-snapshots/action-sheet-scrollable-options-diff-ios-rtl-Mobile-Chrome-linux.png
Oops, something went wrong.
Binary file added
BIN
+35.8 KB
...snapshots/action-sheet-scrollable-options-diff-ios-rtl-Mobile-Firefox-linux.png
Oops, something went wrong.
Binary file added
BIN
+74.9 KB
...-snapshots/action-sheet-scrollable-options-diff-ios-rtl-Mobile-Safari-linux.png
Oops, something went wrong.
Binary file added
BIN
+84.1 KB
...s-snapshots/action-sheet-scrollable-options-diff-md-ltr-Mobile-Chrome-linux.png
Oops, something went wrong.
Binary file added
BIN
+28.3 KB
...-snapshots/action-sheet-scrollable-options-diff-md-ltr-Mobile-Firefox-linux.png
Oops, something went wrong.
Binary file added
BIN
+69.7 KB
...s-snapshots/action-sheet-scrollable-options-diff-md-ltr-Mobile-Safari-linux.png
Oops, something went wrong.
Binary file added
BIN
+83.8 KB
...s-snapshots/action-sheet-scrollable-options-diff-md-rtl-Mobile-Chrome-linux.png
Oops, something went wrong.
Binary file added
BIN
+28.2 KB
...-snapshots/action-sheet-scrollable-options-diff-md-rtl-Mobile-Firefox-linux.png
Oops, something went wrong.
Binary file added
BIN
+69.5 KB
...s-snapshots/action-sheet-scrollable-options-diff-md-rtl-Mobile-Safari-linux.png
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
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.