test(e2e): 覆盖分母补齐 + GA 断言与 opt-in 实现对齐
三件事同批,共同点是「门禁/断言与实现脱钩,而脱钩处恰好没人跑」。
1. GA4 consent 断言(新发现,上一轮遗留)
DEF-09 把 analytics_storage 默认从 granted 改成 denied(opt-in),
实现与单测都改了,e2e/ga4-event-tracking.spec.ts:132 仍断言 granted。
它能藏住是因为那 4 个 @critical 用例**只在 test:e2e:prod 下真正执行**
(dev 下 NEXT_PUBLIC_GA_MEASUREMENT_ID 不存在 ⇒ test.skip)⇒ 本地全绿看不见。
改为同时钉两件事:default 必须是 denied;已存偏好由内联片段在 config
之前以 consent update 放行。只改前者会让「偏好回放坏了」变成新盲区。
判据:E2E_TARGET=production 跑 ga4 spec ⇒ 4 passed。
2. UJ-10 假红(TA-11)
原断言「分类后恰 1 篇 / 全部恰 2 篇」,并行写库用例插入的 E2E 新闻会让它假红。
改为钉两篇种子 slug 的可见/缺席 —— 比数条数更具体:数条数只证明「有 1 条」,
钉 slug 才证明「筛掉的是另一类」。桌面 + 移动两份同步改。
3. 覆盖分母 + 取样稳定性
- headings PAGES 11 → 34 页(与 check:axe:routes 的 35 条对齐,去掉按 404
契约的 /_not-found)。实测 34/34 通过、0 问题。此前只扫 11 页,
新增路由失踪时门禁仍然绿 —— 「分母静默变小」的第三种形态。
- axe settle() 改逐屏 max(400, 0.8×viewport) 步进 + 双 rAF,回顶后等
main * 内 opacity:0 元素清零(8s 超时抛出,不吞)。原「一次跳到底」
会跳过 IntersectionObserver 目标,半透明文字被读成低对比度,失败集合漂移。
- website-acceptance 的 pollBoundingBox 由「非空即返回」改为连续 5 次取样
一致再返回(TA-12):页面入场 transform 未落定时会抓到 29.936px 中途值。
超时仍 throw,判据强度不降。
判据:type-check / type-check:e2e EXIT=0;test:e2e:prod 135 passed / 0 failed
/ 9 skipped / EXIT=0;check:axe 35 路由 × 4 组合 140 rows 全 0、规则级 105/105。
This commit is contained in:
1 parent
3128d59164
commit
eba4e10442
8 files changed
+172
-32
No files matched your search
@@ -202,19 +202,42 @@ if (urls.length === 0) {
|
||||
fatal(`从 ${SITEMAP} 解析出 0 条路由,扫描等于没测,退出 2`, 2);
|
||||
}
|
||||
|
||||
// 2026-10-24(qa-tracker TA-05):原实现「一次跳到底 → 回顶 → 400ms」会跳过中间 IntersectionObserver 目标,
|
||||
// ScrollReveal 元素仍停在 inline opacity:0;axe 把半透明文字读成低对比度,失败集合随并行漂移。
|
||||
// 改为逐屏 260ms + 双 rAF 步进,并等 reveal 真正提交后再扫;超时**抛出而不是吞掉**,
|
||||
// 避免「等不到也照常出绿」——「没量到」不许读作「通过」。
|
||||
async function settle(page) {
|
||||
await page.waitForTimeout(1200);
|
||||
await page.waitForTimeout(600);
|
||||
await page.evaluate(async () => {
|
||||
let last = -1;
|
||||
for (let i = 0; i < 12; i += 1) {
|
||||
window.scrollTo(0, document.body.scrollHeight);
|
||||
await new Promise((r) => setTimeout(r, 180));
|
||||
if (Math.round(window.scrollY) === last) break;
|
||||
last = Math.round(window.scrollY);
|
||||
const nextFrame = () => new Promise((resolve) => requestAnimationFrame(() => requestAnimationFrame(resolve)));
|
||||
const step = Math.max(400, Math.floor(window.innerHeight * 0.8));
|
||||
for (let y = 0; y <= document.body.scrollHeight; y += step) {
|
||||
window.scrollTo(0, y);
|
||||
await new Promise((r) => setTimeout(r, 260));
|
||||
await nextFrame();
|
||||
}
|
||||
window.scrollTo(0, 0);
|
||||
await new Promise((r) => setTimeout(r, 400));
|
||||
});
|
||||
await page.waitForTimeout(400);
|
||||
|
||||
const pendingExpr = () => Array.from(document.querySelectorAll('main *')).filter((el) => {
|
||||
const s = getComputedStyle(el);
|
||||
return el.style.opacity === '0' && s.display !== 'none' && el.getBoundingClientRect().height > 0;
|
||||
});
|
||||
try {
|
||||
await page.waitForFunction(() => {
|
||||
const pending = Array.from(document.querySelectorAll('main *')).filter((el) => {
|
||||
const s = getComputedStyle(el);
|
||||
return el.style.opacity === '0' && s.display !== 'none' && el.getBoundingClientRect().height > 0;
|
||||
});
|
||||
return pending.length === 0;
|
||||
}, undefined, { timeout: 8000, polling: 100 });
|
||||
} catch {
|
||||
const total = await page.evaluate(`(${pendingExpr.toString()})().length`);
|
||||
throw new Error(`settle: ${total} 个元素仍停在 inline opacity:0(a11y 扫描会读到半透明态,拒绝出假读数)`);
|
||||
}
|
||||
await page.evaluate(() => document.fonts?.ready).catch(() => {});
|
||||
await page.waitForTimeout(300);
|
||||
}
|
||||
|
||||
const rows = [];
|
||||
|
||||
@@ -28,6 +28,32 @@ const PAGES = [
|
||||
// 双轴新增的洞察枢纽 —— 不登记就会出现「新页面没人扫,门禁仍然绿」的静默覆盖收缩
|
||||
{ path: "/insights", name: "洞察枢纽" },
|
||||
{ path: "/contact", name: "联系我们" },
|
||||
// 2026-10-24:与 check:axe:routes 的 35 条公开清单对齐(/_not-found 按 404 契约不参与标题层级)。
|
||||
// 此前只扫 11 页,新增路由/详情页失踪时门禁仍然绿,属于「分母静默变小」——
|
||||
// 这是本仓反复踩的那一族:**门禁的分母由人手维护时,它只会越来越小**。
|
||||
{ path: "/about/brand", name: "品牌资产页" },
|
||||
{ path: "/cases", name: "案例列表" },
|
||||
{ path: "/methodology", name: "方法论" },
|
||||
{ path: "/news/company-founded", name: "新闻详情-公司成立" },
|
||||
{ path: "/news/digital-transformation-solution", name: "新闻详情-数字化转型" },
|
||||
{ path: "/privacy", name: "隐私政策" },
|
||||
{ path: "/terms", name: "服务条款" },
|
||||
{ path: "/products/bi", name: "产品详情-BI" },
|
||||
{ path: "/products/cms", name: "产品详情-CMS" },
|
||||
{ path: "/products/crm", name: "产品详情-CRM" },
|
||||
{ path: "/products/erp-upgrade", name: "产品 ERP 升级页" },
|
||||
{ path: "/products/erp-upgrade-v3", name: "产品 ERP 升级页 V3" },
|
||||
{ path: "/products/oa", name: "产品详情-OA" },
|
||||
{ path: "/products/sds", name: "产品详情-SDS" },
|
||||
{ path: "/services/consulting", name: "服务详情-咨询" },
|
||||
{ path: "/services/data", name: "服务详情-数据" },
|
||||
{ path: "/services/solutions", name: "服务详情-解决方案" },
|
||||
{ path: "/solutions/education", name: "解决方案详情-教育" },
|
||||
{ path: "/solutions/finance", name: "解决方案详情-金融" },
|
||||
{ path: "/solutions/healthcare", name: "解决方案详情-医疗" },
|
||||
{ path: "/solutions/logistics", name: "解决方案详情-物流" },
|
||||
{ path: "/solutions/retail", name: "解决方案详情-零售" },
|
||||
{ path: "/team", name: "团队介绍" },
|
||||
];
|
||||
|
||||
interface HeadingIssue {
|
||||
|
||||
Reference in new issue
Block a user