test: add full-stack Playwright integration test infrastructure
Sprint 12 Phase 2: Real integration tests with seed DB - R__seed_test_data.sql (Flyway repeatable, 7 members, strains, batches, docs, board, events) - TestResetController (profile-gated per-test DB reset) - docker-compose.test.yml (self-contained, tmpfs Postgres) - Dockerfile.playwright (v1.60.0, pre-installed deps) - 13 integration spec files, 70+ test cases (@smoke + @full) - seed-constants.ts, selectors.ts, api-client.ts test helpers
This commit is contained in:
+60
-27
@@ -1,46 +1,79 @@
|
||||
# System test profile — runs full stack with seed data + Playwright
|
||||
# Usage: docker compose -f docker-compose.test.yml up --abort-on-container-exit
|
||||
include:
|
||||
- docker-compose.yml
|
||||
|
||||
# Integration test profile — full stack with Flyway seed + Playwright
|
||||
# Usage: docker compose -f docker-compose.test.yml up --build --abort-on-container-exit
|
||||
services:
|
||||
# Override db to include seed data
|
||||
db:
|
||||
volumes:
|
||||
- pgdata:/var/lib/postgresql/data
|
||||
- ./scripts/seed/init.sql:/docker-entrypoint-initdb.d/99-seed.sql:ro
|
||||
image: postgres:16-alpine
|
||||
container_name: cannamanage-test-db
|
||||
tmpfs:
|
||||
- /var/lib/postgresql/data
|
||||
environment:
|
||||
POSTGRES_DB: cannamanage_test
|
||||
POSTGRES_USER: cannamanage
|
||||
POSTGRES_PASSWORD: cannamanage_test
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U cannamanage -d cannamanage_test"]
|
||||
interval: 3s
|
||||
timeout: 2s
|
||||
retries: 10
|
||||
|
||||
# Seed container: waits for backend health, then validates readiness
|
||||
seed:
|
||||
image: curlimages/curl:latest
|
||||
container_name: cannamanage-seed
|
||||
backend:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile.backend
|
||||
container_name: cannamanage-test-backend
|
||||
environment:
|
||||
SPRING_PROFILES_ACTIVE: test
|
||||
SPRING_DATASOURCE_URL: jdbc:postgresql://db:5432/cannamanage_test
|
||||
SPRING_DATASOURCE_USERNAME: cannamanage
|
||||
SPRING_DATASOURCE_PASSWORD: cannamanage_test
|
||||
CANNAMANAGE_SECURITY_JWT_SECRET: dGVzdC1zZWNyZXQtZm9yLWludGVncmF0aW9uLXRlc3RzLW9ubHktMzJjaGFycw==
|
||||
depends_on:
|
||||
db:
|
||||
condition: service_healthy
|
||||
healthcheck:
|
||||
test: ["CMD", "wget", "--spider", "-q", "http://localhost:8080/actuator/health"]
|
||||
interval: 5s
|
||||
timeout: 3s
|
||||
retries: 15
|
||||
start_period: 30s
|
||||
|
||||
frontend:
|
||||
build:
|
||||
context: ./cannamanage-frontend
|
||||
dockerfile: Dockerfile
|
||||
container_name: cannamanage-test-frontend
|
||||
environment:
|
||||
NEXTAUTH_URL: http://localhost:3000
|
||||
NEXTAUTH_SECRET: test-nextauth-secret-minimum-32-characters
|
||||
BACKEND_URL: http://backend:8080
|
||||
AUTH_URL: http://localhost:3000
|
||||
depends_on:
|
||||
backend:
|
||||
condition: service_healthy
|
||||
entrypoint: /bin/sh
|
||||
command: ["-c", "/seed/seed.sh"]
|
||||
volumes:
|
||||
- ./scripts/seed:/seed:ro
|
||||
|
||||
# Playwright system tests
|
||||
playwright:
|
||||
image: mcr.microsoft.com/playwright:v1.52.0-noble
|
||||
container_name: cannamanage-playwright
|
||||
build:
|
||||
context: ./cannamanage-frontend
|
||||
dockerfile: Dockerfile.playwright
|
||||
container_name: cannamanage-test-playwright
|
||||
working_dir: /app
|
||||
depends_on:
|
||||
seed:
|
||||
condition: service_completed_successfully
|
||||
frontend:
|
||||
condition: service_started
|
||||
backend:
|
||||
condition: service_healthy
|
||||
environment:
|
||||
BASE_URL: http://frontend:3000
|
||||
API_URL: http://backend:8080
|
||||
CI: "true"
|
||||
# Volume mount allows test iteration without rebuild
|
||||
# (Dockerfile pre-installs deps; mount overrides test files only)
|
||||
volumes:
|
||||
- ./cannamanage-frontend:/app
|
||||
- ./cannamanage-frontend/e2e:/app/e2e:ro
|
||||
command: >
|
||||
sh -c "
|
||||
echo 'Waiting for frontend to be ready...' &&
|
||||
timeout 60 sh -c 'until wget -q -O /dev/null http://frontend:3000 2>/dev/null; do sleep 2; done' &&
|
||||
echo 'Frontend ready — running system tests...' &&
|
||||
npx playwright test e2e/system-test.spec.ts --reporter=list
|
||||
echo 'Waiting for frontend...' &&
|
||||
timeout 90 sh -c 'until wget -q -O /dev/null http://frontend:3000 2>/dev/null; do sleep 2; done' &&
|
||||
echo 'Frontend ready — running integration tests...' &&
|
||||
npx playwright test e2e/integration/ --reporter=html --grep @smoke
|
||||
"
|
||||
|
||||
Reference in New Issue
Block a user