@@ -3,6 +3,7 @@ import os from "node:os";
|
3 | 3 | import path from "node:path"; |
4 | 4 | import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; |
5 | 5 | import { |
| 6 | +clickChromeMcpCoords, |
6 | 7 | clickChromeMcpElement, |
7 | 8 | buildChromeMcpArgs, |
8 | 9 | decodeChromeMcpStderrTail, |
@@ -509,6 +510,31 @@ describe("chrome MCP page parsing", () => {
|
509 | 510 | expect(result).toBe(123); |
510 | 511 | }); |
511 | 512 | |
| 513 | +it("defaults non-finite coordinate click delays before injecting the browser script", async () => { |
| 514 | +const session = createFakeSession(); |
| 515 | +const callTool = vi.fn(async ({ name }: ToolCall) => { |
| 516 | +if (name === "evaluate_script") { |
| 517 | +return { content: [{ type: "text", text: "```json\nnull\n```" }] }; |
| 518 | +} |
| 519 | +throw new Error(`unexpected tool ${name}`); |
| 520 | +}); |
| 521 | +session.client.callTool = callTool as typeof session.client.callTool; |
| 522 | +setChromeMcpSessionFactoryForTest(async () => session); |
| 523 | + |
| 524 | +await clickChromeMcpCoords({ |
| 525 | +profileName: "chrome-live", |
| 526 | +targetId: "1", |
| 527 | +x: 10, |
| 528 | +y: 20, |
| 529 | +delayMs: Number.NaN, |
| 530 | +}); |
| 531 | + |
| 532 | +const callToolMock = callTool as unknown as ToolCallMock; |
| 533 | +const evaluateCall = callToolMock.mock.calls.find(([call]) => call.name === "evaluate_script"); |
| 534 | +const fn = evaluateCall?.[0].arguments?.function; |
| 535 | +expect(typeof fn === "string" ? fn : "").toContain("const delayMs = 0;"); |
| 536 | +}); |
| 537 | + |
512 | 538 | it("does not cache an ephemeral availability probe before the next real attach", async () => { |
513 | 539 | let factoryCalls = 0; |
514 | 540 | const closeMocks: Array<ReturnType<typeof vi.fn>> = []; |
|