From 36a5ff81350525a7397359f7db81c6eab355908a Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Mon, 16 Feb 2026 15:42:50 +0000 Subject: [PATCH] refactor(test): consolidate provider-auth config snapshot typing --- ...-non-interactive.provider-auth.e2e.test.ts | 89 +++++-------------- 1 file changed, 22 insertions(+), 67 deletions(-) diff --git a/src/commands/onboard-non-interactive.provider-auth.e2e.test.ts b/src/commands/onboard-non-interactive.provider-auth.e2e.test.ts index ac32b68f998..abc9a299251 100644 --- a/src/commands/onboard-non-interactive.provider-auth.e2e.test.ts +++ b/src/commands/onboard-non-interactive.provider-auth.e2e.test.ts @@ -21,7 +21,17 @@ type OnboardEnv = { type ProviderAuthConfigSnapshot = { auth?: { profiles?: Record }; agents?: { defaults?: { model?: { primary?: string } } }; - models?: { providers?: Record }; + models?: { + providers?: Record< + string, + { + baseUrl?: string; + api?: string; + apiKey?: string; + models?: Array<{ id?: string }>; + } + >; + }; }; async function removeDirWithRetry(dir: string): Promise { @@ -166,16 +176,7 @@ async function runCustomLocalNonInteractive( } async function readCustomLocalProviderApiKey(configPath: string): Promise { - const cfg = await readJsonFile<{ - models?: { - providers?: Record< - string, - { - apiKey?: string; - } - >; - }; - }>(configPath); + const cfg = await readJsonFile(configPath); return cfg.models?.providers?.[CUSTOM_LOCAL_PROVIDER_ID]?.apiKey; } @@ -245,11 +246,7 @@ describe("onboard (non-interactive): provider auth", () => { skipSkills: true, }); - const cfg = await readJsonFile<{ - auth?: { profiles?: Record }; - agents?: { defaults?: { model?: { primary?: string } } }; - models?: { providers?: Record }; - }>(configPath); + const cfg = await readJsonFile(configPath); expect(cfg.auth?.profiles?.["zai:default"]?.provider).toBe("zai"); expect(cfg.auth?.profiles?.["zai:default"]?.mode).toBe("api_key"); @@ -267,9 +264,7 @@ describe("onboard (non-interactive): provider auth", () => { skipSkills: true, }); - const cfg = await readJsonFile<{ - models?: { providers?: Record }; - }>(configPath); + const cfg = await readJsonFile(configPath); expect(cfg.models?.providers?.zai?.baseUrl).toBe( "https://open.bigmodel.cn/api/coding/paas/v4", @@ -286,10 +281,7 @@ describe("onboard (non-interactive): provider auth", () => { skipSkills: true, }); - const cfg = await readJsonFile<{ - auth?: { profiles?: Record }; - agents?: { defaults?: { model?: { primary?: string } } }; - }>(configPath); + const cfg = await readJsonFile(configPath); expect(cfg.auth?.profiles?.["xai:default"]?.provider).toBe("xai"); expect(cfg.auth?.profiles?.["xai:default"]?.mode).toBe("api_key"); @@ -306,10 +298,7 @@ describe("onboard (non-interactive): provider auth", () => { skipSkills: true, }); - const cfg = await readJsonFile<{ - auth?: { profiles?: Record }; - agents?: { defaults?: { model?: { primary?: string } } }; - }>(configPath); + const cfg = await readJsonFile(configPath); expect(cfg.auth?.profiles?.["vercel-ai-gateway:default"]?.provider).toBe("vercel-ai-gateway"); expect(cfg.auth?.profiles?.["vercel-ai-gateway:default"]?.mode).toBe("api_key"); @@ -336,9 +325,7 @@ describe("onboard (non-interactive): provider auth", () => { tokenProfileId: "anthropic:default", }); - const cfg = await readJsonFile<{ - auth?: { profiles?: Record }; - }>(configPath); + const cfg = await readJsonFile(configPath); expect(cfg.auth?.profiles?.["anthropic:default"]?.provider).toBe("anthropic"); expect(cfg.auth?.profiles?.["anthropic:default"]?.mode).toBe("token"); @@ -362,9 +349,7 @@ describe("onboard (non-interactive): provider auth", () => { skipSkills: true, }); - const cfg = await readJsonFile<{ - agents?: { defaults?: { model?: { primary?: string } } }; - }>(configPath); + const cfg = await readJsonFile(configPath); expect(cfg.agents?.defaults?.model?.primary).toBe(OPENAI_DEFAULT_MODEL); }); @@ -389,10 +374,7 @@ describe("onboard (non-interactive): provider auth", () => { skipSkills: true, }); - const cfg = await readJsonFile<{ - auth?: { profiles?: Record }; - agents?: { defaults?: { model?: { primary?: string } } }; - }>(configPath); + const cfg = await readJsonFile(configPath); expect(cfg.auth?.profiles?.["litellm:default"]?.provider).toBe("litellm"); expect(cfg.auth?.profiles?.["litellm:default"]?.mode).toBe("api_key"); @@ -437,10 +419,7 @@ describe("onboard (non-interactive): provider auth", () => { runtime, ); - const cfg = await readJsonFile<{ - auth?: { profiles?: Record }; - agents?: { defaults?: { model?: { primary?: string } } }; - }>(configPath); + const cfg = await readJsonFile(configPath); expect(cfg.auth?.profiles?.["cloudflare-ai-gateway:default"]?.provider).toBe( "cloudflare-ai-gateway", @@ -512,20 +491,7 @@ describe("onboard (non-interactive): provider auth", () => { runtime, ); - const cfg = await readJsonFile<{ - models?: { - providers?: Record< - string, - { - baseUrl?: string; - api?: string; - apiKey?: string; - models?: Array<{ id?: string }>; - } - >; - }; - agents?: { defaults?: { model?: { primary?: string } } }; - }>(configPath); + const cfg = await readJsonFile(configPath); const provider = cfg.models?.providers?.["custom-llm-example-com"]; expect(provider?.baseUrl).toBe("https://llm.example.com/v1"); @@ -554,18 +520,7 @@ describe("onboard (non-interactive): provider auth", () => { runtime, ); - const cfg = await readJsonFile<{ - models?: { - providers?: Record< - string, - { - baseUrl?: string; - api?: string; - } - >; - }; - agents?: { defaults?: { model?: { primary?: string } } }; - }>(configPath); + const cfg = await readJsonFile(configPath); expect(cfg.models?.providers?.["custom-models-custom-local"]?.baseUrl).toBe( "https://models.custom.local/v1",