mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-05-05 09:46:30 +00:00
- Add .catch() to initial and periodic sync promises (Gemini, Kilo) - Wrap JSON.parse in try-catch for corrupted DB data (Kilo) - Wrap response.json() in try-catch for invalid LiteLLM JSON (Kilo) - Validate PRICING_SYNC_INTERVAL (guard against NaN/0 → tight loop) (Copilot) - Validate and allowlist sources — reject unknown, prevent empty sync from clearing pricing_synced data (Copilot, Kilo) - Extract merge loop into shared iteration to reduce duplication (Gemini) - Add data/warnings fields to MCP output schema (Copilot) - Remove unused z import in vitest (Copilot) - Filter non-string entries from sources array in API route (Copilot) - Track active interval for accurate getSyncStatus().nextSync (Copilot)
59 lines
1.9 KiB
TypeScript
59 lines
1.9 KiB
TypeScript
import { describe, it, expect } from "vitest";
|
|
import { syncPricingInput, syncPricingTool, MCP_TOOLS, MCP_TOOL_MAP } from "../schemas/tools.ts";
|
|
|
|
describe("omniroute_sync_pricing MCP tool schema", () => {
|
|
it("should be registered in MCP_TOOLS", () => {
|
|
const tool = MCP_TOOLS.find((t) => t.name === "omniroute_sync_pricing");
|
|
expect(tool).toBeDefined();
|
|
expect(tool?.phase).toBe(2);
|
|
});
|
|
|
|
it("should be in MCP_TOOL_MAP", () => {
|
|
expect(MCP_TOOL_MAP["omniroute_sync_pricing"]).toBeDefined();
|
|
});
|
|
|
|
it("should require pricing:write scope", () => {
|
|
expect(syncPricingTool.scopes).toContain("pricing:write");
|
|
});
|
|
|
|
it("should have full audit level", () => {
|
|
expect(syncPricingTool.auditLevel).toBe("full");
|
|
});
|
|
|
|
it("should validate empty input (all fields optional)", () => {
|
|
const result = syncPricingInput.safeParse({});
|
|
expect(result.success).toBe(true);
|
|
});
|
|
|
|
it("should validate input with sources array", () => {
|
|
const result = syncPricingInput.safeParse({ sources: ["litellm"] });
|
|
expect(result.success).toBe(true);
|
|
});
|
|
|
|
it("should validate input with dryRun", () => {
|
|
const result = syncPricingInput.safeParse({ dryRun: true });
|
|
expect(result.success).toBe(true);
|
|
});
|
|
|
|
it("should validate full input", () => {
|
|
const result = syncPricingInput.safeParse({
|
|
sources: ["litellm"],
|
|
dryRun: false,
|
|
});
|
|
expect(result.success).toBe(true);
|
|
});
|
|
|
|
it("should reject invalid sources type", () => {
|
|
const result = syncPricingInput.safeParse({ sources: "litellm" });
|
|
expect(result.success).toBe(false);
|
|
});
|
|
|
|
it("should reject invalid dryRun type", () => {
|
|
const result = syncPricingInput.safeParse({ dryRun: "yes" });
|
|
expect(result.success).toBe(false);
|
|
});
|
|
|
|
it("should point to correct source endpoint", () => {
|
|
expect(syncPricingTool.sourceEndpoints).toContain("/api/pricing/sync");
|
|
});
|
|
});
|