import * as fs from "node:fs/promises"; import { Command } from "commander"; import { afterAll, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import { IOS_NODE, createIosNodeListResponse } from "./program.nodes-test-helpers.js"; import { callGateway, installBaseProgramMocks, runtime } from "./program.test-mocks.js";
installBaseProgramMocks();
let registerNodesCli: (program: Command) => void;
function getFirstRuntimeLogLine(): string { const first = runtime.log.mock.calls[0]?.[0]; if (typeof first !== "string") { thrownew Error(`Expected runtime.log first arg to be string, got ${typeof first}`);
} return first;
}
it("runs nodes camera snap and prints two MEDIA paths", async () => {
mockNodeGateway("camera.snap", { format: "jpg", base64: "aGk=", width: 1, height: 1 });
const out = getFirstRuntimeLogLine(); const mediaPaths = out
.split("\n")
.filter((l) => l.startsWith("MEDIA:"))
.map((l) => l.replace(/^MEDIA:/, ""))
.filter(Boolean);
expect(mediaPaths).toHaveLength(2);
expect(mediaPaths[0]).toContain("openclaw-camera-snap-");
expect(mediaPaths[1]).toContain("openclaw-camera-snap-");
try { // Content bytes are covered by single-output camera/file tests; here we // only verify dual snapshot behavior and that both paths were written.
await expect(fs.stat(mediaPaths[0])).resolves.toBeTruthy();
await expect(fs.stat(mediaPaths[1])).resolves.toBeTruthy();
} finally {
await Promise.all(mediaPaths.map((p) => fs.unlink(p).catch(() => {})));
}
});
it("runs nodes camera clip and prints one MEDIA path", async () => {
mockNodeGateway("camera.clip", {
format: "mp4",
base64: "aGk=",
durationMs: 3000,
hasAudio: true,
});
it("fails nodes camera snap when --facing both and --device-id are combined", async () => {
await expectCameraSnapParseFailure(
[ "nodes", "camera", "snap", "--node", "ios-node", "--facing", "both", "--device-id", "cam-123",
],
/facing=both is not allowed when --device-id is set/i,
);
});
describe("URL-based payloads", () => {
let originalFetch: typeof globalThis.fetch;
beforeAll(() => {
originalFetch = globalThis.fetch;
globalThis.fetch = vi.fn(
async () => new Response("url-content", {
status: 200,
headers: { "content-length": "11" },
}),
) as unknown as typeof globalThis.fetch;
});
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.