test(searchbar): break up screenshot test (#26455)

This commit is contained in:
Liam DeBeasi
2022-12-09 11:32:43 -05:00
committed by GitHub
parent a99401bf0a
commit 8122494a60
55 changed files with 74 additions and 18 deletions

View File

@ -1,28 +1,11 @@
import { expect } from '@playwright/test';
import { test } from '@utils/test/playwright';
test.describe('searchbar: basic', () => {
test.describe('searchbar: cancel button', () => {
test.beforeEach(async ({ page }) => {
await page.goto(`/src/components/searchbar/test/basic`);
});
test('should not have visual regressions', async ({ page }) => {
await page.setIonViewport();
/**
* The searchbar test template is rendering an ion-searchbar
* that is animated. This requires the searchbar to render,
* before the cancel button can be positioned correctly.
*
* We wait for changes to ensure the searchbar has rendered
* correctly before capturing the screenshot.
*/
await page.waitForChanges();
expect(await page.screenshot({ animations: 'disabled' })).toMatchSnapshot(
`searchbar-diff-${page.getSnapshotSettings()}.png`
);
});
test('should show cancel button on focus if show-cancel-button=focus', async ({ page }) => {
const searchbar = page.locator('#basic');
const cancelButton = searchbar.locator('.searchbar-cancel-button');
@ -89,3 +72,76 @@ test.describe('searchbar: clear button', () => {
await expect(nativeInput).toBeFocused();
});
});
test.describe('searchbar: rendering', () => {
test('should render searchbar', async ({ page }) => {
await page.setContent(`
<ion-searchbar></ion-searchbar>
`);
const searchbar = page.locator('ion-searchbar');
expect(await searchbar.screenshot()).toMatchSnapshot(`searchbar-${page.getSnapshotSettings()}.png`);
});
test('should render cancel and clear buttons', async ({ page }) => {
await page.setContent(`
<ion-searchbar show-cancel-button="always" show-clear-button="always"></ion-searchbar>
`);
const searchbar = page.locator('ion-searchbar');
expect(await searchbar.screenshot()).toMatchSnapshot(`searchbar-buttons-${page.getSnapshotSettings()}.png`);
});
test('should render searchbar with color', async ({ page, skip }) => {
skip.rtl();
await page.setContent(`
<ion-searchbar color="danger" show-cancel-button="always" show-clear-button="always"></ion-searchbar>
`);
const searchbar = page.locator('ion-searchbar');
expect(await searchbar.screenshot()).toMatchSnapshot(`searchbar-color-${page.getSnapshotSettings()}.png`);
});
test('should render disabled searchbar', async ({ page, skip }) => {
skip.rtl();
await page.setContent(`
<ion-searchbar disabled="true"></ion-searchbar>
`);
const searchbar = page.locator('ion-searchbar');
expect(await searchbar.screenshot()).toMatchSnapshot(`searchbar-disabled-${page.getSnapshotSettings()}.png`);
});
test('should render custom search icon', async ({ page, skip }) => {
skip.rtl();
await page.setContent(`
<ion-searchbar search-icon="home"></ion-searchbar>
`);
const icon = page.locator('ion-searchbar ion-icon.searchbar-search-icon');
expect(await icon.screenshot()).toMatchSnapshot(`searchbar-search-icon-${page.getSnapshotSettings()}.png`);
});
});
test.describe('searchbar: placeholder', () => {
test.beforeEach(({ skip }) => {
skip.rtl();
skip.mode('ios');
});
test('should set placeholder', async ({ page }) => {
await page.setContent(`
<ion-searchbar placeholder="My Placeholder"></ion-searchbar>
`);
const nativeInput = page.locator('ion-searchbar input');
await expect(nativeInput).toHaveAttribute('placeholder', 'My Placeholder');
});
});

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB