test(label): migrate to generators (#27325)

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

Label sliding tests use legacy syntax

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

- Label 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:50:03 -04:00
committed by GitHub
parent 89f710c6c9
commit dc4165874a
84 changed files with 129 additions and 108 deletions

View File

@ -1,49 +0,0 @@
import { expect } from '@playwright/test';
import { test } from '@utils/test/playwright';
test.describe('label: rendering', () => {
test('should not have visual regressions', async ({ page }) => {
await page.setContent(`
<ion-label>My Label</ion-label>
`);
const labelEl = page.locator('ion-label');
await expect(labelEl).toHaveScreenshot(`label-basic-${page.getSnapshotSettings()}.png`);
});
test('should not have visual regressions with fixed label', async ({ page }) => {
await page.setContent(`
<ion-item>
<ion-label>My Label</ion-label>
</ion-item>
`);
const itemEl = page.locator('ion-item');
await expect(itemEl).toHaveScreenshot(`label-fixed-${page.getSnapshotSettings()}.png`);
});
test('should not have visual regressions with stacked label', async ({ page }) => {
await page.setContent(`
<ion-item>
<ion-label position="stacked">My Label</ion-label>
<ion-input></ion-input>
</ion-item>
`);
const itemEl = page.locator('ion-item');
await expect(itemEl).toHaveScreenshot(`label-stacked-${page.getSnapshotSettings()}.png`);
});
test('should not have visual regressions with floating label', async ({ page }) => {
await page.setContent(`
<ion-item>
<ion-label position="floating">My Label</ion-label>
<ion-input></ion-input>
</ion-item>
`);
const itemEl = page.locator('ion-item');
await expect(itemEl).toHaveScreenshot(`label-floating-${page.getSnapshotSettings()}.png`);
});
});

View File

@ -0,0 +1,63 @@
import { expect } from '@playwright/test';
import { configs, test } from '@utils/test/playwright';
configs().forEach(({ title, screenshot, config }) => {
test.describe(title('label: rendering'), () => {
test('should not have visual regressions', async ({ page }) => {
await page.setContent(
`
<ion-label>My Label</ion-label>
`,
config
);
const labelEl = page.locator('ion-label');
await expect(labelEl).toHaveScreenshot(screenshot(`label-basic`));
});
test('should not have visual regressions with fixed label', async ({ page }) => {
await page.setContent(
`
<ion-item>
<ion-label>My Label</ion-label>
</ion-item>
`,
config
);
const itemEl = page.locator('ion-item');
await expect(itemEl).toHaveScreenshot(screenshot(`label-fixed`));
});
test('should not have visual regressions with stacked label', async ({ page }) => {
await page.setContent(
`
<ion-item>
<ion-label position="stacked">My Label</ion-label>
<ion-input></ion-input>
</ion-item>
`,
config
);
const itemEl = page.locator('ion-item');
await expect(itemEl).toHaveScreenshot(screenshot(`label-stacked`));
});
test('should not have visual regressions with floating label', async ({ page }) => {
await page.setContent(
`
<ion-item>
<ion-label position="floating">My Label</ion-label>
<ion-input></ion-input>
</ion-item>
`,
config
);
const itemEl = page.locator('ion-item');
await expect(itemEl).toHaveScreenshot(screenshot(`label-floating`));
});
});
});

View File

@ -1,46 +0,0 @@
import { expect } from '@playwright/test';
import { test } from '@utils/test/playwright';
test.describe('label: rendering', () => {
test.beforeEach(({ skip }) => {
skip.rtl();
});
test('should not inherit color from content', async ({ page }) => {
await page.goto(`/src/components/label/test/color`);
const item = page.locator('ion-item');
await expect(item).toHaveScreenshot(`item-color-inherit-${page.getSnapshotSettings()}.png`);
});
test('should set color directly', async ({ page }) => {
await page.setContent(`
<ion-label color="danger">Label Text</ion-label>
`);
const labelEl = page.locator('ion-label');
await expect(labelEl).toHaveScreenshot(`label-color-${page.getSnapshotSettings()}.png`);
});
test('should use contrast color when color is set on item', async ({ page }) => {
await page.setContent(`
<ion-item color="danger">
<ion-label>Label Text</ion-label>
</ion-item>
`);
const labelEl = page.locator('ion-label');
await expect(labelEl).toHaveScreenshot(`label-color-contrast-${page.getSnapshotSettings()}.png`);
});
test('should override color even if color set on item', async ({ page }) => {
await page.setContent(`
<ion-item color="danger">
<ion-label color="dark">Label Text</ion-label>
</ion-item>
`);
const labelEl = page.locator('ion-label');
await expect(labelEl).toHaveScreenshot(`label-color-override-${page.getSnapshotSettings()}.png`);
});
});

View File

@ -0,0 +1,54 @@
import { expect } from '@playwright/test';
import { configs, test } from '@utils/test/playwright';
configs({ directions: ['ltr'] }).forEach(({ title, screenshot, config }) => {
test.describe(title('label: rendering'), () => {
test('should not inherit color from content', async ({ page }) => {
await page.goto(`/src/components/label/test/color`, config);
const item = page.locator('ion-item');
await expect(item).toHaveScreenshot(screenshot(`item-color-inherit`));
});
test('should set color directly', async ({ page }) => {
await page.setContent(
`
<ion-label color="danger">Label Text</ion-label>
`,
config
);
const labelEl = page.locator('ion-label');
await expect(labelEl).toHaveScreenshot(screenshot(`label-color`));
});
test('should use contrast color when color is set on item', async ({ page }) => {
await page.setContent(
`
<ion-item color="danger">
<ion-label>Label Text</ion-label>
</ion-item>
`,
config
);
const labelEl = page.locator('ion-label');
await expect(labelEl).toHaveScreenshot(screenshot(`label-color-contrast`));
});
test('should override color even if color set on item', async ({ page }) => {
await page.setContent(
`
<ion-item color="danger">
<ion-label color="dark">Label Text</ion-label>
</ion-item>
`,
config
);
const labelEl = page.locator('ion-label');
await expect(labelEl).toHaveScreenshot(screenshot(`label-color-override`));
});
});
});

View File

@ -1,13 +0,0 @@
import { expect } from '@playwright/test';
import { test } from '@utils/test/playwright';
test.describe('label: rendering', () => {
test.beforeEach(({ skip }) => {
skip.rtl();
});
test('should inherit text overflow for headings', async ({ page }) => {
await page.goto(`/src/components/label/test/headings`);
await expect(page).toHaveScreenshot(`item-headings-inherit-${page.getSnapshotSettings()}.png`);
});
});

View File

@ -0,0 +1,12 @@
import { expect } from '@playwright/test';
import { configs, test } from '@utils/test/playwright';
configs({ directions: ['ltr'] }).forEach(({ title, screenshot, config }) => {
test.describe(title('label: rendering'), () => {
test('should inherit text overflow for headings', async ({ page }) => {
await page.goto(`/src/components/label/test/headings`, config);
await expect(page).toHaveScreenshot(screenshot(`item-headings-inherit`));
});
});
});