Add comprehensive test suite for v5 (unit, integration, UI, E2E)#26
Conversation
Establish a fully-mocked, CI-friendly test suite for the v5 app: - Tooling: Vitest + React Testing Library + user-event + jest-dom + MSW for unit/integration/component tests; Playwright for E2E. Shared harness under v5/test/ (MSW handlers, Notion/catalog fixtures, next/cache mock, server-only alias, i18n render helper) plus 5 npm scripts. - Unit (src/lib, src/i18n): catalog, notion, rate-limit, site-config, i18n config — pure logic and the Notion data layer (parsers, pagination, retry, write payloads), all mocked via MSW. - Integration (API routes): /api/chat (streamText-capture pattern), /api/mcp (real JSON-RPC), /api/upload-notion, /api/admin/revalidate. - Component (RTL): ToolCard, GalleryShell, UnitsList, DetailShell, ChatFab, LanguageSelector, ThemeToggle, GlobalChrome, PrimaryNav. - E2E (Playwright): gallery, tool detail, search, chat (intercepted stream), theme/i18n, navigation — app runs against the built-in mock catalog with NOTION_* unset, no live external calls anywhere. - Docs: design/dispatch plan in docs/superpowers/specs and a v5/TESTING.md runbook. 224 Vitest tests + 15 Playwright tests; lint and tsc clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 93fe6beee7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| "devDependencies": { | ||
| "@playwright/test": "^1.60.0", | ||
| "@tailwindcss/postcss": "^4", | ||
| "@testing-library/dom": "^10.4.1", | ||
| "@testing-library/jest-dom": "^6.9.1", | ||
| "@testing-library/react": "^16.3.2", | ||
| "@testing-library/user-event": "^14.6.1", | ||
| "@types/node": "^20", | ||
| "@types/react": "^19", | ||
| "@types/react-dom": "^19", | ||
| "@vitejs/plugin-react": "^6.0.2", | ||
| "eslint": "^9", | ||
| "eslint-config-next": "16.1.6", | ||
| "jsdom": "^29.1.1", | ||
| "msw": "^2.14.6", | ||
| "tailwindcss": "^4", | ||
| "typescript": "^5" | ||
| "typescript": "^5", | ||
| "vitest": "^4.1.7" |
There was a problem hiding this comment.
Regenerate the lockfile so clean installs work
After this lockfile update, a fresh install is blocked before any tests can run: I checked v5 with npm ci, and npm exits with package.json and package-lock.json ... are in sync plus missing entries such as @emnapi/runtime, @emnapi/core, and @swc/helpers. This means CI or any new checkout that uses the committed lockfile cannot install the dependencies added for the test suite until the lockfile is regenerated from a complete install.
Useful? React with 👍 / 👎.
| "typecheck": "tsc --noEmit", | ||
| "test": "vitest run", | ||
| "test:watch": "vitest", | ||
| "test:coverage": "vitest run --coverage", |
There was a problem hiding this comment.
Add the Vitest V8 coverage provider dependency
The new test:coverage script selects coverage.provider: "v8", but @vitest/coverage-v8 is not installed as a dev dependency; in the lockfile it only appears in Vitest's optional peer metadata, and there is no node_modules/@vitest/coverage-v8 package entry. On a fresh install after the lockfile is fixed, npm run test:coverage will fail or prompt for the missing provider instead of producing coverage, which breaks the documented coverage workflow.
Useful? React with 👍 / 👎.
Summary
Establishes a comprehensive, fully-mocked, CI-friendly test suite for the v5 app — there were previously zero tests and no test tooling. Four layers: unit, integration, component/UI, and end-to-end. No layer makes live calls to Notion, Anthropic, or Redis, so the whole thing runs offline and deterministically.
Totals: 224 Vitest tests + 15 Playwright E2E tests. Lint and
tscclean.Tooling & harness
user-event+jest-dom+ MSW for unit/integration/component.NOTION_*unset so it serves the built-in mock catalog;/api/chatis intercepted at the network layer).v5/test/: MSW handlers, Notion + catalog fixtures,next/cachemock,server-onlyalias, and a custom i18nrenderhelper. Documented inv5/test/README.md.test,test:watch,test:coverage,test:e2e,test:e2e:ui.Coverage
src/lib,src/i18n)catalog,notion(parsers, pagination, 429 retry, write payloads),rate-limit,site-config,i18n/config/api/chat(streamText-capture pattern),/api/mcp(real JSON-RPC),/api/upload-notion,/api/admin/revalidateNotes
not-foundreturning 200 undernext dev), the tests follow the source and the divergences are documented inline.window.localStoragebreakage (Node's--localstorage-fileclobbers jsdom'sStorage) centrally invitest.setup.ts.test:coverage.docs/superpowers/specs/2026-05-29-v5-test-suite-design.md. Runbook:v5/TESTING.md.Test plan
🤖 Generated with Claude Code