diff --git a/src/commands/agent.delivery.test.ts b/src/commands/agent.delivery.test.ts index 0830d20a2c2..7d9867cbaf3 100644 --- a/src/commands/agent.delivery.test.ts +++ b/src/commands/agent.delivery.test.ts @@ -29,6 +29,8 @@ vi.mock("../infra/outbound/targets.js", async () => { }; }); +const { deliverAgentCommandResult } = await import("./agent/delivery.js"); + describe("deliverAgentCommandResult", () => { function createRuntime(): RuntimeEnv { return { @@ -54,7 +56,6 @@ describe("deliverAgentCommandResult", () => { const deps = {} as CliDeps; const runtime = params.runtime ?? createRuntime(); const result = createResult(params.resultText); - const { deliverAgentCommandResult } = await import("./agent/delivery.js"); await deliverAgentCommandResult({ cfg, diff --git a/src/commands/onboard-non-interactive.gateway.test.ts b/src/commands/onboard-non-interactive.gateway.test.ts index bfd0a728c99..8e94fd17bfe 100644 --- a/src/commands/onboard-non-interactive.gateway.test.ts +++ b/src/commands/onboard-non-interactive.gateway.test.ts @@ -3,11 +3,7 @@ import path from "node:path"; import { afterAll, beforeAll, describe, expect, it, vi } from "vitest"; import { makeTempWorkspace } from "../test-helpers/workspace.js"; import { captureEnv } from "../test-utils/env.js"; -import { - createThrowingRuntime, - readJsonFile, - runNonInteractiveOnboarding, -} from "./onboard-non-interactive.test-helpers.js"; +import { createThrowingRuntime, readJsonFile } from "./onboard-non-interactive.test-helpers.js"; const gatewayClientCalls: Array<{ url?: string; @@ -53,6 +49,11 @@ vi.mock("./onboard-helpers.js", async (importOriginal) => { }; }); +const { runNonInteractiveOnboarding } = await import("./onboard-non-interactive.js"); +const { resolveConfigPath: resolveStateConfigPath } = await import("../config/paths.js"); +const { resolveConfigPath } = await import("../config/config.js"); +const { callGateway } = await import("../gateway/call.js"); + function getPseudoPort(base: number): number { return base + (process.pid % 1000); } @@ -136,8 +137,7 @@ describe("onboard (non-interactive): gateway and remote auth", () => { runtime, ); - const { resolveConfigPath } = await import("../config/paths.js"); - const configPath = resolveConfigPath(process.env, stateDir); + const configPath = resolveStateConfigPath(process.env, stateDir); const cfg = await readJsonFile<{ gateway?: { auth?: { mode?: string; token?: string } }; agents?: { defaults?: { workspace?: string } }; @@ -165,7 +165,6 @@ describe("onboard (non-interactive): gateway and remote auth", () => { runtime, ); - const { resolveConfigPath } = await import("../config/config.js"); const cfg = await readJsonFile<{ gateway?: { mode?: string; remote?: { url?: string; token?: string } }; }>(resolveConfigPath()); @@ -175,7 +174,6 @@ describe("onboard (non-interactive): gateway and remote auth", () => { expect(cfg.gateway?.remote?.token).toBe(token); gatewayClientCalls.length = 0; - const { callGateway } = await import("../gateway/call.js"); const health = await callGateway<{ ok?: boolean }>({ method: "health" }); expect(health?.ok).toBe(true); const lastCall = gatewayClientCalls[gatewayClientCalls.length - 1]; @@ -211,8 +209,7 @@ describe("onboard (non-interactive): gateway and remote auth", () => { runtime, ); - const { resolveConfigPath } = await import("../config/paths.js"); - const configPath = resolveConfigPath(process.env, stateDir); + const configPath = resolveStateConfigPath(process.env, stateDir); const cfg = await readJsonFile<{ gateway?: { bind?: string; diff --git a/src/commands/onboard-non-interactive.provider-auth.test.ts b/src/commands/onboard-non-interactive.provider-auth.test.ts index e98777c2d7c..0a97d032d66 100644 --- a/src/commands/onboard-non-interactive.provider-auth.test.ts +++ b/src/commands/onboard-non-interactive.provider-auth.test.ts @@ -8,7 +8,6 @@ import { MINIMAX_API_BASE_URL, MINIMAX_CN_API_BASE_URL } from "./onboard-auth.js import { createThrowingRuntime, readJsonFile, - runNonInteractiveOnboardingWithDefaults, type NonInteractiveRuntime, } from "./onboard-non-interactive.test-helpers.js"; import { OPENAI_DEFAULT_MODEL } from "./openai-model-default.js"; @@ -28,6 +27,15 @@ vi.mock("./onboard-helpers.js", async (importOriginal) => { }; }); +const { runNonInteractiveOnboarding } = await import("./onboard-non-interactive.js"); + +const NON_INTERACTIVE_DEFAULT_OPTIONS = { + nonInteractive: true, + skipHealth: true, + skipChannels: true, + json: true, +} as const; + let ensureAuthProfileStore: typeof import("../agents/auth-profiles.js").ensureAuthProfileStore; let upsertAuthProfile: typeof import("../agents/auth-profiles.js").upsertAuthProfile; @@ -95,6 +103,19 @@ async function withOnboardEnv( } } +async function runNonInteractiveOnboardingWithDefaults( + runtime: NonInteractiveRuntime, + options: Record, +): Promise { + await runNonInteractiveOnboarding( + { + ...NON_INTERACTIVE_DEFAULT_OPTIONS, + ...options, + }, + runtime, + ); +} + async function runOnboardingAndReadConfig( env: OnboardEnv, options: Record,