version: '3.8'

services:
  browser-tests:
    build:
      context: ..
      dockerfile: docker/Dockerfile
    environment:
      - NODE_ENV=test
      - PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
    volumes:
      - ../tests:/app/tests
      - ../src:/app/src
    command: npm test

  # Interactive browser session for debugging
  browser-debug:
    build:
      context: ..
      dockerfile: docker/Dockerfile
    environment:
      - NODE_ENV=development
      - PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
    ports:
      - "9222:9222"  # Chrome DevTools Protocol
    volumes:
      - ../:/app
    command: tail -f /dev/null  # Keep container running
    profiles:
      - debug

  # E2E integration tests with real browser
  browser-e2e:
    build:
      context: ..
      dockerfile: docker/Dockerfile
    environment:
      - NODE_ENV=test
      - TEST_URL=http://test-server:3000
    depends_on:
      - test-server
    command: npm run test:e2e
    profiles:
      - e2e

  # Simple test server for E2E tests
  test-server:
    image: nginx:alpine
    volumes:
      - ./test-fixtures:/usr/share/nginx/html:ro
    profiles:
      - e2e
