mirror of
https://github.com/getpaseo/paseo.git
synced 2026-11-25 01:35:31 +00:00
test(website): check plugin search parameters by name
Native GET form submission and hydrated navigation serialize the same filters in different orders. Verify the term and ranking window in both flows.
This commit is contained in:
@@ -177,7 +177,7 @@ test("filters by search and clears to all plugins", async ({ page }) => {
|
||||
test("keeps the directory's ranking window when searching", async ({ page }) => {
|
||||
await page.goto("/plugins?window=month");
|
||||
await submitSearch(page, "graphite");
|
||||
await expect(page).toHaveURL(/\/plugins\/all\?q=graphite&window=month$/);
|
||||
await expectDirectorySearch(page, "graphite", "month");
|
||||
await expect(page.getByRole("link", { name: "This month" })).toHaveAttribute(
|
||||
"aria-current",
|
||||
"true",
|
||||
@@ -358,10 +358,16 @@ test.describe("search engine visits without JavaScript", () => {
|
||||
});
|
||||
|
||||
test("renders search results and submits the search form", async ({ page }) => {
|
||||
await page.goto("/plugins/all?q=graphite");
|
||||
await page.goto("/plugins?window=month");
|
||||
await submitSearch(page, "graphite");
|
||||
await expectDirectorySearch(page, "graphite", "month");
|
||||
await expect(
|
||||
page.getByRole("heading", { level: 1, name: /^Results for “graphite”/ }),
|
||||
).toBeVisible();
|
||||
await expect(page.getByRole("link", { name: "This month" })).toHaveAttribute(
|
||||
"aria-current",
|
||||
"true",
|
||||
);
|
||||
await expect(page.getByRole("main").getByRole("link", { name: /Graphite/ })).toBeVisible();
|
||||
await expect(page.getByRole("link", { name: /Dracula/ })).toHaveCount(0);
|
||||
|
||||
@@ -459,6 +465,15 @@ async function submitSearch(page: Page, term: string) {
|
||||
await page.keyboard.press("Enter");
|
||||
}
|
||||
|
||||
async function expectDirectorySearch(page: Page, term: string, window: string) {
|
||||
await expect(page).toHaveURL(
|
||||
(url) =>
|
||||
url.pathname === "/plugins/all" &&
|
||||
url.searchParams.get("q") === term &&
|
||||
url.searchParams.get("window") === window,
|
||||
);
|
||||
}
|
||||
|
||||
async function typeSearch(page: Page, term: string) {
|
||||
await page.getByRole("searchbox", { name: "Search plugins" }).pressSequentially(term);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user