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

export default defineConfig({
  testDir: './e2e',
  timeout: 45_000,
  expect: { timeout: 8_000 },
  retries: 0,
  reporter: [['list']],
  use: {
    baseURL: 'http://127.0.0.1:4004',
    locale: 'fa-IR',
    timezoneId: 'Asia/Tehran',
    viewport: { width: 1440, height: 1000 },
    colorScheme: 'light',
    trace: 'retain-on-failure',
    screenshot: 'only-on-failure',
    launchOptions: {
      executablePath: process.env.PLAYWRIGHT_EXECUTABLE_PATH
        || (process.platform === 'win32' ? 'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe' : undefined),
    },
  },
  webServer: [
    {
      command: 'php ../backend/artisan serve --host=127.0.0.1 --port=8000',
      url: 'http://127.0.0.1:8000',
      reuseExistingServer: true,
      timeout: 30_000,
    },
    {
      command: 'npm run dev -- --host=127.0.0.1',
      url: 'http://127.0.0.1:4004',
      reuseExistingServer: true,
      timeout: 30_000,
    },
  ],
});
