Commit d376aac
test(frontend): stand up Vitest baseline + wire into CI (TEST-1)
The Next.js app shipped with zero automated tests; CI ran lint + build only, so every piece of client logic (the API error humanizer, auth-session helpers, the quota meter, the tier-gate UI PR #6 changed) was unverified, and the four recent launch commits had no regression net.
Stood up Vitest + React Testing Library + jsdom (the one justified new dependency group for this PR) with a jsdom config (esbuild JSX, @/ alias) and a jest-dom setup whose type augmentation keeps the existing next-build type pass green over .test files. Added a 'npm test' script and a CI Test step between Lint and Build (reusing the same npm ci install). The FE-SEC-1 security headers were extracted to src/lib/securityHeaders.ts (byte-identical) so they can be asserted without loading the Sentry-wrapped next.config.
24 tests across 7 files cover the baseline plus the deferred component tests from earlier commits: humanizeApiError status/leak mapping; api request() 429 -> TierLimitExceededError + POST/credentials wiring (the CRITICAL-2 upgrade-CTA contract); auth-session redirect/cleanup helpers; the security-header set (FE-SEC-1/F4); the useAccessibleDialog Escape + focus-trap behaviour (A11Y-1/A11Y-2); TokenUsageMeter math + over-tone; and the AnalysisRunner premium tier gate (PR #6: a Free tap fires the upgrade CTA, a Pro tap flips the run mode).
Fixes: TEST-1
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>1 parent 6b454c6 commit d376aac
14 files changed
Lines changed: 2435 additions & 61 deletions
File tree
- .github/workflows
- frontend
- src
- components/workspace
- lib
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
74 | 78 | | |
75 | 79 | | |
76 | 80 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
4 | 9 | | |
5 | 10 | | |
6 | 11 | | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | 12 | | |
54 | 13 | | |
55 | 14 | | |
| |||
0 commit comments