test(cli): share nodes ios fixture helpers

This commit is contained in:
Peter Steinberger
2026-02-21 21:55:57 +00:00
parent fb73c0034e
commit d6ad647f56
4 changed files with 29 additions and 22 deletions

View File

@@ -1,6 +1,7 @@
import * as fs from "node:fs/promises";
import { afterAll, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import { parseCameraSnapPayload, parseCameraClipPayload } from "./nodes-camera.js";
import { IOS_NODE, createIosNodeListResponse } from "./program.nodes-test-helpers.js";
import { callGateway, installBaseProgramMocks, runTui, runtime } from "./program.test-mocks.js";
installBaseProgramMocks();
@@ -48,21 +49,11 @@ function expectParserRejectsMissingMedia(
expect(() => parse(payload)).toThrow(expectedMessage);
}
const IOS_NODE = {
nodeId: "ios-node",
displayName: "iOS Node",
remoteIp: "192.168.0.88",
connected: true,
} as const;
function mockNodeGateway(command?: string, payload?: Record<string, unknown>) {
callGateway.mockImplementation(async (...args: unknown[]) => {
const opts = (args[0] ?? {}) as { method?: string };
if (opts.method === "node.list") {
return {
ts: Date.now(),
nodes: [IOS_NODE],
};
return createIosNodeListResponse();
}
if (opts.method === "node.invoke" && command) {
return {