swarm-ui: pick an agent's model from a dropdown of the models the swarm knows, with an other entry for any name
This commit is contained in:
parent
58236e1b7f
commit
658178f9db
1 changed files with 165 additions and 5 deletions
40
frontend/packages/swarm-ui/test/model-choice.test.mjs
Normal file
40
frontend/packages/swarm-ui/test/model-choice.test.mjs
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
// 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);
|
||||
});
|
||||
Loading…
Reference in a new issue