Files
elegalsoftware/apps/api/test-e2e/env.ts
T
Leon SerfatyandClaude Fable 5 d9b807662a
CI / build-and-test (push) Has been cancelled
Add e2e auth test suite, retention crons, and email-verification UX
- E2E suite (23 tests, `npm run test:e2e -w @lawdesk/api`): boots the real
  Fastify app against a disposable Dockerized Postgres (never a real DB) and
  covers signup/login/lockout/rate limits, CSRF (incl. forged-token
  rejection), logout, password reset, email verification, the superadmin
  verified-email promotion gate, and cross-firm tenancy isolation
- packages/db: DATABASE_SSL=disable opt-out for local/test databases that
  don't speak TLS; refused in production
- retention-sweep.ts cron enforcing Privacy Policy windows (sessions,
  tokens, login attempts, tool usage, contact messages, audit log) +
  sweep-orphaned-storage.ts Spaces reconciliation + scripts/README
- Expose emailVerified on the session user; in-app verify-email banner
  with resend, and verified=1|0 toasts on the login page
- Silence Fastify logger under NODE_ENV=test; fix footer resource link;
  document login-attempt/tool-usage retention in the Privacy Policy

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-16 14:32:55 -04:00

34 lines
1.4 KiB
TypeScript

// Shared constants for the e2e harness. The database is a DISPOSABLE Docker container —
// these tests must never point at a real database. global-setup.ts creates/destroys the
// container; auth.e2e.test.ts refuses to run unless DATABASE_URL matches this URL exactly.
export const E2E_CONTAINER = 'elegal-e2e-pg';
export const E2E_DB_PORT = 54329;
export const E2E_DB_NAME = 'elegal_e2e';
export const E2E_DB_PASSWORD = 'e2e_throwaway_password';
export const E2E_DATABASE_URL = `postgres://postgres:${E2E_DB_PASSWORD}@127.0.0.1:${E2E_DB_PORT}/${E2E_DB_NAME}`;
export const E2E_ENV: Record<string, string> = {
NODE_ENV: 'test',
DATABASE_URL: E2E_DATABASE_URL,
DATABASE_SSL: 'disable',
DATABASE_CA_CERT_PATH: '',
PUBLIC_URL: 'http://localhost:8080',
COOKIE_DOMAIN: '',
SESSION_SECRET: 'e2e-session-secret-not-real-0123456789abcdef',
CSRF_SECRET: 'e2e-csrf-secret-not-real-0123456789abcdef',
SUPERADMIN_EMAILS: 'superadmin-e2e@example.com',
// Dummy Spaces config — env.ts requires these; no storage calls happen in auth tests.
SPACES_ENDPOINT: 'https://e2e-invalid.example.com',
SPACES_REGION: 'e2e',
SPACES_BUCKET: 'e2e-bucket',
SPACES_KEY: 'e2e-key',
SPACES_SECRET: 'e2e-secret',
// Empty → email sends are skipped, Stripe/Sentry stay inert.
SMTP2GO_API_KEY: '',
STRIPE_SECRET_KEY: '',
STRIPE_WEBHOOK_SECRET: '',
SENTRY_DSN_API: '',
};