Files
novalon-website/docs/acceptance/2026-10-24-full-qa/tools/summarize-sweep.mjs
T
zhangxiang 763e159ac4 docs(acceptance): 两轮全站验收读数 + 复现脚本 + 企微资产包入库(OPEN-12)
按「这条结论怎么来的必须入库,排查当时的截图只服务当时」的既有口径,
把此前一直悬在 git status 里、归属未定的产物逐组落定:

入库(7.2MB):
- docs/acceptance/2026-10-21-full-qa/、2026-10-24-full-qa/ 的文字与结构化读数
  (README / defects*.json / sweep/summary.json / axe evidence / lighthouse /
  report.json 逐 run 原始读数 / tools 复现脚本)
- docs/acceptance/2026-11-26-axe/ 本轮 axe 复跑证据(35 路由 × 4 组合 140 rows 全 0)
- scripts/acceptance/{sweep-routes,contact-sheet}.mjs —— 两轮 README 里被引用的
  复现脚本,不提交则结论不可复算
- deliverables/.../wecom-pack.cjs + check-wecom.py + WECOM-MANIFEST.md +
  assets-wecom/pack-report.json(生成器/校验器/清单;18 张 PNG 可由脚本从已入库
  SVG 重新栅格化,故仍按既有规则忽略)

忽略(不提交,已写进 .gitignore 并注明归属):
- 两轮验收的逐页截图(172MB):只在排查当时有用
- infra/cicd/gitea{,-custom}/ + 2026-10-22-gitea-branding/(340KB):
  归 feature/gitea-branding,逐文件 sha256 与该分支 50/50 完全一致,
  在本分支提交会造成同一批文件的两份历史

判据:提交后 git status -uall 只剩被忽略项;每条 ?? 都能回答「归谁、为什么在这里」。
2026-11-26 20:03:46 +08:00

76 lines
4.2 KiB
JavaScript
Raw 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.
// 汇总 sweep report.json(只读),产物写 evidence 目录。
import fs from 'fs';
import path from 'path';
const EV = process.env.EV || 'docs/acceptance/2026-10-24-full-qa';
const report = JSON.parse(fs.readFileSync(path.join(EV, 'sweep/report.json'), 'utf8'));
const runs = report.runs || [];
const admin = report.adminRuns || [];
const uniq = (xs) => [...new Set(xs)];
const isRscAbort = (x) => /[?&]_rsc=/.test(x.url || '') && x.error === 'net::ERR_ABORTED';
const isHttpError = (x) => typeof x.status === 'number' && x.status >= 400;
const publicSummary = {
runs: runs.length,
hard: runs.filter((r) => r.hardFailure).length,
opacityBelow099: runs.filter((r) => (r.opacityProduct ?? 1) < 0.99).length,
overflowX: runs.filter((r) => r.overflowX).length,
brokenImages: runs.filter((r) => (r.broken || []).length > 0).length,
pageErrors: runs.filter((r) => (r.pageErrors || []).length > 0).length,
consoleErrorRuns: runs.filter((r) => (r.consoleErrors || []).length > 0).length,
// `_rsc` 预取在导航/滚动时被浏览器 abort 是 Next 的正常噪声,不算失败请求。
prefetchAbortRuns: runs.filter((r) => (r.failedRequests || []).some(isRscAbort)).length,
sameOriginHttpErrorRuns: runs.filter((r) => (r.failedRequests || []).some((x) => isHttpError(x) && !(r.expected404 && /\/_not-found$/.test(x.url || '')))).length,
otherNetworkFailureRuns: runs.filter((r) => (r.failedRequests || []).some((x) => !isRscAbort(x) && !isHttpError(x))).length,
thirdPartyRuns: runs.filter((r) => (r.thirdParty || []).length > 0).length,
routes: uniq(runs.map((r) => r.route)).length,
};
const detectors = {
wrappedNumberRoutes: uniq(runs.filter((r) => (r.wrappedNumbers || []).length > 0).map((r) => r.route)),
gridGapRoutes: uniq(runs.filter((r) => (r.gridGaps || []).length > 0).map((r) => r.route)),
orphanColSpanRoutes: uniq(runs.filter((r) => (r.orphanColSpans || []).length > 0).map((r) => r.route)),
wrappedOccurrences: runs.reduce((n, r) => n + (r.wrappedNumbers || []).length, 0),
gridGapOccurrences: runs.reduce((n, r) => n + (r.gridGaps || []).length, 0),
orphanOccurrences: runs.reduce((n, r) => n + (r.orphanColSpans || []).length, 0),
};
const redRows = runs
.filter((r) => r.shots && typeof r.shots.redPixelRatio === 'number')
.map((r) => ({ route: r.route, vp: r.viewport, theme: r.theme, p: r.shots.redPixelRatio }))
.sort((a, b) => b.p - a.p)
.slice(0, 10);
const design = {
redTouchMin: Math.min(...runs.map((r) => r.redTouches ?? 0)),
redTouchMax: Math.max(...runs.map((r) => r.redTouches ?? 0)),
redPixelRatioTop: redRows,
// 这条判据只匹配 #C41E3A ±28;bg-brand-section(#8B1530) 不在范围内 —— 见 README 的仪器缺口。
redPixelRatioRuleNote: 'matches brand #C41E3A +/-28 only; bg-brand-section #8B1530 is not counted',
};
const form = { contact: [] };
for (const r of runs.filter((x) => x.route === '/contact')) {
if (r.form) form.contact.push({ vp: r.viewport, theme: r.theme, top: r.form.top, inViewport: r.form.inFirstViewport, fields: r.form.fields });
}
const adminSummary = {
runs: admin.length,
hard: admin.filter((r) => r.hardFailure).length,
opacityBelow099: admin.filter((r) => (r.opacityProduct ?? 1) < 0.99).length,
overflowX: admin.filter((r) => r.overflowX).length,
tabBarOn390: admin.filter((r) => r.viewport === '390' && r.mobileTabBar).length,
tabBarRoutes: uniq(admin.filter((r) => r.viewport === '390' && r.mobileTabBar).map((r) => r.route)),
pageErrors: admin.filter((r) => (r.pageErrors || []).length > 0).length,
consoleErrorRuns: admin.filter((r) => (r.consoleErrors || []).length > 0).length,
touchUnder44Runs: admin.filter((r) => (r.touchTargets || []).some((t) => t.w < 44 || t.h < 44)).length,
};
const hardList = [...runs, ...admin]
.filter((r) => r.hardFailure)
.map((r) => ({ kind: r.kind, route: r.route, vp: r.viewport, theme: r.theme, error: r.error, opacity: r.opacityProduct, overflowX: r.overflowX, broken: (r.broken || []).length, pageErrors: (r.pageErrors || []).length, failedRequests: (r.failedRequests || []).length }));
const out = { meta: report.meta, public: publicSummary, detectors, design, form, admin: adminSummary, hardList };
fs.writeFileSync(path.join(EV, 'sweep/summary.json'), JSON.stringify(out, null, 2));
console.log(JSON.stringify(out, null, 2));