Files
OmniRoute/tests/unit/radar-localized-feed.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

61 lines
2.2 KiB
TypeScript

import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import { test } from "node:test";
import { RadarFeedSchema } from "../../src/lib/radar/feedSchema.ts";
const fixture = JSON.parse(
readFileSync(new URL("../fixtures/radar-feed-canonical.json", import.meta.url), "utf8")
) as Record<string, unknown>;
test("canonical fixture carries D25 localized setup and accepts localized quirks", () => {
const localized = structuredClone(fixture) as {
models: Array<{ setup: { steps: unknown[] } | null }>;
quirks: Array<{ title: unknown; body: unknown }>;
};
localized.quirks = [
{
slug: "shared-pool",
title: { en: "Shared quota", pt: "Cota compartilhada" },
body: { en: "Models share one pool." },
severity: "info",
targets: [{ provider: "groq", modelGlob: null }],
},
];
const parsed = RadarFeedSchema.parse(localized);
assert.deepEqual(parsed.models[0]!.setup!.steps[0], {
en: "Create a free account in the Groq console",
pt: "Crie uma conta gratuita no console da Groq",
});
});
test("RadarFeedSchema preserves schema-v1 legacy setup and quirk strings", () => {
const legacy = structuredClone(fixture) as {
models: Array<{ setup: { steps: unknown[] } | null }>;
quirks: Array<{ title: unknown; body: unknown }>;
};
legacy.models[0]!.setup!.steps[0] = "Create an account";
legacy.quirks[0]!.title = "Shared quota";
legacy.quirks[0]!.body = "Models share one pool.";
const parsed = RadarFeedSchema.parse(legacy);
assert.equal(parsed.models[0]!.setup!.steps[0], "Create an account");
assert.equal(parsed.quirks[0]!.title, "Shared quota");
assert.equal(parsed.quirks[0]!.body, "Models share one pool.");
});
test("RadarFeedSchema rejects unsafe setup.keyUrl values", () => {
for (const keyUrl of [
"http://console.example.test/keys",
"https://user:secret@console.example.test/keys",
"https://console.example.test:444/keys",
]) {
const unsafe = structuredClone(fixture) as {
models: Array<{ setup: { keyUrl: string | null } | null }>;
};
assert.ok(unsafe.models[0]?.setup);
unsafe.models[0]!.setup!.keyUrl = keyUrl;
assert.equal(RadarFeedSchema.safeParse(unsafe).success, false, keyUrl);
}
});