diff --git a/src/components/sidebar.test.tsx b/src/components/sidebar.test.tsx index 1e0cc0c..686ee75 100644 --- a/src/components/sidebar.test.tsx +++ b/src/components/sidebar.test.tsx @@ -95,4 +95,31 @@ describe("Sidebar", () => { expect(ops.queryByText("Stock Orders")).not.toBeInTheDocument(); expect(ops.queryByText("Pricelist")).not.toBeInTheDocument(); }); + + it("renders every top-level nav entry, not just the first", () => { + // Regression guard. The top-level nav rendered `dashboardItems[0]` + // — a hardcoded index — so any entry added after Dashboard existed + // in the array and in the build but never appeared in the sidebar. + // That's how the universal Search link shipped invisible: the + // operator asked for it, the code was correct, the entry was simply + // never rendered. + // + // Asserts the full top-level set rather than "Search exists" so the + // next person to append an entry gets a passing test instead of a + // silently invisible link. + render(); + const desktop = screen.getAllByRole("complementary")[0]; + + for (const label of ["Dashboard", "Search"]) { + expect( + within(desktop).queryByText(label, { exact: true }), + `top-level nav should render "${label}"`, + ).toBeInTheDocument(); + } + + // And the Search entry must actually point at the route. + const link = within(desktop).getByText("Search", { exact: true }).closest("a"); + expect(link).not.toBeNull(); + expect(link).toHaveAttribute("href", "/search"); + }); }); diff --git a/src/components/sidebar.tsx b/src/components/sidebar.tsx index b664326..6f4d6f9 100644 --- a/src/components/sidebar.tsx +++ b/src/components/sidebar.tsx @@ -330,12 +330,20 @@ function NavContent({ onLinkClick }: { onLinkClick?: () => void }) { {/* Nav */}