feat(web): add session-specific not-found.tsx for 404 handling

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ashish Huddar 2026-04-05 20:41:37 +05:30 committed by Gaurav Bhola
parent 694332d789
commit d956c52eef
2 changed files with 73 additions and 0 deletions

View File

@ -0,0 +1,42 @@
import { render, screen } from "@testing-library/react";
import { describe, it, expect, vi } from "vitest";
vi.mock("next/link", () => ({
default: ({
children,
...props
}: React.PropsWithChildren<React.AnchorHTMLAttributes<HTMLAnchorElement>>) => (
<a {...props}>{children}</a>
),
}));
import SessionNotFound from "./not-found";
describe("SessionNotFound", () => {
it("renders the session-not-found message", () => {
render(<SessionNotFound />);
expect(screen.getByText("Session not found")).toBeInTheDocument();
});
it("renders descriptive subtext", () => {
render(<SessionNotFound />);
expect(
screen.getByText(
"The session you\u2019re looking for doesn\u2019t exist or has been deleted.",
),
).toBeInTheDocument();
});
it("renders a link back to the dashboard", () => {
render(<SessionNotFound />);
const link = screen.getByText("← Back to dashboard");
expect(link).toBeInTheDocument();
expect(link.closest("a")).toHaveAttribute("href", "/");
});
it("renders the terminal icon", () => {
const { container } = render(<SessionNotFound />);
const svg = container.querySelector("svg");
expect(svg).toBeInTheDocument();
});
});

View File

@ -0,0 +1,31 @@
import Link from "next/link";
export default function SessionNotFound() {
return (
<div className="flex min-h-screen flex-col items-center justify-center gap-4 bg-[var(--color-bg-base)]">
<svg
className="h-8 w-8 text-[var(--color-border-strong)]"
fill="none"
stroke="currentColor"
strokeWidth="1.5"
viewBox="0 0 24 24"
>
<rect x="2" y="4" width="20" height="16" rx="2" />
<path d="M6 9l4 3-4 3M13 15h5" />
</svg>
<p className="text-[13px] text-[var(--color-text-muted)]">
Session not found
</p>
<p className="text-[12px] text-[var(--color-text-tertiary)]">
The session you&rsquo;re looking for doesn&rsquo;t exist or has been
deleted.
</p>
<Link
href="/"
className="text-[12px] text-[var(--color-accent)] hover:underline"
>
Back to dashboard
</Link>
</div>
);
}