droboticflow/tests/frontend/slice-dictionary.test.mjs

23 lines
1.3 KiB
JavaScript

import test from "node:test";
import assert from "node:assert/strict";
import fs from "node:fs";
const read = (p) => fs.readFileSync(new URL("../../" + p, import.meta.url), "utf8");
test("slice dictionary selection carries the displayed classification snapshot without changing boundaries", () => {
const picker = read("src/components/SliceNameDictionaryPicker.tsx");
assert.match(picker, /onSelect\(item.name, dictionarySelection\(item\)\)/);
assert.doesNotMatch(picker, /apiRequest|\.start\s*=|\.end\s*=/);
assert.match(picker, /搜索本项目切片字典/);
assert.match(picker, /请联系管理员配置后再确认切片/);
assert.doesNotMatch(picker, /可直接输入名称/);
const workbench = read("src/components/CaptureAnnotationWorkbench.tsx");
assert.match(workbench, /onSliceNameChange\?\.\(selectedSlice\.id,\s*name,\s*dictionary\)/);
});
test("dictionary management is separated and stale task results are hidden", () => {
assert.match(read("src/pages/ProjectDetail.tsx"), /动作描述字典/);
assert.match(read("src/pages/ProjectDetail.tsx"), /切片字典/);
const hook = read("src/hooks/useProjectSliceDictionary.ts");
assert.match(hook, /AbortController/);
assert.match(hook, /state.owner === owner/);
assert.match(read("src/components/AnnotationLabelsPanel.tsx"), /selectionPath/);
});