forked from longtao.wu/droboticflow
60 lines
2.3 KiB
JavaScript
60 lines
2.3 KiB
JavaScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import {
|
|
summarizeSliceProgress,
|
|
annotationCoverageGaps,
|
|
continuousAnnotationIssues,
|
|
annotationSegmentsForSlice,
|
|
} from "../../src/lib/annotation-workbench.js";
|
|
import { analyzeSliceCoverage } from "../../src/lib/annotation-operations.js";
|
|
import { acceptanceSliceGroups } from "../../src/lib/acceptance-workspace.js";
|
|
const slices = [
|
|
{ id: "a", start: 0, end: 20 },
|
|
{ id: "b", start: 20, end: 40, deliveryDisposition: "discard", discardReason: "遮挡" },
|
|
{ id: "c", start: 40, end: 60 },
|
|
];
|
|
test("discarded interval is handled but not labeled; the complete capture remains gap-free", () => {
|
|
const actions = [
|
|
{ id: "a", start: 0, end: 20, description: "拿取" },
|
|
{ id: "c", start: 40, end: 60, description: "无效片段", isInvalid: true },
|
|
];
|
|
const s = summarizeSliceProgress(slices, actions, {});
|
|
assert.equal(s.completed, 3);
|
|
assert.equal(s.labeled, 2);
|
|
assert.equal(s.discarded, 1);
|
|
assert.equal(s.pending, 0);
|
|
assert.equal(analyzeSliceCoverage(slices, 0, 60).complete, true);
|
|
assert.deepEqual(continuousAnnotationIssues(slices, actions), []);
|
|
assert.deepEqual(annotationSegmentsForSlice(slices[1], [{ start: 20, end: 40, description: "old" }]), []);
|
|
assert.deepEqual(annotationCoverageGaps(slices[1], []), []);
|
|
assert.notDeepEqual(annotationCoverageGaps(slices[0], []), []);
|
|
});
|
|
test("all-discard is handled without pretending any slice was labeled", () => {
|
|
const s = summarizeSliceProgress(
|
|
slices.map((x) => ({ ...x, deliveryDisposition: "discard" })),
|
|
[],
|
|
{},
|
|
);
|
|
assert.equal(s.completed, 3);
|
|
assert.equal(s.discarded, 3);
|
|
assert.equal(s.labeled, 0);
|
|
assert.equal(s.ratio, 1);
|
|
});
|
|
test("acceptance inventory keeps discarded slices and reasons visible", () => {
|
|
const entries = [{ materialization: { artifactId: "m" }, finalSlices: slices }];
|
|
const groups = acceptanceSliceGroups(entries, {
|
|
m: {
|
|
items: [1, 2, 3].map((i) => ({
|
|
group: `slices/slice-${String(i).padStart(6, "0")}`,
|
|
name: "left.mp4",
|
|
sizeBytes: 1,
|
|
contentAvailable: true,
|
|
})),
|
|
},
|
|
});
|
|
assert.equal(groups.length, 3);
|
|
assert.equal(groups[1].deliveryDisposition, "discard");
|
|
assert.equal(groups[1].discardReason, "遮挡");
|
|
});
|
|
// UI confirmation and focus are exercised through tests/browser/workspace-panel-repair.mjs.
|