Files
OmniRoute/tests/unit/freebuff-provider.test.ts
Praveen K Palaniswamy 65e81158ab fix(ollama): route models by advertised capability (#11088)
Landed with the design call resolved per the owner's pick — **option 1**: the synced store is now endpoint-agnostic (persistDiscoveredModels and managedModelImport no longer drop non-chat models at write time), and chat selectability moved to read time (auto-pool expansion in autoStrategy applies filterChatSelectableModels; the models-route projection already had its chatOnly filter). Your discovery test now passes end-to-end (3/3): /api/show capabilities persist per connection and image/embedding requests route through the advertising host.

Reconciliation notes: conflicted areas merged onto the current tip (adobe discovery import, requestedModel preflight signature, resolvedProvider fast-path coexists with the synced-route override — explicit resolution wins); carried base-red drains (#10055 memoization, #11071 test variants) dropped as already-landed; the managed-model-import exclusion test was propagated to the new contract (image/video models persist; the read filter still hides them from chat pickers — pinned by a new assertion). Full battery: 205/206 focused (the one red is a confirmed periodic-timer timing flake on the loaded devbox — 20/20 isolated), autoCombo vitest 30/30, combo suites 46/46, gates + typecheck clean.

Thank you @yourspraveen — the capability probe + routing design was right; it just needed the store contract opened up. Fixes #11087.
2026-08-23 11:45:01 -03:00

60 lines
2.6 KiB
TypeScript

import test from "node:test";
import assert from "node:assert/strict";
import { FreebuffExecutor } from "../../open-sse/executors/freebuff.ts";
import type { ExecuteInput } from "../../open-sse/executors/base.ts";
import { freebuffProvider } from "../../open-sse/config/providers/registry/freebuff/index.ts";
import { APIKEY_PROVIDERS_GATEWAYS } from "../../src/shared/constants/providers/apikey/gateways.ts";
import { validateFreebuffProvider } from "../../src/lib/providers/validation.ts";
test("FreebuffExecutor: constructor initializes provider name correctly", () => {
const executor = new FreebuffExecutor();
assert.equal(executor.getProvider(), "freebuff");
});
test("FreebuffExecutor: returns 401 response when credentials are missing", async () => {
const executor = new FreebuffExecutor();
const res = await executor.execute({
model: "deepseek/deepseek-v4-flash",
body: { messages: [{ role: "user", content: "hello" }] },
stream: false,
credentials: { apiKey: "" },
} as unknown as ExecuteInput);
assert.equal(res.response.status, 401);
const data = (await res.response.json()) as { error: { message: string } };
assert.match(data.error.message, /Freebuff Auth Token required/i);
});
test("freebuffProvider: registry entry has valid structure and catalog", () => {
assert.equal(freebuffProvider.id, "freebuff");
assert.equal(freebuffProvider.format, "openai");
assert.equal(freebuffProvider.executor, "freebuff");
assert.equal(freebuffProvider.baseUrl, "https://www.codebuff.com/api/v1");
assert.ok(Array.isArray(freebuffProvider.models));
assert.ok(freebuffProvider.models.length >= 8);
const flash = freebuffProvider.models.find((m) => m.id === "deepseek/deepseek-v4-flash");
assert.ok(flash, "deepseek/deepseek-v4-flash must exist in freebuff models");
assert.equal(flash?.supportsReasoning, true);
const minimax = freebuffProvider.models.find((m) => m.id === "minimax/minimax-m3");
assert.ok(minimax, "minimax/minimax-m3 must exist in freebuff models");
assert.equal(minimax?.supportsVision, true);
});
test("APIKEY_PROVIDERS_GATEWAYS: freebuff gateway metadata is defined", () => {
const fb = APIKEY_PROVIDERS_GATEWAYS.freebuff;
assert.ok(fb, "freebuff must be in APIKEY_PROVIDERS_GATEWAYS");
assert.equal(fb.id, "freebuff");
assert.equal(fb.name, "Freebuff");
assert.equal(fb.color, "#10B981");
assert.equal(fb.hasFree, true);
});
test("validateFreebuffProvider: returns invalid when apiKey is empty", async () => {
const res = await validateFreebuffProvider({ apiKey: "" });
assert.equal(res.valid, false);
assert.match(res.error || "", /Freebuff Auth Token required/i);
});