test(thumbnail): migrate to generators (#27381)

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

Thumbnail tests are using legacy syntax

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

- Thumbnail tests are using 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-05-03 20:06:41 -04:00
committed by GitHub
parent c50c43a5a9
commit 82b607d6e3
23 changed files with 57 additions and 47 deletions

View File

@ -1,47 +0,0 @@
import { expect } from '@playwright/test';
import { test } from '@utils/test/playwright';
test.describe('thumbnail: basic', () => {
test.beforeEach(async ({ page }) => {
await page.goto(`/src/components/thumbnail/test/basic`);
});
test('should not have visual regressions when rendering <img>', async ({ page, skip }) => {
skip.rtl('ion-thumbnail does not have RTL-specific logic');
skip.mode('md', 'ion-thumbnail does not have mode-specific logic');
const referenceEl = page.locator('#img');
await expect(referenceEl).toHaveScreenshot(`thumbnail-img-diff-${page.getSnapshotSettings()}.png`);
});
/**
* ion-item has mode and RTL specific logic
* for ion-thumbnail which is why we do not skip
* RTL and mode tests here.
*/
test('should not have visual regressions when rendering inside of an <ion-item>', async ({ page }) => {
const referenceEl = page.locator('#ion-item');
await expect(referenceEl).toHaveScreenshot(`thumbnail-ion-item-diff-${page.getSnapshotSettings()}.png`);
});
test('size should be customizable in <ion-item>', async ({ page, skip }) => {
skip.rtl();
test.info().annotations.push({
type: 'issue',
description: 'https://github.com/ionic-team/ionic-framework/issues/22935',
});
await page.setContent(`
<ion-item>
<ion-thumbnail style="--size: 20px">
<img src="/src/components/thumbnail/test/thumbnail.svg" />
</ion-thumbnail>
</ion-item>
`);
const item = page.locator('ion-item');
await expect(item).toHaveScreenshot(`thumbnail-ion-item-size-diff-${page.getSnapshotSettings()}.png`);
});
});

View File

@ -0,0 +1,57 @@
import { expect } from '@playwright/test';
import { configs, test } from '@utils/test/playwright';
/**
* ion-thumbnail does not have mode/RTL-specific logic
*/
configs({ modes: ['ios'], directions: ['ltr'] }).forEach(({ title, screenshot, config }) => {
test.describe(title('thumbnail: rendering'), () => {
test('should not have visual regressions when rendering <img>', async ({ page }) => {
await page.goto(`/src/components/thumbnail/test/basic`, config);
const referenceEl = page.locator('#img');
await expect(referenceEl).toHaveScreenshot(screenshot(`thumbnail-img-diff`));
});
test('size should be customizable in <ion-item>', async ({ page }) => {
test.info().annotations.push({
type: 'issue',
description: 'https://github.com/ionic-team/ionic-framework/issues/22935',
});
await page.setContent(
`
<ion-item>
<ion-thumbnail style="--size: 20px">
<img src="/src/components/thumbnail/test/thumbnail.svg" />
</ion-thumbnail>
</ion-item>
`,
config
);
const item = page.locator('ion-item');
await expect(item).toHaveScreenshot(screenshot(`thumbnail-ion-item-size-diff`));
});
});
});
configs().forEach(({ title, screenshot, config }) => {
test.describe(title('thumbnail: item rendering'), () => {
test.beforeEach(async ({ page }) => {
await page.goto(`/src/components/thumbnail/test/basic`, config);
});
/**
* ion-item has mode and RTL specific logic
* for ion-thumbnail which is why we do not skip
* RTL and mode tests here.
*/
test('should not have visual regressions when rendering inside of an <ion-item>', async ({ page }) => {
const referenceEl = page.locator('#ion-item');
await expect(referenceEl).toHaveScreenshot(screenshot(`thumbnail-ion-item-diff`));
});
});
});