siegebreak/services/vitest.config.ts
caelum0x 80349345d1 feat: match-found screen, backend rate limiting + readiness, lifesteal
Web (web/): add a dedicated "Match Found" experience — when matchmaking
polling reports "matched", the Queue transitions to a MatchFound view
showing the Photon sessionId + deckId, an Enter Battle stub (no realtime
client yet), and Back to Menu that resets queue state. +3 tests (14 total).

Backend (services/): security + ops hardening.
- @fastify/rate-limit: env-driven global default plus stricter per-route
  limits on all /auth/* endpoints and POST /economy/purchase/validate,
  returning 429 { error: "rate_limited" } via the shared error handler.
- GET /ready readiness probe checking Postgres (SELECT 1) + Redis (ping),
  200 ready / 503 not_ready; GET /health stays as liveness.
- Env limits set high in both vitest configs so existing suites don't trip;
  dedicated test asserts the 429 boundary and both /ready outcomes.
  43 unit + 8 integration tests green.

Game (Assets/, Unity C#): add a lifesteal stat on CharacterConfig, wired
into Unit.ExecuteHit (heals attacker by damage*lifesteal via a new clamped
Health.Heal), and a new sustain-bruiser champion "Reaper". Unverified in
editor (no Unity toolchain available).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-25 18:29:12 +03:00

30 lines
1.2 KiB
TypeScript

import { defineConfig } from "vitest/config";
export default defineConfig({
test: {
environment: "node",
include: ["test/**/*.test.ts"],
// Set before any module import so lib/redis (which throws if REDIS_URL is
// unset) and lib/jwt (needs JWT_SECRET) load cleanly. Redis is lazyConnect,
// so this URL is never actually dialed unless a test drives a Redis path.
env: {
NODE_ENV: "test",
JWT_SECRET: "test-secret-do-not-use-in-prod",
REDIS_URL: "redis://localhost:6379",
// The in-memory rate limiter keys on IP and app.inject reuses one IP, so
// low limits would trip the existing suites. Keep the global + auth
// limits effectively unlimited here; the dedicated rate-limit test
// overrides AUTH_RATE_LIMIT_MAX to a small value before its own buildApp().
RATE_LIMIT_MAX: "100000",
AUTH_RATE_LIMIT_MAX: "100000",
},
coverage: {
provider: "v8",
include: ["src/**/*.ts"],
// Entry point and IO-only glue aren't unit-tested here; the route +
// logic modules are what the suite actually exercises.
exclude: ["src/index.ts", "src/db/**", "src/lib/prisma.ts", "src/lib/redis.ts"],
},
},
});