From 271fc360e7ad9ebfaad13fa30e2d7f75bde3ae4f Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Fri, 17 Apr 2026 07:24:52 +0100 Subject: [PATCH] test: mock message command config seam --- src/commands/message.default-agent.test.ts | 31 ++++++++-------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/src/commands/message.default-agent.test.ts b/src/commands/message.default-agent.test.ts index 97f2f9d94a4..11bd4b78278 100644 --- a/src/commands/message.default-agent.test.ts +++ b/src/commands/message.default-agent.test.ts @@ -4,11 +4,10 @@ import type { RuntimeEnv } from "../runtime.js"; import { messageCommand } from "./message.js"; let testConfig: Record = {}; -const applyPluginAutoEnable = vi.hoisted(() => vi.fn(({ config }) => ({ config, changes: [] }))); - -const resolveCommandSecretRefsViaGateway = vi.hoisted(() => +const resolveCommandConfigWithSecrets = vi.hoisted(() => vi.fn(async ({ config }: { config: unknown }) => ({ resolvedConfig: config, + effectiveConfig: config, diagnostics: [] as string[], })), ); @@ -24,20 +23,12 @@ const runMessageAction = vi.hoisted(() => })), ); -vi.mock("../config/config.js", async () => { - const actual = await vi.importActual("../config/config.js"); - return { - ...actual, - loadConfig: () => testConfig, - }; -}); - -vi.mock("../cli/command-secret-gateway.js", () => ({ - resolveCommandSecretRefsViaGateway, +vi.mock("../config/config.js", () => ({ + loadConfig: () => testConfig, })); -vi.mock("../config/plugin-auto-enable.js", () => ({ - applyPluginAutoEnable, +vi.mock("../cli/command-config-resolution.js", () => ({ + resolveCommandConfigWithSecrets, })); vi.mock("../infra/outbound/message-action-runner.js", () => ({ @@ -47,8 +38,7 @@ vi.mock("../infra/outbound/message-action-runner.js", () => ({ describe("messageCommand agent routing", () => { beforeEach(() => { testConfig = {}; - applyPluginAutoEnable.mockClear(); - resolveCommandSecretRefsViaGateway.mockClear(); + resolveCommandConfigWithSecrets.mockClear(); runMessageAction.mockClear(); }); @@ -68,8 +58,9 @@ describe("messageCommand agent routing", () => { }, }; testConfig = rawConfig; - resolveCommandSecretRefsViaGateway.mockResolvedValueOnce({ + resolveCommandConfigWithSecrets.mockResolvedValueOnce({ resolvedConfig, + effectiveConfig: resolvedConfig, diagnostics: [], }); @@ -90,13 +81,13 @@ describe("messageCommand agent routing", () => { runtime, ); - expect(resolveCommandSecretRefsViaGateway).toHaveBeenCalledWith( + expect(resolveCommandConfigWithSecrets).toHaveBeenCalledWith( expect.objectContaining({ config: rawConfig, commandName: "message", }), ); - const call = resolveCommandSecretRefsViaGateway.mock.calls[0]?.[0] as { + const call = resolveCommandConfigWithSecrets.mock.calls[0]?.[0] as { targetIds?: Set; }; expect(call.targetIds).toBeInstanceOf(Set);