Files
novalon-website/e2e/playwright.landing.config.ts
zhangxiang 99eaa8c66a feat(landing): 睿视 landing 由本仓统一管理——源码子目录化 + 四道门禁移植 + 契约路由
承接 ADR-0014 §4「第二等产品镜像起必须子目录化 + rewrites 前缀映射并回溯睿视」。
上一轮(2026-12-02)只搬了字节,源码落在 public/ 根命名空间;本轮把源码、门禁、
发布职责一并收进本仓,authority 侧退役对应产物。

源码与 URL 契约:
- public/novavis/{index.html,css,js,assets,images/logos} 一棵树自成一体
- index.html 引用保持站点级绝对路径(/css /js /assets /images/logos)不变。
  因为同一份字节要服务两个落点:官网镜像 novalon.cn/novavis/,以及独立子域
  novavis.p.novalon.cn/(页面在根路径)。改绝对路径会把子域首页变成 /novavis/
- 故用 4 条 prefix rewrite 把根命名空间映射进子目录,而非改写 HTML

四道门禁(从 authority 的四个 python 脚本移植为 Playwright,已并入 test:all):
- e2e/landing/{layout,motion,demo,a11y}.spec.ts + 独立 config(单引擎单 project 串行)
- layout:几何与焦点 / motion:js-grow 渐进生长与 reduced-motion 直达终态
- demo:首屏剧本四步 + 徽标一一对应 + 无 JS 降级四层真实可见性
- a11y:结构与全量对比度(同色无条件阻断)+ axe critical/serious=0
- 实测 13 passed / EXIT=0(1.4m)

补一个映射期暴露的真缺陷:landing 的 main.js 固定 POST /api/v1/contact 且只认
code===200,而本仓只有 /api/contact(formData + 必填 subject),镜像侧转化路径
一直 404。新增 src/app/api/v1/contact/route.ts 按 authority 契约响应(JSON +
{code:200}),而非改前端去适配本仓——改前端等于把适配成本转嫁给子域,且会让
两个落点的成功判据不一致。9 个单测覆盖校验、限流、上游失败不透传 5xx。

文档与配置同步:CLAUDE.md → AGENTS.md(单文档真源)、docs/landing.md、
docs/deployment.md §八、ADR-0014、qa-tracker §32、README 与 quality-gates 脚本表、
Jenkinsfile 落地「♿ 可访问性门禁」阶段的 landing 四道门禁、eslint 忽略
.next-dev-live 构建产物目录(未忽略时 eslint . 会扫出 21195 errors)。

门禁:tsc 0 / eslint 0 / jest app/api/v1 9/9 / test:landing 13 passed。
2026-12-03 22:56:17 +08:00

73 lines
3.3 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { defineConfig, devices } from '@playwright/test';
import path from 'path';
/**
* Landing 门禁专用 Playwright 配置(`npm run test:landing`)。
*
* ## 为什么单独一份配置
*
* landing 的四道门禁原本是 `novavis-authority` 仓里的四个 python 脚本
* (`verify-landing-layout` / `verify-landing-motion` / `landing-demo-verify` /
* `landing-audit`),2026-12-03 随 landing 源码一起迁入本仓。它们**只在 chrome 单引擎、
* 单 project 下跑**,且每条用例自己 setViewportSize(视口是被测对象的一部分)。
*
* 若塞进 `playwright.config.ts` 的 4 个功能 project(chromium / chromium-mobile /
* firefox / webkit),同一套断言会在 4 个引擎 × 4 个视口下重复执行:
* ① 判据里有多处「窄视口下 X 不可见」的断言,在 mobile project 的固定 390 视口下会被
* spec 自己的 setViewportSize 覆盖,跑 4 遍等于跑 1 遍却贵 4 倍;
* ② webkit/firefox 上 `checkVisibility({checkVisibilityCSS})` 与 `:has()` 支持面不同,
* 会把「引擎差异」混进「landing 是否合规」的读数里。
*
* 所以用独立 config + 独立 project:**一个引擎、一份读数**,与迁移前的四道门禁口径一致。
* 主 config 完全不动(`test:functional` 显式传 --project,不会捡到本文件)。
*
* ## webServer
*
* 与主 config 同源:默认 `npm run dev`;`E2E_TARGET=production` 时打 `dist/standalone/server.js`。
* landing 是 `public/` 下的静态文件 + 4 条 rewrite(`next.config.mjs`),dev 与产物都能服务。
*/
export default defineConfig({
testDir: './landing',
fullyParallel: false, // 门禁共享同一个 dev server 且会改视口/注入 CSS,串行才能保证读数可复现
forbidOnly: !!process.env.CI,
retries: 0,
workers: 1,
reporter: [['list', { printSteps: true }]],
outputDir: path.join(__dirname, 'test-results-landing'),
use: {
baseURL: process.env.E2E_BASE_URL || 'http://localhost:3000',
trace: 'off',
screenshot: 'only-on-failure',
// 门禁自身会按需 setViewportSize,这里给一个与迁移前一致的初始视口
viewport: { width: 1440, height: 900 },
// landing 页无登录态:清空 storageState,避免把主站 cookie 带进来影响读数
storageState: { cookies: [], origins: [] },
ignoreHTTPSErrors: true,
actionTimeout: 15000,
navigationTimeout: 30000,
},
expect: { timeout: 15000 },
projects: [
{
name: 'landing',
// 顺序有意义:`devices[...]` 自带 viewport 1280×720,必须**在展开之后**覆盖,
// 否则 `use` 层写的 1440×900 会被 project 层盖掉(实测:hero 在 720 高视口下
// 落在首屏之外,IntersectionObserver 不触发,剧本采样到空序列而假失败)。
use: { ...devices['Desktop Chrome'], viewport: { width: 1440, height: 900 } },
},
],
webServer: {
command:
process.env.E2E_TARGET === 'production'
? 'HOSTNAME=localhost PORT=3000 node dist/standalone/server.js'
: 'npm run dev',
url: 'http://localhost:3000',
reuseExistingServer: !process.env.CI && process.env.E2E_TARGET !== 'production',
timeout: 180000,
cwd: '..',
env: {
CMS_REVALIDATE_SECRET: process.env.CMS_REVALIDATE_SECRET || 'e2e-test-secret',
},
},
});