test(toggle): migrate to toHaveScreenshot (#28086)

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

Several tests for this component are still using Playwright's old
`toMatchSnapshot` assertion. It's now recommended to use the newer
`toHaveScreenshot` assertion. This new assertion reduces the size of
each screenshot and brings anti-flake improvements such as disabling
animations by default.

We previously migrated most of our codebase to use `toHaveScreenshot`,
but it looks like we missed the tests that were written during the
development of Ionic 7 in a separate branch off `main`.

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

- Migrate component tests to use `toHaveScreenshot`.

Note: There should be no layout changes to any of the screenshots. The
only difference between the old and new screenshots should be image and
file size.

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

---------

Co-authored-by: ionitron <hi@ionicframework.com>
This commit is contained in:
Liam DeBeasi
2023-08-30 13:11:07 -05:00
committed by GitHub
parent 9dfdfe2ed6
commit 271b90deca
140 changed files with 21 additions and 21 deletions

View File

@ -12,7 +12,7 @@ configs({ directions: ['ltr'] }).forEach(({ title, screenshot, config }) => {
); );
const toggle = page.locator('ion-toggle'); const toggle = page.locator('ion-toggle');
expect(await toggle.screenshot()).toMatchSnapshot(screenshot(`toggle-color-checked`)); await expect(toggle).toHaveScreenshot(screenshot(`toggle-color-checked`));
}); });
test('should not apply color when unchecked', async ({ page }) => { test('should not apply color when unchecked', async ({ page }) => {
@ -24,7 +24,7 @@ configs({ directions: ['ltr'] }).forEach(({ title, screenshot, config }) => {
); );
const toggle = page.locator('ion-toggle'); const toggle = page.locator('ion-toggle');
expect(await toggle.screenshot()).toMatchSnapshot(screenshot(`toggle-color-unchecked`)); await expect(toggle).toHaveScreenshot(screenshot(`toggle-color-unchecked`));
}); });
}); });
}); });

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.0 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.6 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.4 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.2 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -15,7 +15,7 @@ configs().forEach(({ title, screenshot, config }) => {
config config
); );
const list = page.locator('ion-list'); const list = page.locator('ion-list');
expect(await list.screenshot()).toMatchSnapshot(screenshot(`toggle-list`)); await expect(list).toHaveScreenshot(screenshot(`toggle-list`));
}); });
test('should render correctly in inset list', async ({ page }) => { test('should render correctly in inset list', async ({ page }) => {
await page.setContent( await page.setContent(
@ -29,7 +29,7 @@ configs().forEach(({ title, screenshot, config }) => {
config config
); );
const list = page.locator('ion-list'); const list = page.locator('ion-list');
expect(await list.screenshot()).toMatchSnapshot(screenshot(`toggle-inset-list`)); await expect(list).toHaveScreenshot(screenshot(`toggle-inset-list`));
}); });
}); });
}); });
@ -46,7 +46,7 @@ configs({ directions: ['ltr'] }).forEach(({ title, screenshot, config }) => {
config config
); );
const item = page.locator('ion-item'); const item = page.locator('ion-item');
expect(await item.screenshot()).toMatchSnapshot(screenshot(`toggle-item-color`)); await expect(item).toHaveScreenshot(screenshot(`toggle-item-color`));
}); });
}); });
}); });
@ -67,7 +67,7 @@ configs({ directions: ['ltr'], modes: ['md'] }).forEach(({ title, screenshot, co
config config
); );
const list = page.locator('ion-list'); const list = page.locator('ion-list');
expect(await list.screenshot()).toMatchSnapshot(screenshot(`toggle-long-label-in-item`)); await expect(list).toHaveScreenshot(screenshot(`toggle-long-label-in-item`));
}); });
}); });
}); });

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

