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:
@@ -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");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user