Files
OmniRoute/tests/unit/mitm-handler-copilot.test.ts
Hernan Javier Ardila Sanchez fd26e601a2 fix(dashboard): use lightweight ping endpoint for MaintenanceBanner (fixes #3040) (#3043)
Integrated into release/v3.8.8. Applied review fixes: moved the SELECT 1 into a pingDb() db helper (no raw SQL in route, Hard Rule #5) + the 503 catch no longer leaks err.message (Hard Rule #12). Thanks @herjarsa!
2026-06-01 14:30:17 -03:00

22 lines
859 B
TypeScript

import test from "node:test";
import assert from "node:assert/strict";
import { CopilotHandler } from "../../src/mitm/handlers/copilot.ts";
import { runHandler } from "./_mitmHandlerHarness.ts";
test("copilot handler — rewrites model and forwards to /v1/chat/completions", async () => {
const r = await runHandler(
new CopilotHandler(),
{ model: "gpt-4o", messages: [] },
"claude-3.5-sonnet"
);
assert.ok(r.fetchCalled);
assert.equal(r.status, 200);
assert.ok(r.fetchUrl?.endsWith("/v1/chat/completions"));
const sent = JSON.parse(r.fetchBody);
assert.equal(sent.model, "claude-3.5-sonnet");
// AgentBridge correlation headers must be present.
const headers = r.fetchHeaders as Record<string, string>;
assert.equal(headers["x-omniroute-source"], "agent-bridge");
assert.equal(headers["x-omniroute-agent"], "copilot");
});