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>
73 lines
2.6 KiB
Plaintext
73 lines
2.6 KiB
Plaintext
# =============================================================================
|
|
# GoodGo Platform — Test Environment Variables
|
|
# Used by E2E tests (Playwright globalSetup loads this automatically)
|
|
#
|
|
# These values MUST match docker-compose.ci.yml service credentials.
|
|
# Ports use CI_* offsets to avoid conflicts with dev containers.
|
|
# =============================================================================
|
|
|
|
# Test database — matches docker-compose.ci.yml postgres service
|
|
# Port 5433 avoids conflict with dev postgres on 5432
|
|
DATABASE_URL=postgresql://goodgo:goodgo_test_secret@localhost:5433/goodgo_test?schema=public
|
|
|
|
# Redis — matches docker-compose.ci.yml redis service
|
|
# Port 6380 avoids conflict with dev redis on 6379
|
|
REDIS_URL=redis://localhost:6380
|
|
REDIS_HOST=localhost
|
|
REDIS_PORT=6380
|
|
|
|
# Typesense — matches docker-compose.ci.yml typesense service
|
|
# Port 8109 avoids conflict with dev typesense on 8108
|
|
TYPESENSE_HOST=localhost
|
|
TYPESENSE_PORT=8109
|
|
TYPESENSE_PROTOCOL=http
|
|
TYPESENSE_API_KEY=ts_ci_key
|
|
|
|
# MinIO — matches docker-compose.ci.yml minio service
|
|
# Port 9002 avoids conflict with dev minio on 9000
|
|
MINIO_ENDPOINT=localhost
|
|
MINIO_PORT=9002
|
|
MINIO_ACCESS_KEY=ci_minio_user
|
|
MINIO_SECRET_KEY=ci_minio_secret_key_32chars!!
|
|
MINIO_BUCKET=goodgo-uploads
|
|
|
|
# Auth (deterministic secrets for test reproducibility)
|
|
JWT_SECRET=e2e-test-jwt-secret-key-minimum-32-chars-long-enough
|
|
JWT_REFRESH_SECRET=e2e-test-refresh-secret-key-minimum-32-chars-ok
|
|
JWT_EXPIRES_IN=15m
|
|
JWT_REFRESH_EXPIRES_IN=7d
|
|
NODE_ENV=test
|
|
|
|
# Server ports — offset to avoid conflicts with dev
|
|
API_PORT=3011
|
|
WEB_PORT=3010
|
|
API_BASE_URL=http://localhost:3011/api/v1/
|
|
WEB_BASE_URL=http://localhost:3010
|
|
NEXT_PUBLIC_API_URL=http://localhost:3011/api/v1
|
|
|
|
# CORS — allow web test origin
|
|
CORS_ORIGINS=http://localhost:3010,http://localhost:3000
|
|
|
|
# Bcrypt (fast rounds for test — production uses 12+)
|
|
BCRYPT_ROUNDS=4
|
|
|
|
# OAuth (test stubs)
|
|
GOOGLE_CLIENT_ID=test-google-client-id
|
|
GOOGLE_CLIENT_SECRET=test-google-client-secret
|
|
GOOGLE_CALLBACK_URL=http://localhost:3001/api/v1/auth/google/callback
|
|
ZALO_APP_ID=test-zalo-app-id
|
|
ZALO_APP_SECRET=test-zalo-app-secret
|
|
ZALO_CALLBACK_URL=http://localhost:3001/api/v1/auth/zalo/callback
|
|
|
|
# Payment (sandbox)
|
|
VNPAY_TMN_CODE=TESTCODE
|
|
VNPAY_HASH_SECRET=TESTHASHSECRETTESTHASHSECRETTEST
|
|
VNPAY_URL=https://sandbox.vnpayment.vn/paymentv2/vpcpay.html
|
|
VNPAY_RETURN_URL=http://localhost:3000/payment/return
|
|
MOMO_PARTNER_CODE=TEST_MOMO_PARTNER
|
|
MOMO_ACCESS_KEY=TEST_MOMO_ACCESS_KEY
|
|
MOMO_SECRET_KEY=TEST_MOMO_SECRET_KEY
|
|
ZALOPAY_APP_ID=TEST_ZALOPAY_APP
|
|
ZALOPAY_KEY1=TEST_ZALOPAY_KEY1
|
|
ZALOPAY_KEY2=TEST_ZALOPAY_KEY2
|