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

export default defineConfig({
  testDir: './specs',
  fullyParallel: false,
  forbidOnly: !!process.env.CI,
  retries: process.env.CI ? 2 : 0,
  workers: 1,
  reporter: [
    ['html', { outputFolder: '../reports/e2e-report' }],
    ['list'],
  ],
  timeout: 30000,
  expect: {
    timeout: 10000,
  },
  use: {
    baseURL: 'http://localhost:5175',
    trace: 'on-first-retry',
    screenshot: 'only-on-failure',
    video: 'retain-on-failure',
  },
  projects: [
    {
      name: 'auth',
      testDir: './specs/auth',
      use: { ...devices['Desktop Chrome'] },
    },
    {
      name: 'space',
      testDir: './specs/space',
      use: { ...devices['Desktop Chrome'] },
    },
    {
      name: 'asset',
      testDir: './specs/asset',
      use: { ...devices['Desktop Chrome'] },
    },
    {
      name: 'ops',
      testDir: './specs/ops',
      use: { ...devices['Desktop Chrome'] },
    },
    {
      name: 'finance',
      testDir: './specs/finance',
      use: { ...devices['Desktop Chrome'] },
    },
    {
      name: 'cross-domain',
      testDir: './specs/cross-domain',
      use: { ...devices['Desktop Chrome'] },
    },
  ],
  webServer: {
    command: 'cd ../../../ether-admin && npm run dev',
    url: 'http://localhost:5175',
    reuseExistingServer: !process.env.CI,
    timeout: 60000,
  },
});
