Skip to content

Commit bf60712

Browse files
authored
chore(playwright): add click method to promise assertion lint checks (#29740)
Issue number: N/A --------- <!-- 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. --> Ionic Framework has a set of custom lint assertions to avoid creating flaky Playwright tests by forgetting to await a promise. However the `click` method was not included in the original list of methods to check. ## What is the new behavior? <!-- Please describe the behavior or changes that are being added by this PR. --> - Developers will receive a lint error when forgetting to await click methods from Playwright - Resolves existing tests where this lint issue was present ## Does this introduce a breaking change? - [ ] Yes - [x] No <!-- If this introduces a breaking change: 1. Describe the impact and migration path for existing applications below. 2. Update the BREAKING.md file with the breaking change. 3. Add "BREAKING CHANGE: [...]" to the commit description when merging. See https://github.com/ionic-team/ionic-framework/blob/main/docs/CONTRIBUTING.md#footer for more information. --> ## Other information <!-- Any other information that is important to this PR such as screenshots of how the component looks before and after the change. -->
1 parent 454e509 commit bf60712

File tree

6 files changed

+13
-10
lines changed

6 files changed

+13
-10
lines changed

core/custom-rules/await-playwright-promise-assertion.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,5 @@ const ASYNC_PLAYWRIGHT_ASSERTS = [
6767
'toHaveTitle',
6868
'toHaveURL',
6969
'toBeOK',
70+
'click'
7071
];

core/src/components/accordion/test/disabled/accordion.e2e.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ configs({ modes: ['md'], directions: ['ltr'] }).forEach(({ config, title }) => {
4848

4949
await expect(accordion).toHaveClass(/accordion-collapsed/);
5050

51-
accordion.click();
51+
await accordion.click();
5252
await page.waitForChanges();
5353

5454
await expect(accordion).toHaveClass(/accordion-collapsed/);
@@ -71,7 +71,7 @@ configs({ modes: ['md'], directions: ['ltr'] }).forEach(({ config, title }) => {
7171

7272
await expect(accordion).toHaveClass(/accordion-collapsed/);
7373

74-
accordion.click();
74+
await accordion.click();
7575
await page.waitForChanges();
7676

7777
await expect(accordion).toHaveClass(/accordion-collapsed/);

core/src/components/accordion/test/readonly/accordion.e2e.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ configs({ modes: ['md'], directions: ['ltr'] }).forEach(({ config, title }) => {
4848

4949
await expect(accordion).toHaveClass(/accordion-collapsed/);
5050

51-
accordion.click();
51+
await accordion.click();
5252
await page.waitForChanges();
5353

5454
await expect(accordion).toHaveClass(/accordion-collapsed/);
@@ -71,7 +71,7 @@ configs({ modes: ['md'], directions: ['ltr'] }).forEach(({ config, title }) => {
7171

7272
await expect(accordion).toHaveClass(/accordion-collapsed/);
7373

74-
accordion.click();
74+
await accordion.click();
7575
await page.waitForChanges();
7676

7777
await expect(accordion).toHaveClass(/accordion-collapsed/);

core/src/components/modal/test/sheet/modal.e2e.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ configs({ modes: ['ios'], directions: ['ltr'] }).forEach(({ title, config }) =>
265265
const backdrop = page.locator('ion-modal ion-backdrop');
266266

267267
await handle.click();
268-
backdrop.click();
268+
await backdrop.click();
269269

270270
await ionBreakpointDidChange.next();
271271

core/src/components/select/test/basic/select.e2e.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,11 @@ configs({ modes: ['ios'], directions: ['ltr'] }).forEach(({ title, config }) =>
8080
* is already visible. We manually click() the element instead
8181
* to avoid flaky tests.
8282
*/
83+
/* eslint-disable custom-rules/await-playwright-promise-assertion */
8384
el.click();
8485
el.click();
8586
el.click();
87+
/* eslint-enable custom-rules/await-playwright-promise-assertion */
8688
});
8789

8890
const alerts = await page.$$('ion-alert');

core/src/utils/animation/test/animationbuilder/animation.e2e.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ const testNavigation = async (page: E2EPage) => {
2020

2121
await page.click('page-root ion-button.next');
2222
await ionRouteDidChange.next();
23-
page.click('page-one ion-button.next');
23+
await page.click('page-one ion-button.next');
2424
await ionRouteDidChange.next();
25-
page.click('page-two ion-button.next');
25+
await page.click('page-two ion-button.next');
2626
await ionRouteDidChange.next();
27-
page.click('page-three ion-back-button');
27+
await page.click('page-three ion-back-button');
2828
await ionRouteDidChange.next();
29-
page.click('page-two ion-back-button');
29+
await page.click('page-two ion-back-button');
3030
await ionRouteDidChange.next();
31-
page.click('page-one ion-back-button');
31+
await page.click('page-one ion-back-button');
3232
await ionRouteDidChange.next();
3333
};

0 commit comments

Comments
 (0)