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>
This commit is contained in:
Ho Ngoc Hai
2026-04-08 13:49:19 +07:00
parent a590a41e73
commit bac3313873
13 changed files with 1031 additions and 0 deletions

View File

@@ -1,4 +1,11 @@
import path from 'node:path';
import { defineConfig, devices } from '@playwright/test';
import { config } from 'dotenv';
// Load .env.test so webServer processes and tests use the test database
if (!process.env.CI) {
config({ path: path.resolve(__dirname, '.env.test'), override: true });
}
/**
* Playwright E2E configuration for Goodgo Platform.
@@ -6,9 +13,15 @@ import { defineConfig, devices } from '@playwright/test';
* Projects:
* - "api" — tests against the NestJS API (port 3001)
* - "web" — tests against the Next.js frontend (port 3000)
*
* Database isolation:
* - globalSetup runs migrations + seed on the test DB
* - globalTeardown cleans up test-generated data after all tests
*/
export default defineConfig({
testDir: './e2e',
globalSetup: './e2e/global-setup.ts',
globalTeardown: './e2e/global-teardown.ts',
fullyParallel: true,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
@@ -50,6 +63,7 @@ export default defineConfig({
timeout: 60_000,
env: {
NODE_ENV: 'test',
DATABASE_URL: process.env.DATABASE_URL ?? '',
},
},
{