mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-18 21:44:47 +00:00
test: guard browser batch mock calls
This commit is contained in:
@@ -38,6 +38,17 @@ vi.mock("./pw-tools-core.snapshot.js", () => ({
|
||||
|
||||
const { batchViaPlaywright } = await import("./pw-tools-core.interactions.js");
|
||||
|
||||
function firstEvaluateCall(): [unknown, { fnBody?: string; timeoutMs?: number }] {
|
||||
if (!page) {
|
||||
throw new Error("expected test page");
|
||||
}
|
||||
const [call] = page.evaluate.mock.calls;
|
||||
if (!call) {
|
||||
throw new Error("expected page.evaluate call");
|
||||
}
|
||||
return call as [unknown, { fnBody?: string; timeoutMs?: number }];
|
||||
}
|
||||
|
||||
describe("batchViaPlaywright", () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
@@ -56,7 +67,7 @@ describe("batchViaPlaywright", () => {
|
||||
});
|
||||
|
||||
expect(result).toEqual({ results: [{ ok: true }] });
|
||||
const [evaluateFn, evaluateOptions] = page?.evaluate.mock.calls[0] ?? [];
|
||||
const [evaluateFn, evaluateOptions] = firstEvaluateCall();
|
||||
expect(typeof evaluateFn).toBe("function");
|
||||
expect(evaluateOptions?.fnBody).toBe("() => 1");
|
||||
expect(evaluateOptions?.timeoutMs).toBe(4500);
|
||||
|
||||
Reference in New Issue
Block a user