Files
HealthLog/tests/integration
Marc-André Bombeck 02003428df test(integration): 24 critical-path tests across auth, withings, cache
Closes the highest-severity gaps from the v1.4.34.3 test-coverage
audit. Five new integration files, 24 new cases.

auth-password-change.test.ts (5 cases):
  Pins the v1.4.34.3+ `destroyAllSessions` contract end-to-end.
  Asserts that after a successful password change the user's
  Session.deleteMany ran, ApiToken.revoked flipped to true, and
  RefreshToken.revokedAt was set. Plus wrong-current-password (401)
  and weak-new-password (422) negative paths. A second
  concurrent-request that holds the old session cookie is rejected
  by the next session-protected endpoint.

admin-reset-password.test.ts (5 cases):
  Same three-transport revocation shape for the admin-driven
  reset. Non-admin auth rejects with 403. Audit-log row carries
  the action name `admin.user.reset-password` and the actor's
  user-id.

withings-oauth.test.ts (5 cases):
  GET /api/integrations/withings/connect returns the upstream
  authorise URL with the right scopes + redirect URI. GET
  /api/withings/callback exchanges code for tokens by stubbing
  the Withings token endpoint; the user row's encrypted token
  pair populates. POST /api/withings/disconnect clears them.
  State-token replay (wrong cookie) rejects with 400. The
  Set-Cookie header carries the URL-encoded form of the state
  string — the assertion compares on the encoded value, not the
  literal.

passkey-register.test.ts (4 cases):
  /api/auth/passkey/register-options issues a fresh challenge
  bound to the RP-ID. /api/auth/passkey/register-verify against a
  stubbed @simplewebauthn/server verifier creates the Passkey
  row. A tampered attestation rejects with 422 + a clear
  errorCode. The challenge is single-use.

cache-invalidation-coverage.test.ts (5 cases):
  Grids the v1.4.34 IW-G invalidation matrix across 5 write
  surfaces: measurement POST evicts caches.analytics; mood-entry
  POST evicts caches.moodAnalytics; medication POST evicts
  caches.medications; dashboard-widgets PUT evicts
  caches.dashboardWidgets; admin app-settings PATCH evicts
  caches.bugreportStatus. The integration setup's `isolate: false`
  parallel-DB-bleed quirk on app_settings was handled with a
  `vi.importActual("@/lib/db-compat").ensureDbCompatibility()`
  in beforeEach — pattern worth noting for any future test
  touching that table.

Run: `pnpm test:integration` reports 222/222 passing across 55
files (was 197 in 50 files before this batch); tsc + lint clean.
2026-05-17 00:49:57 +02:00
..