Add a real test suite and CI/CD for the webapp
Nothing existed before this - first tests for the project. Vitest + React Testing Library (jsdom environment), all explicit imports (no reliance on injected globals, even though globals: true is set). Coverage, prioritized by actual risk rather than 100%-for-its-own-sake: - client.ts (highest value): auth header injection, json/form body serialization, error parsing, and - the trickiest logic in the app - the 401-refresh-and-retry flow, including that concurrent 401s share a single in-flight refresh instead of each firing their own, and that a failed refresh doesn't loop. - jwt.ts: real base64url decode (not a simplified stand-in), including the -/_ substitution path standard base64 doesn't need. - AuthContext: the dev auto-login bypass specifically - doesn't auto-authenticate without configured tokens, does with them, doesn't clobber an already-real session, and logout actually clears state. Uses vi.resetModules() + dynamic import per test since DEV_ACCESS_TOKEN is captured as a module-level const at import time, so env stubs set after the module already loaded would silently do nothing. - UI primitives (Button/ProgressBar/EmptyState): rendering + interaction. - Library page: empty state, list rendering, error display, and the play/pause flow including that pausing doesn't re-fetch the stream. jsdom needed two stubs in test/setup.ts: HTMLMediaElement.play/pause (Library calls these for real) and URL.createObjectURL/revokeObjectURL (jsdom has no real object URL storage) - both throw "Not implemented" without them. .gitlab-ci.yml: deliberately minimal after everything the backend's pipeline taught this session - no Docker, no apt-get, just npm ci -> tsc -> vitest -> vite build on node:20-slim. Verified locally: npm ci works cleanly against the lockfile (real risk after many incremental npm installs), and the exact CI command sequence passes end to end. Co-Authored-By:Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019i3NAUkLkHNbsPg5vKfzF9
Showing
.gitlab-ci.yml
0 → 100644
This diff is collapsed.
| ... | ... | @@ -7,7 +7,9 @@ |
| "dev": "vite", | ||
| "build": "tsc -b && vite build", | ||
| "lint": "oxlint", | ||
| "preview": "vite preview" | ||
| "preview": "vite preview", | ||
| "test": "vitest run", | ||
| "test:watch": "vitest" | ||
| }, | ||
| "dependencies": { | ||
| "lucide-react": "^1.31.0", | ||
| ... | ... | @@ -17,13 +19,18 @@ |
| }, | ||
| "devDependencies": { | ||
| "@tailwindcss/vite": "^4.3.3", | ||
| "@testing-library/jest-dom": "^6.9.1", | ||
| "@testing-library/react": "^16.3.2", | ||
| "@testing-library/user-event": "^14.6.3", | ||
| "@types/node": "^24.13.3", | ||
| "@types/react": "^19.2.17", | ||
| "@types/react-dom": "^19.2.3", | ||
| "@vitejs/plugin-react": "^6.0.4", | ||
| "jsdom": "^29.1.1", | ||
| "oxlint": "^1.75.0", | ||
| "tailwindcss": "^4.3.3", | ||
| "typescript": "~6.0.2", | ||
| "vite": "^8.2.0" | ||
| "vite": "^8.2.0", | ||
| "vitest": "^4.1.10" | ||
| } | ||
| } |
src/api/client.test.ts
0 → 100644
src/api/jwt.test.ts
0 → 100644
src/pages/Library.test.tsx
0 → 100644
src/test/setup.ts
0 → 100644
Please
register
or
sign in
to comment