fix: keep project entity selection and ignore placeholder hits

This commit is contained in:
muena
2026-09-26 15:09:53 +02:00
parent 5877b7cf5f
commit 6cb5b0efc5
5 changed files with 90 additions and 10 deletions

View File

@@ -1,7 +1,7 @@
import { expect, it } from "bun:test";
import {
canonicalPerson, filenameScanText, groupReviewHits, makeTextBatches, mappingForSelection, mergePeople,
spansBySegment, withoutWhitelistedHits, withoutWhitelistedRules,
spansBySegment, withoutPlaceholderHits, withoutWhitelistedHits, withoutWhitelistedRules,
} from "../src/lib/project-review";
it("liest Unterstriche in Namen als Leerzeichen und bewahrt bekannte Codebegriffe", () => {
@@ -58,6 +58,17 @@ it("unterdrückt projektweit nur exakt abgewählte Begriffe samt erzwungener Reg
], whitelist)).toEqual([{ type: "ORG", value: "Max Muster" }]);
});
it("zeigt beim erneuten Lauf keine Treffer, die einen bestehenden Platzhalter einschließen", () => {
const hits = [
{ type: "PERSON", original: "PERSON_39, Roman" },
{ type: "KUNDE", original: "KUNDE_100005" },
{ type: "PERSON", original: "Roman" },
{ type: "PERSON", original: "Anlage44" },
{ type: "PASSWORT", original: "ORT_08!" },
];
expect(withoutPlaceholderHits(hits)).toEqual(hits.slice(2));
});
it("fasst ausgewählte Personen zu einem kanonischen Platzhalter zusammen und bewahrt alte Zuordnungen", () => {
let merges = mergePeople({}, "PERSON_02", "PERSON_01");
merges = mergePeople(merges, "PERSON_03", "PERSON_02");

View File

@@ -53,6 +53,20 @@ describe("Velum-Projektstände", () => {
.toEqual([first.run.id, second.run.id].sort());
});
it("behält die Kategorieauswahl pro Projekt für den nächsten Lauf", async () => {
const root = await fs.mkdtemp(join(tmpdir(), "velum-entity-types-test-"));
roots.push(root);
const source = join(root, "Quelle");
const other = join(root, "Anderes Projekt");
const support = join(root, "Raycast");
await fs.mkdir(source);
await fs.mkdir(other);
expect(await project.loadProjectEntityTypes(source, support)).toBeNull();
await project.saveProjectEntityTypes(`${source}/`, ["PERSON", "ORG", "PERSON"], support);
expect(await project.loadProjectEntityTypes(source, support)).toEqual(["PERSON", "ORG"]);
expect(await project.loadProjectEntityTypes(other, support)).toBeNull();
});
it("ersetzt nur bestätigte Vorkommen und stellt Dateinamen wieder her", () => {
const hits = [
{ id: "a", start: 0, end: 3, placeholder: "PERSON_01" },