Skip to content

Commit ed54a78

Browse files
committed
fix(visual): guard pageCount for parse-error reports, fix widespread threshold
- Parse-error reports have no pageCount — guard against TypeError - Use Math.ceil for 50%+ threshold so odd counts don't misclassify
1 parent 2b8dbce commit ed54a78

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

tests/layout-snapshots/compare-layout-snapshots.mjs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1707,7 +1707,7 @@ async function main() {
17071707

17081708
// ---- Widespread diff detection ----
17091709
const totalChangedDocs = pendingReports.length;
1710-
const widespreadThreshold = Math.max(1, Math.floor(totalChangedDocs * 0.5));
1710+
const widespreadThreshold = Math.max(1, Math.ceil(totalChangedDocs * 0.5));
17111711
/** @type {Array<{ path: string, kind: string, docCount: number }>} */
17121712
const widespreadDiffs = [];
17131713
const widespreadPathKeys = new Set();
@@ -1731,8 +1731,10 @@ async function main() {
17311731
d.widespread = widespreadPathKeys.has(key);
17321732
}
17331733

1734-
// Flag page count changes
1735-
const pageCountChanged = docReport.pageCount.candidate !== docReport.pageCount.reference;
1734+
// Flag page count changes (parse-error reports have no pageCount)
1735+
const pageCountChanged = docReport.pageCount
1736+
? docReport.pageCount.candidate !== docReport.pageCount.reference
1737+
: false;
17361738
if (pageCountChanged) docReport.pageCountChanged = true;
17371739

17381740
// Write report

0 commit comments

Comments
 (0)