@ -21,7 +21,7 @@ configs().forEach(({ title, screenshot, config }) => {
); );
const toggle = page.locator('ion-toggle'); const toggle = page.locator('ion-toggle');
expect(await toggle.screenshot()).toMatchSnapshot(screenshot(`toggle-label-start-justify-start`)); await expect(toggle).toHaveScreenshot(screenshot(`toggle-label-start-justify-start`));
}); });
test('should render an end justification with label in the start position', async ({ page }) => { test('should render an end justification with label in the start position', async ({ page }) => {
await page.setContent( await page.setContent(
@ -33,7 +33,7 @@ configs().forEach(({ title, screenshot, config }) => {
); );
const toggle = page.locator('ion-toggle'); const toggle = page.locator('ion-toggle');
expect(await toggle.screenshot()).toMatchSnapshot(screenshot(`toggle-label-start-justify-end`)); await expect(toggle).toHaveScreenshot(screenshot(`toggle-label-start-justify-end`));
}); });
test('should render a space between justification with label in the start position', async ({ page }) => { test('should render a space between justification with label in the start position', async ({ page }) => {
await page.setContent( await page.setContent(
@ -45,7 +45,7 @@ configs().forEach(({ title, screenshot, config }) => {
); );
const toggle = page.locator('ion-toggle'); const toggle = page.locator('ion-toggle');
expect(await toggle.screenshot()).toMatchSnapshot(screenshot(`toggle-label-start-justify-space-between`)); await expect(toggle).toHaveScreenshot(screenshot(`toggle-label-start-justify-space-between`));
}); });
}); });
@ -60,7 +60,7 @@ configs().forEach(({ title, screenshot, config }) => {
); );
const toggle = page.locator('ion-toggle'); const toggle = page.locator('ion-toggle');
expect(await toggle.screenshot()).toMatchSnapshot(screenshot(`toggle-label-end-justify-start`)); await expect(toggle).toHaveScreenshot(screenshot(`toggle-label-end-justify-start`));
}); });
test('should render an end justification with label in the end position', async ({ page }) => { test('should render an end justification with label in the end position', async ({ page }) => {
await page.setContent( await page.setContent(
@ -72,7 +72,7 @@ configs().forEach(({ title, screenshot, config }) => {
); );
const toggle = page.locator('ion-toggle'); const toggle = page.locator('ion-toggle');
expect(await toggle.screenshot()).toMatchSnapshot(screenshot(`toggle-label-end-justify-end`)); await expect(toggle).toHaveScreenshot(screenshot(`toggle-label-end-justify-end`));
}); });
test('should render a space between justification with label in the end position', async ({ page }) => { test('should render a space between justification with label in the end position', async ({ page }) => {
await page.setContent( await page.setContent(
@ -84,7 +84,7 @@ configs().forEach(({ title, screenshot, config }) => {
); );
const toggle = page.locator('ion-toggle'); const toggle = page.locator('ion-toggle');
expect(await toggle.screenshot()).toMatchSnapshot(screenshot(`toggle-label-end-justify-space-between`)); await expect(toggle).toHaveScreenshot(screenshot(`toggle-label-end-justify-space-between`));
}); });
}); });
@ -99,7 +99,7 @@ configs().forEach(({ title, screenshot, config }) => {
); );
const toggle = page.locator('ion-toggle'); const toggle = page.locator('ion-toggle');
expect(await toggle.screenshot()).toMatchSnapshot(screenshot(`toggle-label-fixed-justify-start`)); await expect(toggle).toHaveScreenshot(screenshot(`toggle-label-fixed-justify-start`));
}); });
test('should render an end justification with label in the fixed position', async ({ page }) => { test('should render an end justification with label in the fixed position', async ({ page }) => {
await page.setContent( await page.setContent(
@ -111,7 +111,7 @@ configs().forEach(({ title, screenshot, config }) => {
); );
const toggle = page.locator('ion-toggle'); const toggle = page.locator('ion-toggle');
expect(await toggle.screenshot()).toMatchSnapshot(screenshot(`toggle-label-fixed-justify-end`)); await expect(toggle).toHaveScreenshot(screenshot(`toggle-label-fixed-justify-end`));
}); });
test('should render a space between justification with label in the fixed position', async ({ page }) => { test('should render a space between justification with label in the fixed position', async ({ page }) => {
await page.setContent( await page.setContent(
@ -123,7 +123,7 @@ configs().forEach(({ title, screenshot, config }) => {
); );
const toggle = page.locator('ion-toggle'); const toggle = page.locator('ion-toggle');
expect(await toggle.screenshot()).toMatchSnapshot(screenshot(`toggle-label-fixed-justify-space-between`)); await expect(toggle).toHaveScreenshot(screenshot(`toggle-label-fixed-justify-space-between`));
}); });
}); });
}); });

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.8 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.6 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.6 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.8 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.6 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.6 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.6 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.8 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.6 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.0 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.7 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.0 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.9 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.9 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.0 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.7 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.0 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.9 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.9 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.8 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.7 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.1 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.0 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.9 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.8 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.6 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.6 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.8 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.6 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.6 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.8 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.8 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Some files were not shown because too many files have changed in this diff Show More