diff --git a/scripts/capture-game-lineage-visual.mjs b/scripts/capture-game-lineage-visual.mjs index 0dc01947f..8ad125e79 100644 --- a/scripts/capture-game-lineage-visual.mjs +++ b/scripts/capture-game-lineage-visual.mjs @@ -509,6 +509,9 @@ async function captureExistingUrls() { const lineageUrl = (process.env.E2E_CAPTURE_LINEAGE_URL ?? '').trim(); const themeUrl = (process.env.E2E_CAPTURE_THEME_URL ?? '').trim(); const selectTitle = (process.env.E2E_CAPTURE_SELECT_TITLE ?? '').trim(); + // 最小节点数:两节点的子树(例如「母版 → 一个衍生」)也要能截,默认 3。 + const minNodes = + Number.parseInt((process.env.E2E_CAPTURE_MIN_NODES ?? '').trim(), 10) || 3; // 视口可配:全树总览常常比 960 高,给个高的窗口才能真的「一眼看全」。 const sizeMatch = /^(\d{3,4})x(\d{3,4})$/u.exec( (process.env.E2E_CAPTURE_WINDOW ?? '').trim(), @@ -555,8 +558,8 @@ async function captureExistingUrls() { const page = await desktop.newPage(); await page.goto(lineageUrl, { waitUntil: 'commit', timeout: 120_000 }); await page.waitForFunction( - () => document.querySelectorAll('.game-lineage-node').length >= 3, - undefined, + (min) => document.querySelectorAll('.game-lineage-node').length >= min, + minNodes, { timeout: 120_000 }, ); await page.waitForTimeout(1400); @@ -564,7 +567,7 @@ async function captureExistingUrls() { const nodeCount = await page.locator('.game-lineage-node').count(); check( '截图模式:/games/lineage 已渲染多代节点', - nodeCount >= 3, + nodeCount >= minNodes, `nodes=${nodeCount} url=${lineageUrl}`, ); // 首屏视野契约(与 lineage 工具同口径):要么真的全览,要么按可读缩放下限 + 提示。 @@ -645,8 +648,8 @@ async function captureExistingUrls() { timeout: 120_000, }); await mobilePage.waitForFunction( - () => document.querySelectorAll('.game-lineage-node').length >= 3, - undefined, + (min) => document.querySelectorAll('.game-lineage-node').length >= min, + minNodes, { timeout: 120_000 }, ); await mobilePage.waitForTimeout(1400); @@ -668,7 +671,7 @@ async function captureExistingUrls() { })); check( '截图模式:窄屏下族谱画布可见、节点已渲染且页面不横向溢出', - narrow.canvas && narrow.nodes >= 3 && !narrow.overflow, + narrow.canvas && narrow.nodes >= minNodes && !narrow.overflow, `canvas=${narrow.canvas} nodes=${narrow.nodes} overflow=${narrow.overflow}`, ); await take(mobilePage, '03-lineage-narrow.png');