mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-05-05 17:56:56 +00:00
Centralize Antigravity public model definitions and use the client-visible preview aliases in provider discovery, model catalog responses, and default alias seeding. Add Gemini CLI managed-project onboarding with retries when loadCodeAssist does not return a project, and update Gemini CLI header fingerprints to match newer native clients. Improve non-stream handling by converting NDJSON event payloads into SSE-compatible parsing for stream=false requests, add PUT support for the settings API, expand Gemini schema cleanup for local refs and unsupported keys, and include Anthropic beta headers for API-key requests.
96 lines
3.5 KiB
TypeScript
96 lines
3.5 KiB
TypeScript
import { describe, test } from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import { getSettings, updateSettings } from "../../src/lib/db/settings.ts";
|
|
const settingsRoute = await import("../../src/app/api/settings/route.ts");
|
|
|
|
describe("Settings API - debugMode and hiddenSidebarItems", () => {
|
|
describe("debugMode", () => {
|
|
test("updateSettings with debugMode=true succeeds", async () => {
|
|
const result = await updateSettings({ debugMode: true });
|
|
assert.ok(result, "updateSettings should return truthy result");
|
|
|
|
const settings = await getSettings();
|
|
assert.strictEqual(settings.debugMode, true, "debugMode should be true");
|
|
});
|
|
|
|
test("updateSettings with debugMode=false succeeds", async () => {
|
|
const result = await updateSettings({ debugMode: false });
|
|
assert.ok(result, "updateSettings should return truthy result");
|
|
|
|
const settings = await getSettings();
|
|
assert.strictEqual(settings.debugMode, false, "debugMode should be false");
|
|
});
|
|
});
|
|
|
|
describe("hiddenSidebarItems", () => {
|
|
test("updateSettings with hiddenSidebarItems=['translator'] succeeds", async () => {
|
|
const result = await updateSettings({ hiddenSidebarItems: ["translator"] });
|
|
assert.ok(result, "updateSettings should return truthy result");
|
|
|
|
const settings = await getSettings();
|
|
assert.deepStrictEqual(
|
|
settings.hiddenSidebarItems,
|
|
["translator"],
|
|
"hiddenSidebarItems should contain translator"
|
|
);
|
|
});
|
|
|
|
test("updateSettings with empty hiddenSidebarItems succeeds", async () => {
|
|
const result = await updateSettings({ hiddenSidebarItems: [] });
|
|
assert.ok(result, "updateSettings should return truthy result");
|
|
|
|
const settings = await getSettings();
|
|
assert.deepStrictEqual(
|
|
settings.hiddenSidebarItems,
|
|
[],
|
|
"hiddenSidebarItems should be empty array"
|
|
);
|
|
});
|
|
});
|
|
|
|
describe("combined updates", () => {
|
|
test("updateSettings with both debugMode and hiddenSidebarItems succeeds", async () => {
|
|
const result = await updateSettings({
|
|
debugMode: true,
|
|
hiddenSidebarItems: ["translator"],
|
|
});
|
|
assert.ok(result, "updateSettings should return truthy result");
|
|
|
|
const settings = await getSettings();
|
|
assert.strictEqual(settings.debugMode, true, "debugMode should be true");
|
|
assert.deepStrictEqual(
|
|
settings.hiddenSidebarItems,
|
|
["translator"],
|
|
"hiddenSidebarItems should be updated"
|
|
);
|
|
});
|
|
|
|
test("updateSettings persists antigravitySignatureCacheMode", async () => {
|
|
const result = await updateSettings({
|
|
antigravitySignatureCacheMode: "bypass-strict",
|
|
});
|
|
assert.ok(result, "updateSettings should return truthy result");
|
|
|
|
const settings = await getSettings();
|
|
assert.strictEqual(
|
|
settings.antigravitySignatureCacheMode,
|
|
"bypass-strict",
|
|
"antigravitySignatureCacheMode should be updated"
|
|
);
|
|
});
|
|
|
|
test("PUT /api/settings reuses the PATCH update flow", async () => {
|
|
const response = await settingsRoute.PUT(
|
|
new Request("http://localhost/api/settings", {
|
|
method: "PUT",
|
|
headers: { "Content-Type": "application/json" },
|
|
body: JSON.stringify({ antigravitySignatureCacheMode: "bypass" }),
|
|
})
|
|
);
|
|
const body = await response.json();
|
|
|
|
assert.equal(response.status, 200);
|
|
assert.equal(body.antigravitySignatureCacheMode, "bypass");
|
|
});
|
|
});
|
|
});
|