fix(cli): honor check navigation timeout (#2860)

* fix(cli): honor check navigation timeout

* test(cli): clarify diagnostic timeout precedence
This commit is contained in:
Miguel Ángel
2026-07-29 20:50:20 +02:00
committed by GitHub
parent 6cfb05e38b
commit fdc5932897
9 changed files with 60 additions and 7 deletions
@@ -155,6 +155,28 @@ it("carries raw browser geometry through the page driver and pipeline", async ()
expect(mocks.serverClose).toHaveBeenCalledOnce();
});
it("uses check --timeout for both navigation and render-ready settling", async () => {
mountCanvasFixture();
const page = fakePage();
installSessionMock(page);
await runBrowserCheck(
PROJECT,
{ ...DEFAULT_CHECK_OPTIONS, samples: 1, contrast: false, timeout: 30_000 },
{ kind: "none" },
runAuditGrid,
);
expect(openSettledCompositionPage).toHaveBeenCalledWith(
"<html></html>",
"http://127.0.0.1:3000",
expect.objectContaining({
navigationTimeoutMs: 30_000,
renderReadyTimeoutMs: 30_000,
}),
);
});
it("round-trips the browser script's raw contrast candidates back into finish", async () => {
// The U2 regression class: Node parses prepare's candidates for reporting,
// but must hand the UNTOUCHED objects back to __contrastAuditFinish — the
+2
View File
@@ -165,6 +165,7 @@ export async function runBrowserCheck(
try {
const launchSettleStart = Date.now();
const session = await openSettledCompositionPage(html, server.url, {
navigationTimeoutMs: options.timeout,
renderReadyTimeoutMs: options.timeout,
renderReadyWarningSuffix: "checking the current page state",
browserGpuMode: resolveCliChromeGpuMode(),
@@ -225,6 +226,7 @@ export async function captureFindingCrops(
const written: string[] = [];
try {
const session = await openSettledCompositionPage(html, server.url, {
navigationTimeoutMs: options.timeout,
renderReadyTimeoutMs: options.timeout,
renderReadyWarningSuffix: "capturing finding crops",
browserGpuMode: resolveCliChromeGpuMode(),
+17
View File
@@ -118,6 +118,23 @@ describe("resolveDiagnosticNavigationTimeoutMs", () => {
resolveDiagnosticNavigationTimeoutMs({ PRODUCER_PAGE_NAVIGATION_TIMEOUT_MS: "invalid" }),
).toBe(10_000);
});
it("raises the diagnostic navigation budget to a larger caller-provided minimum", () => {
expect(resolveDiagnosticNavigationTimeoutMs({}, 30_000)).toBe(30_000);
});
it("does not let a caller-provided minimum shorten the default budget", () => {
expect(resolveDiagnosticNavigationTimeoutMs({}, 3_000)).toBe(10_000);
});
it("does not let a caller-provided minimum shorten the environment override", () => {
expect(
resolveDiagnosticNavigationTimeoutMs(
{ PRODUCER_PAGE_NAVIGATION_TIMEOUT_MS: "90000" },
30_000,
),
).toBe(90_000);
});
});
describe("parseCompositionEntryArg", () => {
+10 -2
View File
@@ -118,12 +118,20 @@ export function resolveBrowserTimeoutMsArg(raw: string | undefined): number | un
return result.value;
}
/** Navigation budget shared by snapshot/check/inspect browser diagnostics. */
/**
* Navigation budget shared by snapshot/check/inspect browser diagnostics.
*
* The environment variable remains the historical global override. Callers
* with their own timeout knob can supply a minimum without shortening that
* override or the existing 10-second default.
*/
export function resolveDiagnosticNavigationTimeoutMs(
env: Record<string, string | undefined> = process.env,
minimumTimeoutMs = 0,
): number {
const parsed = Number(env.PRODUCER_PAGE_NAVIGATION_TIMEOUT_MS);
return Number.isFinite(parsed) && parsed > 0 ? parsed : 10_000;
const configured = Number.isFinite(parsed) && parsed > 0 ? parsed : 10_000;
return Math.max(configured, minimumTimeoutMs);
}
// ── --composition ──────────────────────────────────────────────────────