// The model dropdown: which names it lists itself and when the text box opens. // Run by `npm test`, which imports the `.ts` module as it is. import assert from "node:assert/strict"; import { test } from "node:test"; import { CUSTOM_MODEL, isListedModel, modelOptions, modelSelectValue, } from "../src/agent/detail/model-choice.ts"; const KNOWN = ["haiku", "opus"]; test("the options are the agent's own, the known models and other", () => { assert.deepEqual( modelOptions(KNOWN).map((o) => o.value), ["", "haiku", "opus", CUSTOM_MODEL], ); assert.deepEqual( modelOptions([]).map((o) => o.value), ["", CUSTOM_MODEL], ); }); test("the agent's own value and the known models are listed", () => { assert.ok(isListedModel("", KNOWN)); assert.ok(isListedModel("opus", KNOWN)); assert.ok(!isListedModel("claude-opus-4-8", KNOWN)); }); test("a name the list lacks selects the custom entry", () => { assert.equal(modelSelectValue("claude-opus-4-8", KNOWN, false), CUSTOM_MODEL); assert.equal(modelSelectValue("opus", KNOWN, false), "opus"); assert.equal(modelSelectValue("", KNOWN, false), ""); }); test("an open custom entry stays selected while its name is empty or listed", () => { assert.equal(modelSelectValue("", KNOWN, true), CUSTOM_MODEL); assert.equal(modelSelectValue("opus", KNOWN, true), CUSTOM_MODEL); });