mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-05-06 02:07:00 +00:00
- Remove `new Request('http://localhost/api/keys')` default arg from GET handler in src/app/api/keys/route.ts (line 26)
- Fix api-key-reveal-route.test.mjs to pass explicit Request instead of calling GET() with no args
- Add --output-dir coverage to all c8 scripts in package.json
- Add coverage.reportsDirectory: 'coverage' to vitest.config.ts and vitest.mcp.config.ts
- Fix CHANGELOG.md structure (# Changelog + [Unreleased] to top)
- Remove 30+ stale coverage-* directories from project root
- Coverage: Statements 78.76% | Branches 72.75% | Functions 80.93% | Lines 78.76% (all thresholds passed)
71 lines
2.3 KiB
JavaScript
71 lines
2.3 KiB
JavaScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
|
|
import { PuterExecutor } from "../../open-sse/executors/puter.ts";
|
|
|
|
test("PuterExecutor.buildUrl always uses Puter OpenAI endpoint", () => {
|
|
const executor = new PuterExecutor();
|
|
assert.equal(
|
|
executor.buildUrl("gpt-4.1", true),
|
|
"https://api.puter.com/puterai/openai/v1/chat/completions"
|
|
);
|
|
});
|
|
|
|
test("PuterExecutor.buildHeaders supports API key, access token and optional SSE accept", () => {
|
|
const executor = new PuterExecutor();
|
|
const apiKeyHeaders = executor.buildHeaders({ apiKey: "puter-key" }, true);
|
|
const accessTokenHeaders = executor.buildHeaders({ accessToken: "puter-token" }, false);
|
|
|
|
assert.deepEqual(apiKeyHeaders, {
|
|
"Content-Type": "application/json",
|
|
Authorization: "Bearer puter-key",
|
|
Accept: "text/event-stream",
|
|
});
|
|
assert.deepEqual(accessTokenHeaders, {
|
|
"Content-Type": "application/json",
|
|
Authorization: "Bearer puter-token",
|
|
});
|
|
});
|
|
|
|
test("PuterExecutor.transformRequest is a passthrough", () => {
|
|
const executor = new PuterExecutor();
|
|
const body = {
|
|
model: "google/gemini-2.5-pro",
|
|
messages: [{ role: "user", content: "hello" }],
|
|
};
|
|
assert.equal(executor.transformRequest(body.model, body, true, {}), body);
|
|
});
|
|
|
|
test("PuterExecutor.execute uses inherited BaseExecutor flow", async () => {
|
|
const executor = new PuterExecutor();
|
|
const originalFetch = globalThis.fetch;
|
|
let captured;
|
|
globalThis.fetch = async (url, options) => {
|
|
captured = { url: String(url), options };
|
|
return new Response(JSON.stringify({ ok: true }), {
|
|
status: 200,
|
|
headers: { "Content-Type": "application/json" },
|
|
});
|
|
};
|
|
|
|
try {
|
|
const body = {
|
|
model: "google/gemini-2.5-pro",
|
|
messages: [{ role: "user", content: "hello" }],
|
|
};
|
|
const result = await executor.execute({
|
|
model: body.model,
|
|
body,
|
|
stream: false,
|
|
credentials: { apiKey: "puter-key" },
|
|
});
|
|
|
|
assert.equal(result.response.status, 200);
|
|
assert.equal(result.transformedBody, body);
|
|
assert.equal(result.url, "https://api.puter.com/puterai/openai/v1/chat/completions");
|
|
assert.equal(captured.options.headers.Authorization, "Bearer puter-key");
|
|
assert.equal(captured.options.body, JSON.stringify(body));
|
|
} finally {
|
|
globalThis.fetch = originalFetch;
|
|
}
|
|
});
|