import { describe, expect, test } from "bun:test"; import { discoverGpt56Profiles, findInitialProfileIndex, findProfile, getSupportedThinkingLevels, jumpCapabilityIndex, moveThinkingIndex, wrapProfileIndex, type DiscoverableModel, } from "./profiles"; function model( provider: string, id: string, thinkingLevelMap: DiscoverableModel["thinkingLevelMap"], reasoning = true, ): DiscoverableModel { return { provider, id, reasoning, thinkingLevelMap }; } const standardMap = { off: "none", minimal: null, low: "low", medium: "medium", high: "high", xhigh: "xhigh", max: "max", } as const; describe("thinking-level discovery", () => { test("matches Pi support semantics for explicit maps", () => { expect( getSupportedThinkingLevels(model("p", "gpt-5.6-sol", standardMap)), ).toEqual(["off", "low", "medium", "high", "xhigh", "max"]); }); test("allows ordinary defaults but requires explicit xhigh and max", () => { expect( getSupportedThinkingLevels(model("p", "gpt-5.6-sol", undefined)), ).toEqual(["off", "minimal", "low", "medium", "high"]); }); test("non-reasoning models expose off only", () => { expect( getSupportedThinkingLevels( model("p", "gpt-5.6-sol", { off: null, max: "max" }, false), ), ).toEqual(["off"]); }); }); describe("current-Provider profile discovery", () => { test("keeps only GPT-5.6 capabilities from the requested Provider", () => { const profiles = discoverGpt56Profiles( [ model("mini", "gpt-5.6-sol", standardMap), model("mini", "gpt-5.6-terra", standardMap), model("mini", "gpt-5.5", standardMap), model("other", "gpt-5.6-luna", standardMap), ], "mini", ); expect(profiles).toHaveLength(12); expect([...new Set(profiles.map((profile) => profile.capability))]).toEqual([ "terra", "sol", ]); expect(profiles.every((profile) => profile.providerId === "mini")).toBe(true); }); test("supports exact profile lookup for command arguments", () => { const profiles = discoverGpt56Profiles( [model("mini", "gpt-5.6-sol", standardMap)], "mini", ); expect(findProfile(profiles, "SOL", "HIGH")).toMatchObject({ modelId: "gpt-5.6-sol", thinkingLevel: "high", }); expect(findProfile(profiles, "sol", "minimal")).toBeUndefined(); }); }); describe("dynamic slider navigation", () => { const profiles = discoverGpt56Profiles( [ model("mini", "gpt-5.6-terra", { off: "none", minimal: null, low: "low", medium: null, high: "high", xhigh: null, max: null, }), model("mini", "gpt-5.6-sol", standardMap), ], "mini", ); test("starts from the active model and thinking level", () => { const index = findInitialProfileIndex(profiles, "gpt-5.6-terra", "high"); expect(profiles[index]).toMatchObject({ capability: "terra", thinkingLevel: "high", }); }); test("moves thinking within one capability row", () => { const terraOff = findInitialProfileIndex(profiles, "gpt-5.6-terra", "off"); const terraHigh = moveThinkingIndex(profiles, terraOff, -1); expect(profiles[terraHigh]).toMatchObject({ capability: "terra", thinkingLevel: "high", }); }); test("skips missing capabilities and clamps missing thinking levels", () => { const solMedium = findInitialProfileIndex(profiles, "gpt-5.6-sol", "medium"); const terra = jumpCapabilityIndex(profiles, solMedium, -1); expect(profiles[terra]).toMatchObject({ capability: "terra", thinkingLevel: "high", }); const wrappedSol = jumpCapabilityIndex(profiles, terra, -1); expect(profiles[wrappedSol]).toMatchObject({ capability: "sol", thinkingLevel: "high", }); }); test("wraps both directions", () => { expect(wrapProfileIndex(-1, 9)).toBe(8); expect(wrapProfileIndex(9, 9)).toBe(0); }); });