Skip to content

Commit 1777950

Browse files
committed
docs: update IMPROVEMENTS.md for 2026-03-20 testing
1 parent 8054623 commit 1777950

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

IMPROVEMENTS.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,24 @@ reader support via aria-busy="true" and aria-label on the skeleton root.
8080

8181
**Files changed:** `web/src/components/DashboardSkeleton.tsx` (new), `web/src/app/dashboard/page.tsx`
8282
**Lines:** +123 / -4
83+
84+
## 2026-03-20 — Testing: Jest unit tests for web API validation and rate-limiter
85+
86+
Added the first unit test suite for the Next.js web layer. The project already had pytest covering
87+
the CLI/desktop; this fills the gap for the server-side API logic that handles all incoming requests.
88+
89+
Two test files, 41 tests total:
90+
- `rate-limit.test.ts`: 27 tests covering checkRateLimit (first request, counting, blocking, window
91+
reset, independent IP/bucket namespacing, default limit) and getClientIP (x-forwarded-for
92+
multi-IP parsing, x-real-ip fallback, 127.0.0.1 fallback, whitespace trimming)
93+
- `validation.test.ts`: 26 tests covering PingResultSchema (field presence, string lengths, numeric
94+
range boundaries, raw_times array limits) and SubmitRequestSchema (defaults, results array limits,
95+
field length limits, nested validation propagation)
96+
97+
Also extracted the Zod schemas from the inline route handler into `src/lib/validation.ts` — a shared
98+
module that the route imports from. No logic changed; pure structural improvement for testability.
99+
100+
**Files changed:** `web/jest.config.js` (new), `web/package.json`, `web/src/lib/validation.ts` (new),
101+
`web/src/__tests__/rate-limit.test.ts` (new), `web/src/__tests__/validation.test.ts` (new),
102+
`web/src/app/api/results/route.ts`
103+
**Lines:** +387 / -20

0 commit comments

Comments
 (0)