mirror of
https://github.com/johannesjo/super-productivity.git
synced 2026-07-18 08:56:41 +00:00
Both round-1 and round-2 reviewers flagged a coverage gap for the two new behaviors most likely to silently regress on future refactors: the WS rate-limit keyGenerator (per-(ip,clientId) keying) and the setErrorHandler WS-429 downgrade. Closing that gap, plus adding a real-network storm-survival test that the fake-timer unit tests cannot model. - Extract `wsRateLimitKeyGenerator` as a named export from websocket.routes.ts so the (ip,cid) composition logic is reachable from a unit test. Behavior unchanged — it was previously an inline property on the rate-limit config object. - Extract `pickErrorLogLevel(url, statusCode)` as a named export from server.ts. The previous inline branch in setErrorHandler did the same work but was untestable without booting a full Fastify app. - Add 7 keyGenerator unit tests covering: compose, distinct keys per cid, missing cid, regex failure, oversize cid (DoS hardening), array-shaped query (?cid=a&cid=b), undefined query. - Add 10 pickErrorLogLevel unit tests covering 5xx → error, the four WS-429 path shapes (exact, trailing slash, query, both) → debug, sibling-route over-match guard, and the 4xx-stays-loud cases. - Add a real-network integration test that boots Fastify on a random TCP port, connects a real `ws` incumbent + 20 challengers under the same clientId, and asserts: every challenger receives 4008, the incumbent stays OPEN, WARN fires exactly once, and the storm-summary INFO fires exactly once on incumbent close. Exercises the @fastify/websocket + ws library + sliding cooldown path end-to-end (no DB needed, auth is mocked). |
||
|---|---|---|
| .. | ||
| multi-client-sync.integration.spec.ts | ||
| snapshot-skip-optimization.integration.spec.ts | ||
| snapshot-vector-clock-sql.integration.spec.ts | ||
| websocket-storm.integration.spec.ts | ||