droboticflow/tests/frontend/annotation-task-action.test.mjs
2026-10-19 16:44:27 +08:00

55 lines
2.2 KiB
JavaScript

import test from "node:test";
import assert from "node:assert/strict";
import { annotationTaskAction } from "../../src/lib/annotation-task-action.js";
for (const [status, label] of [
["pending_quality", "已送检"],
["pending_acceptance", "待验收"],
["accepted", "已完成"],
]) {
test(`${label} stays gray and disabled regardless of stale claim/owner flags`, () => {
let expected;
for (const claimable of [false, true])
for (const claimedByMe of [false, true])
for (const saving of [false, true]) {
const action = annotationTaskAction({ awaitingDownstream: true, status, claimable, claimedByMe, saving });
assert.equal(action.label, label);
assert.equal(action.disabled, true);
assert.equal(action.kind, "none");
assert.match(action.className, /bg-slate-100/);
assert.match(action.className, /dark:bg-slate-800/);
assert.doesNotMatch(action.className, /orange|amber|hover:/);
expected ??= action.className;
assert.equal(action.className, expected);
}
});
}
test("reviewers can still claim downstream review tasks", () => {
const action = annotationTaskAction({
awaitingDownstream: false,
status: "pending_quality",
claimable: true,
claimedByMe: false,
saving: false,
});
assert.equal(action.label, "领取");
assert.equal(action.disabled, false);
assert.match(action.className, /bg-orange-500/);
});
test("active tasks preserve resume, view, and busy states", () => {
assert.equal(annotationTaskAction({ claimedByMe: true }).label, "继续处理");
assert.equal(annotationTaskAction({}).label, "查看");
assert.equal(annotationTaskAction({ claimable: true, saving: true }).disabled, true);
});
test("owned submissions describe progress and reconciliation without changing allocation", () => {
for (const [status, label] of [
["submitting", "查看送检进度"],
["submission_conflicted", "核对送检结果"],
]) {
const action = annotationTaskAction({ status, claimedByMe: true, saving: false });
assert.equal(action.label, label);
assert.equal(action.kind, "resume");
assert.equal(action.disabled, false);
}
});