test(auth-choice): expand api provider dedupe coverage

This commit is contained in:
Peter Steinberger
2026-02-22 11:16:23 +00:00
parent fc60f4923a
commit 11546b1177
4 changed files with 790 additions and 2 deletions

View File

@@ -127,4 +127,37 @@ describe("applyAuthChoiceHuggingface", () => {
const parsed = await readAuthProfiles(agentDir);
expect(parsed.profiles?.["huggingface:default"]?.key).toBe("hf-opts-token");
});
it("accepts mixed-case tokenProvider from opts without prompting", async () => {
const agentDir = await setupTempState();
delete process.env.HF_TOKEN;
delete process.env.HUGGINGFACE_HUB_TOKEN;
const text = vi.fn().mockResolvedValue("hf-text-token");
const select: WizardPrompter["select"] = vi.fn(
async (params) => params.options?.[0]?.value as never,
);
const confirm = vi.fn(async () => true);
const prompter = createHuggingfacePrompter({ text, select, confirm });
const runtime = createExitThrowingRuntime();
const result = await applyAuthChoiceHuggingface({
authChoice: "huggingface-api-key",
config: {},
prompter,
runtime,
setDefaultModel: true,
opts: {
tokenProvider: " HuGgInGfAcE ",
token: "hf-opts-mixed",
},
});
expect(result).not.toBeNull();
expect(confirm).not.toHaveBeenCalled();
expect(text).not.toHaveBeenCalled();
const parsed = await readAuthProfiles(agentDir);
expect(parsed.profiles?.["huggingface:default"]?.key).toBe("hf-opts-mixed");
});
});