Skip to content

Commit

Permalink
test(searchbar): add snapshots for focus
Browse files Browse the repository at this point in the history
  • Loading branch information
thetaPC committed Oct 1, 2024
1 parent 4579aa8 commit 8841115
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions core/src/components/searchbar/test/states/searchbar.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,30 @@ import { configs, test } from '@utils/test/playwright';
*/
configs({ modes: ['ionic-md'], directions: ['ltr'] }).forEach(({ title, screenshot, config }) => {
test.describe(title('searchbar: focused'), () => {
test('should render focus ring on the component', async ({ page, pageUtils }) => {
await page.setContent(
`
<style>
/* Add padding to the container to prevent the focus ring from being clipped */
#container {
padding: 5px;
}
</style>
<div id="container">
<ion-searchbar></ion-searchbar>
</div>
`,
config
);

await pageUtils.pressKeys('Tab'); // Focused on the input

const container = page.locator('#container');

await expect(container).toHaveScreenshot(screenshot(`searchbar-state-focused`));
});

test('should render focus ring on the cancel button', async ({ page, pageUtils }) => {
await page.setContent(
`
Expand All @@ -22,9 +46,7 @@ configs({ modes: ['ionic-md'], directions: ['ltr'] }).forEach(({ title, screensh

await expect(searchbar).toHaveScreenshot(screenshot(`searchbar-state-focused-cancel-button`));
});
});

test.describe(title('searchbar: focused'), () => {
test('should render focus ring on the clear button', async ({ page, pageUtils }) => {
await page.setContent(
`
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 8841115

Please sign in to comment.