test(list): migrate to generators (#27327)

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

List sliding tests use legacy syntax

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

- List sliding 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:47:32 -04:00
committed by GitHub
parent 9aea956e5b
commit 89f710c6c9
94 changed files with 153 additions and 137 deletions

View File

@@ -1,12 +0,0 @@
import { expect } from '@playwright/test';
import { test } from '@utils/test/playwright';
test.describe('list-header: basic', () => {
test('should not have visual regressions', async ({ page }) => {
await page.goto(`/src/components/list-header/test/basic`);
await page.setIonViewport();
await expect(page).toHaveScreenshot(`list-header-${page.getSnapshotSettings()}.png`);
});
});

View File

@@ -0,0 +1,14 @@
import { expect } from '@playwright/test';
import { configs, test } from '@utils/test/playwright';
configs().forEach(({ title, screenshot, config }) => {
test.describe(title('list-header: basic'), () => {
test('should not have visual regressions', async ({ page }) => {
await page.goto(`/src/components/list-header/test/basic`, config);
await page.setIonViewport();
await expect(page).toHaveScreenshot(screenshot(`list-header`));
});
});
});

View File

@@ -1,13 +0,0 @@
import AxeBuilder from '@axe-core/playwright';
import { expect } from '@playwright/test';
import { test } from '@utils/test/playwright';
test.describe('list: a11y', () => {
test('should not have accessibility violations', async ({ page }) => {
await page.goto(`/src/components/list/test/a11y`);
const results = await new AxeBuilder({ page }).analyze();
expect(results.violations).toEqual([]);
});
});

View File

@@ -0,0 +1,15 @@
import AxeBuilder from '@axe-core/playwright';
import { expect } from '@playwright/test';
import { configs, test } from '@utils/test/playwright';
configs().forEach(({ title, config }) => {
test.describe(title('list: a11y'), () => {
test('should not have accessibility violations', async ({ page }) => {
await page.goto(`/src/components/list/test/a11y`, config);
const results = await new AxeBuilder({ page }).analyze();
expect(results.violations).toEqual([]);
});
});
});

View File

@@ -1,12 +0,0 @@
import { expect } from '@playwright/test';
import { test } from '@utils/test/playwright';
test.describe('list: basic', () => {
test('should not have visual regressions', async ({ page }) => {
await page.goto(`/src/components/list/test/basic`);
const list = page.locator('ion-list');
await expect(list).toHaveScreenshot(`list-basic-diff-${page.getSnapshotSettings()}.png`);
});
});

View File

@@ -0,0 +1,14 @@
import { expect } from '@playwright/test';
import { configs, test } from '@utils/test/playwright';
configs().forEach(({ title, screenshot, config }) => {
test.describe(title('list: basic'), () => {
test('should not have visual regressions', async ({ page }) => {
await page.goto(`/src/components/list/test/basic`, config);
const list = page.locator('ion-list');
await expect(list).toHaveScreenshot(screenshot(`list-basic-diff`));
});
});
});

View File

@@ -1,74 +0,0 @@
import { expect } from '@playwright/test';
import { test } from '@utils/test/playwright';
test.describe('list: inset', () => {
test.beforeEach(({ skip }) => {
skip.rtl();
});
test('should render full lines while allowing for overrides', async ({ page }) => {
await page.setContent(`
<ion-content color="primary">
<div class="wrapper" style="display: flex">
<ion-list inset="true" style="width: 100%" lines="full">
<ion-item>
<ion-input aria-label="Input" value="Input Text"></ion-input>
</ion-item>
<ion-item>Pokémon Yellow</ion-item>
<ion-item lines="inset">Super Metroid (with Inset Line)</ion-item>
<ion-item lines="none">Mega Man X (with No Line)</ion-item>
<ion-item>The Legend of Zelda</ion-item>
<ion-item lines="full">Halo</ion-item>
</ion-list>
</div>
</ion-content>
`);
const listWrapper = page.locator('.wrapper');
await expect(listWrapper).toHaveScreenshot(`list-inset-full-lines-${page.getSnapshotSettings()}.png`);
});
test('should render inset lines while allowing for overrides', async ({ page }) => {
await page.setContent(`
<ion-content color="primary">
<div class="wrapper" style="display: flex">
<ion-list inset="true" style="width: 100%" lines="inset">
<ion-item>
<ion-input aria-label="Input" value="Input Text"></ion-input>
</ion-item>
<ion-item>Pokémon Yellow</ion-item>
<ion-item lines="full">Super Metroid (with Full Line)</ion-item>
<ion-item lines="none">Mega Man X (with No Line)</ion-item>
<ion-item>The Legend of Zelda</ion-item>
<ion-item lines="full">Halo</ion-item>
</ion-list>
</div>
</ion-content>
`);
const listWrapper = page.locator('.wrapper');
await expect(listWrapper).toHaveScreenshot(`list-inset-inset-lines-${page.getSnapshotSettings()}.png`);
});
test('should render no lines while allowing for overrides', async ({ page }) => {
await page.setContent(`
<ion-content color="primary">
<div class="wrapper" style="display: flex">
<ion-list inset="true" style="width: 100%" lines="none">
<ion-item>
<ion-input aria-label="Input" value="Input Text"></ion-input>
</ion-item>
<ion-item>Pokémon Yellow</ion-item>
<ion-item lines="full">Super Metroid (with Full Line)</ion-item>
<ion-item lines="inset">Mega Man X (with Inset Line)</ion-item>
<ion-item>The Legend of Zelda</ion-item>
<ion-item lines="full">Halo</ion-item>
</ion-list>
</div>
</ion-content>
`);
const listWrapper = page.locator('.wrapper');
await expect(listWrapper).toHaveScreenshot(`list-inset-no-lines-${page.getSnapshotSettings()}.png`);
});
});

View File

@@ -0,0 +1,82 @@
import { expect } from '@playwright/test';
import { configs, test } from '@utils/test/playwright';
configs({ directions: ['ltr'] }).forEach(({ title, screenshot, config }) => {
test.describe(title('list: inset'), () => {
test('should render full lines while allowing for overrides', async ({ page }) => {
await page.setContent(
`
<ion-content color="primary">
<div class="wrapper" style="display: flex">
<ion-list inset="true" style="width: 100%" lines="full">
<ion-item>
<ion-input aria-label="Input" value="Input Text"></ion-input>
</ion-item>
<ion-item>Pokémon Yellow</ion-item>
<ion-item lines="inset">Super Metroid (with Inset Line)</ion-item>
<ion-item lines="none">Mega Man X (with No Line)</ion-item>
<ion-item>The Legend of Zelda</ion-item>
<ion-item lines="full">Halo</ion-item>
</ion-list>
</div>
</ion-content>
`,
config
);
const listWrapper = page.locator('.wrapper');
await expect(listWrapper).toHaveScreenshot(screenshot(`list-inset-full-lines`));
});
test('should render inset lines while allowing for overrides', async ({ page }) => {
await page.setContent(
`
<ion-content color="primary">
<div class="wrapper" style="display: flex">
<ion-list inset="true" style="width: 100%" lines="inset">
<ion-item>
<ion-input aria-label="Input" value="Input Text"></ion-input>
</ion-item>
<ion-item>Pokémon Yellow</ion-item>
<ion-item lines="full">Super Metroid (with Full Line)</ion-item>
<ion-item lines="none">Mega Man X (with No Line)</ion-item>
<ion-item>The Legend of Zelda</ion-item>
<ion-item lines="full">Halo</ion-item>
</ion-list>
</div>
</ion-content>
`,
config
);
const listWrapper = page.locator('.wrapper');
await expect(listWrapper).toHaveScreenshot(screenshot(`list-inset-inset-lines`));
});
test('should render no lines while allowing for overrides', async ({ page }) => {
await page.setContent(
`
<ion-content color="primary">
<div class="wrapper" style="display: flex">
<ion-list inset="true" style="width: 100%" lines="none">
<ion-item>
<ion-input aria-label="Input" value="Input Text"></ion-input>
</ion-item>
<ion-item>Pokémon Yellow</ion-item>
<ion-item lines="full">Super Metroid (with Full Line)</ion-item>
<ion-item lines="inset">Mega Man X (with Inset Line)</ion-item>
<ion-item>The Legend of Zelda</ion-item>
<ion-item lines="full">Halo</ion-item>
</ion-list>
</div>
</ion-content>
`,
config
);
const listWrapper = page.locator('.wrapper');
await expect(listWrapper).toHaveScreenshot(screenshot(`list-inset-no-lines`));
});
});
});

View File

@@ -1,26 +0,0 @@
import { expect } from '@playwright/test';
import { test } from '@utils/test/playwright';
test.describe('list: lines', () => {
test('lines="full" should render correctly', async ({ page }) => {
await page.goto(`/src/components/list/test/lines`);
const list = page.locator('ion-list[lines="full"]');
await expect(list).toHaveScreenshot(`list-lines-full-${page.getSnapshotSettings()}.png`);
});
test('lines="inset" should render correctly', async ({ page }) => {
await page.goto(`/src/components/list/test/lines`);
const list = page.locator('ion-list[lines="inset"]');
await expect(list).toHaveScreenshot(`list-lines-inset-${page.getSnapshotSettings()}.png`);
});
test('lines="none" should render correctly', async ({ page }) => {
await page.goto(`/src/components/list/test/lines`);
const list = page.locator('ion-list[lines="none"]');
await expect(list).toHaveScreenshot(`list-lines-none-${page.getSnapshotSettings()}.png`);
});
});

View File

@@ -0,0 +1,28 @@
import { expect } from '@playwright/test';
import { configs, test } from '@utils/test/playwright';
configs().forEach(({ title, screenshot, config }) => {
test.describe(title('list: lines'), () => {
test('lines="full" should render correctly', async ({ page }) => {
await page.goto(`/src/components/list/test/lines`, config);
const list = page.locator('ion-list[lines="full"]');
await expect(list).toHaveScreenshot(screenshot(`list-lines-full`));
});
test('lines="inset" should render correctly', async ({ page }) => {
await page.goto(`/src/components/list/test/lines`, config);
const list = page.locator('ion-list[lines="inset"]', config);
await expect(list).toHaveScreenshot(screenshot(`list-lines-inset`));
});
test('lines="none" should render correctly', async ({ page }) => {
await page.goto(`/src/components/list/test/lines`, config);
const list = page.locator('ion-list[lines="none"]', config);
await expect(list).toHaveScreenshot(screenshot(`list-lines-none`));
});
});
});