mirror of
https://github.com/moltbot/moltbot.git
synced 2026-04-24 07:01:49 +00:00
Tests: add provider registry contract suite
This commit is contained in:
43
src/plugins/contracts/registry.contract.test.ts
Normal file
43
src/plugins/contracts/registry.contract.test.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { providerContractRegistry, webSearchProviderContractRegistry } from "./registry.js";
|
||||
|
||||
function findProviderIdsForPlugin(pluginId: string) {
|
||||
return providerContractRegistry
|
||||
.filter((entry) => entry.pluginId === pluginId)
|
||||
.map((entry) => entry.provider.id)
|
||||
.toSorted((left, right) => left.localeCompare(right));
|
||||
}
|
||||
|
||||
function findWebSearchIdsForPlugin(pluginId: string) {
|
||||
return webSearchProviderContractRegistry
|
||||
.filter((entry) => entry.pluginId === pluginId)
|
||||
.map((entry) => entry.provider.id)
|
||||
.toSorted((left, right) => left.localeCompare(right));
|
||||
}
|
||||
|
||||
describe("plugin contract registry", () => {
|
||||
it("does not duplicate bundled provider ids", () => {
|
||||
const ids = providerContractRegistry.map((entry) => entry.provider.id);
|
||||
expect(ids).toEqual([...new Set(ids)]);
|
||||
});
|
||||
|
||||
it("does not duplicate bundled web search provider ids", () => {
|
||||
const ids = webSearchProviderContractRegistry.map((entry) => entry.provider.id);
|
||||
expect(ids).toEqual([...new Set(ids)]);
|
||||
});
|
||||
|
||||
it("keeps multi-provider plugin ownership explicit", () => {
|
||||
expect(findProviderIdsForPlugin("google")).toEqual(["google", "google-gemini-cli"]);
|
||||
expect(findProviderIdsForPlugin("minimax")).toEqual(["minimax", "minimax-portal"]);
|
||||
expect(findProviderIdsForPlugin("openai")).toEqual(["openai", "openai-codex"]);
|
||||
});
|
||||
|
||||
it("keeps bundled web search ownership explicit", () => {
|
||||
expect(findWebSearchIdsForPlugin("brave")).toEqual(["brave"]);
|
||||
expect(findWebSearchIdsForPlugin("firecrawl")).toEqual(["firecrawl"]);
|
||||
expect(findWebSearchIdsForPlugin("google")).toEqual(["gemini"]);
|
||||
expect(findWebSearchIdsForPlugin("moonshot")).toEqual(["kimi"]);
|
||||
expect(findWebSearchIdsForPlugin("perplexity")).toEqual(["perplexity"]);
|
||||
expect(findWebSearchIdsForPlugin("xai")).toEqual(["grok"]);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user