Skip to content

Commit ed8f377

Browse files
committed
fix(cli): adapt consent-settle tests to ScreenshotCaptureResult and keep comment share flat
1 parent c1bc452 commit ed8f377

2 files changed

Lines changed: 5 additions & 13 deletions

File tree

‎packages/cli/src/capture/screenshotCapture.test.ts‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ describe("captureScrollScreenshots — consent-click page reload (#4923)", () =>
484484
const dir = tempDir("hf-scroll-reload-");
485485
const { page, evaluate, waitForNetworkIdle } = reloadingPage();
486486

487-
const files = await captureScrollScreenshots(page, dir);
487+
const { files } = await captureScrollScreenshots(page, dir);
488488

489489
expect(files.length).toBeGreaterThan(0);
490490
expect(waitForNetworkIdle).toHaveBeenCalled();
@@ -515,7 +515,7 @@ describe("captureScrollScreenshots — consent-click page reload (#4923)", () =>
515515
const dir = tempDir("hf-scroll-no-reload-");
516516
const { page, waitForNetworkIdle } = fakePage();
517517

518-
const files = await captureScrollScreenshots(page, dir);
518+
const { files } = await captureScrollScreenshots(page, dir);
519519

520520
// The document reports parsed on the first probe, so the settle pays
521521
// exactly one idle wait and the run still finishes.
@@ -536,7 +536,7 @@ describe("captureScrollScreenshots — consent-click page reload (#4923)", () =>
536536
const waitForNetworkIdle = vi.fn(async () => undefined);
537537
const { page } = scrollablePage(evaluate, waitForNetworkIdle);
538538

539-
const files = await captureScrollScreenshots(page, dir);
539+
const { files } = await captureScrollScreenshots(page, dir);
540540

541541
expect(files.length).toBeGreaterThan(0);
542542
expect(waitForNetworkIdle).not.toHaveBeenCalled();
@@ -553,7 +553,7 @@ describe("captureScrollScreenshots — consent-click page reload (#4923)", () =>
553553
const waitForNetworkIdle = vi.fn(async () => undefined);
554554
const { page } = scrollablePage(evaluate, waitForNetworkIdle);
555555

556-
const files = await captureScrollScreenshots(page, dir);
556+
const { files } = await captureScrollScreenshots(page, dir);
557557

558558
expect(files.length).toBeGreaterThan(0);
559559
expect(waitForNetworkIdle).toHaveBeenCalledTimes(1);
@@ -594,7 +594,7 @@ describe("captureScrollScreenshots — consent-click page reload (#4923)", () =>
594594
const dir = tempDir("hf-scroll-loading-doc-");
595595
const { page, evaluate, waitForNetworkIdle } = loadingDocumentPage();
596596

597-
const files = await captureScrollScreenshots(page, dir);
597+
const { files } = await captureScrollScreenshots(page, dir);
598598

599599
expect(files.length).toBeGreaterThan(0);
600600
// A second idle wait runs once the document finishes loading, before the

‎packages/cli/src/capture/screenshotCapture.ts‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,6 @@ export async function captureScrollScreenshots(
165165
// Dismiss marketing banners, cookie consents, and popups before scrolling.
166166
// These overlay content and contaminate screenshots with UI that doesn't
167167
// belong in video compositions (cookie popups, newsletter modals, etc.)
168-
// A consent click can reload the page (some CMPs reload once consent is
169-
// stored); a swapped document reads as a new performance.timeOrigin. Read
170-
// it around the sweep so a banner-free page skips the settle and keeps
171-
// the old flat-400ms cost — an unreadable (NaN) pair counts as "cannot
172-
// prove unchanged" and settles on the safe side.
173168
const readTimeOrigin = async (): Promise<number> => {
174169
const value: unknown = await page.evaluate(`performance.timeOrigin`).catch((err: unknown) => {
175170
if (isDegradableEvaluateTimeoutError(err)) throw err;
@@ -229,9 +224,6 @@ export async function captureScrollScreenshots(
229224
return 0;
230225
});
231226
await new Promise((r) => setTimeout(r, 400));
232-
// Settle only when the sweep clicked a control or the document was
233-
// swapped under us — the click reload is the case that needs it (#4923),
234-
// and the wait shares the stage's remaining budget.
235227
if (clickedCount > 0 || (await readTimeOrigin()) !== originBefore) {
236228
await waitForPageReady(page, {
237229
timeoutMs: Math.min(15_000, budget.remainingMs?.() ?? 15_000),

0 commit comments

Comments
 (0)