Broaden orphan candidate detection

This commit is contained in:
2026-04-21 15:29:21 +00:00
parent 987d20ce15
commit 366a7fbf50
5 changed files with 45 additions and 17 deletions

View File

@@ -0,0 +1,38 @@
import assert from "node:assert/strict";
import { buildFindings, createFileRecord } from "../scripts/core/finding-engine.js";
import { createFileLocator } from "../scripts/core/path-utils.js";
const files = [
createFileRecord(createFileLocator("data", "assets/user-upload/example.webp"), 100),
createFileRecord(createFileLocator("data", "worlds/demo-world/assets/maps/map.webp"), 200),
createFileRecord(createFileLocator("public", "icons/custom/example.webp"), 300),
createFileRecord(createFileLocator("data", "worlds/demo-world/assets/scenes/exampleScene-thumb.webp"), 400)
];
const { findings } = buildFindings({ files, references: [] });
assert.equal(
findings.some(finding => finding.kind === "orphan-file" && finding.target.locator === "data:assets/user-upload/example.webp"),
true,
"unreferenced user assets should be reported as orphan candidates"
);
assert.equal(
findings.some(finding => finding.kind === "orphan-file" && finding.target.locator === "data:worlds/demo-world/assets/maps/map.webp"),
true,
"unreferenced world assets should be reported as orphan candidates"
);
assert.equal(
findings.some(finding => finding.kind === "orphan-file" && finding.target.locator === "public:icons/custom/example.webp"),
true,
"unreferenced public media should be reported as orphan candidates"
);
assert.equal(
findings.some(finding => finding.kind === "orphan-file" && finding.target.locator === "data:worlds/demo-world/assets/scenes/exampleScene-thumb.webp"),
false,
"derived scene thumbnails must stay excluded from orphan candidates"
);
console.log("global-orphan-candidate-test: ok");