Files
omp-pygienium/tests/extensibility.test.ts

63 lines
2.2 KiB
TypeScript

/**
* extensibility.test.ts — the registry extensibility claim (task 14).
*
* Proves a NEW check registered via the public API yields a working
* `/pygienium-<name>` command with ZERO `index.ts` command-wiring changes: an
* in-test `registerCheck()` call makes the generic command-binding path
* (`registerPygieniumCommands`, the exact function `index.ts` calls) expose
* `/pygienium-witness` and `/pygienium-help` lists it. The shipped checks are
* each exercised by their own test files, so this suite only needs a synthetic
* witness.
*/
import { describe, expect, it, afterEach } from "bun:test";
import {
clearChecks,
getCheck,
getAllChecks,
registerCheck,
type CheckDefinition,
} from "../src/checks/registry.js";
import { registerPygieniumCommands } from "../src/commands.js";
import { buildPygieniumHelpLines } from "../src/help.js";
/** A synthetic check registered only for this suite. */
const witnessCheck: CheckDefinition = {
name: "witness",
label: "Witness",
description: "Test-only check proving zero-wiring extensibility.",
agentName: "scanner",
fixAgentName: "fixer",
phaseId: "witness",
buildScanTask: () =>
"# Task: witness scan\nwrite findings.md: witness: 0 issues",
buildFixTask: () => "# Task: witness fix\nwrite changes.md: witness: 0 edits",
gate: () => undefined,
};
describe("registry extensibility (task 14)", () => {
afterEach(() => clearChecks());
it("a registered check is visible via getCheck/getAllChecks", () => {
registerCheck(witnessCheck);
expect(getCheck("witness")).toBe(witnessCheck);
expect(getAllChecks().some((c) => c.name === "witness")).toBe(true);
});
it("registerPygieniumCommands exposes /pygienium-<name> (zero wiring)", () => {
registerCheck(witnessCheck);
const names: string[] = [];
registerPygieniumCommands((name) => names.push(name));
expect(names).toContain("pygienium-witness");
// And the operator commands are still wired.
expect(names).toContain("pygienium-help");
expect(names).toContain("pygienium-all");
});
it("/pygienium-help lists a registered check", () => {
registerCheck(witnessCheck);
const text = buildPygieniumHelpLines().join("\n");
expect(text).toContain("/pygienium-witness");
expect(text).toContain(witnessCheck.description);
});
});