import type { Decision, DecisionStatus, DownloadTask } from "@umt/contracts"; import { describe, expect, it } from "vitest"; import { buildTimeline } from "./tasks.ts"; const task = { id: "download", name: "作品", origin: "user", status: "queued", createdAt: "2026-10-13T00:00:00Z", } as unknown as DownloadTask; const decision = (status: DecisionStatus): Decision => ({ id: "decision", status, title: "等待补全资源规格", summary: "规格缺少编码", severity: "critical", subjectType: "download_task", subjectId: "download", agentRunId: "agent", createdAt: "2026-10-13T00:00:01Z", updatedAt: "2026-10-13T00:00:02Z", evidence: {}, }) as Decision; describe("下载时间线的异常状态", () => { it.each([ ["open", "待处理", "destructive", false], ["investigating", "智能体调查中", "neutral", true], ["awaiting_user", "等你决定", "destructive", false], ["resolved", "已处理", "success", false], ["dismissed", "已忽略", "neutral", false], ["expired", "已过期", "neutral", false], ] as const)("%s按实际状态显示,不凭会话ID判断仍需人工", (status, label, tone, ongoing) => { const events = buildTimeline({ task, decisions: [decision(status)] }); expect(events.find((e) => e.key === "dec-decision")).toMatchObject({ title: `${label}:等待补全资源规格`, tone, ongoing, href: "/console/downloads?open=download", }); expect(events.find((e) => e.key === "agent-decision")).toMatchObject({ title: "智能体调查记录", tone: "neutral", href: "/console/agent/agent", }); }); it("交还人工时展示已有恢复建议,计划事项定位到计划", () => { const d = { ...decision("awaiting_user"), subjectType: "acquisition_plan", subjectId: "plan", evidence: { autoRecover: { suggestion: "请确认资源详情的编码" } }, }; expect(buildTimeline({ task, decisions: [d] }).find((e) => e.key === "dec-decision")).toMatchObject({ detail: "请确认资源详情的编码", href: "/console/downloads?plan=plan", }); }); });