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

appSettings.test.ts

105 lines3.0 KB

1import { describe, expect, it } from "vitest";
2​
3import {
4 getAppModelOptions,
5 getSlashModelOptions,
6 normalizeCustomModelSlugs,
7 resolveAppServiceTier,
8 shouldShowFastTierIcon,
9 resolveAppModelSelection,
10} from "./appSettings";
11​
12describe("normalizeCustomModelSlugs", () => {
13 it("normalizes aliases, removes built-ins, and deduplicates values", () => {
14 expect(
15 normalizeCustomModelSlugs([
16 " custom/internal-model ",
17 "gpt-5.3-codex",
18 "5.3",
19 "custom/internal-model",
20 "",
21 null,
22 ]),
23 ).toEqual(["custom/internal-model"]);
24 });
25});
26​
27describe("getAppModelOptions", () => {
28 it("appends saved custom models after the built-in options", () => {
29 const options = getAppModelOptions("codex", ["custom/internal-model"]);
30​
31 expect(options.map((option) => option.slug)).toEqual([
32 "gpt-5.4",
33 "gpt-5.3-codex",
34 "gpt-5.3-codex-spark",
35 "gpt-5.2-codex",
36 "gpt-5.2",
37 "custom/internal-model",
38 ]);
39 });
40​
41 it("keeps the currently selected custom model available even if it is no longer saved", () => {
42 const options = getAppModelOptions("codex", [], "custom/selected-model");
43​
44 expect(options.at(-1)).toEqual({
45 slug: "custom/selected-model",
46 name: "custom/selected-model",
47 isCustom: true,
48 });
49 });
50});
51​
52describe("resolveAppModelSelection", () => {
53 it("preserves saved custom model slugs instead of falling back to the default", () => {
54 expect(resolveAppModelSelection("codex", ["galapagos-alpha"], "galapagos-alpha")).toBe(
55 "galapagos-alpha",
56 );
57 });
58​
59 it("falls back to the provider default when no model is selected", () => {
60 expect(resolveAppModelSelection("codex", [], "")).toBe("gpt-5.4");
61 });
62});
63​
64describe("getSlashModelOptions", () => {
65 it("includes saved custom model slugs for /model command suggestions", () => {
66 const options = getSlashModelOptions(
67 "codex",
68 ["custom/internal-model"],
69 "",
70 "gpt-5.3-codex",
71 );
72​
73 expect(options.some((option) => option.slug === "custom/internal-model")).toBe(true);
74 });
75​
76 it("filters slash-model suggestions across built-in and custom model names", () => {
77 const options = getSlashModelOptions(
78 "codex",
79 ["openai/gpt-oss-120b"],
80 "oss",
81 "gpt-5.3-codex",
82 );
83​
84 expect(options.map((option) => option.slug)).toEqual(["openai/gpt-oss-120b"]);
85 });
86});
87​
88describe("resolveAppServiceTier", () => {
89 it("maps automatic to no override", () => {
90 expect(resolveAppServiceTier("auto")).toBeNull();
91 });
92​
93 it("preserves explicit service tier overrides", () => {
94 expect(resolveAppServiceTier("fast")).toBe("fast");
95 expect(resolveAppServiceTier("flex")).toBe("flex");
96 });
97});
98​
99describe("shouldShowFastTierIcon", () => {
100 it("shows the fast-tier icon only for gpt-5.4 on fast tier", () => {
101 expect(shouldShowFastTierIcon("gpt-5.4", "fast")).toBe(true);
102 expect(shouldShowFastTierIcon("gpt-5.4", "auto")).toBe(false);
103 expect(shouldShowFastTierIcon("gpt-5.3-codex", "fast")).toBe(false);
104 });
105});