docs(evidence): /about 排查探针与 reduce 实测截图 #49

Merged
zhangxiang merged 1 commits from worktree-ui-grammar-two-axis into dev 2026-10-20 08:03:41 +08:00
3 changed files with 43 additions and 0 deletions

No files matched your search

Binary file not shown.

After

Width:  |  Height:  |  Size: 632 KiB

@@ -0,0 +1,18 @@
import { webkit, chromium } from 'playwright';
for (const [name, engine] of [['webkit', webkit], ['chromium', chromium]]) {
const b = await engine.launch();
const ctx = await b.newContext({ viewport:{width:1280,height:900}, reducedMotion:'reduce' });
const p = await ctx.newPage();
const errs = [];
p.on('pageerror', e => errs.push(String(e).slice(0,200)));
p.on('console', m => { if (m.type()==='error' && /hydrat|418|did not match/i.test(m.text())) errs.push('console: '+m.text().slice(0,160)); });
await p.goto('https://www.novalon.cn/about', { waitUntil:'networkidle', timeout:60000 }).catch(()=>{});
await p.waitForTimeout(2000);
const info = await p.evaluate(() => ({
reduce: matchMedia('(prefers-reduced-motion: reduce)').matches,
hidden: [...document.querySelectorAll('main *')].filter(e=>parseFloat(getComputedStyle(e).opacity)===0).length,
h1opacity: Number(getComputedStyle(document.querySelector('h1')).opacity),
}));
console.log(name, JSON.stringify(info), 'hydrationErrors', errs.length, JSON.stringify(errs.slice(0,2)));
await b.close();
}
@@ -0,0 +1,25 @@
import { webkit } from 'playwright';
const b = await webkit.launch();
const ctx = await b.newContext({ viewport:{width:1280,height:900}, reducedMotion:'reduce' });
const p = await ctx.newPage();
const errs=[]; p.on('pageerror', e=>errs.push(String(e).slice(0,160)));
await p.goto('https://www.novalon.cn/about', { waitUntil:'networkidle', timeout:60000 });
const before = await p.evaluate(() => [...document.querySelectorAll('main *')].filter(e=>parseFloat(getComputedStyle(e).opacity)===0).length);
// 逐屏滚动到底(同时给 whileInView 触发机会)
await p.evaluate(async () => {
for (let y = 0; y < document.body.scrollHeight; y += 600) {
window.scrollTo(0, y);
await new Promise(r => setTimeout(r, 120));
}
window.scrollTo(0, document.body.scrollHeight);
});
await p.waitForTimeout(1500);
const after = await p.evaluate(() => {
const hidden = [...document.querySelectorAll('main *')].filter(e=>parseFloat(getComputedStyle(e).opacity)===0);
const late = [...document.querySelectorAll('h2,h3')].find(h => /准备好开始了吗/.test(h.innerText));
return { hidden: hidden.length, lateOpacity: late ? Number(getComputedStyle(late).opacity) : null,
hiddenTexts: hidden.slice(0,3).map(e=>(e.innerText||'').slice(0,18)) };
});
await p.screenshot({ path:'docs/acceptance/2026-10-20-prod-about/about-reduce-after-scroll.png', fullPage:true });
console.log('reduce 滚动前隐藏:', before, '· 滚动后:', JSON.stringify(after), '· pageerrors:', errs.length);
await b.close();