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。
This commit was merged in pull request #70.
This commit is contained in:
1 parent
f20fc92dc3
commit
99eaa8c66a
38 files changed
+3904
-48
No files matched your search
@@ -0,0 +1,226 @@
|
||||
#!/usr/bin/env python3
|
||||
"""验证 landing 页面的渐进生长动效(GROW 模块)。
|
||||
|
||||
前置:先起本地静态服务
|
||||
cd landing && python3 -m http.server 8088 --bind 127.0.0.1
|
||||
|
||||
用法:
|
||||
python3 scripts/verify-landing-motion.py [base_url]
|
||||
|
||||
检查项:
|
||||
1. html.js-grow 已挂载(CSS 初始隐藏态生效的前提)
|
||||
2. Hero mockup 在进入视口后元素依次点亮(密集采样至终态,剧本会循环复位)
|
||||
3. Showcase 四个 panel 切 tab 后各自重播到全部点亮
|
||||
4. 离开视口后复位(is-grown 清零)
|
||||
5. prefers-reduced-motion 下直接呈现终态
|
||||
6. 装饰性图形对 AT 隐藏,且 aria-hidden 子树内无可聚焦元素(axe aria-hidden-focus)
|
||||
7. 无 JS 运行时错误
|
||||
|
||||
注意:生长动效由剧本时间轴驱动(Hero 约 7s 到终态后循环复位),固定短窗口采样会假失败,
|
||||
故 2/3 用「密集采样取峰值」判定,峰值须等于目标总数。
|
||||
|
||||
Last updated: 2026-09-19
|
||||
"""
|
||||
import sys
|
||||
import time
|
||||
|
||||
from playwright.sync_api import sync_playwright
|
||||
|
||||
BASE = sys.argv[1] if len(sys.argv) > 1 else "http://127.0.0.1:8088/"
|
||||
|
||||
PANELS = [
|
||||
("#showcase-tab-graph", "#showcase-panel-graph", "关系图谱"),
|
||||
("#showcase-tab-flow", "#showcase-panel-flow", "资金流向"),
|
||||
("#showcase-tab-ai", "#showcase-panel-ai", "AI 分析"),
|
||||
("#showcase-tab-process", "#showcase-panel-process", "分析过程"),
|
||||
]
|
||||
|
||||
|
||||
def total_targets(page, sel):
|
||||
"""统计该容器内的待点亮目标总数(与 JS targetsOf 的规则一致)。"""
|
||||
return page.evaluate(
|
||||
"""(s) => {
|
||||
const root = document.querySelector(s);
|
||||
if (!root) return 0;
|
||||
let n = 0;
|
||||
root.querySelectorAll('[data-grow]').forEach(el => {
|
||||
n += (el.tagName.toLowerCase() === 'g') ? el.children.length : 1;
|
||||
});
|
||||
return n;
|
||||
}""",
|
||||
sel,
|
||||
)
|
||||
|
||||
|
||||
def grown(page, sel):
|
||||
return page.locator(f"{sel} .is-grown").count()
|
||||
|
||||
|
||||
def watch_growth(page, sel, total, window=12.0, interval=0.4):
|
||||
"""密集采样到峰值:剧本会循环复位,故以「是否曾到达终态」而非末次快照判定。"""
|
||||
peak, samples, waited = 0, [], 0.0
|
||||
while waited < window:
|
||||
cur = grown(page, sel)
|
||||
peak = max(peak, cur)
|
||||
samples.append(cur)
|
||||
if peak == total:
|
||||
break
|
||||
time.sleep(interval)
|
||||
waited += interval
|
||||
return peak, samples
|
||||
|
||||
|
||||
def watch_demo_steps(page, selector, window=14.0):
|
||||
"""采样 demo-step-* 类的推进序列(去重、保序)。
|
||||
|
||||
用于 /home 剧本:hero 改画任务工作台后不再有 data-grow 元素,
|
||||
「动画在跑」这件事改由步骤类推进来证明。
|
||||
"""
|
||||
seen = []
|
||||
samples = []
|
||||
t0 = time.time()
|
||||
while time.time() - t0 < window:
|
||||
cls = page.evaluate(
|
||||
"sel => document.querySelector(sel)?.className ?? ''", selector)
|
||||
cur = None
|
||||
for step in ("demo-step-1", "demo-step-2", "demo-step-3", "demo-step-4"):
|
||||
if step in cls:
|
||||
cur = step
|
||||
samples.append(cur)
|
||||
if cur is not None and cur not in seen:
|
||||
seen.append(cur)
|
||||
time.sleep(0.25)
|
||||
return seen, samples
|
||||
|
||||
|
||||
def main():
|
||||
failures = []
|
||||
with sync_playwright() as p:
|
||||
browser = p.chromium.launch(channel="chrome", headless=True)
|
||||
page = browser.new_page(viewport={"width": 1440, "height": 900})
|
||||
errors = []
|
||||
page.on("pageerror", lambda e: errors.append(str(e)))
|
||||
page.goto(BASE, wait_until="load")
|
||||
time.sleep(1.5)
|
||||
|
||||
print("== 1. html.js-grow 挂载 ==")
|
||||
ok = page.evaluate("document.documentElement.classList.contains('js-grow')")
|
||||
print(f" js-grow = {ok}")
|
||||
if not ok:
|
||||
failures.append("html.js-grow 未挂载")
|
||||
|
||||
# == 2. Hero 首屏演示推进 ==
|
||||
# 2026-11-07:hero 主图由图窗改为 /home 任务工作台,图窗那批 data-grow 元素随之移出 hero,
|
||||
# 故"生长"这一判据在 hero 上已无作用对象(目标总数恒 0)。判据换成**同一意图的等价物**:
|
||||
# 首屏演示是否真的在推进 —— 采样 demo-step-* 类为单一线性推进(1→2→3→4),
|
||||
# 且不回头。这与"元素逐批生长"检验的是同一件事:剧本在跑、不是冻在第一帧。
|
||||
# 四屏 showcase 的 data-grow 判据(第 3 节)保持原样不动,那里仍有 37/6/7/7 个生长目标。
|
||||
print("\n== 2. Hero 首屏演示推进(/home 剧本)==")
|
||||
h_total = total_targets(page, ".hero-visual")
|
||||
steps_seen, step_samples = watch_demo_steps(page, "#heroDemo", window=14.0)
|
||||
print(f" data-grow 目标={h_total}(/home 上预期 0) 观察到的步骤={steps_seen}")
|
||||
if h_total != 0:
|
||||
print(f" 注:hero 上出现 {h_total} 个 data-grow 目标,将同时按生长判据检查")
|
||||
if len(steps_seen) < 3:
|
||||
failures.append(f"Hero 剧本未推进:只观察到 {steps_seen}(样本 {step_samples})")
|
||||
if "demo-step-1" not in steps_seen or not any(
|
||||
x in steps_seen for x in ("demo-step-3", "demo-step-4")):
|
||||
failures.append(f"Hero 剧本未走完前半程:{steps_seen}")
|
||||
|
||||
print("\n== 3. Showcase 四个 panel 重播 ==")
|
||||
page.locator("#showcase").scroll_into_view_if_needed()
|
||||
time.sleep(0.5)
|
||||
for tab_sel, panel_sel, name in PANELS:
|
||||
page.click(tab_sel)
|
||||
time.sleep(0.2)
|
||||
total = total_targets(page, panel_sel)
|
||||
before = grown(page, panel_sel)
|
||||
peak, samples = watch_growth(page, panel_sel, total, window=10.0)
|
||||
grew = before < peak or peak == total
|
||||
print(f" {name}: 总数={total:>3} 切换后={before:>3} 峰值={peak:>3} "
|
||||
f"采样步数={len(samples)}")
|
||||
if not grew:
|
||||
failures.append(f"{name} 切换后未重播: 峰值 {peak}(切换后 {before})")
|
||||
if peak != total:
|
||||
failures.append(f"{name} 未跑完: 峰值 {peak}/{total}")
|
||||
|
||||
print("\n== 4. 离开视口复位 ==")
|
||||
page.evaluate("window.scrollTo(0, document.body.scrollHeight)")
|
||||
time.sleep(1.0)
|
||||
after_leave = grown(page, "#showcase-panel-process")
|
||||
print(f" 滚到页面底部后 is-grown = {after_leave} (期望 0)")
|
||||
if after_leave != 0:
|
||||
failures.append(f"离开视口未复位: {after_leave}")
|
||||
|
||||
print("\n== 5. prefers-reduced-motion 直接终态 ==")
|
||||
page.emulate_media(reduced_motion="reduce")
|
||||
page.reload(wait_until="load")
|
||||
time.sleep(1.2)
|
||||
page.locator("#showcase").scroll_into_view_if_needed()
|
||||
time.sleep(0.4)
|
||||
r_total = total_targets(page, "#showcase-panel-graph")
|
||||
r_grown = grown(page, "#showcase-panel-graph")
|
||||
print(f" reduced-motion 下 is-grown = {r_grown}/{r_total} (期望相等)")
|
||||
if r_grown != r_total:
|
||||
failures.append(f"reduced-motion 未直达终态: {r_grown}/{r_total}")
|
||||
page.emulate_media(reduced_motion="no-preference")
|
||||
|
||||
print("\n== 6. 装饰性图形无障碍属性 ==")
|
||||
a11y = page.evaluate(
|
||||
"""() => {
|
||||
const FOCUSABLE = 'a[href], button, input, select, textarea, [tabindex]';
|
||||
const focusable = (sel) => [...document.querySelectorAll(sel)]
|
||||
.filter(e => e.matches(FOCUSABLE) || e.querySelector(FOCUSABLE))
|
||||
.map(e => e.id || e.className);
|
||||
return {
|
||||
heroDemo: document.querySelector('#heroDemo')?.getAttribute('aria-hidden') ?? null,
|
||||
showcaseVisuals: [...document.querySelectorAll('.showcase-visual')]
|
||||
.map(e => e.getAttribute('aria-hidden')),
|
||||
heroVisual: document.querySelector('.hero-visual')?.getAttribute('aria-hidden') ?? null,
|
||||
focusableInHidden: [...document.querySelectorAll('[aria-hidden="true"]')]
|
||||
.flatMap(root => [...root.querySelectorAll(FOCUSABLE)])
|
||||
.filter(e => !e.hasAttribute('disabled') && e.tabIndex >= 0)
|
||||
.map(e => `${e.tagName.toLowerCase()}#${e.id}`),
|
||||
demoPause: (() => {
|
||||
const btn = document.querySelector('#demoPause');
|
||||
return btn ? { exists: true, label: btn.getAttribute('aria-label'),
|
||||
pressed: btn.getAttribute('aria-pressed') } : { exists: false };
|
||||
})(),
|
||||
};
|
||||
}"""
|
||||
)
|
||||
print(f" #heroDemo aria-hidden = {a11y['heroDemo']} (期望 true)")
|
||||
print(f" .showcase-visual aria-hidden = {set(a11y['showcaseVisuals'])} (期望 {{'true'}})")
|
||||
print(f" .hero-visual aria-hidden = {a11y['heroVisual']!r} "
|
||||
f"(期望 None——容器承载暂停按钮,隐藏会连带隐藏控件)")
|
||||
print(f" aria-hidden 子树内可聚焦元素 = {a11y['focusableInHidden'] or '无'} (期望 无)")
|
||||
print(f" 暂停控件 = {a11y['demoPause']}")
|
||||
if a11y["heroDemo"] != "true":
|
||||
failures.append(f"演示层未对 AT 隐藏: {a11y['heroDemo']}")
|
||||
if set(a11y["showcaseVisuals"]) != {"true"} or not a11y["showcaseVisuals"]:
|
||||
failures.append(f"showcase 装饰图形 aria-hidden 异常: {a11y['showcaseVisuals']}")
|
||||
if a11y["heroVisual"] == "true":
|
||||
failures.append(".hero-visual 不应整体 aria-hidden(内含暂停按钮)")
|
||||
if a11y["focusableInHidden"]:
|
||||
failures.append(f"aria-hidden 子树内含可聚焦元素: {a11y['focusableInHidden']}")
|
||||
if not a11y["demoPause"].get("exists") or not a11y["demoPause"].get("label"):
|
||||
failures.append(f"暂停按钮缺失或无无障碍名: {a11y['demoPause']}")
|
||||
|
||||
print("\n== 7. JS 运行时错误 ==")
|
||||
print(f" {errors or '无'}")
|
||||
if errors:
|
||||
failures.append(f"JS 错误: {errors}")
|
||||
|
||||
browser.close()
|
||||
|
||||
print("\n" + "=" * 46)
|
||||
if failures:
|
||||
print("RESULT: FAIL")
|
||||
for f in failures:
|
||||
print(" -", f)
|
||||
sys.exit(1)
|
||||
print("RESULT: PASS")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in new issue
Block a user