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

/**
 * EN: Playwright E2E test configuration for GoodGo TPOS Blazor WASM app.
 * VI: Cau hinh Playwright E2E test cho ung dung Blazor WASM GoodGo TPOS.
 *
 * The Blazor WASM app is served by the .NET Server project (BFF with YARP).
 * Default local URL: http://localhost:5092
 */
export default defineConfig({
  testDir: './tests',
  fullyParallel: false,
  forbidOnly: !!process.env.CI,
  retries: process.env.CI ? 2 : 1,
  workers: process.env.CI ? 1 : undefined,
  reporter: [
    ['html', { open: 'never' }],
    ['list'],
  ],
  timeout: 60_000,

  use: {
    baseURL: process.env.BASE_URL || 'http://localhost:5092',
    screenshot: 'only-on-failure',
    trace: 'on-first-retry',
    actionTimeout: 15_000,
    navigationTimeout: 30_000,
  },

  projects: [
    {
      name: 'chromium',
      use: { browserName: 'chromium' },
    },
  ],

  /* Optionally start the Blazor Server project before tests */
  // webServer: {
  //   command: 'dotnet run --project ../../src/WebClientTpos.Server',
  //   url: 'http://localhost:5092/health',
  //   reuseExistingServer: !process.env.CI,
  //   timeout: 120_000,
  // },
});
