mirror of
https://git.zavage.net/Zavage-Software/search-with-chatgpt-powered-by-openai-extension.git
synced 2026-08-31 22:20:47 -06:00
fix: prefer the focused frame, bound model length, drop dead flag
This commit is contained in:
+15
-1
@@ -1,7 +1,7 @@
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
|
||||
import { DEFAULT_SETTINGS } from "../lib/defaults.js";
|
||||
import { DEFAULT_SETTINGS, MAX_MODEL_CHARS } from "../lib/defaults.js";
|
||||
import { mergeSettings } from "../lib/settings.js";
|
||||
|
||||
test("empty object yields the defaults", () => {
|
||||
@@ -78,3 +78,17 @@ test("mergeSettings does not mutate DEFAULT_SETTINGS", () => {
|
||||
mergeSettings({ model: "mutated" });
|
||||
assert.equal(DEFAULT_SETTINGS.model, "");
|
||||
});
|
||||
|
||||
// An unbounded model string can, on its own, push the finished URL over
|
||||
// MAX_URL_CHARS (lib/build-url.js), which silently drops `q` — the user's
|
||||
// selection vanishes with no signal. mergeSettings() must bound `model` the
|
||||
// same way it already bounds an out-of-range openIn: fall back to the default.
|
||||
test("a model at exactly MAX_MODEL_CHARS is accepted", () => {
|
||||
const model = "m".repeat(MAX_MODEL_CHARS);
|
||||
assert.equal(mergeSettings({ model }).model, model);
|
||||
});
|
||||
|
||||
test("a model one character over MAX_MODEL_CHARS falls back to the default", () => {
|
||||
const model = "m".repeat(MAX_MODEL_CHARS + 1);
|
||||
assert.equal(mergeSettings({ model }).model, DEFAULT_SETTINGS.model);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user