fix(qa): 修页面还原对比 harness(Mac死路径 + file://token崩)+ 全量28页跑通
当年只对了 account/team 两页就卡住,真因两个: - compare-all.mjs designRoot 写死成原开发者 Mac 路径 → 本机找不到 HTML 稿,改 repoRoot 自适配 - compare-page.mjs preparePage 对 file:// 设计稿也注入 token(file:// origin=null)→ 崩, 限定 token 只对 http 目标注入(登录后页面如 dashboard 当年对不了的根因) 全量 28 页 pixelmatch:22 优秀(<2%)+ 3 良好(2-5%);3 个大 diff 均为有意偏离 (login/register 认证去邮箱)或真实数据(dashboard 修正后 6.38%),非回归。 + _shot-extract-flow.mjs:提取新流程无头走查脚本。 报告:docs/todo/页面还原-截图对比收尾-2026-06-19.md Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
69163a8f7f
commit
352f99d479
@@ -38,7 +38,7 @@ async function preparePage(page, url, shouldClearStorage, token) {
|
||||
// 先到同源根页注入 token,再进目标路由 —— 否则目标路由在「无 token 首跳」时
|
||||
// 会跑一遍登出/重定向 boot,某些路由(如 /model-photo)即便随后 reload 也回不来,
|
||||
// 导致截图停在登录页(假性 ~27% diff)。
|
||||
if (token) {
|
||||
if (token && /^https?:\/\//.test(url)) {
|
||||
await page.goto(new URL(url).origin + "/", { waitUntil: "domcontentloaded" });
|
||||
await page.evaluate((value) => localStorage.setItem("airshelf_token", value), token);
|
||||
}
|
||||
@@ -51,7 +51,7 @@ async function preparePage(page, url, shouldClearStorage, token) {
|
||||
await page.goto(url, { waitUntil: "networkidle" });
|
||||
}
|
||||
// 注入登录 token,让受保护的真 React 路由 + /exact 镜像都能 hydrate 同一份真实数据
|
||||
if (token) {
|
||||
if (token && /^https?:\/\//.test(url)) {
|
||||
await page.evaluate((value) => localStorage.setItem("airshelf_token", value), token);
|
||||
await page.goto(url, { waitUntil: "networkidle" });
|
||||
await page.waitForTimeout(900); // 等异步数据 hydrate 落定
|
||||
|
||||
Reference in New Issue
Block a user