import { defineConfig } from '@playwright/test';

export default defineConfig({
  testDir: './test/e2e',
  timeout: 30000,
  retries: 0,
  use: {
    baseURL: 'http://localhost:5173',
    headless: true,
    screenshot: 'only-on-failure',
  },
  webServer: [
    {
      // Backend test server with isolated test_db.sqlite3
      command: 'cd ../backend && source venv/bin/activate && TESTING=true python manage.py migrate --run-syncdb > /dev/null 2>&1 && TESTING=true python manage.py runserver 8000',
      port: 8000,
      reuseExistingServer: false,
      timeout: 30000,
      env: { TESTING: 'true' },
    },
    {
      command: 'npm run dev',
      port: 5173,
      reuseExistingServer: true,
      timeout: 30000,
    },
  ],
});
