mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-05 09:28:08 +00:00
fix(cli): honor check navigation timeout (#2860)
* fix(cli): honor check navigation timeout * test(cli): clarify diagnostic timeout precedence
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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(),
|
||||
|
||||
@@ -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", () => {
|
||||
|
||||
@@ -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 ──────────────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user