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 只剩被忽略项;每条 ?? 都能回答「归谁、为什么在这里」。
This commit is contained in:
1 parent
938af25030
commit
763e159ac4
45 files changed
+257540
No files matched your search
@@ -0,0 +1,127 @@
|
||||
// 2026-10-24 新增视觉基线的清单 + 拼版工具(只读 e2e/visual-snapshots,只在证据目录写产物)
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import crypto from 'crypto';
|
||||
import sharp from 'sharp';
|
||||
|
||||
const ROOT = '/Users/zhangxiang/Codes/Novalon/novalon-website';
|
||||
const EV = path.join(ROOT, 'docs/acceptance/2026-10-24-full-qa');
|
||||
const SNAP = path.join(ROOT, 'e2e/visual-snapshots');
|
||||
const OUT = path.join(EV, 'contact-sheets/baselines');
|
||||
fs.mkdirSync(OUT, { recursive: true });
|
||||
|
||||
const PROJECTS = [
|
||||
'visual-chromium-desktop',
|
||||
'visual-chromium-tablet',
|
||||
'visual-chromium-mobile',
|
||||
'visual-firefox-desktop',
|
||||
'visual-webkit-desktop',
|
||||
];
|
||||
|
||||
const ROUTES = [
|
||||
['not-found', '/_not-found'],
|
||||
['cases', '/cases'],
|
||||
['insights', '/insights'],
|
||||
['news-digital-transformation', '/news/digital-transformation-solution'],
|
||||
['privacy', '/privacy'],
|
||||
['terms', '/terms'],
|
||||
['product-bi', '/products/bi'],
|
||||
['product-cms', '/products/cms'],
|
||||
['product-crm', '/products/crm'],
|
||||
['product-oa', '/products/oa'],
|
||||
['product-sds', '/products/sds'],
|
||||
['product-erp-upgrade-v3', '/products/erp-upgrade-v3'],
|
||||
['service-consulting', '/services/consulting'],
|
||||
['service-data', '/services/data'],
|
||||
['service-solutions', '/services/solutions'],
|
||||
['solution-education', '/solutions/education'],
|
||||
['solution-finance', '/solutions/finance'],
|
||||
['solution-healthcare', '/solutions/healthcare'],
|
||||
['solution-logistics', '/solutions/logistics'],
|
||||
['solution-retail', '/solutions/retail'],
|
||||
];
|
||||
|
||||
const sha256 = (buf) => crypto.createHash('sha256').update(buf).digest('hex');
|
||||
const esc = (s) => s.replace(/[<>&'"]/g, (c) => ({ '<': '<', '>': '>', '&': '&', "'": ''', '"': '"' }[c]));
|
||||
|
||||
const manifest = [];
|
||||
for (const project of PROJECTS) {
|
||||
for (const [name, route] of ROUTES) {
|
||||
const file = path.join(SNAP, project, 'visual-regression.spec.ts', `${name}-fullpage-${project}.png`);
|
||||
if (!fs.existsSync(file)) {
|
||||
manifest.push({ project, name, route, file, exists: false });
|
||||
continue;
|
||||
}
|
||||
const buf = fs.readFileSync(file);
|
||||
const meta = await sharp(buf).metadata();
|
||||
const stats = await sharp(buf).stats();
|
||||
const channels = stats.channels.slice(0, 3);
|
||||
const stdev = Math.max(...channels.map((c) => c.stdev));
|
||||
const entropy = Math.max(...channels.map((c) => c.entropy));
|
||||
manifest.push({
|
||||
project,
|
||||
name,
|
||||
route,
|
||||
file: path.relative(ROOT, file),
|
||||
exists: true,
|
||||
width: meta.width,
|
||||
height: meta.height,
|
||||
bytes: buf.length,
|
||||
sha256: sha256(buf),
|
||||
maxChannelStdev: +stdev.toFixed(2),
|
||||
maxChannelEntropy: +entropy.toFixed(3),
|
||||
blankSuspicion: stdev < 6 || entropy < 1.2,
|
||||
});
|
||||
}
|
||||
}
|
||||
fs.writeFileSync(path.join(EV, 'baseline-manifest.json'), JSON.stringify(manifest, null, 2));
|
||||
console.log(`manifest=${manifest.length} missing=${manifest.filter((m) => !m.exists).length} blankSuspicion=${manifest.filter((m) => m.blankSuspicion).length}`);
|
||||
|
||||
async function labeledTile(file, width, cropTop) {
|
||||
let src = await sharp(file).resize({ width, withoutEnlargement: true }).jpeg({ quality: 80 }).toBuffer();
|
||||
let m = await sharp(src).metadata();
|
||||
if (cropTop && m.height > cropTop) {
|
||||
src = await sharp(src).extract({ left: 0, top: 0, width: m.width, height: cropTop }).jpeg({ quality: 80 }).toBuffer();
|
||||
m = await sharp(src).metadata();
|
||||
}
|
||||
const label = Buffer.from(
|
||||
`<svg width="${m.width}" height="24" xmlns="http://www.w3.org/2000/svg">`
|
||||
+ `<rect width="${m.width}" height="24" fill="#fff"/>`
|
||||
+ `<text x="4" y="16" font-family="Helvetica,Arial,sans-serif" font-size="11" fill="#111">${esc(path.basename(file).replace('-fullpage-' + path.basename(path.dirname(path.dirname(file))) + '.png', ''))}</text></svg>`,
|
||||
);
|
||||
return {
|
||||
buf: await sharp({ create: { width: m.width, height: m.height + 24, channels: 3, background: '#fff' } })
|
||||
.composite([{ input: src, top: 0, left: 0 }, { input: label, top: m.height, left: 0 }])
|
||||
.jpeg({ quality: 82 }).toBuffer(),
|
||||
height: m.height + 24,
|
||||
};
|
||||
}
|
||||
|
||||
async function sheet(files, out, width, cols, cropTop) {
|
||||
const tiles = [];
|
||||
for (const f of files) tiles.push(await labeledTile(f, width, cropTop));
|
||||
const rows = [];
|
||||
for (let i = 0; i < tiles.length; i += cols) rows.push(tiles.slice(i, i + cols));
|
||||
const gap = 8;
|
||||
const heights = rows.map((r) => Math.max(...r.map((t) => t.height)));
|
||||
const w = cols * width + (cols - 1) * gap;
|
||||
const h = heights.reduce((a, b) => a + b, 0) + (rows.length - 1) * gap;
|
||||
const comps = [];
|
||||
let y = 0;
|
||||
rows.forEach((r, ri) => {
|
||||
let x = 0;
|
||||
r.forEach((t) => { comps.push({ input: t.buf, top: y, left: x }); x += width + gap; });
|
||||
y += heights[ri] + gap;
|
||||
});
|
||||
await sharp({ create: { width: w, height: h, channels: 3, background: '#fff' } })
|
||||
.composite(comps).jpeg({ quality: 80 }).toFile(out);
|
||||
console.log(`sheet ${path.basename(out)} ${files.length} tiles ${w}x${h}`);
|
||||
}
|
||||
|
||||
for (const project of PROJECTS) {
|
||||
const files = ROUTES.map(([name]) => path.join(SNAP, project, 'visual-regression.spec.ts', `${name}-fullpage-${project}.png`)).filter(fs.existsSync);
|
||||
await sheet(files, path.join(OUT, `${project}__top.jpg`), 300, 5, 900);
|
||||
for (let i = 0; i < files.length; i += 5) {
|
||||
await sheet(files.slice(i, i + 5), path.join(OUT, `${project}__full-${String(i / 5 + 1).padStart(2, '0')}.jpg`), 300, 5, 0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
// 生成 35 公开 + 9 Admin 的覆盖矩阵(读取本轮证据,不重新跑任何东西)。
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
const EV = process.env.EV || 'docs/acceptance/2026-10-24-full-qa';
|
||||
const routes = JSON.parse(fs.readFileSync(path.join(EV, 'routes.json'), 'utf8')).routes;
|
||||
const baselines = JSON.parse(fs.readFileSync(path.join(EV, 'baseline-manifest.json'), 'utf8'));
|
||||
const sweep = JSON.parse(fs.readFileSync(path.join(EV, 'sweep/report.json'), 'utf8'));
|
||||
const axe = JSON.parse(fs.readFileSync(path.join(EV, 'axe/run1/axe-evidence.json'), 'utf8'));
|
||||
const lh = JSON.parse(fs.readFileSync('config/test/lighthouserc.json', 'utf8')).ci.collect.url.map((u) => new URL(u).pathname);
|
||||
|
||||
const visualByRoute = new Map();
|
||||
for (const b of baselines) {
|
||||
if (!b.exists) continue;
|
||||
if (!visualByRoute.has(b.route)) visualByRoute.set(b.route, new Set());
|
||||
visualByRoute.get(b.route).add(b.project);
|
||||
}
|
||||
const sweepByRoute = new Map();
|
||||
for (const r of sweep.runs) {
|
||||
if (!sweepByRoute.has(r.route)) sweepByRoute.set(r.route, { combos: 0, extra: 0, hard: 0 });
|
||||
const x = sweepByRoute.get(r.route);
|
||||
if (r.engine === 'chromium') x.combos += 1;
|
||||
else x.extra += 1;
|
||||
if (r.hardFailure) x.hard += 1;
|
||||
}
|
||||
const axeByRoute = new Map();
|
||||
for (const r of axe.rows) {
|
||||
if (!axeByRoute.has(r.url)) axeByRoute.set(r.url, { combos: 0, violations: 0, contrast: 0 });
|
||||
const x = axeByRoute.get(r.url);
|
||||
x.combos += 1;
|
||||
x.violations += r.violationNodes;
|
||||
x.contrast += r.contrastNodes;
|
||||
}
|
||||
const e2eRoutes = new Set(['/', '/about', '/contact', '/products', '/solutions', '/services', '/news', '/insights', '/team', '/methodology']);
|
||||
|
||||
const rows = routes.map((route) => {
|
||||
const s = sweepByRoute.get(route) || { combos: 0, extra: 0, hard: 0 };
|
||||
const a = axeByRoute.get(route) || { combos: 0, violations: 0, contrast: 0 };
|
||||
return `| \`${route}\` | 5/5 | ${s.combos}/5${s.extra ? ` +${s.extra} 跨引擎` : ''}${s.hard ? ` · hard ${s.hard}` : ''} | ${a.combos}/4${a.violations ? ` · ${a.violations} nodes` : ''} | ${lh.includes(route) ? '✓' : '—'} | ${e2eRoutes.has(route) ? '关键路径' : '—'} |`;
|
||||
}).join('\n');
|
||||
|
||||
const adminRoutes = [...new Set((sweep.adminRuns || []).map((r) => r.route))];
|
||||
const adminRows = adminRoutes.map((route) => {
|
||||
const rs = (sweep.adminRuns || []).filter((r) => r.route === route);
|
||||
const hard = rs.filter((r) => r.hardFailure).length;
|
||||
const tab = rs.filter((r) => r.viewport === '390' && r.mobileTabBar).length;
|
||||
return `| \`${route}\` | ${rs.length}/5${hard ? ` · hard ${hard}` : ''} | ${tab ? `390 档 ${tab}/2 命中` : '—'} | 无像素基线(数据/登录态) |`;
|
||||
}).join('\n');
|
||||
|
||||
const md = `# 覆盖矩阵(2026-10-24)
|
||||
|
||||
- 公开页分母:\`routes.json\` = **${routes.length}** 条(sitemap ∪ 预渲染 ∪ BFS)。
|
||||
- 像素基线:35 条 × 5 project;新增 100 张,工作树共 227 张。
|
||||
- Sweep:35 × 5 组合(chromium)+ firefox/webkit 抽样;Admin 9 × 5。
|
||||
- axe:chromium/firefox × light/dark,每页两遍(tag + rules)。
|
||||
- Lighthouse:门禁固定 11 URL(抽样,不是全站)。
|
||||
- E2E:按关键路径覆盖,不是逐路由像素级。
|
||||
- 清单外契约:/products/standalone/novavis 本地与线上均 307 → https://novavis.p.novalon.cn;Admin 既有条目编辑器 1 条(登录态,/admin/content/news/<id>)已验证渲染与字段回填。
|
||||
|
||||
## 公开页
|
||||
|
||||
| 路由 | 像素基线 | Sweep | axe | Lighthouse | E2E |
|
||||
|---|---|---|---|---|---|
|
||||
${rows}
|
||||
|
||||
## Admin
|
||||
|
||||
| 路由 | Sweep 5 组合 | 390 tab bar | 像素基线 |
|
||||
|---|---|---|---|
|
||||
${adminRows}
|
||||
`;
|
||||
fs.writeFileSync(path.join(EV, 'coverage-matrix.md'), md);
|
||||
console.log(md);
|
||||
@@ -0,0 +1,117 @@
|
||||
// 线上只读验收:35 条公开路由 GET + 8 次同口径渲染。不登录、不 POST、不写任何远端状态。
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { chromium } from 'playwright';
|
||||
|
||||
const BASE = (process.env.BASE || 'https://www.novalon.cn').replace(/\/$/, '');
|
||||
const OUT = process.env.OUT || 'docs/acceptance/2026-10-24-full-qa/prod-readonly';
|
||||
const ROUTES = JSON.parse(fs.readFileSync(process.env.ROUTES_JSON || 'docs/acceptance/2026-10-24-full-qa/routes.json', 'utf8')).routes;
|
||||
fs.mkdirSync(path.join(OUT, 'screenshots'), { recursive: true });
|
||||
|
||||
const report = { base: BASE, startedAt: new Date().toISOString(), http: [], render: [] };
|
||||
|
||||
for (const route of ROUTES) {
|
||||
const started = Date.now();
|
||||
try {
|
||||
const res = await fetch(BASE + route, { redirect: 'follow', signal: AbortSignal.timeout(30000) });
|
||||
const body = await res.text();
|
||||
const title = (body.match(/<title[^>]*>([\s\S]*?)<\/title>/i) || [])[1]?.trim() || '';
|
||||
const h1 = (body.match(/<h1[^>]*>([\s\S]*?)<\/h1>/i) || [])[1]?.replace(/<[^>]+>/g, '').trim() || '';
|
||||
report.http.push({
|
||||
route, status: res.status, finalUrl: res.url, ms: Date.now() - started,
|
||||
bytes: body.length, title: title.slice(0, 160), h1: h1.slice(0, 160),
|
||||
cache: res.headers.get('x-nextjs-cache') || '', server: res.headers.get('server') || '',
|
||||
});
|
||||
} catch (err) {
|
||||
report.http.push({ route, status: 0, error: String(err).slice(0, 300), ms: Date.now() - started });
|
||||
}
|
||||
console.log(`[http] ${route} ${report.http.at(-1).status} ${report.http.at(-1).ms}ms`);
|
||||
}
|
||||
|
||||
const browser = await chromium.launch();
|
||||
const targets = ['/', '/about', '/contact', '/products'];
|
||||
for (const route of targets) {
|
||||
for (const vp of [{ w: 1440, h: 900, name: '1440' }, { w: 390, h: 844, name: '390', mobile: true }]) {
|
||||
const ctx = await browser.newContext({
|
||||
viewport: { width: vp.w, height: vp.h },
|
||||
...(vp.mobile ? { isMobile: true, hasTouch: true, deviceScaleFactor: 2 } : {}),
|
||||
reducedMotion: 'reduce',
|
||||
});
|
||||
const page = await ctx.newPage();
|
||||
const consoleErrors = [];
|
||||
const pageErrors = [];
|
||||
const failed = [];
|
||||
page.on('console', (m) => { if (m.type() === 'error') consoleErrors.push(m.text().slice(0, 200)); });
|
||||
page.on('pageerror', (e) => pageErrors.push(String(e).slice(0, 200)));
|
||||
page.on('requestfailed', (r) => failed.push({ url: r.url().slice(0, 160), err: r.failure()?.errorText }));
|
||||
page.on('response', (r) => {
|
||||
if (r.status() >= 400 && new URL(r.url()).origin === new URL(BASE).origin) failed.push({ url: r.url().slice(0, 160), status: r.status() });
|
||||
});
|
||||
const started = Date.now();
|
||||
let metrics = null;
|
||||
let error = null;
|
||||
try {
|
||||
await page.goto(BASE + route, { waitUntil: 'domcontentloaded', timeout: 45000 });
|
||||
await page.waitForTimeout(1200);
|
||||
await page.evaluate(() => document.querySelectorAll('img').forEach((img) => { img.loading = 'eager'; }));
|
||||
await page.evaluate(async () => {
|
||||
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));
|
||||
}
|
||||
window.scrollTo(0, 0);
|
||||
await new Promise((r) => setTimeout(r, 400));
|
||||
});
|
||||
// decode() 会等图片真正可用;lazy-load 下 complete 标志不可靠,不能单凭它判破图。
|
||||
await page.evaluate(async () => {
|
||||
await Promise.race([
|
||||
Promise.all([...document.images].map((img) => img.decode().catch(() => null))),
|
||||
new Promise((r) => setTimeout(r, 15000)),
|
||||
]);
|
||||
}).catch(() => {});
|
||||
await page.evaluate(() => document.fonts?.ready).catch(() => {});
|
||||
await page.waitForTimeout(800);
|
||||
metrics = await page.evaluate(() => {
|
||||
let el = document.querySelector('main');
|
||||
let op = 1;
|
||||
while (el) { op *= parseFloat(getComputedStyle(el).opacity || '1'); el = el.parentElement; }
|
||||
const iw = window.innerWidth;
|
||||
const overflowX = document.documentElement.scrollWidth > iw + 1;
|
||||
const overflowElements = [...document.querySelectorAll('body *')].filter((n) => {
|
||||
const r = n.getBoundingClientRect();
|
||||
const s = getComputedStyle(n);
|
||||
if (!(r.width > 0 && r.height > 0 && s.display !== 'none' && s.visibility !== 'hidden')) return false;
|
||||
// 跳过链接等 intentional off-screen 元素(完全在视口左侧)不算横向溢出。
|
||||
return (r.right > iw + 1 && r.left < iw) || (r.left < -1 && r.right > 0);
|
||||
}).slice(0, 5).map((n) => ({ tag: n.tagName, cls: String(n.className).slice(0, 80) }));
|
||||
const images = [...document.images].filter((i) => i.currentSrc || i.src);
|
||||
const broken = images.filter((i) => i.complete && i.naturalWidth === 0).map((i) => (i.currentSrc || i.src).slice(0, 160));
|
||||
const pendingImages = images.filter((i) => !i.complete).map((i) => (i.currentSrc || i.src).slice(0, 160));
|
||||
return {
|
||||
opacityProduct: +op.toFixed(4), overflowX, overflowElements, broken, pendingImages,
|
||||
h1: (document.querySelector('h1')?.textContent || '').trim().slice(0, 160),
|
||||
title: document.title.slice(0, 160),
|
||||
};
|
||||
});
|
||||
await page.screenshot({ path: path.join(OUT, 'screenshots', `${route === '/' ? 'home' : route.replace(/^\//, '').replace(/\//g, '_')}__${vp.name}.png`), fullPage: true }).catch(() => {});
|
||||
} catch (err) {
|
||||
error = String(err).slice(0, 300);
|
||||
}
|
||||
const isRscAbort = (x) => /[?&]_rsc=/.test(x.url || '') && x.err === 'net::ERR_ABORTED';
|
||||
const sameOriginFailed = failed.filter((x) => !isRscAbort(x) && (x.status >= 400 || x.err));
|
||||
report.render.push({
|
||||
route, viewport: vp.name, ms: Date.now() - started, metrics, error,
|
||||
consoleErrors, pageErrors, sameOriginFailed,
|
||||
hard: Boolean(error) || !metrics || metrics.opacityProduct < 0.99 || metrics.overflowX || metrics.broken.length > 0 || pageErrors.length > 0 || sameOriginFailed.length > 0,
|
||||
});
|
||||
console.log(`[render] ${route} ${vp.name} hard=${report.render.at(-1).hard}`);
|
||||
await ctx.close();
|
||||
}
|
||||
}
|
||||
await browser.close();
|
||||
report.finishedAt = new Date().toISOString();
|
||||
report.hardCount = report.render.filter((r) => r.hard).length;
|
||||
fs.writeFileSync(path.join(OUT, 'report.json'), JSON.stringify(report, null, 2));
|
||||
console.log(`DONE http=${report.http.length} render=${report.render.length} hard=${report.hardCount}`);
|
||||
process.exit(report.hardCount > 0 ? 1 : 0);
|
||||
@@ -0,0 +1,36 @@
|
||||
// 全站 bg-brand-section 扫描:量化“满幅饱和红面”在哪些路由仍存在。
|
||||
// 只读 3100 本地产物;不截图、不写远端。
|
||||
import fs from 'fs';
|
||||
import { chromium } from 'playwright';
|
||||
|
||||
const BASE = (process.env.BASE || 'http://127.0.0.1:3100').replace(/\/$/, '');
|
||||
const EV = process.env.EV || 'docs/acceptance/2026-10-24-full-qa';
|
||||
const routes = JSON.parse(fs.readFileSync(`${EV}/routes.json`, 'utf8')).routes;
|
||||
const browser = await chromium.launch();
|
||||
const page = await browser.newPage({ viewport: { width: 1440, height: 900 }, reducedMotion: 'reduce' });
|
||||
const out = [];
|
||||
for (const route of routes) {
|
||||
await page.goto(BASE + route, { waitUntil: 'domcontentloaded', timeout: 45000 });
|
||||
await page.waitForTimeout(400);
|
||||
const found = await page.evaluate(() => {
|
||||
const els = [...document.querySelectorAll('.bg-brand-section, [class*="bg-brand-section"]')];
|
||||
const docH = document.documentElement.scrollHeight || 1;
|
||||
return els.map((el) => {
|
||||
const r = el.getBoundingClientRect();
|
||||
const s = getComputedStyle(el);
|
||||
return {
|
||||
tag: el.tagName,
|
||||
cls: String(el.className || '').slice(0, 160),
|
||||
text: (el.innerText || '').trim().slice(0, 80),
|
||||
w: Math.round(r.width), h: Math.round(r.height), top: Math.round(r.top + window.scrollY),
|
||||
opacity: s.opacity, bg: s.backgroundColor,
|
||||
pageRatio: +(r.width * r.height / (window.innerWidth * docH)).toFixed(4),
|
||||
};
|
||||
});
|
||||
});
|
||||
out.push({ route, count: found.length, elements: found });
|
||||
console.log(`${route} count=${found.length} ${found.map((f) => `${f.w}x${f.h}@${f.top}`).join(' ')}`);
|
||||
}
|
||||
await browser.close();
|
||||
fs.writeFileSync(`${EV}/visual/bg-brand-section.json`, JSON.stringify(out, null, 2));
|
||||
console.log('DONE routes=' + out.length + ' hits=' + out.filter((x) => x.count > 0).length);
|
||||
@@ -0,0 +1,75 @@
|
||||
// 汇总 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));
|
||||
Reference in new issue
Block a user