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

export default defineConfig({
  testDir: './tests/ui',
  timeout: 90_000,
  fullyParallel: true,
  forbidOnly: !!process.env.CI,
  retries: process.env.CI ? 2 : 0,
  workers: process.env.CI ? 1 : undefined,
  reporter: 'html',
  use: {
    baseURL: process.env.E2E_BASE_URL ?? 'https://test-y0k0.fotospiel.app',
    extraHTTPHeaders: process.env.E2E_TESTING_TOKEN
      ? { 'X-Testing-Token': process.env.E2E_TESTING_TOKEN }
      : undefined,
    trace: 'on-first-retry',
    headless: true,
    screenshot: 'only-on-failure',
    video: 'retain-on-failure',
  },
  projects: [
    {
      name: 'purchase',
      testDir: './tests/ui/purchase',
      use: { ...devices['Desktop Chrome'] },
    },
    {
      name: 'auth',
      testDir: './tests/ui/auth',
      use: { ...devices['Desktop Chrome'] },
    },
    {
      name: 'admin',
      testDir: './tests/ui/admin',
      use: { ...devices['Desktop Chrome'] },
    },
    {
      name: 'guest',
      testDir: './tests/ui/guest',
      use: { ...devices['Desktop Chrome'] },
    },
  ],
});
