/**
 * Playwright Configuration for Trainer Management Tests
 * 
 * @package HVAC_Community_Events
 * @version 2.0.0
 */

const { defineConfig, devices } = require('@playwright/test');

module.exports = defineConfig({
  testDir: '.',
  fullyParallel: false, // Run tests sequentially for comprehensive testing
  forbidOnly: !!process.env.CI,
  retries: process.env.CI ? 2 : 1,
  workers: 1, // Single worker for comprehensive testing
  reporter: [['line'], ['html']],
  
  use: {
    baseURL: 'https://upskill-staging.measurequick.com',
    trace: 'on-first-retry',
    screenshot: 'only-on-failure',
    video: 'retain-on-failure',
    headless: process.env.HEADLESS === 'true',
    viewport: { width: 1280, height: 720 },
    ignoreHTTPSErrors: true, // For staging SSL issues
    actionTimeout: 30000,
    navigationTimeout: 30000,
  },

  projects: [
    {
      name: 'trainer-management',
      use: {
        ...devices['Desktop Chrome'],
        channel: 'chrome',
        launchOptions: {
          args: [
            '--ignore-certificate-errors',
            '--ignore-ssl-errors',
            '--disable-web-security'
          ]
        }
      },
      testMatch: 'trainer-management-comprehensive.test.js',
    },
  ],

  timeout: 60000, // 1 minute per test
  globalTimeout: 20 * 60 * 1000, // 20 minutes total
});