import test from "node:test"; import assert from "node:assert/strict"; import { kbCanReindex, type KnowledgeBase } from "../lib/knowledge-helpers"; function kb(overrides: Partial): KnowledgeBase { return { name: "kb", status: "ready", statistics: { raw_documents: 1 }, ...overrides, }; } test("kbCanReindex allows failed knowledge bases with source files", () => { assert.equal( kbCanReindex( kb({ status: "error", statistics: { raw_documents: 1, active_match: true }, }), ), true, ); }); test("kbCanReindex keeps empty failed knowledge bases disabled", () => { assert.equal( kbCanReindex( kb({ status: "error", statistics: { raw_documents: 0, active_match: false }, }), ), false, ); }); test("kbCanReindex preserves mismatch and needs-reindex behavior", () => { assert.equal( kbCanReindex(kb({ statistics: { raw_documents: 1, needs_reindex: true } })), true, ); assert.equal( kbCanReindex(kb({ statistics: { raw_documents: 1, active_match: false } })), true, ); assert.equal( kbCanReindex(kb({ statistics: { raw_documents: 1, active_match: true } })), false, ); });