mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-30 11:26:46 +00:00
test: preload onboarding command modules in hot suites
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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<string, unknown>,
|
||||
): Promise<void> {
|
||||
await runNonInteractiveOnboarding(
|
||||
{
|
||||
...NON_INTERACTIVE_DEFAULT_OPTIONS,
|
||||
...options,
|
||||
},
|
||||
runtime,
|
||||
);
|
||||
}
|
||||
|
||||
async function runOnboardingAndReadConfig(
|
||||
env: OnboardEnv,
|
||||
options: Record<string, unknown>,
|
||||
|
||||
Reference in New Issue
Block a user