Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions src/app/dashboard/dev-errors/boundary-error/page.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
import { notFound } from "next/navigation";
import TriggerBoundaryError from "./TriggerBoundaryError";

const DEV_ERRORS_ENABLED = process.env.NODE_ENV !== "production";

export default function DashboardBoundaryErrorPage() {
if (!DEV_ERRORS_ENABLED) {
notFound();
}

return (
<main className="space-y-4">
<h1 className="text-2xl font-semibold text-text-primary">
Expand Down
19 changes: 19 additions & 0 deletions src/app/dashboard/dev-errors/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { notFound } from "next/navigation";
import type { ReactNode } from "react";

const DEV_ERRORS_ENABLED = process.env.NODE_ENV !== "production";

export default function DevErrorsLayout({ children }: { children: ReactNode }) {
if (!DEV_ERRORS_ENABLED) {
notFound();
}

return (
<div className="rounded-lg border border-dashed border-yellow-500/40 bg-yellow-500/5 p-4">
<p className="mb-4 text-xs font-semibold uppercase tracking-wider text-yellow-400">
Internal — dev-only route
</p>
{children}
</div>
);
}
7 changes: 0 additions & 7 deletions src/app/dashboard/dev-errors/page.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
import Link from "next/link";
import { notFound } from "next/navigation";

const DEV_ERRORS_ENABLED = process.env.NODE_ENV !== "production";

export default function DashboardDevErrorsPage() {
if (!DEV_ERRORS_ENABLED) {
notFound();
}

return (
<main className="space-y-8">
<header>
Expand Down
8 changes: 0 additions & 8 deletions src/app/dashboard/dev-errors/route-error/page.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
import { notFound } from "next/navigation";

const DEV_ERRORS_ENABLED = process.env.NODE_ENV !== "production";

export default function DashboardRouteErrorPage() {
if (!DEV_ERRORS_ENABLED) {
notFound();
}

throw new Error("Intentional dashboard route error for boundary testing");
}
8 changes: 8 additions & 0 deletions src/lib/routeMetadata.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,3 +200,11 @@ test("breadcrumbs for docs/tokens path are correct", () => {
["Home", "Docs", "Design Tokens"],
);
});

test("breadcrumbs skip devOnly routes", () => {
const breadcrumbs = buildBreadcrumbsFromPath("/dashboard/dev-errors/boundary-error");
const labels = breadcrumbs.map((b) => b.label);
assert.ok(!labels.includes("Dev Errors"), "dev-errors should not appear in breadcrumbs");
assert.ok(!labels.includes("Boundary Error"), "boundary-error should not appear in breadcrumbs");
assert.deepEqual(labels, ["Home", "Dashboard"]);
});
9 changes: 9 additions & 0 deletions src/lib/routeMetadata.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,10 @@ export function getRouteLabel(pathname: string, fallback = "Dashboard"): string
export function buildBreadcrumbsFromPath(
pathname: string,
): import("@/types/breadcrumb.types").BreadcrumbItem[] {
const devOnlyHrefs = new Set(
appRouteDefinitions.filter((d) => d.devOnly).map((d) => d.href),
);

const segments = pathname.split("/").filter(Boolean);
const items: import("@/types/breadcrumb.types").BreadcrumbItem[] = [
{ label: "Home", href: "/", icon: routeMetadata["/"]?.icon },
Expand All @@ -248,6 +252,11 @@ export function buildBreadcrumbsFromPath(
let cumulative = "";
segments.forEach((seg, idx) => {
cumulative += `/${seg}`;

if (devOnlyHrefs.has(cumulative)) {
return;
}

const meta = routeMetadata[cumulative];
items.push({
label: meta?.label ?? seg.charAt(0).toUpperCase() + seg.slice(1),
Expand Down
Loading