test(refresher): migrate to generators (#27370)

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. -->

Refresher tests are using legacy syntax

## What is the new behavior?
<!-- Please describe the behavior or changes that are being added by
this PR. -->

- Refresher tests are using modern syntax


299b562d52

- 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

<!-- 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:
Liam DeBeasi
2023-05-03 19:57:54 -04:00
committed by GitHub
parent c6ecadd267
commit 141683a4a2
4 changed files with 96 additions and 85 deletions

View File

@ -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);
});
});
});

View File

@ -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);
});
});
});
});

View File

@ -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);
});
});
});

View File

@ -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);
});
});
});
});