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

// Single-target Chromium config: the e2e suite is narrow (smoke
// the production-shaped flow against the docker-compose stack).
// Cross-browser matrix doesn't add signal — what we're verifying is
// the server's HTML and the agent's WebSocket handshake, neither of
// which depends on browser engine.

const baseURL = process.env.RM_BASE_URL ?? 'http://127.0.0.1:8080';

export default defineConfig({
    testDir: './tests',
    // 4 minutes — the smoke test waits for: enrolment + bootstrap
    // (~5s), auto-init landing (~10s), backup completion (~120s
    // budget). 60s is far too tight in CI; 4m gives headroom even
    // on a contended runner without masking real regressions.
    timeout: 240_000,
    expect: { timeout: 10_000 },
    fullyParallel: false,
    retries: process.env.CI ? 1 : 0,
    workers: 1,
    reporter: [['list'], ['html', { open: 'never' }]],
    use: {
        baseURL,
        trace: 'retain-on-failure',
        screenshot: 'only-on-failure',
        video: 'retain-on-failure',
    },
    projects: [
        {
            name: 'chromium',
            use: { ...devices['Desktop Chrome'] },
        },
    ],
});
