Skip to content

Commit f97426e

Browse files
committed
Add search modal visual test
1 parent 0d5a896 commit f97426e

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

tests/Visual/SearchModal.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.hero-versions {
2+
visibility: hidden !important;
3+
}

tests/Visual/SearchModal.spec.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { test, expect } from "@playwright/test";
2+
import path from "path";
3+
4+
const httpHost = process.env.HTTP_HOST;
5+
6+
if (typeof httpHost !== "string") {
7+
throw new Error('Environment variable "HTTP_HOST" is not set.');
8+
}
9+
10+
test.beforeEach(async ({ page }) => {
11+
await page.goto(httpHost);
12+
});
13+
14+
const openSearchModal = async (page) => {
15+
await page.getByRole("button", { name: "Search" }).click();
16+
const modal = await page.getByRole("dialog", { name: "Search modal" });
17+
18+
// Wait for the modal animation to finish
19+
await expect(page.locator("#search-modal__backdrop.show")).not.toHaveClass(
20+
"showing",
21+
);
22+
23+
expect(modal).toBeVisible();
24+
return modal;
25+
};
26+
27+
test("should match search modal visual snapshot", async ({ page }) => {
28+
const modal = await openSearchModal(page);
29+
await modal.getByRole("searchbox").fill("array");
30+
await expect(page).toHaveScreenshot(`tests/screenshots/search-modal.png`, {
31+
// Cannot use mask as it ignores z-index
32+
// See https://github.com/microsoft/playwright/issues/19002
33+
stylePath: path.join(__dirname, "SearchModal.css"),
34+
});
35+
});
85 KB
Loading

0 commit comments

Comments
 (0)