From eddbc04f4bdf0920f4091a97a0ad79033fbfcd89 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Fri, 10 Apr 2026 16:46:09 +0100 Subject: [PATCH] test: narrow command runtime config coverage --- src/commands/agent.runtime-config.test.ts | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/commands/agent.runtime-config.test.ts b/src/commands/agent.runtime-config.test.ts index 01c763547c5..36eb42ec5c3 100644 --- a/src/commands/agent.runtime-config.test.ts +++ b/src/commands/agent.runtime-config.test.ts @@ -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( @@ -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); }); }); });