diff --git a/packages/web/src/app/sessions/[id]/not-found.test.tsx b/packages/web/src/app/sessions/[id]/not-found.test.tsx new file mode 100644 index 000000000..7edf1f315 --- /dev/null +++ b/packages/web/src/app/sessions/[id]/not-found.test.tsx @@ -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>) => ( + {children} + ), +})); + +import SessionNotFound from "./not-found"; + +describe("SessionNotFound", () => { + it("renders the session-not-found message", () => { + render(); + expect(screen.getByText("Session not found")).toBeInTheDocument(); + }); + + it("renders descriptive subtext", () => { + render(); + 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(); + const link = screen.getByText("← Back to dashboard"); + expect(link).toBeInTheDocument(); + expect(link.closest("a")).toHaveAttribute("href", "/"); + }); + + it("renders the terminal icon", () => { + const { container } = render(); + const svg = container.querySelector("svg"); + expect(svg).toBeInTheDocument(); + }); +}); diff --git a/packages/web/src/app/sessions/[id]/not-found.tsx b/packages/web/src/app/sessions/[id]/not-found.tsx new file mode 100644 index 000000000..7fd7481fb --- /dev/null +++ b/packages/web/src/app/sessions/[id]/not-found.tsx @@ -0,0 +1,31 @@ +import Link from "next/link"; + +export default function SessionNotFound() { + return ( +
+ + + + +

+ Session not found +

+

+ The session you’re looking for doesn’t exist or has been + deleted. +

+ + ← Back to dashboard + +
+ ); +}