refactor(test): dedupe cloudflare onboarding provider auth cases

This commit is contained in:
Peter Steinberger
2026-02-14 23:56:55 +00:00
parent 1f18592754
commit 0e6aefde33

View File

@@ -446,44 +446,23 @@ describe("onboard (non-interactive): provider auth", () => {
}); });
}, 60_000); }, 60_000);
it("stores Cloudflare AI Gateway API key and metadata", async () => { it.each([
await withOnboardEnv("openclaw-onboard-cf-gateway-", async ({ configPath, runtime }) => {
await runNonInteractive(
{ {
nonInteractive: true, name: "stores Cloudflare AI Gateway API key and metadata",
prefix: "openclaw-onboard-cf-gateway-",
options: {
authChoice: "cloudflare-ai-gateway-api-key", authChoice: "cloudflare-ai-gateway-api-key",
cloudflareAiGatewayAccountId: "cf-account-id",
cloudflareAiGatewayGatewayId: "cf-gateway-id",
cloudflareAiGatewayApiKey: "cf-gateway-test-key",
skipHealth: true,
skipChannels: true,
skipSkills: true,
json: true,
}, },
runtime, },
); {
name: "infers Cloudflare auth choice from API key flags",
const cfg = await readJsonFile<{ prefix: "openclaw-onboard-cf-gateway-infer-",
auth?: { profiles?: Record<string, { provider?: string; mode?: string }> }; options: {},
agents?: { defaults?: { model?: { primary?: string } } }; },
}>(configPath); ])(
"$name",
expect(cfg.auth?.profiles?.["cloudflare-ai-gateway:default"]?.provider).toBe( async ({ prefix, options }) => {
"cloudflare-ai-gateway", await withOnboardEnv(prefix, async ({ configPath, runtime }) => {
);
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" },
});
});
}, 60_000);
it("infers Cloudflare auth choice from API key flags", async () => {
await withOnboardEnv("openclaw-onboard-cf-gateway-infer-", async ({ configPath, runtime }) => {
await runNonInteractive( await runNonInteractive(
{ {
nonInteractive: true, nonInteractive: true,
@@ -494,6 +473,7 @@ describe("onboard (non-interactive): provider auth", () => {
skipChannels: true, skipChannels: true,
skipSkills: true, skipSkills: true,
json: true, json: true,
...options,
}, },
runtime, runtime,
); );
@@ -507,7 +487,9 @@ describe("onboard (non-interactive): provider auth", () => {
"cloudflare-ai-gateway", "cloudflare-ai-gateway",
); );
expect(cfg.auth?.profiles?.["cloudflare-ai-gateway:default"]?.mode).toBe("api_key"); 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"); expect(cfg.agents?.defaults?.model?.primary).toBe(
"cloudflare-ai-gateway/claude-sonnet-4-5",
);
await expectApiKeyProfile({ await expectApiKeyProfile({
profileId: "cloudflare-ai-gateway:default", profileId: "cloudflare-ai-gateway:default",
provider: "cloudflare-ai-gateway", provider: "cloudflare-ai-gateway",
@@ -515,7 +497,9 @@ describe("onboard (non-interactive): provider auth", () => {
metadata: { accountId: "cf-account-id", gatewayId: "cf-gateway-id" }, metadata: { accountId: "cf-account-id", gatewayId: "cf-gateway-id" },
}); });
}); });
}, 60_000); },
60_000,
);
it("infers Together auth choice from --together-api-key and sets default model", async () => { it("infers Together auth choice from --together-api-key and sets default model", async () => {
await withOnboardEnv("openclaw-onboard-together-infer-", async ({ configPath, runtime }) => { await withOnboardEnv("openclaw-onboard-together-infer-", async ({ configPath, runtime }) => {