From 9e190f1f6adbf893dbbf9b4ac7bb8af1155f17a5 Mon Sep 17 00:00:00 2001 From: Shakker Date: Sat, 25 Apr 2026 03:43:42 +0100 Subject: [PATCH] test: cover manifest model catalog planner --- src/model-catalog/manifest-planner.test.ts | 124 +++++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 src/model-catalog/manifest-planner.test.ts diff --git a/src/model-catalog/manifest-planner.test.ts b/src/model-catalog/manifest-planner.test.ts new file mode 100644 index 00000000000..a4490bd97b9 --- /dev/null +++ b/src/model-catalog/manifest-planner.test.ts @@ -0,0 +1,124 @@ +import { describe, expect, it } from "vitest"; +import { planManifestModelCatalogRows } from "./index.js"; + +describe("manifest model catalog planner", () => { + it("builds manifest rows from plugin-owned catalog providers", () => { + const plan = planManifestModelCatalogRows({ + registry: { + plugins: [ + { + id: "moonshot", + modelCatalog: { + providers: { + Moonshot: { + api: "openai-responses", + baseUrl: "https://api.moonshot.ai/v1", + models: [ + { + id: "kimi-k2.6", + input: ["text", "image"], + contextWindow: 256000, + }, + ], + }, + }, + }, + }, + ], + }, + }); + + expect(plan.entries).toEqual([ + { + pluginId: "moonshot", + provider: "moonshot", + rows: [ + { + provider: "moonshot", + id: "kimi-k2.6", + ref: "moonshot/kimi-k2.6", + mergeKey: "moonshot::kimi-k2.6", + name: "kimi-k2.6", + source: "manifest", + input: ["text", "image"], + reasoning: false, + status: "available", + api: "openai-responses", + baseUrl: "https://api.moonshot.ai/v1", + contextWindow: 256000, + }, + ], + }, + ]); + expect(plan.rows.map((row) => row.ref)).toEqual(["moonshot/kimi-k2.6"]); + }); + + it("filters providers before row planning", () => { + const plan = planManifestModelCatalogRows({ + providerFilter: "openrouter", + registry: { + plugins: [ + { + id: "moonshot", + modelCatalog: { + providers: { + moonshot: { + models: [{ id: "kimi-k2.6" }], + }, + }, + }, + }, + { + id: "openrouter", + modelCatalog: { + providers: { + openrouter: { + models: [{ id: "anthropic/claude-sonnet-4.6" }], + }, + }, + }, + }, + ], + }, + }); + + expect(plan.entries.map((entry) => entry.pluginId)).toEqual(["openrouter"]); + expect(plan.rows.map((row) => row.ref)).toEqual(["openrouter/anthropic/claude-sonnet-4.6"]); + }); + + it("keeps the first registry row for duplicate provider/model keys", () => { + const plan = planManifestModelCatalogRows({ + registry: { + plugins: [ + { + id: "z-first", + modelCatalog: { + providers: { + openai: { + models: [{ id: "gpt-5.4", name: "First GPT-5.4" }], + }, + }, + }, + }, + { + id: "a-second", + modelCatalog: { + providers: { + openai: { + models: [{ id: "GPT-5.4", name: "Second GPT-5.4" }], + }, + }, + }, + }, + ], + }, + }); + + expect(plan.entries).toHaveLength(2); + expect(plan.rows).toHaveLength(1); + expect(plan.rows[0]).toMatchObject({ + mergeKey: "openai::gpt-5.4", + name: "First GPT-5.4", + }); + }); +});