|
| 1 | +import { describe, expect, it } from "vitest"; |
| 2 | +import { applyModelAliasDefaults } from "./defaults.js"; |
| 3 | +import type { ClawdbotConfig } from "./types.js"; |
| 4 | + |
| 5 | +describe("applyModelAliasDefaults", () => { |
| 6 | + it("adds default shorthands", () => { |
| 7 | + const cfg = { agent: {} } satisfies ClawdbotConfig; |
| 8 | + const next = applyModelAliasDefaults(cfg); |
| 9 | + |
| 10 | + expect(next.agent?.modelAliases).toEqual({ |
| 11 | + opus: "anthropic/claude-opus-4-5", |
| 12 | + sonnet: "anthropic/claude-sonnet-4-5", |
| 13 | + gpt: "openai/gpt-5.2", |
| 14 | + "gpt-mini": "openai/gpt-5-mini", |
| 15 | + gemini: "google/gemini-3-pro-preview", |
| 16 | + "gemini-flash": "google/gemini-3-flash-preview", |
| 17 | + }); |
| 18 | + }); |
| 19 | + |
| 20 | + it("normalizes casing when alias matches the default target", () => { |
| 21 | + const cfg = { |
| 22 | + agent: { modelAliases: { Opus: "anthropic/claude-opus-4-5" } }, |
| 23 | + } satisfies ClawdbotConfig; |
| 24 | + |
| 25 | + const next = applyModelAliasDefaults(cfg); |
| 26 | + |
| 27 | + expect(next.agent?.modelAliases).toMatchObject({ |
| 28 | + opus: "anthropic/claude-opus-4-5", |
| 29 | + }); |
| 30 | + expect(next.agent?.modelAliases).not.toHaveProperty("Opus"); |
| 31 | + }); |
| 32 | + |
| 33 | + it("does not override existing alias values", () => { |
| 34 | + const cfg = { |
| 35 | + agent: { modelAliases: { gpt: "openai/gpt-4.1" } }, |
| 36 | + } satisfies ClawdbotConfig; |
| 37 | + |
| 38 | + const next = applyModelAliasDefaults(cfg); |
| 39 | + |
| 40 | + expect(next.agent?.modelAliases?.gpt).toBe("openai/gpt-4.1"); |
| 41 | + expect(next.agent?.modelAliases).toMatchObject({ |
| 42 | + "gpt-mini": "openai/gpt-5-mini", |
| 43 | + opus: "anthropic/claude-opus-4-5", |
| 44 | + sonnet: "anthropic/claude-sonnet-4-5", |
| 45 | + gemini: "google/gemini-3-pro-preview", |
| 46 | + "gemini-flash": "google/gemini-3-flash-preview", |
| 47 | + }); |
| 48 | + }); |
| 49 | + |
| 50 | + it("does not rename when casing differs and value differs", () => { |
| 51 | + const cfg = { |
| 52 | + agent: { modelAliases: { GPT: "openai/gpt-4.1-mini" } }, |
| 53 | + } satisfies ClawdbotConfig; |
| 54 | + |
| 55 | + const next = applyModelAliasDefaults(cfg); |
| 56 | + |
| 57 | + expect(next.agent?.modelAliases).toMatchObject({ |
| 58 | + GPT: "openai/gpt-4.1-mini", |
| 59 | + }); |
| 60 | + expect(next.agent?.modelAliases).not.toHaveProperty("gpt"); |
| 61 | + }); |
| 62 | + |
| 63 | + it("respects explicit empty-string disables", () => { |
| 64 | + const cfg = { |
| 65 | + agent: { modelAliases: { gemini: "" } }, |
| 66 | + } satisfies ClawdbotConfig; |
| 67 | + |
| 68 | + const next = applyModelAliasDefaults(cfg); |
| 69 | + |
| 70 | + expect(next.agent?.modelAliases?.gemini).toBe(""); |
| 71 | + expect(next.agent?.modelAliases).toHaveProperty( |
| 72 | + "gemini-flash", |
| 73 | + "google/gemini-3-flash-preview", |
| 74 | + ); |
| 75 | + }); |
| 76 | +}); |
0 commit comments