Some checks failed
CI / Frontend Lint (push) Has been cancelled
CI / Frontend Type Check (push) Has been cancelled
CI / Frontend Build (push) Has been cancelled
CI / Frontend E2E Tests (push) Has been cancelled
CI / Orchestrator Build (push) Has been cancelled
CI / Orchestrator Unit Tests (push) Has been cancelled
CI / Orchestrator E2E (Testcontainers) (push) Has been cancelled
CI / Contracts Compile (push) Has been cancelled
CI / Contracts Test (push) Has been cancelled
Security Scan / Dependency Vulnerability Scan (push) Has been cancelled
Security Scan / OWASP ZAP Scan (push) Has been cancelled
120 lines
4.0 KiB
TypeScript
120 lines
4.0 KiB
TypeScript
/**
|
|
* Unit tests for the EXT-* external-dependency blocker registry.
|
|
* Headless — no network, no UI.
|
|
*/
|
|
|
|
import {
|
|
EXT_BLOCKER_IDS,
|
|
BLOCKER_DETAILS,
|
|
evaluateBlockers,
|
|
activeBlockers,
|
|
logBlockerStatusAtBoot,
|
|
} from "../../src/config/externalBlockers";
|
|
|
|
describe("externalBlockers registry", () => {
|
|
it("exposes exactly the 7 blocker IDs the proxmox checker tracks", () => {
|
|
expect(EXT_BLOCKER_IDS).toEqual([
|
|
"EXT-DBIS-CORE",
|
|
"EXT-CC-PAYMENT-ADAPTERS",
|
|
"EXT-CC-AUDIT-LEDGER",
|
|
"EXT-CC-SHARED-EVENTS",
|
|
"EXT-CC-SHARED-SCHEMAS",
|
|
"EXT-FIN-GATEWAY",
|
|
"EXT-CHAIN138-CI-RPC",
|
|
]);
|
|
});
|
|
|
|
it("has a detail record for every id", () => {
|
|
for (const id of EXT_BLOCKER_IDS) {
|
|
expect(BLOCKER_DETAILS[id]).toBeDefined();
|
|
expect(BLOCKER_DETAILS[id].id).toBe(id);
|
|
expect(BLOCKER_DETAILS[id].title.length).toBeGreaterThan(0);
|
|
expect(BLOCKER_DETAILS[id].description.length).toBeGreaterThan(0);
|
|
}
|
|
});
|
|
});
|
|
|
|
describe("evaluateBlockers()", () => {
|
|
it("marks everything active on an empty env", () => {
|
|
const records = evaluateBlockers({});
|
|
expect(records).toHaveLength(EXT_BLOCKER_IDS.length);
|
|
expect(records.every((r) => r.status === "active")).toBe(true);
|
|
});
|
|
|
|
it("resolves EXT-DBIS-CORE when DBIS_CORE_URL is set", () => {
|
|
const records = evaluateBlockers({ DBIS_CORE_URL: "http://x.test" });
|
|
const rec = records.find((r) => r.id === "EXT-DBIS-CORE");
|
|
expect(rec?.status).toBe("resolved");
|
|
expect(rec?.resolvedVia).toBe("DBIS_CORE_URL");
|
|
});
|
|
|
|
it("resolves EXT-FIN-GATEWAY when FIN_SANDBOX_URL is set", () => {
|
|
const records = evaluateBlockers({ FIN_SANDBOX_URL: "http://fin.test" });
|
|
expect(records.find((r) => r.id === "EXT-FIN-GATEWAY")?.status).toBe("resolved");
|
|
});
|
|
|
|
it("resolves EXT-CHAIN138-CI-RPC when CHAIN_138_RPC_URL is set", () => {
|
|
const records = evaluateBlockers({
|
|
CHAIN_138_RPC_URL: "https://rpc.public-0138.defi-oracle.io",
|
|
});
|
|
expect(records.find((r) => r.id === "EXT-CHAIN138-CI-RPC")?.status).toBe("resolved");
|
|
});
|
|
|
|
it("leaves cc-* scaffold blockers active regardless of env", () => {
|
|
const records = evaluateBlockers({
|
|
DBIS_CORE_URL: "http://x",
|
|
FIN_SANDBOX_URL: "http://y",
|
|
CHAIN_138_RPC_URL: "http://z",
|
|
});
|
|
const scaffoldIds = [
|
|
"EXT-CC-PAYMENT-ADAPTERS",
|
|
"EXT-CC-AUDIT-LEDGER",
|
|
"EXT-CC-SHARED-EVENTS",
|
|
"EXT-CC-SHARED-SCHEMAS",
|
|
];
|
|
for (const id of scaffoldIds) {
|
|
expect(records.find((r) => r.id === id)?.status).toBe("active");
|
|
}
|
|
});
|
|
|
|
it("treats empty-string env var as unset (not resolved)", () => {
|
|
const records = evaluateBlockers({ DBIS_CORE_URL: "" });
|
|
expect(records.find((r) => r.id === "EXT-DBIS-CORE")?.status).toBe("active");
|
|
});
|
|
});
|
|
|
|
describe("activeBlockers()", () => {
|
|
it("returns 7 when env is empty", () => {
|
|
expect(activeBlockers({})).toHaveLength(7);
|
|
});
|
|
|
|
it("returns 6 when Chain-138 RPC is resolved", () => {
|
|
const ids = activeBlockers({
|
|
CHAIN_138_RPC_URL: "https://rpc.public-0138.defi-oracle.io",
|
|
});
|
|
expect(ids).not.toContain("EXT-CHAIN138-CI-RPC");
|
|
expect(ids).toHaveLength(6);
|
|
});
|
|
});
|
|
|
|
describe("logBlockerStatusAtBoot()", () => {
|
|
it("emits a single summary with active + resolved counts", () => {
|
|
const calls: Array<{ obj: Record<string, unknown>; msg: string }> = [];
|
|
const fakeLogger = {
|
|
info: (obj: Record<string, unknown>, msg: string) => calls.push({ obj, msg }),
|
|
};
|
|
const prev = process.env.CHAIN_138_RPC_URL;
|
|
process.env.CHAIN_138_RPC_URL = "https://rpc.public-0138.defi-oracle.io";
|
|
try {
|
|
logBlockerStatusAtBoot(fakeLogger);
|
|
} finally {
|
|
if (prev === undefined) delete process.env.CHAIN_138_RPC_URL;
|
|
else process.env.CHAIN_138_RPC_URL = prev;
|
|
}
|
|
expect(calls).toHaveLength(1);
|
|
expect(calls[0].msg).toMatch(/active,.*resolved/);
|
|
expect((calls[0].obj.activeCount as number) + (calls[0].obj.resolvedCount as number)).toBe(7);
|
|
expect(calls[0].obj.resolvedCount).toBeGreaterThanOrEqual(1);
|
|
});
|
|
});
|