mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-20 12:29:55 +08:00
test(many): do not await page.locator (#27267)
Issue number: N/A --------- <!-- 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. --> `page.locator` is synchronous, but we were `await`ing the calls: https://playwright.dev/docs/api/class-page#page-locator We were also doing `page.locator(...).click()` when we can just do `page.click([selector])` directly, ## What is the new behavior? <!-- Please describe the behavior or changes that are being added by this PR. --> - Removes `await` usage from `page.locator` - Removes `page.locator().click()` usage in favor of `page.click()` ## 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:
@ -16,7 +16,7 @@ test.describe('datetime-button: switching to correct view', () => {
|
||||
const datetime = page.locator('ion-datetime');
|
||||
await expect(datetime).toHaveJSProperty('presentation', 'date-time');
|
||||
|
||||
await page.locator('#date-button').click();
|
||||
await page.click('#date-button');
|
||||
await page.waitForChanges();
|
||||
|
||||
await expect(datetime).toHaveJSProperty('presentation', 'date');
|
||||
@ -25,7 +25,7 @@ test.describe('datetime-button: switching to correct view', () => {
|
||||
const datetime = page.locator('ion-datetime');
|
||||
await expect(datetime).toHaveJSProperty('presentation', 'date-time');
|
||||
|
||||
await page.locator('#time-button').click();
|
||||
await page.click('#time-button');
|
||||
await page.waitForChanges();
|
||||
|
||||
await expect(datetime).toHaveJSProperty('presentation', 'time');
|
||||
|
@ -65,40 +65,40 @@ test.describe('datetime-button: popover', () => {
|
||||
ionPopoverDidDismiss = await page.spyOnEvent('ionPopoverDidDismiss');
|
||||
});
|
||||
test('should open the date popover', async ({ page }) => {
|
||||
await page.locator('#date-button').click();
|
||||
await page.click('#date-button');
|
||||
|
||||
await ionPopoverDidPresent.next();
|
||||
|
||||
await expect(datetime).toBeVisible();
|
||||
});
|
||||
test('should open the time popover', async ({ page }) => {
|
||||
await page.locator('#time-button').click();
|
||||
await page.click('#time-button');
|
||||
|
||||
await ionPopoverDidPresent.next();
|
||||
|
||||
await expect(datetime).toBeVisible();
|
||||
});
|
||||
test('should open the date popover then the time popover', async ({ page }) => {
|
||||
await page.locator('#date-button').click();
|
||||
await page.click('#date-button');
|
||||
await ionPopoverDidPresent.next();
|
||||
await expect(datetime).toBeVisible();
|
||||
|
||||
await popover.evaluate((el: HTMLIonPopoverElement) => el.dismiss());
|
||||
await ionPopoverDidDismiss.next();
|
||||
|
||||
await page.locator('#time-button').click();
|
||||
await page.click('#time-button');
|
||||
await ionPopoverDidPresent.next();
|
||||
await expect(datetime).toBeVisible();
|
||||
});
|
||||
test('should open the time popover then the date popover', async ({ page }) => {
|
||||
await page.locator('#time-button').click();
|
||||
await page.click('#time-button');
|
||||
await ionPopoverDidPresent.next();
|
||||
await expect(datetime).toBeVisible();
|
||||
|
||||
await popover.evaluate((el: HTMLIonPopoverElement) => el.dismiss());
|
||||
await ionPopoverDidDismiss.next();
|
||||
|
||||
await page.locator('#date-button').click();
|
||||
await page.click('#date-button');
|
||||
await ionPopoverDidPresent.next();
|
||||
await expect(datetime).toBeVisible();
|
||||
});
|
||||
@ -127,40 +127,40 @@ test.describe('datetime-button: modal', () => {
|
||||
ionModalDidDismiss = await page.spyOnEvent('ionModalDidDismiss');
|
||||
});
|
||||
test('should open the date modal', async ({ page }) => {
|
||||
await page.locator('#date-button').click();
|
||||
await page.click('#date-button');
|
||||
|
||||
await ionModalDidPresent.next();
|
||||
|
||||
await expect(datetime).toBeVisible();
|
||||
});
|
||||
test('should open the time modal', async ({ page }) => {
|
||||
await page.locator('#time-button').click();
|
||||
await page.click('#time-button');
|
||||
|
||||
await ionModalDidPresent.next();
|
||||
|
||||
await expect(datetime).toBeVisible();
|
||||
});
|
||||
test('should open the date modal then the time modal', async ({ page }) => {
|
||||
await page.locator('#date-button').click();
|
||||
await page.click('#date-button');
|
||||
await ionModalDidPresent.next();
|
||||
await expect(datetime).toBeVisible();
|
||||
|
||||
await modal.evaluate((el: HTMLIonModalElement) => el.dismiss());
|
||||
await ionModalDidDismiss.next();
|
||||
|
||||
await page.locator('#time-button').click();
|
||||
await page.click('#time-button');
|
||||
await ionModalDidPresent.next();
|
||||
await expect(datetime).toBeVisible();
|
||||
});
|
||||
test('should open the time modal then the date modal', async ({ page }) => {
|
||||
await page.locator('#time-button').click();
|
||||
await page.click('#time-button');
|
||||
await ionModalDidPresent.next();
|
||||
await expect(datetime).toBeVisible();
|
||||
|
||||
await modal.evaluate((el: HTMLIonModalElement) => el.dismiss());
|
||||
await ionModalDidDismiss.next();
|
||||
|
||||
await page.locator('#date-button').click();
|
||||
await page.click('#date-button');
|
||||
await ionModalDidPresent.next();
|
||||
await expect(datetime).toBeVisible();
|
||||
});
|
||||
|
Reference in New Issue
Block a user