2026-08-27 19:30:37 -07:00
|
|
|
import assert from "node:assert/strict";
|
|
|
|
|
import test from "node:test";
|
2026-10-02 13:56:44 -07:00
|
|
|
import { buildQuickQuestionRequest, pickQuickQuestionModel } from "../src/lib/quick-question.ts";
|
|
|
|
|
|
|
|
|
|
test("quick questions default to chat-latest before and after the model catalog loads", () => {
|
|
|
|
|
for (const options of [[], ["gpt-4.1-mini"], ["gpt-4.1-mini", "chat-latest"]]) {
|
|
|
|
|
const model = pickQuickQuestionModel("openai", options);
|
|
|
|
|
assert.equal(model, "chat-latest");
|
|
|
|
|
assert.deepEqual(buildQuickQuestionRequest({ provider: "openai", model, content: "What is UTC?" }), {
|
|
|
|
|
provider: "openai",
|
|
|
|
|
model: "chat-latest",
|
|
|
|
|
question: "What is UTC?",
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test("quick questions preserve saved models and use provider-specific choices when switching providers", () => {
|
|
|
|
|
assert.equal(pickQuickQuestionModel("openai", ["chat-latest"], " gpt-4.1-mini "), "gpt-4.1-mini");
|
|
|
|
|
assert.equal(pickQuickQuestionModel("openai", ["gpt-4.1-mini"], " "), "chat-latest");
|
|
|
|
|
assert.equal(pickQuickQuestionModel("anthropic", ["claude-3-5-sonnet-latest"]), "claude-3-5-sonnet-latest");
|
|
|
|
|
assert.equal(pickQuickQuestionModel("anthropic", ["claude-3-5-sonnet-latest"], "claude-3-haiku"), "claude-3-haiku");
|
|
|
|
|
assert.equal(pickQuickQuestionModel("anthropic", []), "");
|
|
|
|
|
assert.equal(pickQuickQuestionModel("openai", ["gpt-4.1-mini", "chat-latest"]), "chat-latest");
|
|
|
|
|
});
|
2026-08-27 19:30:37 -07:00
|
|
|
|
|
|
|
|
test("quick question requests use the dedicated server endpoint shape", () => {
|
|
|
|
|
const request = buildQuickQuestionRequest({
|
|
|
|
|
provider: "openai",
|
|
|
|
|
model: "gpt-4.1-mini",
|
|
|
|
|
content: "How do I reset my password?",
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
assert.deepEqual(request, {
|
|
|
|
|
provider: "openai",
|
|
|
|
|
model: "gpt-4.1-mini",
|
|
|
|
|
question: "How do I reset my password?",
|
|
|
|
|
});
|
|
|
|
|
assert.equal("additionalSystemPrompt" in request, false);
|
|
|
|
|
});
|