/* @vitest-environment node */ import { describe, it, expect, vi } from "vitest"; import React from "react"; import { renderToString } from "react-dom/server"; /** * We mock `next/link` so this unit test does not depend on the Next.js runtime. * For a server-render smoke test, a minimal replacement is enough. */ vi.mock("next/link", async () => { const ReactNs = await import("react"); const React = ReactNs.default ?? ReactNs; function LinkMock({ href, children, ...props }) { const resolvedHref = typeof href === "string" ? href : href?.pathname ? String(href.pathname) : ""; return React.createElement("a", { href: resolvedHref, ...props }, children); } return { default: LinkMock }; }); import AppShell from "./AppShell"; describe("components/app-shell/AppShell", () => { it("renders the shell without crashing and includes key areas", () => { const element = React.createElement( AppShell, null, React.createElement("div", null, "Child content") ); const html = renderToString(element); // TopNav brand expect(html).toContain("RHL Lieferscheine"); // Sidebar placeholder content expect(html).toContain("Sidebar"); // Rendered children expect(html).toContain("Child content"); }); });