test: narrow command runtime config coverage

This commit is contained in:
Peter Steinberger
2026-04-10 16:46:09 +01:00
parent 8a5b7cf573
commit eddbc04f4b

View File

@@ -1,10 +1,10 @@
import fs from "node:fs";
import path from "node:path";
import { beforeEach, describe, expect, it, vi } from "vitest";
import "./agent-command.test-mocks.js";
import "../cron/isolated-agent.mocks.js";
import { __testing as acpManagerTesting } from "../acp/control-plane/manager.js";
import { __testing as agentCommandTesting } from "../agents/agent-command.js";
import { resolveSession } from "../agents/command/session.js";
import { loadModelCatalog } from "../agents/model-catalog.js";
import * as modelSelectionModule from "../agents/model-selection.js";
import { runEmbeddedPiAgent } from "../agents/pi-embedded.js";
@@ -20,7 +20,6 @@ import {
mockAgentCommandConfig,
withAgentCommandTempHome,
} from "./agent-command.test-support.js";
import { agentCommand } from "./agent.js";
vi.mock("../agents/auth-profiles.js", async () => {
const actual = await vi.importActual<typeof import("../agents/auth-profiles.js")>(
@@ -184,19 +183,17 @@ describe("agentCommand runtime config", () => {
});
});
it("creates a session entry when deriving from --to", async () => {
it("derives a fresh session from --to", async () => {
await withTempHome(async (home) => {
const store = path.join(home, "sessions.json");
mockConfig(home, store);
const cfg = mockConfig(home, store);
await agentCommand({ message: "hello", to: "+1555" }, runtime);
const resolved = resolveSession({ cfg, to: "+1555" });
const saved = JSON.parse(fs.readFileSync(store, "utf-8")) as Record<
string,
{ sessionId: string }
>;
const entry = Object.values(saved)[0];
expect(entry.sessionId).toBeTruthy();
expect(resolved.storePath).toBe(store);
expect(resolved.sessionKey).toBeTruthy();
expect(resolved.sessionId).toBeTruthy();
expect(resolved.isNewSession).toBe(true);
});
});
});