import assert from "node:assert/strict"; import { readFile } from "node:fs/promises"; import { test } from "node:test"; const component = (name) => new URL(`../src/components/laboratory/${name}`, import.meta.url); test("semantic evidence mask is decoded, cached, cancelled and object-contained client-side", async () => { const source = await readFile(component("RecordedEvidenceSemanticMaskOverlay.tsx"), "utf8"); assert.match(source, /decodedMaskCache/); assert.match(source, /pendingMaskCache/); assert.match(source, /AbortController/); assert.match(source, /getImageData/); assert.match(source, /8-bit grayscale class-id PNG/); assert.match(source, /ResizeObserver/); assert.match(source, /Math\.min\(width \/ imageWidth, height \/ imageHeight\)/); assert.match(source, /decoded\.key !== expectedKey/); assert.match(source, /mask\?\.key === expectedKey/); assert.match(source, /необъявленный class ID/); assert.match(source, /recorded-evidence-semantic-mask-overlay__error/); assert.match(source, /role="alert"/); }); test("shared recorded scenes place optional semantic masks beneath boxes", async () => { const [imageScene, videoScene] = await Promise.all([ readFile(component("RecordedEvidenceImageScene.tsx"), "utf8"), readFile(component("RecordedEvidenceVideoScene.tsx"), "utf8"), ]); for (const source of [imageScene, videoScene]) { assert.match(source, /semanticOverlay\?: RecordedEvidenceSemanticOverlay/); assert.ok( source.indexOf(" { const source = await readFile(component("LaboratoryMetricEvidenceScene.tsx"), "utf8"); assert.match(source, /pointSemanticClassIds\?: readonly \(number \| null\)\[\]/); assert.match(source, /pointSemanticClassIds\.length === pointCloudBodyXyzM\.length/); assert.match(source, /classId === null \? undefined : colorsByClassId\.get\(classId\)/); assert.match(source, /data-decision="semantic"/); assert.match(source, /recordedEvidenceSemanticCssColor/); }); test("semantic point alignment is enforced only when M4 exposes the exact spatial increment", async () => { const source = await readFile( new URL("../src/workspaces/laboratory/M4ReplayThreatVisual.tsx", import.meta.url), "utf8", ); assert.match(source, /semantic && frame\?\.spatialAvailable && semanticFrame/); assert.match(source, /\|\| !frame\.spatialAvailable\s*\|\| !semanticFrame/); assert.match(source, /semanticFrame\.sourcePointCount !== frame\.pointCloudSourceCount/); }); test("M4 mounts semantic mask overlays only for the active VIDEO or CAMERA layer", async () => { const source = await readFile( new URL("../src/workspaces/laboratory/M4ReplayThreatVisual.tsx", import.meta.url), "utf8", ); assert.match( source, /semanticOverlay=\{mode === "video" \? semanticOverlay : undefined\}/, ); assert.match( source, /semanticOverlay=\{mode === "camera" \? semanticOverlay : undefined\}/, ); });