|
4 | 4 | GLOBAL_SETTINGS_KEYS, |
5 | 5 | globalSettingsSchema, |
6 | 6 | } from "../global-settings.js" |
| 7 | +import { resolveMcpDynamicLoadSettings } from "../mcp.js" |
7 | 8 |
|
8 | 9 | describe("destructive command guard global setting", () => { |
9 | 10 | it("is opt-in by default", () => { |
@@ -51,3 +52,26 @@ describe("collapseCommandOutputByDefault global setting", () => { |
51 | 52 | expect(globalSettingsSchema.safeParse({ collapseCommandOutputByDefault: "true" }).success).toBe(false) |
52 | 53 | }) |
53 | 54 | }) |
| 55 | + |
| 56 | +describe.each(["mcp.dynamicLoad.threshold", "mcp.dynamicLoad.initialK"] as const)("%s", (key) => { |
| 57 | + it.each([undefined, 1, 30, 50, 100])("round-trips %s through the settings schema", (value) => { |
| 58 | + const settings = globalSettingsSchema.parse({ [key]: value }) |
| 59 | + expect(globalSettingsSchema.parse(JSON.parse(JSON.stringify(settings)))[key]).toBe(value) |
| 60 | + expect(GLOBAL_SETTINGS_KEYS).toContain(key) |
| 61 | + }) |
| 62 | + it.each([-1, 1.5, NaN, Infinity, "30", null])("rejects %s", (value) => { |
| 63 | + expect(globalSettingsSchema.safeParse({ [key]: value }).success).toBe(false) |
| 64 | + }) |
| 65 | + it("allows zero only for the threshold", () => { |
| 66 | + expect(globalSettingsSchema.safeParse({ [key]: 0 }).success).toBe(key === "mcp.dynamicLoad.threshold") |
| 67 | + }) |
| 68 | +}) |
| 69 | + |
| 70 | +describe("runtime MCP routing defaults", () => { |
| 71 | + it.each([undefined, null, -1, 1.5, NaN, Infinity, "30", {}])("replaces invalid input %j", (value) => { |
| 72 | + expect(resolveMcpDynamicLoadSettings(value, value)).toEqual({ threshold: 50, initialK: 30 }) |
| 73 | + }) |
| 74 | + it("preserves a zero threshold and a positive limit", () => { |
| 75 | + expect(resolveMcpDynamicLoadSettings(0, 1)).toEqual({ threshold: 0, initialK: 1 }) |
| 76 | + }) |
| 77 | +}) |
0 commit comments