From cba37f99b6892f70307c511d407f42f6e43f4770 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Fri, 2 Jan 2026 18:25:22 +0100 Subject: [PATCH] test: cover camera device selection --- CHANGELOG.md | 1 + src/agents/clawdis-tools.camera.test.ts | 35 +++++++++++++++++++++++++ src/cli/program.test.ts | 9 +++++++ 3 files changed, 45 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b36870df..70887b0cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -81,6 +81,7 @@ - macOS camera: wait for exposure/white balance to settle before capturing a snap to avoid dark images. - Camera snap: add `delayMs` parameter (default 2000ms on macOS) to improve exposure reliability. - Camera: add `camera.list` and optional `deviceId` selection for snaps/clips. +- Tests: cover camera device selection params in CLI + agent tools. - macOS packaging: move rpath config into swift build for reliability (#69) — thanks @petter-b - macOS: prioritize main bundle for device resources to prevent crash (#73) — thanks @petter-b - macOS remote: route settings through gateway config and avoid local config reads in remote mode. diff --git a/src/agents/clawdis-tools.camera.test.ts b/src/agents/clawdis-tools.camera.test.ts index d292f5ca9..e41b09d91 100644 --- a/src/agents/clawdis-tools.camera.test.ts +++ b/src/agents/clawdis-tools.camera.test.ts @@ -50,4 +50,39 @@ describe("clawdis_nodes camera_snap", () => { expect(images).toHaveLength(1); expect(images[0]?.mimeType).toBe("image/jpeg"); }); + + it("passes deviceId when provided", async () => { + callGateway.mockImplementation(async ({ method, params }) => { + if (method === "node.list") { + return { nodes: [{ nodeId: "mac-1" }] }; + } + if (method === "node.invoke") { + expect(params).toMatchObject({ + command: "camera.snap", + params: { deviceId: "cam-123" }, + }); + return { + payload: { + format: "jpg", + base64: "aGVsbG8=", + width: 1, + height: 1, + }, + }; + } + throw new Error(`unexpected method: ${String(method)}`); + }); + + const tool = createClawdisTools().find( + (candidate) => candidate.name === "clawdis_nodes", + ); + if (!tool) throw new Error("missing clawdis_nodes tool"); + + await tool.execute("call1", { + action: "camera_snap", + node: "mac-1", + facing: "front", + deviceId: "cam-123", + }); + }); }); diff --git a/src/cli/program.test.ts b/src/cli/program.test.ts index 0fbbd7f80..da2f1dcfe 100644 --- a/src/cli/program.test.ts +++ b/src/cli/program.test.ts @@ -425,6 +425,10 @@ describe("cli program", () => { "640", "--quality", "0.8", + "--delay-ms", + "2000", + "--device-id", + "cam-123", ], { from: "user" }, ); @@ -442,6 +446,8 @@ describe("cli program", () => { facing: "front", maxWidth: 640, quality: 0.8, + delayMs: 2000, + deviceId: "cam-123", }), }), }), @@ -494,6 +500,8 @@ describe("cli program", () => { "--duration", "3000", "--no-audio", + "--device-id", + "cam-123", ], { from: "user" }, ); @@ -509,6 +517,7 @@ describe("cli program", () => { idempotencyKey: "idem-test", params: expect.objectContaining({ includeAudio: false, + deviceId: "cam-123", }), }), }),