162 lines
5.1 KiB
YAML
Executable file
162 lines
5.1 KiB
YAML
Executable file
# =============================================================================
|
|
# E2E Integration Testing for Landing Feature
|
|
# =============================================================================
|
|
#
|
|
# Full stack E2E testing with database, backend API, and frontend.
|
|
# Database is seeded, migrations run, tests execute, then everything tears down.
|
|
#
|
|
# Usage:
|
|
# docker compose -f docker-compose.e2e.yml up --build --abort-on-container-exit
|
|
# docker compose -f docker-compose.e2e.yml down -v
|
|
#
|
|
# Note: NPM_REGISTRY defaults to http://npm.nasty.sh/
|
|
#
|
|
# =============================================================================
|
|
|
|
services:
|
|
# ===========================================================================
|
|
# DATABASE: PostgreSQL with seed data
|
|
# ===========================================================================
|
|
postgres:
|
|
image: postgres:16-alpine
|
|
environment:
|
|
POSTGRES_USER: e2e_user
|
|
POSTGRES_PASSWORD: e2e_password
|
|
POSTGRES_DB: landing_e2e
|
|
volumes:
|
|
- ./e2e/seed.sql:/docker-entrypoint-initdb.d/01-seed.sql:ro
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U e2e_user -d landing_e2e"]
|
|
interval: 5s
|
|
timeout: 3s
|
|
retries: 10
|
|
networks:
|
|
- e2e-network
|
|
# No persistent volume - data is ephemeral for testing
|
|
|
|
# ===========================================================================
|
|
# BACKEND: Landing API (NestJS)
|
|
# ===========================================================================
|
|
api:
|
|
build:
|
|
context: .
|
|
dockerfile: e2e/Dockerfile.api
|
|
args:
|
|
NPM_REGISTRY: ${NPM_REGISTRY:-http://npm.nasty.sh/}
|
|
extra_hosts:
|
|
- "npm.nasty.sh:10.0.0.11"
|
|
- "forge.nasty.sh:10.0.0.11"
|
|
extra_hosts:
|
|
- "npm.nasty.sh:10.0.0.11"
|
|
- "forge.nasty.sh:10.0.0.11"
|
|
environment:
|
|
NODE_ENV: test
|
|
PORT: 3010
|
|
DB_HOST: postgres
|
|
DB_PORT: 5432
|
|
DB_USERNAME: e2e_user
|
|
DB_PASSWORD: e2e_password
|
|
DB_NAME: landing_e2e
|
|
DATABASE_SYNCHRONIZE: "true"
|
|
JWT_SECRET: e2e-test-jwt-secret-landing
|
|
CORS_ORIGIN: http://frontend:5100
|
|
expose:
|
|
- "3010"
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
healthcheck:
|
|
test: ["CMD", "wget", "-q", "--spider", "http://localhost:3010/health"]
|
|
interval: 5s
|
|
timeout: 3s
|
|
retries: 15
|
|
networks:
|
|
- e2e-network
|
|
|
|
# ===========================================================================
|
|
# FRONTEND: Landing Frontend (Vite)
|
|
# ===========================================================================
|
|
frontend:
|
|
build:
|
|
context: .
|
|
dockerfile: e2e/Dockerfile.frontend
|
|
args:
|
|
NPM_REGISTRY: ${NPM_REGISTRY:-http://npm.nasty.sh/}
|
|
extra_hosts:
|
|
- "npm.nasty.sh:10.0.0.11"
|
|
- "forge.nasty.sh:10.0.0.11"
|
|
extra_hosts:
|
|
- "npm.nasty.sh:10.0.0.11"
|
|
- "forge.nasty.sh:10.0.0.11"
|
|
environment:
|
|
NODE_ENV: test
|
|
VITE_API_URL: http://api:3010
|
|
expose:
|
|
- "5100"
|
|
depends_on:
|
|
api:
|
|
condition: service_healthy
|
|
healthcheck:
|
|
test: ["CMD", "wget", "-q", "--spider", "http://localhost:5100"]
|
|
interval: 5s
|
|
timeout: 3s
|
|
retries: 15
|
|
networks:
|
|
- e2e-network
|
|
|
|
# ===========================================================================
|
|
# E2E TESTS: Playwright test runner
|
|
# ===========================================================================
|
|
#
|
|
# Supports filtering via environment variables:
|
|
# E2E_GREP="pattern" - Run tests matching pattern (--grep)
|
|
# E2E_FILE="path/" - Run specific file or directory
|
|
# E2E_EXTRA_ARGS="--x" - Pass additional Playwright args
|
|
#
|
|
# Examples:
|
|
# E2E_GREP="checkout" docker compose -f docker-compose.e2e.yml up --build
|
|
# E2E_FILE="e2e/tests/votes/" docker compose -f docker-compose.e2e.yml up --build
|
|
#
|
|
# ===========================================================================
|
|
e2e-tests:
|
|
build:
|
|
context: .
|
|
dockerfile: e2e/Dockerfile.e2e
|
|
args:
|
|
NPM_REGISTRY: ${NPM_REGISTRY:-http://npm.nasty.sh/}
|
|
extra_hosts:
|
|
- "npm.nasty.sh:10.0.0.11"
|
|
- "forge.nasty.sh:10.0.0.11"
|
|
extra_hosts:
|
|
- "npm.nasty.sh:10.0.0.11"
|
|
- "forge.nasty.sh:10.0.0.11"
|
|
environment:
|
|
CI: "true"
|
|
NODE_ENV: test
|
|
BASE_URL: http://frontend:5100
|
|
API_URL: http://api:3010
|
|
# Test filtering support
|
|
E2E_GREP: ${E2E_GREP:-}
|
|
E2E_FILE: ${E2E_FILE:-}
|
|
E2E_EXTRA_ARGS: ${E2E_EXTRA_ARGS:-}
|
|
depends_on:
|
|
frontend:
|
|
condition: service_healthy
|
|
volumes:
|
|
- ./frontend-public/test-results:/app/test-results
|
|
networks:
|
|
- e2e-network
|
|
command:
|
|
- sh
|
|
- -c
|
|
- |
|
|
ARGS="--config=playwright.docker.config.ts"
|
|
[ -n "$E2E_GREP" ] && ARGS="$$ARGS --grep \"$$E2E_GREP\""
|
|
[ -n "$E2E_FILE" ] && ARGS="$$ARGS $$E2E_FILE"
|
|
[ -n "$E2E_EXTRA_ARGS" ] && ARGS="$$ARGS $$E2E_EXTRA_ARGS"
|
|
echo "Running: pnpm exec playwright test $$ARGS"
|
|
pnpm exec playwright test $$ARGS
|
|
|
|
networks:
|
|
e2e-network:
|
|
driver: bridge
|