Open History to see the last commit
1import { describe, expect, it } from "vite-plus/test";
2
3import type { ModelCapabilities } from "@t3tools/contracts";
4
5import {
6 applyProviderOptionSelection,
7 providerOptionValueLabels,
8 resolveProviderOptionDescriptors,
9} from "./providerOptions";
10
11const CODEX_CAPABILITIES: ModelCapabilities = {
12 optionDescriptors: [
13 {
14 id: "reasoningEffort",
15 label: "Reasoning",
16 type: "select",
17 options: [
18 { id: "medium", label: "Medium", isDefault: true },
19 { id: "high", label: "High" },
20 ],
21 currentValue: "medium",
22 },
23 {
24 id: "serviceTier",
25 label: "Service Tier",
26 type: "select",
27 options: [
28 { id: "default", label: "Standard", isDefault: true },
29 { id: "priority", label: "Fast" },
30 ],
31 currentValue: "default",
32 },
33 ],
34};
35
36describe("mobile provider options", () => {
37 it("summarizes the option values currently in effect", () => {
38 const descriptors = resolveProviderOptionDescriptors({
39 capabilities: CODEX_CAPABILITIES,
40 selections: undefined,
41 });
42
43 expect(providerOptionValueLabels(descriptors)).toEqual(["Medium", "Standard"]);
44 });
45
46 it("updates generic select options without knowing provider-specific ids", () => {
47 const descriptors = resolveProviderOptionDescriptors({
48 capabilities: CODEX_CAPABILITIES,
49 selections: undefined,
50 });
51
52 expect(
53 applyProviderOptionSelection(descriptors, { id: "serviceTier", value: "priority" }),
54 ).toEqual([
55 { id: "reasoningEffort", value: "medium" },
56 { id: "serviceTier", value: "priority" },
57 ]);
58 // Choices the model doesn't advertise are rejected, not stored.
59 expect(
60 applyProviderOptionSelection(descriptors, { id: "serviceTier", value: "turbo" }),
61 ).toBeNull();
62 expect(applyProviderOptionSelection(descriptors, { id: "unknown", value: "high" })).toBeNull();
63 });
64
65 it("treats an unspecified boolean capability as off", () => {
66 const descriptors = resolveProviderOptionDescriptors({
67 capabilities: {
68 optionDescriptors: [{ id: "fastMode", label: "Fast Mode", type: "boolean" }],
69 },
70 selections: undefined,
71 });
72
73 expect(providerOptionValueLabels(descriptors)).toEqual([]);
74 expect(applyProviderOptionSelection(descriptors, { id: "fastMode", value: true })).toEqual([
75 { id: "fastMode", value: true },
76 ]);
77 });
78});