Commit Graph

5 Commits

Author SHA1 Message Date
Ho Ngoc Hai
db0fe8b9b7 fix(e2e): unblock E2E test environment — CSP, CORS, and env var fixes
Root causes of web E2E failures:
1. CSP connect-src only included API origin for NODE_ENV=development,
   blocking test mode (NODE_ENV=test) from fetching API data
2. CORS_ORIGINS missing the test web port (3010), so API rejected
   cross-origin requests from the web app
3. NEXT_PUBLIC_API_URL not set in .env.test or playwright config,
   causing web app to default to port 3001 instead of test port 3011
4. Playwright webServer config didn't inherit parent env vars,
   so API server lacked Redis/Typesense/MinIO connection info

Fixes:
- next.config.js: CSP connect-src allows API origins for all non-prod envs
- next.config.js: image remotePatterns allow localhost in test mode
- .env.test: add NEXT_PUBLIC_API_URL and CORS_ORIGINS
- playwright.config.ts: spread process.env into webServer env configs
- e2e.yml: add NEXT_PUBLIC_API_URL, API_PORT, WEB_PORT to GH Actions env
- homepage.spec.ts: update stale assertions to match current UI

Result: 147/202 tests passing (111 API + 36 web), up from 37/91.
Remaining 55 web failures are stale UI assertions needing frontend update.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-13 01:55:04 +07:00
Ho Ngoc Hai
25420720e7 fix(api,ci): remove type-only imports for DI and isolate CI ports from dev
- Remove `type` keyword from NestJS injectable class imports across all
  modules to fix runtime DI resolution (330+ handler/listener files)
- Offset CI docker-compose ports (5433/6380/8109/9002) to avoid
  conflicts with running dev containers
- Update .env.test, playwright.config.ts, and e2e workflow to use
  isolated CI ports with configurable overrides
- Fix prisma/seed.ts to use deterministic IDs for Prisma 7 upsert
  compatibility (phoneHash replaced phone as unique index)
- Add dedicated Docker bridge network for CI service containers

Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>
2026-04-13 01:40:14 +07:00
Ho Ngoc Hai
d4652fd0f9 fix(auth): use env-configurable bcrypt rounds to prevent test timeout
HashedPassword.vo.spec.ts was timing out because SALT_ROUNDS=12 is too
expensive for the test runner. Make bcrypt rounds configurable via
BCRYPT_ROUNDS env var (default 12 for production), and set BCRYPT_ROUNDS=4
in vitest config for fast unit tests.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-10 23:26:43 +07:00
Ho Ngoc Hai
03231271ca fix(security): remove MinIO hardcoded credentials & add presigned URL support
- Remove hardcoded minioadmin/minioadmin_secret fallback from docker-compose.yml,
  require MINIO_ACCESS_KEY/MINIO_SECRET_KEY env vars (fail-fast with :? syntax)
- Align docker-compose.yml env var names with .env.example (MINIO_ACCESS_KEY/SECRET_KEY)
- Update CI e2e workflow to use GitHub vars with non-default fallbacks
- Update .env.test to use non-default test credentials
- Add @aws-sdk/s3-request-presigner and getPresignedUploadUrl() method to
  MinioMediaStorageService for properly signed client-side uploads
- Remove hardcoded credentials from dev-environment docs

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-08 22:44:50 +07:00
Ho Ngoc Hai
bac3313873 test(auth,payments,subs): add 58 unit tests for critical auth, payment, and subscription paths
Cover auth handlers (RegisterUser, LoginUser, RefreshToken), TokenService
(token rotation, reuse attack detection), payment callback edge cases
(duplicate/concurrent callbacks, multi-provider), subscription lifecycle
transitions (expire, pastDue, renew), and throttler proxy guard.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-08 13:49:19 +07:00