feat(web): set breadcrumb trails on all AppShell routes (#54)

This commit is contained in:
2026-06-07 19:18:43 +02:00
parent af6004f731
commit 4b55218c69
9 changed files with 68 additions and 8 deletions
+22 -1
View File
@@ -1,6 +1,9 @@
import { expect, test } from "vitest";
import { screen } from "@testing-library/react";
import { screen, within } from "@testing-library/react";
import { Routes, Route } from "react-router-dom";
import { renderApp } from "../test/render";
import { AppShell } from "./app-shell";
import { ObjectNewPage } from "../objects/object-new-page";
import { BreadcrumbProvider } from "./breadcrumb-provider";
import { Breadcrumb } from "./breadcrumb";
import { useBreadcrumb } from "./use-breadcrumb";
@@ -24,3 +27,21 @@ test("renders the trail with a link on non-leaf crumbs", async () => {
expect(link).toHaveAttribute("href", "/objects");
expect(screen.getByText("LM-0042")).toBeInTheDocument();
});
test("a nested route sets the header breadcrumb inside AppShell", async () => {
renderApp(
<Routes>
<Route element={<AppShell />}>
<Route path="/objects/new" element={<ObjectNewPage />} />
</Route>
</Routes>,
{ route: "/objects/new" },
);
const nav = await screen.findByRole("navigation", { name: "Breadcrumb" });
const within_nav = within(nav);
const objectsLink = within_nav.getByRole("link", { name: "Objects" });
expect(objectsLink).toHaveAttribute("href", "/objects");
expect(within_nav.getByText("New object")).toBeInTheDocument();
});