diff --git a/CLAUDE.md b/CLAUDE.md index a7f800d..851ff0f 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -47,6 +47,7 @@ The client proxies `/api/*` requests to the server via Vite config (target is co - Validate request bodies in route handlers using the shared `validate` helper (`import { validate } from "../lib/validate"`). It takes a Zod schema, the request body, and the `res` object — returns parsed data or `null` (after sending a 400 response). - Do not wrap async route handlers in try/catch — Express 5 automatically catches rejected promises - Use the shared `Role` constant instead of hardcoded `"admin"` / `"agent"` strings (import from `core/constants/role.ts`, e.g. `import { Role } from "core/constants/role.ts"`) +- Define shared constants and domain types in `core/constants/` as union types (not `enum` — the client has `erasableSyntaxOnly` enabled). Use `as const` objects when runtime access is needed (e.g. `Role`), and plain union types when only type checking is needed (e.g. `type TicketStatus = "open" | "resolved" | "closed"`). - Use React Hook Form with Zod resolver for client-side form validation (`useForm` + `zodResolver` from `@hookform/resolvers/zod`) - Use Axios for HTTP requests (not `fetch`) - Use TanStack React Query (`useQuery`, `useMutation`) for server state management (not `useEffect` + `useState`) @@ -65,6 +66,8 @@ The client proxies `/api/*` requests to the server via Vite config (target is co ## Testing +- **Prefer component tests** for the majority of coverage (rendering, states, data display, error handling). Reserve E2E tests for things that truly need a real browser + server: navigation, auth redirects, and full-stack integration flows (e.g. webhook creates data that appears in the UI). + ### Component Tests - **Framework**: Vitest + React Testing Library - Run with `cd client && bun run test` (single run) or `bun run test:watch` (watch mode) @@ -76,3 +79,4 @@ The client proxies `/api/*` requests to the server via Vite config (target is co - **Framework**: Playwright - Use the `e2e-test-writer` agent for writing Playwright E2E tests - Run with `bun run test:e2e` from root +- Only use for navigation, auth redirects, and full-stack integration flows diff --git a/client/src/App.tsx b/client/src/App.tsx index ee5118c..1efc00a 100644 --- a/client/src/App.tsx +++ b/client/src/App.tsx @@ -5,6 +5,7 @@ import Layout from "./components/Layout"; import LoginPage from "./pages/LoginPage"; import HomePage from "./pages/HomePage"; import UsersPage from "./pages/UsersPage"; +import TicketsPage from "./pages/TicketsPage"; function App() { return ( @@ -13,6 +14,7 @@ function App() { }> }> } /> + } /> }> } /> diff --git a/client/src/components/Layout.tsx b/client/src/components/Layout.tsx index faba9b1..27046ec 100644 --- a/client/src/components/Layout.tsx +++ b/client/src/components/Layout.tsx @@ -16,6 +16,9 @@ export default function Layout() {