Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

appSettings.test.ts

59 lines1.6 KB

1import { describe, expect, it } from "vitest";
2​
3import {
4 getAppModelOptions,
5 normalizeCustomModelSlugs,
6 resolveAppModelSelection,
7} from "./appSettings";
8​
9describe("normalizeCustomModelSlugs", () => {
10 it("normalizes aliases, removes built-ins, and deduplicates values", () => {
11 expect(
12 normalizeCustomModelSlugs([
13 " custom/internal-model ",
14 "gpt-5.3-codex",
15 "5.3",
16 "custom/internal-model",
17 "",
18 null,
19 ]),
20 ).toEqual(["custom/internal-model"]);
21 });
22});
23​
24describe("getAppModelOptions", () => {
25 it("appends saved custom models after the built-in options", () => {
26 const options = getAppModelOptions("codex", ["custom/internal-model"]);
27​
28 expect(options.map((option) => option.slug)).toEqual([
29 "gpt-5.4",
30 "gpt-5.3-codex",
31 "gpt-5.3-codex-spark",
32 "gpt-5.2-codex",
33 "gpt-5.2",
34 "custom/internal-model",
35 ]);
36 });
37​
38 it("keeps the currently selected custom model available even if it is no longer saved", () => {
39 const options = getAppModelOptions("codex", [], "custom/selected-model");
40​
41 expect(options.at(-1)).toEqual({
42 slug: "custom/selected-model",
43 name: "custom/selected-model",
44 isCustom: true,
45 });
46 });
47});
48​
49describe("resolveAppModelSelection", () => {
50 it("preserves saved custom model slugs instead of falling back to the default", () => {
51 expect(resolveAppModelSelection("codex", ["galapagos-alpha"], "galapagos-alpha")).toBe(
52 "galapagos-alpha",
53 );
54 });
55​
56 it("falls back to the provider default when no model is selected", () => {
57 expect(resolveAppModelSelection("codex", [], "")).toBe("gpt-5.4");
58 });
59});