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

/**
 * Playwright configuration for website integration tests
 * 
 * Purpose: Test authentication flows, route guards, and session management
 * Scope: Complete auth flow integration testing
 * 
 * Critical Coverage:
 * - Middleware route protection
 * - AuthGuard component functionality
 * - Session management and loading states
 * - Role-based access control
 * - Auth state transitions
 * - API integration
 */

export default defineConfig({
  testDir: './tests/integration/website',
  testMatch: ['**/*.test.ts'],
  
  // Serial execution for auth flow consistency
  fullyParallel: false,
  workers: 1,
  
  // Continue on errors to see all failures
  maxFailures: undefined,
  
  // Longer timeout for integration tests
  timeout: 60_000,
  
  // Base URL for the website (Docker test environment)
  use: {
    baseURL: 'http://localhost:3100',
    screenshot: 'only-on-failure',
    video: 'retain-on-failure',
    trace: 'retain-on-failure',
  },
  
  // Reporter: verbose for debugging
  reporter: [
    ['list'],
    ['html', { open: 'never' }]
  ],
  
  // No retry - integration tests must pass on first run
  retries: 0,
  
  // No webServer - using Docker environment
  webServer: undefined,
  
  // Browser projects
  projects: [
    {
      name: 'chromium',
      use: { ...devices['Desktop Chrome'] },
    },
  ],
});