import { describe, expect, it } from "vitest"; import { AI_PRESETS, findAiPreset } from "./aiPresets"; describe("AI 预设表", () => { it("id 唯一且包含本地与自定义兜底", () => { const ids = AI_PRESETS.map((p) => p.id); expect(new Set(ids).size).toBe(ids.length); expect(findAiPreset("ollama")?.allowInsecureHttp).toBe(true); expect(findAiPreset("custom")?.baseUrl).toBe(""); }); it("云端预设一律 https 且默认不放行 http", () => { for (const p of AI_PRESETS.filter((x) => x.id !== "ollama" && x.id !== "custom")) { expect(p.baseUrl.startsWith("https://"), p.id).toBe(true); expect(p.allowInsecureHttp, p.id).toBe(false); } }); it("anthropic 协议与 x-api-key 配对,其余为 bearer/none", () => { for (const p of AI_PRESETS) { if (p.protocol === "anthropic") expect(p.authStyle, p.id).toBe("x-api-key"); else expect(["bearer", "none"], p.id).toContain(p.authStyle); } }); it("除自定义外默认模型都在模型清单中", () => { for (const p of AI_PRESETS.filter((x) => x.id !== "custom")) { expect(p.models, p.id).toContain(p.defaultModel); } }); });