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

/**
 * Playwright E2E测试配置
 * 蚊子项目端到端测试配置
 */
module.exports = defineConfig({
  // 测试目录
  testDir: './e2e',

  // 测试文件匹配模式
  testMatch: ['e2e/tests/**/*.spec.ts'],

  // 忽略其他测试目录
  testIgnore: ['**/h5/**', '**/admin/**', '**/node_modules/**'],

  // 完全并行执行
  fullyParallel: true,

  // 重试策略
  retries: 1,

  // 并行工作进程数
  workers: undefined,

  // 测试报告器
  reporter: [['list']],

  // 共享配置
  use: {
    baseURL: 'http://localhost:5175',
    apiBaseURL: 'http://localhost:8080',
    trace: 'on-first-retry',
    screenshot: 'only-on-failure',
    actionTimeout: 15000,
    navigationTimeout: 30000,
    viewport: { width: 1280, height: 720 },
    ignoreHTTPSErrors: true,
  },

  // 项目配置（只使用chromium简化）
  projects: [
    {
      name: 'chromium',
      use: { 
        browserName: 'chromium',
        launchOptions: {
          executablePath: '/home/long/.cache/ms-playwright/chromium-1200/chrome-linux64/chrome',
          args: ['--no-sandbox', '--disable-setuid-sandbox', '--disable-gpu']
        }
      },
    },
  ],
});
