Files
openclaw/src/agents/model-ref-profile.test.ts
Peter Steinberger e4e5d9c98c fix(model): land #30932 auth-profile @ parsing for /model (@haosenwang1018)
Landed from contributor PR #30932 by @haosenwang1018.

Co-authored-by: haosenwang1018 <haosenwang1018@users.noreply.github.com>
2026-03-02 03:05:03 +00:00

57 lines
1.8 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { splitTrailingAuthProfile } from "./model-ref-profile.js";
describe("splitTrailingAuthProfile", () => {
it("returns trimmed model when no profile suffix exists", () => {
expect(splitTrailingAuthProfile(" openai/gpt-5 ")).toEqual({
model: "openai/gpt-5",
});
});
it("splits trailing @profile suffix", () => {
expect(splitTrailingAuthProfile("openai/gpt-5@work")).toEqual({
model: "openai/gpt-5",
profile: "work",
});
});
it("keeps @-prefixed path segments in model ids", () => {
expect(splitTrailingAuthProfile("openai/@cf/openai/gpt-oss-20b")).toEqual({
model: "openai/@cf/openai/gpt-oss-20b",
});
});
it("supports trailing profile override after @-prefixed path segments", () => {
expect(splitTrailingAuthProfile("openai/@cf/openai/gpt-oss-20b@cf:default")).toEqual({
model: "openai/@cf/openai/gpt-oss-20b",
profile: "cf:default",
});
});
it("keeps openrouter preset paths without profile override", () => {
expect(splitTrailingAuthProfile("openrouter/@preset/kimi-2-5")).toEqual({
model: "openrouter/@preset/kimi-2-5",
});
});
it("supports openrouter preset profile overrides", () => {
expect(splitTrailingAuthProfile("openrouter/@preset/kimi-2-5@work")).toEqual({
model: "openrouter/@preset/kimi-2-5",
profile: "work",
});
});
it("does not split when suffix after @ contains slash", () => {
expect(splitTrailingAuthProfile("provider/foo@bar/baz")).toEqual({
model: "provider/foo@bar/baz",
});
});
it("uses first @ after last slash for email-based auth profiles", () => {
expect(splitTrailingAuthProfile("flash@google-gemini-cli:test@gmail.com")).toEqual({
model: "flash",
profile: "google-gemini-cli:test@gmail.com",
});
});
});