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
8 changes: 8 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import RouteProgressBar from './components/RouteProgressBar';
import ServerError from './components/ServerError';
import useDocumentTitle from "./hooks/useDocumentTitle";
import NotFound from './components/NotFound';
import DesignSystemDocs from './pages/DesignSystemDocs';
import { startRouteLoading, stopRouteLoading } from './hooks/useRouteLoading';
import useDocumentTitle from './hooks/useDocumentTitle';
import { formatUsdc, formatUsdShortcut } from './utils/format';
Expand Down Expand Up @@ -109,6 +110,7 @@ const APP_ROUTES = {
documentation: "/documentation",
status: "/status",
themePlayground: "/theme-playground",
designSystem: "/design-system/docs",
serverError: "/500",
} as const;

Expand Down Expand Up @@ -550,6 +552,7 @@ function App() {
<NavLink to={APP_ROUTES.marketplace} className={({ isActive }) => isActive ? "link-nav active" : "link-nav"}>Marketplace</NavLink>
<NavLink to={APP_ROUTES.billing} className={({ isActive }) => isActive ? "link-nav active" : "link-nav"}>Billing</NavLink>
<NavLink to={APP_ROUTES.themePlayground} className={({ isActive }) => isActive ? "link-nav active" : "link-nav"}>Theme Playground</NavLink>
<NavLink to={APP_ROUTES.designSystem} className={({ isActive }) => isActive ? "link-nav active" : "link-nav"}>Design System</NavLink>
</nav>
<ThemeToggle />
</div>
Expand Down Expand Up @@ -709,6 +712,11 @@ function App() {

<Route path="/api-usage" element={<ApiUsage />} />

<Route
path={APP_ROUTES.designSystem}
element={<DesignSystemDocs />}
/>

<Route
path={APP_ROUTES.serverError}
element={
Expand Down
44 changes: 44 additions & 0 deletions src/pages/DesignSystemDocs.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// @vitest-environment jsdom

import { cleanup, fireEvent, render, screen } from "@testing-library/react";
import { afterEach, describe, expect, it } from "vitest";
import DesignSystemDocs from "./DesignSystemDocs";

describe("DesignSystemDocs", () => {
afterEach(() => {
cleanup();
});

it("renders the page heading", () => {
render(<DesignSystemDocs />);
expect(screen.getByRole("heading", { name: "Design System" })).toBeTruthy();
});

it("shows the first component expanded by default and the rest collapsed", () => {
render(<DesignSystemDocs />);
// First component section (Primary Button) is open by default
expect(screen.getByText("Live example")).toBeTruthy();
// Verify the collapse/expand toggle buttons are present
const expandAllBtn = screen.getByRole("button", { name: "Expand all" });
expect(expandAllBtn).toBeTruthy();
});

it("collapses all sections when 'Collapse all' is clicked", () => {
render(<DesignSystemDocs />);
fireEvent.click(screen.getByRole("button", { name: "Collapse all" }));
// All component headers remain but no prop tables are shown
expect(screen.queryAllByText("Live example")).toHaveLength(0);
});

it("expands all sections when 'Expand all' is clicked", () => {
render(<DesignSystemDocs />);
// Collapse everything first
fireEvent.click(screen.getByRole("button", { name: "Collapse all" }));
expect(screen.queryAllByText("Live example")).toHaveLength(0);
// Then expand all
fireEvent.click(screen.getByRole("button", { name: "Expand all" }));
// Every component section should now show a "Live example" label
const liveExampleLabels = screen.queryAllByText("Live example");
expect(liveExampleLabels.length).toBeGreaterThan(1);
});
});
Loading