test(note): migrate to generators (#27333)

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

Note tests use legacy syntax

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

- Note 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 13:03:50 -04:00
committed by GitHub
parent f5e668c390
commit fe86d9a586
38 changed files with 99 additions and 75 deletions

View File

@@ -1,75 +0,0 @@
import { expect } from '@playwright/test';
import { test } from '@utils/test/playwright';
test.describe('note: rendering', () => {
test.beforeEach(({ skip }) => {
skip.rtl('Note has no custom RTL logic');
});
test('should not have visual regressions', async ({ page }) => {
await page.setContent(`
<ion-note>99</ion-note>
`);
const note = page.locator('ion-note');
await expect(note).toHaveScreenshot(`note-diff-${page.getSnapshotSettings()}.png`);
});
test('should render color correctly', async ({ page }) => {
await page.setContent(`
<ion-note color="danger">99</ion-note>
`);
const note = page.locator('ion-note');
await expect(note).toHaveScreenshot(`note-color-${page.getSnapshotSettings()}.png`);
});
});
test.describe('note: item', () => {
test.beforeEach(({ skip }) => {
skip.mode('ios', 'Only MD ion-item has ion-note specific logic');
});
test('should not have visual regressions when in the start slot of an item', async ({ page }) => {
await page.setContent(`
<ion-item>
<ion-label>Label</ion-label>
<ion-note slot="start">Start Note</ion-note>
</ion-item>
`);
const item = page.locator('ion-item');
await expect(item).toHaveScreenshot(`note-item-start-${page.getSnapshotSettings()}.png`);
});
test('should not have visual regressions when in the end slot of an item', async ({ page }) => {
await page.setContent(`
<ion-item>
<ion-label>Label</ion-label>
<ion-note slot="end">End Note</ion-note>
</ion-item>
`);
const item = page.locator('ion-item');
await expect(item).toHaveScreenshot(`note-item-end-${page.getSnapshotSettings()}.png`);
});
});
test.describe('note: item-divider', () => {
test.beforeEach(({ skip }) => {
skip.mode('ios', 'Only MD ion-item-divider has ion-note specific logic');
});
test('should not have visual regressions when in the start slot of an item-divider', async ({ page }) => {
await page.setContent(`
<ion-item-divider>
<ion-note slot="start">Start Note</ion-note>
</ion-item-divider>
`);
const itemDivider = page.locator('ion-item-divider');
await expect(itemDivider).toHaveScreenshot(`note-item-divider-start-${page.getSnapshotSettings()}.png`);
});
test('should not have visual regressions when in the end slot of an item-divider', async ({ page }) => {
await page.setContent(`
<ion-item-divider>
<ion-note slot="start">End Note</ion-note>
</ion-item-divider>
`);
const itemDivider = page.locator('ion-item-divider');
await expect(itemDivider).toHaveScreenshot(`note-item-divider-end-${page.getSnapshotSettings()}.png`);
});
});

View File

@@ -0,0 +1,99 @@
import { expect } from '@playwright/test';
import { configs, test } from '@utils/test/playwright';
/**
* Note has no custom RTL logic
*/
configs({ directions: ['ltr'] }).forEach(({ title, screenshot, config }) => {
test.describe(title('note: rendering'), () => {
test('should not have visual regressions', async ({ page }) => {
await page.setContent(
`
<ion-note>99</ion-note>
`,
config
);
const note = page.locator('ion-note');
await expect(note).toHaveScreenshot(screenshot(`note-diff`));
});
test('should render color correctly', async ({ page }) => {
await page.setContent(
`
<ion-note color="danger">99</ion-note>
`,
config
);
const note = page.locator('ion-note');
await expect(note).toHaveScreenshot(screenshot(`note-color`));
});
});
});
/**
* Only MD ion-item has ion-note specific logic
*/
configs({ modes: ['md'] }).forEach(({ title, screenshot, config }) => {
test.describe(title('note: item'), () => {
test('should not have visual regressions when in the start slot of an item', async ({ page }) => {
await page.setContent(
`
<ion-item>
<ion-label>Label</ion-label>
<ion-note slot="start">Start Note</ion-note>
</ion-item>
`,
config
);
const item = page.locator('ion-item');
await expect(item).toHaveScreenshot(screenshot(`note-item-start`));
});
test('should not have visual regressions when in the end slot of an item', async ({ page }) => {
await page.setContent(
`
<ion-item>
<ion-label>Label</ion-label>
<ion-note slot="end">End Note</ion-note>
</ion-item>
`,
config
);
const item = page.locator('ion-item');
await expect(item).toHaveScreenshot(screenshot(`note-item-end`));
});
});
});
/**
* Only MD ion-item-divider has ion-note specific logic
*/
configs({ modes: ['md'] }).forEach(({ title, screenshot, config }) => {
test.describe(title('note: item-divider'), () => {
test('should not have visual regressions when in the start slot of an item-divider', async ({ page }) => {
await page.setContent(
`
<ion-item-divider>
<ion-note slot="start">Start Note</ion-note>
</ion-item-divider>
`,
config
);
const itemDivider = page.locator('ion-item-divider');
await expect(itemDivider).toHaveScreenshot(screenshot(`note-item-divider-start`));
});
test('should not have visual regressions when in the end slot of an item-divider', async ({ page }) => {
await page.setContent(
`
<ion-item-divider>
<ion-note slot="start">End Note</ion-note>
</ion-item-divider>
`,
config
);
const itemDivider = page.locator('ion-item-divider');
await expect(itemDivider).toHaveScreenshot(screenshot(`note-item-divider-end`));
});
});
});