Files
OmniRoute/tests/unit/request-defaults-store-session.test.mjs
diegosouzapw 48467bc514 feat(core): add db health checks and provider interoperability
Add automated SQLite health diagnostics with optional auto-repair,
startup and scheduled execution, authenticated API routes, an MCP tool,
and dashboard visibility for status and repair actions.

Improve provider compatibility by adding Cursor usage fetching and
v3.1.0 parity headers, introducing a per-connection Codex Responses
store opt-in with session fallback, fixing Codex non-stream combo and
SSE translation behavior, sanitizing Gemini googleSearch tool payloads
and Qwen thinking tool_choice handling, and hardening cleanup and call
log storage paths.
2026-04-13 13:11:30 -03:00

41 lines
1.5 KiB
JavaScript

import test from "node:test";
import assert from "node:assert/strict";
const { buildOpenAIStoreSessionId, ensureOpenAIStoreSessionFallback } =
await import("../../src/lib/providers/requestDefaults.ts");
test("buildOpenAIStoreSessionId normalizes external and generated session ids", () => {
assert.equal(
buildOpenAIStoreSessionId("ext:client session/abc"),
"omniroute-session-client-session-abc"
);
assert.equal(
buildOpenAIStoreSessionId(" internal:session "),
"omniroute-session-internal:session"
);
assert.equal(buildOpenAIStoreSessionId(""), undefined);
});
test("ensureOpenAIStoreSessionFallback injects session_id only when no stable cache key exists", () => {
const injected = ensureOpenAIStoreSessionFallback({ model: "gpt-5.3-codex" }, "ext:session-1");
assert.equal(injected.session_id, "omniroute-session-session-1");
const withPromptCacheKey = ensureOpenAIStoreSessionFallback(
{ model: "gpt-5.3-codex", prompt_cache_key: "cache-123" },
"ext:session-2"
);
assert.equal(withPromptCacheKey.session_id, undefined);
const withConversation = ensureOpenAIStoreSessionFallback(
{ model: "gpt-5.3-codex", conversation_id: "conv-1" },
"ext:session-3"
);
assert.equal(withConversation.session_id, undefined);
const withExplicitSession = ensureOpenAIStoreSessionFallback(
{ model: "gpt-5.3-codex", session_id: "existing-session" },
"ext:session-4"
);
assert.equal(withExplicitSession.session_id, "existing-session");
});