mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-09 08:09:32 +08:00
test(many): use web-first assertions (#27113)
<!-- Please refer to our contributing documentation for any questions on submitting a pull request, or let us know here if you need any help: https://ionicframework.com/docs/building/contributing --> <!-- Some docs updates need to be made in the `ionic-docs` repo, in a separate PR. See https://github.com/ionic-team/ionic-framework/blob/main/.github/CONTRIBUTING.md#modifying-documentation for details. --> <!-- Please do not submit updates to dependencies unless it fixes an issue. --> <!-- Please try to limit your pull request to one type (bugfix, feature, etc). Submit multiple pull requests if needed. --> ## What is the current behavior? <!-- Please describe the current behavior that you are modifying. --> <!-- Issues are required for both bug fixes and features. --> Issue URL: N/A Playwright recommends using Locators with web-first assertions instead of using `waitForSelector`: https://playwright.dev/docs/api/class-frame#frame-wait-for-selector ## What is the new behavior? <!-- Please describe the behavior or changes that are being added by this PR. --> - Removes waitForSelector usages for checking if components are visible in favor of the `toBeVisible` or `toBeHidden` assertions. ## Does this introduce a breaking change? - [ ] Yes - [x] No <!-- If this introduces a breaking change, please describe the impact and migration path for existing applications below. --> ## Other information <!-- Any other information that is important to this PR such as screenshots of how the component looks before and after the change. -->
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
import { expect } from '@playwright/test';
|
||||
import { test } from '@utils/test/playwright';
|
||||
|
||||
test.describe('picker: isOpen', () => {
|
||||
@ -9,22 +10,25 @@ test.describe('picker: isOpen', () => {
|
||||
|
||||
test('should open the picker', async ({ page }) => {
|
||||
const ionPickerDidPresent = await page.spyOnEvent('ionPickerDidPresent');
|
||||
const picker = page.locator('ion-picker');
|
||||
|
||||
await page.click('#default');
|
||||
|
||||
await ionPickerDidPresent.next();
|
||||
await page.waitForSelector('ion-picker', { state: 'visible' });
|
||||
await expect(picker).toBeVisible();
|
||||
});
|
||||
|
||||
test('should open the picker then close after a timeout', async ({ page }) => {
|
||||
const ionPickerDidPresent = await page.spyOnEvent('ionPickerDidPresent');
|
||||
const ionPickerDidDismiss = await page.spyOnEvent('ionPickerDidDismiss');
|
||||
const picker = page.locator('ion-picker');
|
||||
|
||||
await page.click('#timeout');
|
||||
|
||||
await ionPickerDidPresent.next();
|
||||
await page.waitForSelector('ion-picker', { state: 'visible' });
|
||||
await expect(picker).toBeVisible();
|
||||
|
||||
await ionPickerDidDismiss.next();
|
||||
|
||||
await page.waitForSelector('ion-picker', { state: 'hidden' });
|
||||
await expect(picker).toBeHidden();
|
||||
});
|
||||
});
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import { expect } from '@playwright/test';
|
||||
import { test } from '@utils/test/playwright';
|
||||
|
||||
test.describe('picker: trigger', () => {
|
||||
@ -9,15 +10,18 @@ test.describe('picker: trigger', () => {
|
||||
|
||||
test('should open the picker', async ({ page }) => {
|
||||
const ionPickerDidPresent = await page.spyOnEvent('ionPickerDidPresent');
|
||||
const picker = page.locator('#default-picker');
|
||||
|
||||
await page.click('#default');
|
||||
|
||||
await ionPickerDidPresent.next();
|
||||
await page.waitForSelector('#default-picker', { state: 'visible' });
|
||||
await expect(picker).toBeVisible();
|
||||
});
|
||||
|
||||
test('should present a previously presented picker', async ({ page }) => {
|
||||
const ionPickerDidPresent = await page.spyOnEvent('ionPickerDidPresent');
|
||||
const ionPickerDidDismiss = await page.spyOnEvent('ionPickerDidDismiss');
|
||||
const picker = page.locator('#timeout-picker');
|
||||
|
||||
await page.click('#timeout');
|
||||
|
||||
@ -26,6 +30,6 @@ test.describe('picker: trigger', () => {
|
||||
await page.click('#timeout');
|
||||
|
||||
await ionPickerDidPresent.next();
|
||||
await page.waitForSelector('#timeout-picker', { state: 'visible' });
|
||||
await expect(picker).toBeVisible();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user