Files
Agent-System/web/playwright.config.ts
T

61 lines
2.1 KiB
TypeScript

import { defineConfig, devices } from '@playwright/test';
import * as path from 'path';
import { fileURLToPath } from 'url';
import {
assertWritableUiAcceptanceAssetsDir,
playwrightArtifactDirNames,
resolveUiAcceptanceAssetsDir,
} from './src/lib/playwrightPhaseArtifacts';
/**
* Ubuntu Server headless UI acceptance config (DOCREV runtime).
* Enable only when RUN_UI_ACCEPTANCE=1 against a real dev stack — no mocks.
* Script never touches docker; UI_PHASE=post-restart is a second run after host restart.
* outputDir / HTML report are split by UI_PHASE so post-restart cannot wipe main traces.
* Default assets dir is date-stamped; historical evidence trees are refused.
*/
const runAcceptance = process.env.RUN_UI_ACCEPTANCE === '1';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const evidenceRoot = resolveUiAcceptanceAssetsDir(__dirname, process.env.UI_ACCEPTANCE_ASSETS_DIR);
if (runAcceptance) {
assertWritableUiAcceptanceAssetsDir(evidenceRoot);
}
const phaseDirs = playwrightArtifactDirNames(process.env.UI_PHASE);
export default defineConfig({
testDir: './e2e',
fullyParallel: false,
forbidOnly: !!process.env.CI,
retries: 0,
workers: 1,
timeout: 600_000,
outputDir: path.join(evidenceRoot, phaseDirs.outputDirName),
reporter: [
['list'],
['html', { open: 'never', outputFolder: path.join(evidenceRoot, phaseDirs.reportDirName) }],
],
use: {
baseURL: process.env.BASE_URL || 'http://127.0.0.1:8080',
headless: true,
actionTimeout: 30_000,
locale: 'zh-CN',
// Custom shot() covers evidence screenshots. Disable Playwright auto
// artifacts so concurrent cleans cannot ENOENT mid long UI-03 waits.
trace: 'off',
screenshot: 'off',
video: 'off',
},
projects: [
{
name: 'chromium',
use: {
...devices['Desktop Chrome'],
// Prefer PLAYWRIGHT_CHANNEL (e.g. msedge) when bundled Chromium cannot be downloaded.
...(process.env.PLAYWRIGHT_CHANNEL
? { channel: process.env.PLAYWRIGHT_CHANNEL as 'chrome' | 'chrome-beta' | 'chrome-dev' | 'msedge' | 'msedge-beta' | 'msedge-dev' }
: {}),
},
},
],
});