Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 20 additions & 11 deletions tests/multi-folder-scan.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1324,25 +1324,34 @@ describe("handleMultiFolderScan - maintenance risk JSON output", () => {
describe("handleMultiFolderScan - maintenance risk terminal render", () => {
it("prints gate-class section headings from the shared labels", async () => {
const { GATE_CLASS_LABELS } = await import("../src/utils/severity.js");
const originalOverrideHygiene = GATE_CLASS_LABELS.overrideHygiene;
const originalMaintenanceRisk = GATE_CLASS_LABELS.maintenanceRisk;
Object.defineProperty(GATE_CLASS_LABELS, "overrideHygiene", { value: "__override_heading__" });
Object.defineProperty(GATE_CLASS_LABELS, "maintenanceRisk", { value: "__maintenance_heading__" });

loadMultiplePackagesMock.mockReturnValue([
{ subfolder: "a", scanInput: makeScanInput() },
]);
detectDM001Mock.mockResolvedValue([
{ ruleId: "DM001", severity: "high", package: { name: "gray-matter", version: "4.0.3" }, drag: [], message: "x" },
]);

await handleMultiFolderScan({
projectRoot: "/project",
batchSize: 100,
options: { ...baseOptions, checkOverrides: true, checkMaintenance: true },
});
try {
await handleMultiFolderScan({
projectRoot: "/project",
batchSize: 100,
options: { ...baseOptions, checkOverrides: true, checkMaintenance: true },
});

const written = stdoutWriteSpy.mock.calls.map(call => String(call[0])).join("");
expect(written).toContain(GATE_CLASS_LABELS.overrideHygiene);
expect(written).toContain(GATE_CLASS_LABELS.maintenanceRisk);
// and none of the hand-typed copies satisfy the sentinels above
expect(written).not.toContain("override hygiene");
expect(written).not.toContain("maintenance risk");
const written = stdoutWriteSpy.mock.calls.map(call => String(call[0])).join("");
expect(written).toContain("__override_heading__");
expect(written).toContain("__maintenance_heading__");
expect(written).not.toContain("override hygiene");
expect(written).not.toContain("maintenance risk");
} finally {
Object.defineProperty(GATE_CLASS_LABELS, "overrideHygiene", { value: originalOverrideHygiene });
Object.defineProperty(GATE_CLASS_LABELS, "maintenanceRisk", { value: originalMaintenanceRisk });
}
});
});

Expand Down
Loading