e4dcfc49aa
Tests / Import Check (Python 3.13) (push) Has been cancelled
Tests / Import Check (Python 3.14) (push) Has been cancelled
Tests / Python Tests (Python 3.11) (push) Has been cancelled
Tests / Python Tests (Python 3.12) (push) Has been cancelled
Tests / Python Tests (Python 3.14) (push) Has been cancelled
Tests / Test Summary (push) Has been cancelled
Tests / Lint and Format (push) Has been cancelled
Tests / Web Node Tests (push) Has been cancelled
Tests / Import Check (Python 3.11) (push) Has been cancelled
Tests / Import Check (Python 3.12) (push) Has been cancelled
Tests / Python Tests (Python 3.13) (push) Has been cancelled
53 lines
1.2 KiB
TypeScript
53 lines
1.2 KiB
TypeScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
|
|
import { kbCanReindex, type KnowledgeBase } from "../lib/knowledge-helpers";
|
|
|
|
function kb(overrides: Partial<KnowledgeBase>): 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,
|
|
);
|
|
});
|