###############################################################################
# Test infrastructure - run with:
#   docker compose -f docker/docker-compose.test.yml up --build --abort-on-container-exit
###############################################################################
services:
  # ── Unit + Integration tests ─────────────────────────────────────────────
  test-unit:
    build:
      context: ..
      dockerfile: docker/Dockerfile.test
    container_name: ashim-test-unit
    command: ["pnpm", "test:ci"]
    environment:
      - NODE_ENV=test
      - AUTH_ENABLED=true
      - DEFAULT_USERNAME=admin
      - DEFAULT_PASSWORD=admin
      - DB_PATH=/tmp/test-ashim.db
      - WORKSPACE_PATH=/tmp/test-workspace
      - MAX_MEGAPIXELS=100
      - RATE_LIMIT_PER_MIN=1000
    tmpfs:
      - /tmp/test-workspace
      - /tmp

  # ── E2E tests (Playwright against full app) ─────────────────────────────
  test-e2e:
    build:
      context: ..
      dockerfile: docker/Dockerfile.test
    container_name: ashim-test-e2e
    command: ["sh", "-c", "npx playwright install --with-deps chromium && pnpm test:e2e"]
    environment:
      - NODE_ENV=test
      - AUTH_ENABLED=true
      - DEFAULT_USERNAME=admin
      - DEFAULT_PASSWORD=admin
      - DB_PATH=/tmp/test-ashim.db
      - WORKSPACE_PATH=/tmp/test-workspace
      - MAX_MEGAPIXELS=100
      - RATE_LIMIT_PER_MIN=1000
      - CI=true
    tmpfs:
      - /tmp/test-workspace
      - /tmp
    depends_on:
      test-unit:
        condition: service_completed_successfully
