test(infinite-scroll): migrate to generators (#27320)

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

Infinite scroll tests use legacy syntax

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

- Infinite scroll tests use modern syntax

## 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-04-28 11:08:41 -04:00
committed by GitHub
parent dbb139afa0
commit bc05c57c3c
6 changed files with 60 additions and 66 deletions

View File

@ -1,22 +0,0 @@
import { expect } from '@playwright/test';
import { test } from '@utils/test/playwright';
test.describe('infinite-scroll: basic', () => {
test.beforeEach(({ skip }) => {
skip.rtl();
skip.mode('ios');
});
test('should load more items when scrolled to the bottom', async ({ page }) => {
await page.goto('/src/components/infinite-scroll/test/basic');
const ionInfiniteComplete = await page.spyOnEvent('ionInfiniteComplete');
const content = page.locator('ion-content');
const items = page.locator('ion-item');
expect(await items.count()).toBe(30);
await content.evaluate((el: HTMLIonContentElement) => el.scrollToBottom(0));
await ionInfiniteComplete.next();
expect(await items.count()).toBe(60);
});
});

View File

@ -0,0 +1,20 @@
import { expect } from '@playwright/test';
import { configs, test } from '@utils/test/playwright';
configs({ modes: ['md'], directions: ['ltr'] }).forEach(({ title, config }) => {
test.describe(title('infinite-scroll: basic'), () => {
test('should load more items when scrolled to the bottom', async ({ page }) => {
await page.goto('/src/components/infinite-scroll/test/basic', config);
const ionInfiniteComplete = await page.spyOnEvent('ionInfiniteComplete');
const content = page.locator('ion-content');
const items = page.locator('ion-item');
expect(await items.count()).toBe(30);
await content.evaluate((el: HTMLIonContentElement) => el.scrollToBottom(0));
await ionInfiniteComplete.next();
expect(await items.count()).toBe(60);
});
});
});

View File

@ -1,22 +0,0 @@
import { expect } from '@playwright/test';
import { test } from '@utils/test/playwright';
test.describe('infinite-scroll: scroll-target', () => {
test.beforeEach(({ skip }) => {
skip.rtl();
skip.mode('ios');
});
test('should load more items when scroll target is scrolled to the bottom', async ({ page }) => {
await page.goto('/src/components/infinite-scroll/test/scroll-target');
const ionInfiniteComplete = await page.spyOnEvent('ionInfiniteComplete');
const content = page.locator('#scroll-target');
const items = page.locator('ion-item');
expect(await items.count()).toBe(30);
await content.evaluate((el: HTMLElement) => (el.scrollTop = el.scrollHeight));
await ionInfiniteComplete.next();
expect(await items.count()).toBe(60);
});
});

View File

@ -0,0 +1,20 @@
import { expect } from '@playwright/test';
import { configs, test } from '@utils/test/playwright';
configs({ modes: ['md'], directions: ['ltr'] }).forEach(({ title, config }) => {
test.describe(title('infinite-scroll: scroll-target'), () => {
test('should load more items when scroll target is scrolled to the bottom', async ({ page }) => {
await page.goto('/src/components/infinite-scroll/test/scroll-target', config);
const ionInfiniteComplete = await page.spyOnEvent('ionInfiniteComplete');
const content = page.locator('#scroll-target');
const items = page.locator('ion-item');
expect(await items.count()).toBe(30);
await content.evaluate((el: HTMLElement) => (el.scrollTop = el.scrollHeight));
await ionInfiniteComplete.next();
expect(await items.count()).toBe(60);
});
});
});

View File

@ -1,22 +0,0 @@
import { expect } from '@playwright/test';
import { test } from '@utils/test/playwright';
test.describe('infinite-scroll: top', () => {
test.beforeEach(({ skip }) => {
skip.rtl();
skip.mode('ios');
});
test('should load more items when scrolled to the top', async ({ page }) => {
await page.goto('/src/components/infinite-scroll/test/top');
const ionInfiniteComplete = await page.spyOnEvent('ionInfiniteComplete');
const content = page.locator('ion-content');
const items = page.locator('ion-item');
expect(await items.count()).toBe(30);
await content.evaluate((el: HTMLIonContentElement) => el.scrollToTop(0));
await ionInfiniteComplete.next();
expect(await items.count()).toBe(60);
});
});

View File

@ -0,0 +1,20 @@
import { expect } from '@playwright/test';
import { configs, test } from '@utils/test/playwright';
configs({ modes: ['md'], directions: ['ltr'] }).forEach(({ title, config }) => {
test.describe(title('infinite-scroll: top'), () => {
test('should load more items when scrolled to the top', async ({ page }) => {
await page.goto('/src/components/infinite-scroll/test/top', config);
const ionInfiniteComplete = await page.spyOnEvent('ionInfiniteComplete');
const content = page.locator('ion-content');
const items = page.locator('ion-item');
expect(await items.count()).toBe(30);
await content.evaluate((el: HTMLIonContentElement) => el.scrollToTop(0));
await ionInfiniteComplete.next();
expect(await items.count()).toBe(60);
});
});
});