fix: align retry backoff semantics and test mock signatures

This commit is contained in:
Peter Steinberger
2026-02-18 04:32:49 +01:00
parent 0bf1b38cc0
commit 50e5553533
5 changed files with 19 additions and 40 deletions

View File

@@ -4,18 +4,7 @@ import type { BrowserParentOpts } from "./browser-cli-shared.js";
import { registerBrowserStateCommands } from "./browser-cli-state.js";
const mocks = vi.hoisted(() => ({
callBrowserRequest: vi.fn(
async (
_opts: BrowserParentOpts,
_params: {
method: "GET" | "POST" | "DELETE";
path: string;
query?: Record<string, string | number | boolean | undefined>;
body?: unknown;
},
_extra?: { timeoutMs?: number; progress?: boolean },
) => ({ ok: true }),
),
callBrowserRequest: vi.fn(async (..._args: unknown[]) => ({ ok: true })),
runBrowserResizeWithOutput: vi.fn(async (_params: unknown) => {}),
runtime: {
log: vi.fn(),
@@ -25,20 +14,11 @@ const mocks = vi.hoisted(() => ({
}));
vi.mock("./browser-cli-shared.js", () => ({
callBrowserRequest: (
opts: BrowserParentOpts,
params: {
method: "GET" | "POST" | "DELETE";
path: string;
query?: Record<string, string | number | boolean | undefined>;
body?: unknown;
},
extra?: { timeoutMs?: number; progress?: boolean },
) => mocks.callBrowserRequest(opts, params, extra),
callBrowserRequest: mocks.callBrowserRequest,
}));
vi.mock("./browser-cli-resize.js", () => ({
runBrowserResizeWithOutput: (params: unknown) => mocks.runBrowserResizeWithOutput(params),
runBrowserResizeWithOutput: mocks.runBrowserResizeWithOutput,
}));
vi.mock("../runtime.js", () => ({
@@ -82,7 +62,7 @@ describe("browser state option collisions", () => {
const call = mocks.callBrowserRequest.mock.calls.at(-1);
expect(call).toBeDefined();
if (!call) {
throw new Error("Expected callBrowserRequest to be called");
throw new Error("expected browser request call");
}
const request = call[1] as { body?: { targetId?: string } };
expect(request.body?.targetId).toBe("tab-1");
@@ -105,7 +85,7 @@ describe("browser state option collisions", () => {
const call = mocks.callBrowserRequest.mock.calls.at(-1);
expect(call).toBeDefined();
if (!call) {
throw new Error("Expected callBrowserRequest to be called");
throw new Error("expected browser request call");
}
const request = call[1] as { body?: { headers?: Record<string, string> } };
expect(request.body?.headers).toEqual({ "x-auth": "ok" });