// Dedicated config for the throwaway discovery spec. Kept separate so the spec
// doesn't run with `npm run test:themes`. Run explicitly:
//
//   CLOVER_PAKMS=… CLOVER_MERCHANT_ID=… \
//     npx playwright test -c tests/_discovery/playwright.config.ts --reporter=list --headed
//
// Static-serves the fixture over HTTP because Clover's iframes target the
// parent origin via postMessage; `file://` resolves to `null` and Clover
// silently drops all event delivery.

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

const PORT = 4173;
const BASE_URL = `http://127.0.0.1:${PORT}`;

export default defineConfig({
  testDir: '.',
  testMatch: ['clover-events.spec.ts'],
  fullyParallel: false,
  retries: 0,
  reporter: 'list',
  timeout: 5 * 60_000,
  use: {
    headless: true,
    screenshot: 'only-on-failure',
    actionTimeout: 15_000,
    baseURL: BASE_URL,
  },
  webServer: {
    command: `python3 -m http.server ${PORT} --bind 127.0.0.1 --directory .`,
    url: BASE_URL,
    timeout: 30_000,
    reuseExistingServer: true,
    stdout: 'ignore',
    stderr: 'pipe',
  },
  projects: [
    { name: 'chromium', use: { ...devices['Desktop Chrome'] } },
  ],
});
