Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Storybook visual regression tests more strict #4919

Merged
merged 1 commit into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ const meta = {

parameters: {
height: "480px",
viewport: {
defaultViewport: "sm",
},
},

argTypes: {
Expand All @@ -29,7 +32,15 @@ export const Default = {
render: (args) => ({
components: { VSearchTypes },
setup() {
return () => h(VSearchTypes, args)
return () =>
h(
"div",
{
style: args.size === "small" ? "width: max-content;" : "",
class: "wrapper p-2",
},
[h(VSearchTypes, args)]
)
},
}),
name: "Default",
Expand Down
2 changes: 1 addition & 1 deletion frontend/test/storybook/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default defineConfig({
expect: {
toMatchSnapshot: {
// To avoid flaky tests, we allow a small amount of pixel difference.
maxDiffPixelRatio: 0.01,
maxDiffPixelRatio: 0.003,
},
},
})
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.
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.
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.
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.
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.
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.
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.
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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,29 @@ test.describe("VSearchTypes", () => {
await expect(page.getByRole("radio").nth(0)).toBeEnabled()
})
test("medium resting", async ({ page }) => {
await expectSnapshot(page, "v-search-types-medium-at-rest", page)
await expectSnapshot(
page,
"v-search-types-medium-at-rest",
page.locator(".wrapper")
)
})

test("medium images hovered", async ({ page }) => {
await page.hover(audioButtonLocator)
await expectSnapshot(page, "v-search-types-medium-images-hovered", page)
await expectSnapshot(
page,
"v-search-types-medium-images-hovered",
page.locator(".wrapper")
)
})

test("medium focused", async ({ page }) => {
await page.keyboard.press("Tab")
await expectSnapshot(page, "v-search-types-medium-focused", page)
await expectSnapshot(
page,
"v-search-types-medium-focused",
page.locator(".wrapper")
)
})
})

Expand All @@ -39,17 +51,29 @@ test.describe("VSearchTypes", () => {
})

test("small resting", async ({ page }) => {
await expectSnapshot(page, "v-search-types-small-at-rest", page)
await expectSnapshot(
page,
"v-search-types-small-at-rest",
page.locator(".wrapper")
)
})

test("small images hovered", async ({ page }) => {
await page.hover(audioButtonLocator)
await expectSnapshot(page, "v-search-types-small-images-hovered", page)
await expectSnapshot(
page,
"v-search-types-small-images-hovered",
page.locator(".wrapper")
)
})

test("small focused", async ({ page }) => {
await page.keyboard.press("Tab")
await expectSnapshot(page, "v-search-types-small-focused", page)
await expectSnapshot(
page,
"v-search-types-small-focused",
page.locator(".wrapper")
)
})
})
})