fix(cli): propagate live capture budget

This commit is contained in:
Miguel Ángel
2026-07-31 20:30:07 +00:00
parent 45aead84c9
commit 49091e6142
11 changed files with 393 additions and 57 deletions
+53
View File
@@ -52,6 +52,15 @@ describe("capture command — vision control", () => {
});
});
it("declares --capture-budget separately from navigation --timeout", () => {
const captureBudgetArg = captureCommand.args
? Reflect.get(captureCommand.args, "capture-budget")
: undefined;
expect(captureBudgetArg).toMatchObject({ type: "string" });
expect(captureBudgetArg?.description.toLowerCase()).toContain("post-navigation");
expect(captureBudgetArg?.description).toContain("--timeout");
});
it("plumbs --skip-vision into capture options", async () => {
vi.spyOn(console, "log").mockImplementation(() => {});
vi.spyOn(console, "error").mockImplementation(() => {});
@@ -72,6 +81,50 @@ describe("capture command — vision control", () => {
);
});
it("plumbs a positive --capture-budget into the post-navigation budget", async () => {
vi.spyOn(console, "log").mockImplementation(() => {});
vi.spyOn(console, "error").mockImplementation(() => {});
await captureCommand.run!({
args: {
url: "https://example.com",
output: "/tmp/hf-capture-budget-test",
"skip-assets": false,
"skip-vision": false,
"capture-budget": "45000",
json: true,
},
} as never);
expect(captureWebsiteMock).toHaveBeenCalledWith(
expect.objectContaining({ postNavigationBudgetMs: 45_000 }),
undefined,
);
});
it.each(["0", "-1", "Infinity", "not-a-number"])(
"rejects invalid --capture-budget %s before capture starts",
async (captureBudget) => {
vi.spyOn(console, "log").mockImplementation(() => {});
vi.spyOn(console, "error").mockImplementation(() => {});
await expect(
captureCommand.run!({
args: {
url: "https://example.com",
output: "/tmp/hf-invalid-capture-budget-test",
"skip-assets": false,
"skip-vision": false,
"capture-budget": captureBudget,
json: true,
},
} as never),
).rejects.toBeInstanceOf(CliRuntimeError);
expect(captureWebsiteMock).not.toHaveBeenCalled();
},
);
it("emits a versioned phase record without the captured URL", async () => {
vi.spyOn(console, "log").mockImplementation(() => {});
const error = vi.spyOn(console, "error").mockImplementation(() => {});