63 lines
3.0 KiB
JavaScript
63 lines
3.0 KiB
JavaScript
import assert from "node:assert/strict";
|
|
import { readFile } from "node:fs/promises";
|
|
import test from "node:test";
|
|
|
|
const operationsURL = new URL("../../src/pages/AnnotationOperations.tsx", import.meta.url);
|
|
const usersURL = new URL("../../src/pages/Users.tsx", import.meta.url);
|
|
const rolesURL = new URL("../../src/lib/user-roles.ts", import.meta.url);
|
|
const apiURL = new URL("../../src/services/api/human-loop.ts", import.meta.url);
|
|
|
|
test("annotation workbench separates available, mine, and administrator task pools", async () => {
|
|
const source = await readFile(operationsURL, "utf8");
|
|
// Endpoint selection moved to the pool loader; its behavioral tests verify
|
|
// role-specific available/mine/all requests and server eligibility.
|
|
assert.match(source, /loadAnnotationPoolPage\(\{/);
|
|
assert.match(source, /可领取/);
|
|
assert.match(source, /我的任务/);
|
|
assert.match(source, /全部任务/);
|
|
assert.match(source, /data-testid="acceptance-random-claim"/);
|
|
assert.match(source, /\{randomClaimBusy \? "正在领取…" : "随机领取"\}/);
|
|
// Random-claim behavior across unloaded pools is exercised by review-random-claim.test.mjs.
|
|
assert.match(source, /管理员任务改派/);
|
|
assert.match(source, /humanLoopApi\.assign/);
|
|
assert.match(source, /problemSliceIds/);
|
|
assert.match(source, /打回必须填写原因/);
|
|
});
|
|
|
|
test("project members expose the confirmed three-role responsibilities without workgroup assignment", async () => {
|
|
const [users, operations, roles] = await Promise.all([
|
|
readFile(usersURL, "utf8"),
|
|
readFile(operationsURL, "utf8"),
|
|
readFile(rolesURL, "utf8"),
|
|
]);
|
|
assert.doesNotMatch(users, /选择工作组/);
|
|
assert.match(operations, /projectsApi\.listMembers/);
|
|
assert.match(operations, /projectMembers/);
|
|
assert.match(roles, /value: "annotator"[\s\S]*label: "标注员"/);
|
|
assert.doesNotMatch(roles, /旧版剪切员/);
|
|
assert.match(roles, /value: "quality_reviewer"[\s\S]*label: "质检审核员"/);
|
|
assert.match(roles, /value: "acceptance_reviewer"[\s\S]*label: "最终验收员"/);
|
|
});
|
|
|
|
test("user supplier is selected at creation, with no later transfer flow", async () => {
|
|
const source = await readFile(usersURL, "utf8");
|
|
assert.match(source, /suppliersApi\.list\(\)/);
|
|
assert.match(source, /aria-label="所属供应商"/);
|
|
assert.match(source, /创建后不可更改/);
|
|
assert.match(source, /readOnly/);
|
|
assert.doesNotMatch(source, /supplierProjectsReviewed|syncMemberIds|updateMember\(/);
|
|
const edit = source.slice(
|
|
source.indexOf("usersApi.update("),
|
|
source.indexOf("request", source.indexOf("usersApi.update(")),
|
|
);
|
|
assert.doesNotMatch(edit, /supplierId:/);
|
|
assert.match(source, /supplier\.id === u\.supplierId/);
|
|
});
|
|
|
|
test("human-loop client supports audited administrator assignment", async () => {
|
|
const source = await readFile(apiURL, "utf8");
|
|
assert.match(source, /assign: \(id: string, version: number, assignedUserId: string\)/);
|
|
assert.match(source, /\/human-items\/\$\{encodeURIComponent\(id\)\}\/assignment/);
|
|
assert.match(source, /method: "PATCH"/);
|
|
});
|