Files
boss/tests/dispatch-plan-ui.test.ts
2026-03-30 17:11:07 +08:00

57 lines
1.8 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import test from "node:test";
import assert from "node:assert/strict";
import {
extractApprovedTargetProjectIds,
latestPendingDispatchPlan,
summarizeDispatchPlan,
} from "@/lib/dispatch-plan-ui";
test("summarizeDispatchPlan combines summary and recommended target titles", () => {
const summary = summarizeDispatchPlan({
planId: "dispatch-plan-0",
summary: "主 Agent 建议先同步 UI 和设备线程",
targets: [
{ projectId: "p1", threadDisplayName: "Boss UI 主线程" },
{ projectId: "p2", threadDisplayName: "设备接入线程" },
],
});
assert.equal(summary, "主 Agent 建议先同步 UI 和设备线程\n推荐线程Boss UI 主线程、设备接入线程");
});
test("extractApprovedTargetProjectIds keeps target order and drops blanks", () => {
const ids = extractApprovedTargetProjectIds({
planId: "dispatch-plan-0",
targets: [
{ projectId: "p2", threadDisplayName: "设备接入线程" },
{ projectId: "p1", threadDisplayName: "Boss UI 主线程" },
],
});
assert.deepEqual(ids, ["p2", "p1"]);
});
test("latestPendingDispatchPlan returns the latest waiting confirmation item", () => {
const plan = latestPendingDispatchPlan([
{
planId: "dispatch-plan-1",
status: "dispatched",
summary: "已完成的推荐",
targets: [{ projectId: "p1", threadDisplayName: "Boss UI 主线程" }],
},
{
planId: "dispatch-plan-2",
status: "pending_user_confirmation",
summary: "等待确认的推荐",
targets: [{ projectId: "p2", threadDisplayName: "设备接入线程" }],
},
]);
assert.deepEqual(plan, {
planId: "dispatch-plan-2",
status: "pending_user_confirmation",
summary: "等待确认的推荐",
targets: [{ projectId: "p2", threadDisplayName: "设备接入线程" }],
});
});