perf(test): run nodes program tests on focused nodes-cli harness

This commit is contained in:
Peter Steinberger
2026-02-22 17:19:45 +00:00
parent 0e38505d3d
commit 4493f7325d
2 changed files with 28 additions and 36 deletions

View File

@@ -1,17 +1,10 @@
import { beforeEach, describe, expect, it, vi } from "vitest";
import { Command } from "commander";
import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import { createIosNodeListResponse } from "./program.nodes-test-helpers.js";
import {
callGateway,
installBaseProgramMocks,
installSmokeProgramMocks,
runTui,
runtime,
} from "./program.test-mocks.js";
import { callGateway, installBaseProgramMocks, runtime } from "./program.test-mocks.js";
installBaseProgramMocks();
installSmokeProgramMocks();
const { buildProgram } = await import("./program.js");
let registerNodesCli: (program: Command) => void;
function formatRuntimeLogCallArg(value: unknown): string {
if (typeof value === "string") {
@@ -31,14 +24,17 @@ function formatRuntimeLogCallArg(value: unknown): string {
}
describe("cli program (nodes basics)", () => {
function createProgramWithCleanRuntimeLog() {
const program = buildProgram();
runtime.log.mockClear();
return program;
}
let program: Command;
beforeAll(async () => {
({ registerNodesCli } = await import("./nodes-cli.js"));
program = new Command();
program.exitOverride();
registerNodesCli(program);
});
async function runProgram(argv: string[]) {
const program = createProgramWithCleanRuntimeLog();
runtime.log.mockClear();
await program.parseAsync(argv, { from: "user" });
}
@@ -61,7 +57,6 @@ describe("cli program (nodes basics)", () => {
beforeEach(() => {
vi.clearAllMocks();
runTui.mockResolvedValue(undefined);
});
it("runs nodes list --connected and filters to connected nodes", async () => {

View File

@@ -1,16 +1,11 @@
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,
installSmokeProgramMocks,
runTui,
runtime,
} from "./program.test-mocks.js";
import { callGateway, installBaseProgramMocks, runtime } from "./program.test-mocks.js";
installBaseProgramMocks();
installSmokeProgramMocks();
let registerNodesCli: (program: Command) => void;
function getFirstRuntimeLogLine(): string {
const first = runtime.log.mock.calls[0]?.[0];
@@ -55,17 +50,18 @@ function mockNodeGateway(command?: string, payload?: Record<string, unknown>) {
});
}
const { buildProgram } = await import("./program.js");
describe("cli program (nodes media)", () => {
function createProgramWithCleanRuntimeLog() {
const program = buildProgram();
runtime.log.mockClear();
return program;
}
let program: Command;
beforeAll(async () => {
({ registerNodesCli } = await import("./nodes-cli.js"));
program = new Command();
program.exitOverride();
registerNodesCli(program);
});
async function runNodesCommand(argv: string[]) {
const program = createProgramWithCleanRuntimeLog();
runtime.log.mockClear();
await program.parseAsync(argv, { from: "user" });
}
@@ -85,7 +81,6 @@ describe("cli program (nodes media)", () => {
beforeEach(() => {
vi.clearAllMocks();
runTui.mockResolvedValue(undefined);
});
it("runs nodes camera snap and prints two MEDIA paths", async () => {
@@ -273,7 +268,9 @@ describe("cli program (nodes media)", () => {
it("fails nodes camera snap on invalid facing", async () => {
mockNodeGateway();
const program = buildProgram();
const program = new Command();
program.exitOverride();
registerNodesCli(program);
runtime.error.mockClear();
await expect(