polish(web): search pill aria-pressed, keepPreviousData, plural result count, URL-hydration test

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-04 12:47:38 +02:00
parent 358d793e44
commit 4dd00362b8
5 changed files with 21 additions and 4 deletions
+14 -1
View File
@@ -1,5 +1,5 @@
import { expect, test } from "vitest";
import { screen, waitFor } from "@testing-library/react";
import { screen, waitFor, within } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { http, HttpResponse } from "msw";
import { Route, Routes } from "react-router-dom";
@@ -75,3 +75,16 @@ test("clicking a result shows the object in the detail pane", async () => {
expect(await screen.findByText(amphora.object_name)).toBeInTheDocument();
});
test("hydrates query and visibility from the initial URL", async () => {
renderApp(tree(), { route: "/search?q=bronze" });
expect(screen.getByLabelText(/search the collection/i)).toHaveValue("bronze");
expect(await screen.findByText("Bronze figurine")).toBeInTheDocument();
const { container } = renderApp(tree(), { route: "/search?q=bronze&visibility=internal" });
expect(
within(container).getByRole("button", { name: /^internal$/i }),
).toHaveAttribute("aria-pressed", "true");
});