Update hivegrid-cloud reference to latest main
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e98d38e716
commit
7b21524c86
3781 files changed
+373484
-225607
No files matched your search
+60
@@ -0,0 +1,60 @@
|
||||
import { beforeEach, describe, expect, it } from "vitest";
|
||||
import {
|
||||
checkCatalogDrift,
|
||||
clearIntegrationAdapters,
|
||||
getIntegrationAdapter,
|
||||
listIntegrationAdapterKeys,
|
||||
registerIntegrationAdapter,
|
||||
type IntegrationAdapter,
|
||||
} from "./integration-adapters.js";
|
||||
|
||||
// R-P5 — type-safe adapter registry + drift check (DoD #2). A new integration is
|
||||
// added by registering an adapter (no core change); drift between registry and
|
||||
// the App catalog surfaces a Klartext warning.
|
||||
|
||||
const fakeAdapter = (key: string): IntegrationAdapter => ({
|
||||
key,
|
||||
connectionType: "api_key",
|
||||
validateConnection: () => Promise.resolve({ ok: true, health: "active", messageKey: "integrations.health.active" }),
|
||||
healthCheck: () => Promise.resolve({ ok: true, health: "active", messageKey: "integrations.health.active" }),
|
||||
sync: () => Promise.resolve({ items: [], summaryKey: "integrations.sync.summary.empty" }),
|
||||
});
|
||||
|
||||
beforeEach(() => clearIntegrationAdapters());
|
||||
|
||||
describe("integration adapter registry", () => {
|
||||
it("registers and looks up an adapter by key", () => {
|
||||
registerIntegrationAdapter(fakeAdapter("acme-crm"));
|
||||
expect(getIntegrationAdapter("acme-crm")?.connectionType).toBe("api_key");
|
||||
expect(getIntegrationAdapter("missing")).toBeUndefined();
|
||||
});
|
||||
|
||||
it("lists registered keys sorted", () => {
|
||||
registerIntegrationAdapter(fakeAdapter("zeta"));
|
||||
registerIntegrationAdapter(fakeAdapter("alpha"));
|
||||
expect(listIntegrationAdapterKeys()).toEqual(["alpha", "zeta"]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("checkCatalogDrift", () => {
|
||||
it("reports in-sync when adapters and catalog match", () => {
|
||||
const drift = checkCatalogDrift(["gmail", "mollie"], ["mollie", "gmail"]);
|
||||
expect(drift.inSync).toBe(true);
|
||||
expect(drift.missingAdapters).toEqual([]);
|
||||
expect(drift.orphanAdapters).toEqual([]);
|
||||
});
|
||||
|
||||
it("flags a catalog App with no adapter (cannot connect)", () => {
|
||||
const drift = checkCatalogDrift(["gmail"], ["gmail", "aircall"]);
|
||||
expect(drift.inSync).toBe(false);
|
||||
expect(drift.missingAdapters).toEqual(["aircall"]);
|
||||
expect(drift.orphanAdapters).toEqual([]);
|
||||
});
|
||||
|
||||
it("flags an orphan adapter with no catalog App (invisible)", () => {
|
||||
const drift = checkCatalogDrift(["gmail", "legacy"], ["gmail"]);
|
||||
expect(drift.inSync).toBe(false);
|
||||
expect(drift.missingAdapters).toEqual([]);
|
||||
expect(drift.orphanAdapters).toEqual(["legacy"]);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user