openclaw/src/cli/nodes-camera.test.ts

65 lines
1.6 KiB
TypeScript
Raw Normal View History

2025-12-14 00:48:58 +00:00
import * as fs from "node:fs/promises";
import * as os from "node:os";
import * as path from "node:path";
import { describe, expect, it } from "vitest";
import {
cameraTempPath,
parseCameraClipPayload,
parseCameraSnapPayload,
writeBase64ToFile,
} from "./nodes-camera.js";
describe("nodes camera helpers", () => {
it("parses camera.snap payload", () => {
expect(
parseCameraSnapPayload({
format: "jpg",
base64: "aGk=",
width: 10,
height: 20,
}),
).toEqual({ format: "jpg", base64: "aGk=", width: 10, height: 20 });
});
it("rejects invalid camera.snap payload", () => {
expect(() => parseCameraSnapPayload({ format: "jpg" })).toThrow(
/invalid camera\.snap payload/i,
);
});
it("parses camera.clip payload", () => {
expect(
parseCameraClipPayload({
format: "mp4",
base64: "AAEC",
durationMs: 1234,
hasAudio: true,
}),
).toEqual({
format: "mp4",
base64: "AAEC",
durationMs: 1234,
hasAudio: true,
});
});
it("builds stable temp paths when id provided", () => {
const p = cameraTempPath({
kind: "snap",
facing: "front",
ext: "jpg",
tmpDir: "/tmp",
id: "id1",
});
Ironclaw rename: update CLI binary references, fix Next.js invocation, harden package resolution Comprehensive update to complete the openclaw → ironclaw CLI rename across the codebase, fix build/runtime issues, and add test coverage for infra modules. CLI binary rename (openclaw → ironclaw): - Update DEFAULT_CLI_NAME and all argv parsing to recognize "ironclaw" binary - Extend package name sets (CORE_PACKAGE_NAMES, ALL_PACKAGE_NAMES) to include both "ironclaw" and "openclaw" for backward compatibility - Update NPM registry URL to fetch from ironclaw package - Update gateway lock detection, port listener classification, and launchd/systemd service scanning to recognize ironclaw-prefixed services and binaries - Update daemon inspect markers and legacy detection for ironclaw - Update voice-call extension core-bridge to resolve ironclaw package root - Fix install instructions in embeddings error messages (npm i -g ironclaw@latest) Web app / Next.js fixes: - Replace fragile `npx next` invocations with direct `node next-bin` resolution to avoid broken pnpm virtual-store symlinks in global installs - Add resolveNextBin() helper that resolves apps/web/node_modules/next directly Infra hardening: - Workspace templates: compute both source and dist fallback paths for template directory resolution (fixes templates not found in bundled builds) - Control UI assets: recognize both "openclaw" and "ironclaw" package names - Update-check, update-runner, update-cli: normalize ironclaw@ tag prefixes New tests: - Add openclaw-root.test.ts, ports-format.test.ts, update-global.test.ts - Add workspace-templates.test.ts and control-ui-assets.test.ts coverage - Add argv.test.ts coverage for ironclaw binary detection Test fixes (28 failures → 0): - Update all test assertions expecting "openclaw" CLI command output to "ironclaw" - Fix version.test.ts package name from "openclaw" to "ironclaw" - Fix camera/canvas temp path patterns in nodes-camera and program.nodes-media tests - Fix pairing message, telegram bot, channels, daemon, onboard, gateway tool, status, and profile test expectations Version: 2026.2.10-1.2 (published to npm as ironclaw@2026.2.10-1.2) Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-12 12:19:49 -08:00
expect(p).toBe(path.join("/tmp", "ironclaw-camera-snap-front-id1.jpg"));
2025-12-14 00:48:58 +00:00
});
it("writes base64 to file", async () => {
2026-01-30 03:15:10 +01:00
const dir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-test-"));
2025-12-14 00:48:58 +00:00
const out = path.join(dir, "x.bin");
await writeBase64ToFile(out, "aGk=");
await expect(fs.readFile(out, "utf8")).resolves.toBe("hi");
await fs.rm(dir, { recursive: true, force: true });
});
});