feat(web): UserMenu (email/role + sign out) + HeaderSearch components (#54)

This commit is contained in:
2026-06-07 19:23:43 +02:00
parent 4b55218c69
commit 5c8fe3cd81
6 changed files with 163 additions and 0 deletions
+47
View File
@@ -0,0 +1,47 @@
import { expect, test } from "vitest";
import { screen } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { Routes, Route, useLocation } from "react-router-dom";
import { renderApp } from "../test/render";
import { HeaderSearch } from "./header-search";
function LocationProbe() {
const location = useLocation();
return <div data-testid="location">{location.pathname + location.search}</div>;
}
function tree() {
return (
<Routes>
<Route
path="/"
element={
<>
<HeaderSearch />
<LocationProbe />
</>
}
/>
<Route path="/search" element={<LocationProbe />} />
</Routes>
);
}
test("submitting a query navigates to /search?q=", async () => {
renderApp(tree());
const input = await screen.findByRole("searchbox", { name: "Search" });
await userEvent.type(input, "amphora{Enter}");
expect(await screen.findByTestId("location")).toHaveTextContent("/search?q=amphora");
});
test("submitting an empty query does not navigate", async () => {
renderApp(tree());
const input = await screen.findByRole("searchbox", { name: "Search" });
await userEvent.type(input, " {Enter}");
expect(screen.getByTestId("location")).toHaveTextContent("/");
expect(screen.getByTestId("location")).not.toHaveTextContent("/search");
});