super-productivity/packages/super-sync-server/tests/integration
Johannes Millan d05444e2af test(supersync): cover WS storm fixes with unit + integration tests
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).
2026-05-20 15:57:00 +02:00
..
multi-client-sync.integration.spec.ts refactor(sync): unify JWT expiry to 365 days for all auth methods 2026-02-16 18:44:27 +01:00
snapshot-skip-optimization.integration.spec.ts refactor(sync): decompose SuperSync server giants into cohesive modules 2026-05-15 20:06:12 +02:00
snapshot-vector-clock-sql.integration.spec.ts fix(sync): preserve own vector clock counter across full-state op resets 2026-04-01 15:41:13 +02:00
websocket-storm.integration.spec.ts test(supersync): cover WS storm fixes with unit + integration tests 2026-05-20 15:57:00 +02:00