Files
novalon-website/e2e/playwright.config.ts
T
张翔 10404dbb36 chore: sync marketing pages, CMS extensions, tests and project docs
同步工作区剩余变更,主要包括:
- 营销页面组件与布局持续优化(about/news/services/solutions/team 等)
- 详情页四层叙事组件、布局组件、UI 组件调整
- CMS 数据模型、API 路由、权限、工作流、站内通知、媒体管理扩展
- 新增/补充单元测试与 E2E 测试(cms-workflow.spec.ts 等)
- ESLint 9 迁移、jest/tsconfig 配置更新、依赖调整
- 新增 ADR、CMS 评估文档、Release Review / Acceptance 报告
- 移除水墨装饰组件与大体积未使用字体文件
2026-07-25 08:04:01 +08:00

109 lines
2.8 KiB
TypeScript

import { defineConfig, devices } from '@playwright/test';
// 为 CMS 工作流 E2E 测试提供默认 revalidate secret
process.env.CMS_REVALIDATE_SECRET = process.env.CMS_REVALIDATE_SECRET || 'e2e-test-secret';
export default defineConfig({
testDir: './',
fullyParallel: true,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
workers: process.env.CI ? 1 : undefined,
reporter: [
['html', { open: 'never' }],
['list', { printSteps: true }],
],
snapshotDir: './visual-snapshots',
snapshotPathTemplate: '{snapshotDir}/{projectName}/{testFilePath}/{arg}-{projectName}{ext}',
use: {
baseURL: process.env.E2E_BASE_URL || 'http://localhost:3000',
storageState: './storageState.json',
trace: 'on-first-retry',
screenshot: 'only-on-failure',
ignoreHTTPSErrors: true,
actionTimeout: 15000,
navigationTimeout: 30000,
},
expect: {
toHaveScreenshot: {
maxDiffPixels: 200,
maxDiffPixelRatio: 0.005,
threshold: 0.3,
animations: 'disabled',
caret: 'hide',
scale: 'device',
timeout: 20000,
},
timeout: 15000,
},
projects: [
{
name: 'visual-chromium-desktop',
use: {
...devices['Desktop Chrome'],
viewport: { width: 1280, height: 800 },
},
testMatch: 'visual-regression.spec.ts',
},
{
name: 'visual-chromium-tablet',
use: {
...devices['iPad Pro 11'],
viewport: { width: 834, height: 1194 },
},
testMatch: 'visual-regression.spec.ts',
},
{
name: 'visual-chromium-mobile',
use: {
...devices['iPhone 14'],
viewport: { width: 390, height: 844 },
isMobile: true,
hasTouch: true,
},
testMatch: 'visual-regression.spec.ts',
},
{
name: 'visual-firefox-desktop',
use: {
...devices['Desktop Firefox'],
viewport: { width: 1280, height: 800 },
},
testMatch: 'visual-regression.spec.ts',
},
{
name: 'visual-webkit-desktop',
use: {
...devices['Desktop Safari'],
viewport: { width: 1280, height: 800 },
},
testMatch: 'visual-regression.spec.ts',
},
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
testIgnore: 'visual-regression.spec.ts',
},
{
name: 'firefox',
use: { ...devices['Desktop Firefox'] },
testIgnore: 'visual-regression.spec.ts',
},
{
name: 'webkit',
use: { ...devices['Desktop Safari'] },
testIgnore: 'visual-regression.spec.ts',
},
],
webServer: {
command: 'npm run preview',
url: 'http://localhost:3000',
reuseExistingServer: true,
timeout: 120000,
cwd: '..',
env: {
CMS_REVALIDATE_SECRET: process.env.CMS_REVALIDATE_SECRET || 'e2e-test-secret',
},
},
});