Files
PaperClipAI/server/src/services/adapter-registry-bootstrap.reconcile.test.ts
T
DottaandPaperclip 8f822bfcf7 fix(cloud): persist configuration and load release-image packages (#18335)
Land the approved Cloud configuration and release-image package stack.

Includes the separately reviewed adapter settings (#18335), external adapters (#18333), bundled plugins (#18336), startup configuration (#18339), and migration/package checks (#18341).

Includes the final image-owned loader and linked-dependency inventory corrections.

Verified stack head: 462716170d.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-10-30 19:21:33 +00:00

45 lines
1.5 KiB
TypeScript

import { describe, expect, it, vi } from "vitest";
const setAdapterDisabled = vi.fn();
vi.mock("../adapters/registry.js", async (orig) => ({
...(await orig()),
listServerAdapters: () => [
{ type: "claude_local" },
{ type: "opencode_local" },
{ type: "pi_local" },
],
}));
vi.mock("./adapter-plugin-store.js", () => ({
listAdapterPlugins: () => [],
setAdapterDisabled: (type: string, disabled: boolean) => setAdapterDisabled(type, disabled),
}));
const { reconcileAdapterAvailability } = await import("./adapter-registry-bootstrap.js");
describe("reconcileAdapterAvailability", () => {
it("is a no-op when registry is null", () => {
setAdapterDisabled.mockReset();
expect(reconcileAdapterAvailability(null)).toEqual({ enabled: [], disabled: [] });
expect(setAdapterDisabled).not.toHaveBeenCalled();
});
it("enables declared, disables everything else (e.g. drops claude_local)", () => {
setAdapterDisabled.mockReset();
const result = reconcileAdapterAvailability([
{ adapterType: "opencode_local", enabled: true },
]);
expect(result.enabled).toEqual(["opencode_local"]);
expect(result.disabled.sort()).toEqual(["claude_local", "pi_local"]);
expect(setAdapterDisabled).not.toHaveBeenCalled();
});
it("throws when a declared adapter has no installed implementation", () => {
setAdapterDisabled.mockReset();
expect(() =>
reconcileAdapterAvailability([{ adapterType: "ghost_adapter", enabled: true }]),
).toThrow(/no installed adapter: ghost_adapter/);
});
});