Files
PaperClipAI/server/src/__tests__/harness-availability.test.ts
T
Devin FoleyandPaperclip ae2afd525b Make harness choices deployment-configurable
Managed deployments need to control harness availability without changing Core policy. Add a generic environment contract and apply it across harness and model selectors, preserving saved supported profiles and validating import, team, and invite selections. Document deployment ownership in agent guidance.

Validation: focused local tests and typechecks passed; all applicable CI checks passed on the reviewed head. Greptile scored 5/5 with no unresolved comments.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-11-20 15:45:36 -08:00

31 lines
1.5 KiB
TypeScript

import { afterEach, describe, expect, it, vi } from "vitest";
import { logger } from "../middleware/logger.js";
import { getAvailableHarnesses } from "../services/harness-availability.js";
describe("deployment harness availability", () => {
afterEach(() => vi.restoreAllMocks());
it("has no built-in deployment allowlist", () => {
expect(getAvailableHarnesses({})).toBeUndefined();
});
it("accepts deployment-chosen IDs and refreshes when configuration changes", () => {
const env = { PAPERCLIP_AVAILABLE_HARNESSES: '["gemini_local","plugin:example","gemini_local"]' };
expect(getAvailableHarnesses(env)).toEqual(["gemini_local", "plugin:example"]);
env.PAPERCLIP_AVAILABLE_HARNESSES = '["pi_local"]';
expect(getAvailableHarnesses(env)).toEqual(["pi_local"]);
env.PAPERCLIP_AVAILABLE_HARNESSES = "[]";
expect(getAvailableHarnesses(env)).toEqual([]);
expect(getAvailableHarnesses({})).toBeUndefined();
});
it.each(["", "claude_local", "{}", "null", '["valid",1]', '["Invalid"]', '["has space"]', JSON.stringify(["a".repeat(129)]), JSON.stringify(Array(129).fill("codex_local")), " ".repeat(16_385)])(
"fails closed for malformed configuration %# without logging its value", raw => {
getAvailableHarnesses({});
const warn = vi.spyOn(logger, "warn").mockImplementation(() => undefined);
expect(getAvailableHarnesses({ PAPERCLIP_AVAILABLE_HARNESSES: raw })).toEqual([]);
expect(warn).toHaveBeenCalledExactlyOnceWith("PAPERCLIP_AVAILABLE_HARNESSES is invalid; harness selection is disabled");
},
);
});