From 141683a4a259c8078c8a0c915ed1eb41d5dece13 Mon Sep 17 00:00:00 2001 From: Liam DeBeasi Date: Wed, 3 May 2023 19:57:54 -0400 Subject: [PATCH] test(refresher): migrate to generators (#27370) Issue number: N/A --------- ## What is the current behavior? Refresher tests are using legacy syntax ## What is the new behavior? - Refresher tests are using modern syntax https://github.com/ionic-team/ionic-framework/pull/27370/commits/299b562d521d7fd792b46456341eb1f58b3812d7 - These tests check the pull to refresh behavior which does not vary across directions, so I removed the extra checks. ## Does this introduce a breaking change? - [ ] Yes - [x] No ## Other information --- .../test/basic/refresher.e2e-legacy.ts | 42 ---------------- .../refresher/test/basic/refresher.e2e.ts | 48 +++++++++++++++++++ .../scroll-target/refresher.e2e-legacy.ts | 43 ----------------- .../test/scroll-target/refresher.e2e.ts | 48 +++++++++++++++++++ 4 files changed, 96 insertions(+), 85 deletions(-) delete mode 100644 core/src/components/refresher/test/basic/refresher.e2e-legacy.ts create mode 100644 core/src/components/refresher/test/basic/refresher.e2e.ts delete mode 100644 core/src/components/refresher/test/scroll-target/refresher.e2e-legacy.ts create mode 100644 core/src/components/refresher/test/scroll-target/refresher.e2e.ts diff --git a/core/src/components/refresher/test/basic/refresher.e2e-legacy.ts b/core/src/components/refresher/test/basic/refresher.e2e-legacy.ts deleted file mode 100644 index 219fa1fbf7..0000000000 --- a/core/src/components/refresher/test/basic/refresher.e2e-legacy.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { expect } from '@playwright/test'; -import { test } from '@utils/test/playwright'; - -import { pullToRefresh } from '../test.utils'; - -// TODO FW-2795: Enable this test when touch events/gestures are better supported in Playwright -test.skip('refresher: basic', () => { - test.beforeEach(async ({ page }) => { - await page.goto('/src/components/refresher/test/basic'); - }); - - test.describe('legacy refresher', () => { - test('should load more items when performing a pull-to-refresh', async ({ page }) => { - const items = page.locator('ion-item'); - - expect(await items.count()).toBe(30); - - await pullToRefresh(page); - - expect(await items.count()).toBe(60); - }); - }); - - test.describe('native refresher', () => { - test('should load more items when performing a pull-to-refresh', async ({ page }) => { - const refresherContent = page.locator('ion-refresher-content'); - refresherContent.evaluateHandle((el: any) => { - // Resets the pullingIcon to enable the native refresher - el.pullingIcon = undefined; - }); - - await page.waitForChanges(); - - const items = page.locator('ion-item'); - expect(await items.count()).toBe(30); - - await pullToRefresh(page); - - expect(await items.count()).toBe(60); - }); - }); -}); diff --git a/core/src/components/refresher/test/basic/refresher.e2e.ts b/core/src/components/refresher/test/basic/refresher.e2e.ts new file mode 100644 index 0000000000..fe17dd7fca --- /dev/null +++ b/core/src/components/refresher/test/basic/refresher.e2e.ts @@ -0,0 +1,48 @@ +import { expect } from '@playwright/test'; +import { configs, test } from '@utils/test/playwright'; + +import { pullToRefresh } from '../test.utils'; + +// TODO FW-2795: Enable this test when touch events/gestures are better supported in Playwright + +/** + * This behavior does not vary across directions. + */ +configs({ directions: ['ltr'] }).forEach(({ title, config }) => { + test.describe.skip(title('refresher: basic'), () => { + test.beforeEach(async ({ page }) => { + await page.goto('/src/components/refresher/test/basic', config); + }); + + test.describe('legacy refresher', () => { + test('should load more items when performing a pull-to-refresh', async ({ page }) => { + const items = page.locator('ion-item'); + + expect(await items.count()).toBe(30); + + await pullToRefresh(page); + + expect(await items.count()).toBe(60); + }); + }); + + test.describe('native refresher', () => { + test('should load more items when performing a pull-to-refresh', async ({ page }) => { + const refresherContent = page.locator('ion-refresher-content'); + refresherContent.evaluateHandle((el: any) => { + // Resets the pullingIcon to enable the native refresher + el.pullingIcon = undefined; + }); + + await page.waitForChanges(); + + const items = page.locator('ion-item'); + expect(await items.count()).toBe(30); + + await pullToRefresh(page); + + expect(await items.count()).toBe(60); + }); + }); + }); +}); diff --git a/core/src/components/refresher/test/scroll-target/refresher.e2e-legacy.ts b/core/src/components/refresher/test/scroll-target/refresher.e2e-legacy.ts deleted file mode 100644 index d7904f0552..0000000000 --- a/core/src/components/refresher/test/scroll-target/refresher.e2e-legacy.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { expect } from '@playwright/test'; -import { test } from '@utils/test/playwright'; - -import { pullToRefresh } from '../test.utils'; - -// TODO FW-2795: Enable this test when touch events/gestures are better supported in Playwright -test.skip('refresher: custom scroll target', () => { - test.beforeEach(async ({ page }) => { - await page.goto('/src/components/refresher/test/scroll-target'); - }); - - test.describe('legacy refresher', () => { - test('should load more items when performing a pull-to-refresh', async ({ page }) => { - const items = page.locator('ion-item'); - - expect(await items.count()).toBe(30); - - await pullToRefresh(page, '#inner-scroll'); - - expect(await items.count()).toBe(60); - }); - }); - - test.describe('native refresher', () => { - test('should load more items when performing a pull-to-refresh', async ({ page }) => { - const refresherContent = page.locator('ion-refresher-content'); - refresherContent.evaluateHandle((el: any) => { - // Resets the pullingIcon to enable the native refresher - el.pullingIcon = undefined; - }); - - await page.waitForChanges(); - - const items = page.locator('ion-item'); - - expect(await items.count()).toBe(30); - - await pullToRefresh(page, '#inner-scroll'); - - expect(await items.count()).toBe(60); - }); - }); -}); diff --git a/core/src/components/refresher/test/scroll-target/refresher.e2e.ts b/core/src/components/refresher/test/scroll-target/refresher.e2e.ts new file mode 100644 index 0000000000..8cd3547651 --- /dev/null +++ b/core/src/components/refresher/test/scroll-target/refresher.e2e.ts @@ -0,0 +1,48 @@ +import { expect } from '@playwright/test'; +import { configs, test } from '@utils/test/playwright'; + +import { pullToRefresh } from '../test.utils'; + +// TODO FW-2795: Enable this test when touch events/gestures are better supported in Playwright +/** + * This behavior does not vary across directions. + */ +configs({ directions: ['ltr'] }).forEach(({ title, config }) => { + test.describe.skip(title('refresher: custom scroll target'), () => { + test.beforeEach(async ({ page }) => { + await page.goto('/src/components/refresher/test/scroll-target', config); + }); + + test.describe('legacy refresher', () => { + test('should load more items when performing a pull-to-refresh', async ({ page }) => { + const items = page.locator('ion-item'); + + expect(await items.count()).toBe(30); + + await pullToRefresh(page, '#inner-scroll'); + + expect(await items.count()).toBe(60); + }); + }); + + test.describe('native refresher', () => { + test('should load more items when performing a pull-to-refresh', async ({ page }) => { + const refresherContent = page.locator('ion-refresher-content'); + refresherContent.evaluateHandle((el: any) => { + // Resets the pullingIcon to enable the native refresher + el.pullingIcon = undefined; + }); + + await page.waitForChanges(); + + const items = page.locator('ion-item'); + + expect(await items.count()).toBe(30); + + await pullToRefresh(page, '#inner-scroll'); + + expect(await items.count()).toBe(60); + }); + }); + }); +});