test(core): trim redundant setup and tighten waits

This commit is contained in:
Peter Steinberger
2026-02-24 00:31:36 +00:00
parent f58c1ef34e
commit 663f784e4e
6 changed files with 76 additions and 73 deletions

View File

@@ -30,7 +30,7 @@ describe("doctor command", () => {
const stateNote = note.mock.calls.find((call) => call[1] === "State integrity");
expect(stateNote).toBeTruthy();
expect(String(stateNote?.[0])).toContain("CRITICAL");
}, 30_000);
});
it("warns about opencode provider overrides", async () => {
mockDoctorConfigSnapshot({

View File

@@ -66,7 +66,7 @@ async function removeDirWithRetry(dir: string): Promise<void> {
if (!isTransient || attempt === 4) {
throw error;
}
await delay(25 * (attempt + 1));
await delay(10 * (attempt + 1));
}
}
}
@@ -189,7 +189,7 @@ describe("onboard (non-interactive): provider auth", () => {
key: "sk-minimax-test",
});
});
}, 60_000);
});
it("supports MiniMax CN API endpoint auth choice", async () => {
await withOnboardEnv("openclaw-onboard-minimax-cn-", async (env) => {
@@ -208,7 +208,7 @@ describe("onboard (non-interactive): provider auth", () => {
key: "sk-minimax-test",
});
});
}, 60_000);
});
it("stores Z.AI API key and uses global baseUrl by default", async () => {
await withOnboardEnv("openclaw-onboard-zai-", async (env) => {
@@ -223,7 +223,7 @@ describe("onboard (non-interactive): provider auth", () => {
expect(cfg.agents?.defaults?.model?.primary).toBe("zai/glm-5");
await expectApiKeyProfile({ profileId: "zai:default", provider: "zai", key: "zai-test-key" });
});
}, 60_000);
});
it("supports Z.AI CN coding endpoint auth choice", async () => {
await withOnboardEnv("openclaw-onboard-zai-cn-", async (env) => {
@@ -236,7 +236,7 @@ describe("onboard (non-interactive): provider auth", () => {
"https://open.bigmodel.cn/api/coding/paas/v4",
);
});
}, 60_000);
});
it("stores xAI API key and sets default model", async () => {
await withOnboardEnv("openclaw-onboard-xai-", async (env) => {
@@ -251,7 +251,7 @@ describe("onboard (non-interactive): provider auth", () => {
expect(cfg.agents?.defaults?.model?.primary).toBe("xai/grok-4");
await expectApiKeyProfile({ profileId: "xai:default", provider: "xai", key: "xai-test-key" });
});
}, 60_000);
});
it("infers Mistral auth choice from --mistral-api-key and sets default model", async () => {
await withOnboardEnv("openclaw-onboard-mistral-infer-", async (env) => {
@@ -268,7 +268,7 @@ describe("onboard (non-interactive): provider auth", () => {
key: "mistral-test-key",
});
});
}, 60_000);
});
it("stores Volcano Engine API key and sets default model", async () => {
await withOnboardEnv("openclaw-onboard-volcengine-", async (env) => {
@@ -279,7 +279,7 @@ describe("onboard (non-interactive): provider auth", () => {
expect(cfg.agents?.defaults?.model?.primary).toBe("volcengine-plan/ark-code-latest");
});
}, 60_000);
});
it("infers BytePlus auth choice from --byteplus-api-key and sets default model", async () => {
await withOnboardEnv("openclaw-onboard-byteplus-infer-", async (env) => {
@@ -289,7 +289,7 @@ describe("onboard (non-interactive): provider auth", () => {
expect(cfg.agents?.defaults?.model?.primary).toBe("byteplus-plan/ark-code-latest");
});
}, 60_000);
});
it("stores Vercel AI Gateway API key and sets default model", async () => {
await withOnboardEnv("openclaw-onboard-ai-gateway-", async (env) => {
@@ -309,7 +309,7 @@ describe("onboard (non-interactive): provider auth", () => {
key: "gateway-test-key",
});
});
}, 60_000);
});
it("stores token auth profile", async () => {
await withOnboardEnv("openclaw-onboard-token-", async ({ configPath, runtime }) => {
@@ -336,7 +336,7 @@ describe("onboard (non-interactive): provider auth", () => {
expect(profile.token).toBe(cleanToken);
}
});
}, 60_000);
});
it("stores OpenAI API key and sets OpenAI default model", async () => {
await withOnboardEnv("openclaw-onboard-openai-", async (env) => {
@@ -347,7 +347,7 @@ describe("onboard (non-interactive): provider auth", () => {
expect(cfg.agents?.defaults?.model?.primary).toBe(OPENAI_DEFAULT_MODEL);
});
}, 60_000);
});
it("rejects vLLM auth choice in non-interactive mode", async () => {
await withOnboardEnv("openclaw-onboard-vllm-non-interactive-", async ({ runtime }) => {
@@ -358,7 +358,7 @@ describe("onboard (non-interactive): provider auth", () => {
}),
).rejects.toThrow('Auth choice "vllm" requires interactive mode.');
});
}, 60_000);
});
it("stores LiteLLM API key and sets default model", async () => {
await withOnboardEnv("openclaw-onboard-litellm-", async (env) => {
@@ -376,7 +376,7 @@ describe("onboard (non-interactive): provider auth", () => {
key: "litellm-test-key",
});
});
}, 60_000);
});
it.each([
{
@@ -391,37 +391,31 @@ describe("onboard (non-interactive): provider auth", () => {
prefix: "openclaw-onboard-cf-gateway-infer-",
options: {},
},
])(
"$name",
async ({ prefix, options }) => {
await withOnboardEnv(prefix, async ({ configPath, runtime }) => {
await runNonInteractiveOnboardingWithDefaults(runtime, {
cloudflareAiGatewayAccountId: "cf-account-id",
cloudflareAiGatewayGatewayId: "cf-gateway-id",
cloudflareAiGatewayApiKey: "cf-gateway-test-key",
skipSkills: true,
...options,
});
const cfg = await readJsonFile<ProviderAuthConfigSnapshot>(configPath);
expect(cfg.auth?.profiles?.["cloudflare-ai-gateway:default"]?.provider).toBe(
"cloudflare-ai-gateway",
);
expect(cfg.auth?.profiles?.["cloudflare-ai-gateway:default"]?.mode).toBe("api_key");
expect(cfg.agents?.defaults?.model?.primary).toBe(
"cloudflare-ai-gateway/claude-sonnet-4-5",
);
await expectApiKeyProfile({
profileId: "cloudflare-ai-gateway:default",
provider: "cloudflare-ai-gateway",
key: "cf-gateway-test-key",
metadata: { accountId: "cf-account-id", gatewayId: "cf-gateway-id" },
});
])("$name", async ({ prefix, options }) => {
await withOnboardEnv(prefix, async ({ configPath, runtime }) => {
await runNonInteractiveOnboardingWithDefaults(runtime, {
cloudflareAiGatewayAccountId: "cf-account-id",
cloudflareAiGatewayGatewayId: "cf-gateway-id",
cloudflareAiGatewayApiKey: "cf-gateway-test-key",
skipSkills: true,
...options,
});
},
60_000,
);
const cfg = await readJsonFile<ProviderAuthConfigSnapshot>(configPath);
expect(cfg.auth?.profiles?.["cloudflare-ai-gateway:default"]?.provider).toBe(
"cloudflare-ai-gateway",
);
expect(cfg.auth?.profiles?.["cloudflare-ai-gateway:default"]?.mode).toBe("api_key");
expect(cfg.agents?.defaults?.model?.primary).toBe("cloudflare-ai-gateway/claude-sonnet-4-5");
await expectApiKeyProfile({
profileId: "cloudflare-ai-gateway:default",
provider: "cloudflare-ai-gateway",
key: "cf-gateway-test-key",
metadata: { accountId: "cf-account-id", gatewayId: "cf-gateway-id" },
});
});
});
it("infers Together auth choice from --together-api-key and sets default model", async () => {
await withOnboardEnv("openclaw-onboard-together-infer-", async (env) => {
@@ -438,7 +432,7 @@ describe("onboard (non-interactive): provider auth", () => {
key: "together-test-key",
});
});
}, 60_000);
});
it("infers QIANFAN auth choice from --qianfan-api-key and sets default model", async () => {
await withOnboardEnv("openclaw-onboard-qianfan-infer-", async (env) => {
@@ -455,7 +449,7 @@ describe("onboard (non-interactive): provider auth", () => {
key: "qianfan-test-key",
});
});
}, 60_000);
});
it("configures a custom provider from non-interactive flags", async () => {
await withOnboardEnv("openclaw-onboard-custom-provider-", async ({ configPath, runtime }) => {
@@ -477,7 +471,7 @@ describe("onboard (non-interactive): provider auth", () => {
expect(provider?.models?.some((model) => model.id === "foo-large")).toBe(true);
expect(cfg.agents?.defaults?.model?.primary).toBe("custom-llm-example-com/foo-large");
});
}, 60_000);
});
it("infers custom provider auth choice from custom flags", async () => {
await withOnboardEnv(
@@ -501,7 +495,7 @@ describe("onboard (non-interactive): provider auth", () => {
expect(cfg.agents?.defaults?.model?.primary).toBe("custom-models-custom-local/local-large");
},
);
}, 60_000);
});
it("uses CUSTOM_API_KEY env fallback for non-interactive custom provider auth", async () => {
await withOnboardEnv(
@@ -512,7 +506,7 @@ describe("onboard (non-interactive): provider auth", () => {
expect(await readCustomLocalProviderApiKey(configPath)).toBe("custom-env-key");
},
);
}, 60_000);
});
it("uses matching profile fallback for non-interactive custom provider auth", async () => {
await withOnboardEnv(
@@ -530,7 +524,7 @@ describe("onboard (non-interactive): provider auth", () => {
expect(await readCustomLocalProviderApiKey(configPath)).toBe("custom-profile-key");
},
);
}, 60_000);
});
it("fails custom provider auth when compatibility is invalid", async () => {
await withOnboardEnv(
@@ -547,7 +541,7 @@ describe("onboard (non-interactive): provider auth", () => {
).rejects.toThrow('Invalid --custom-compatibility (use "openai" or "anthropic").');
},
);
}, 60_000);
});
it("fails custom provider auth when explicit provider id is invalid", async () => {
await withOnboardEnv("openclaw-onboard-custom-provider-invalid-id-", async ({ runtime }) => {
@@ -563,7 +557,7 @@ describe("onboard (non-interactive): provider auth", () => {
"Invalid custom provider config: Custom provider ID must include letters, numbers, or hyphens.",
);
});
}, 60_000);
});
it("fails inferred custom auth when required flags are incomplete", async () => {
await withOnboardEnv(
@@ -577,5 +571,5 @@ describe("onboard (non-interactive): provider auth", () => {
).rejects.toThrow('Auth choice "custom-api-key" requires a base URL and model ID.');
},
);
}, 60_000);
});
});