吸收数字员工审批跨端冲突可视化

This commit is contained in:
baiyanyun
2026-06-11 21:53:08 +08:00
parent 84d34236e8
commit e57c94c19d
15 changed files with 625 additions and 208 deletions

View File

@@ -423,6 +423,59 @@ describe("digital employee sync service", () => {
]));
});
it("counts conflicted remote approval updates and records the pull summary", async () => {
mockState.db?.approvals.set("approval-conflict-1", {
id: "approval-conflict-1",
plan_id: "plan-1",
task_id: "task-1",
run_id: "run-1",
title: "本地已同意审批",
status: "approved",
payload: JSON.stringify({ workflow: { current_step_id: "step-1", decision_history: [{ decision: "approved" }] } }),
remote_id: null,
sync_status: "pending",
sync_error: null,
last_synced_at: null,
created_at: "2026-06-07T07:50:00.000Z",
updated_at: "2026-06-07T08:05:00.000Z",
});
mockState.fetch.mockResolvedValue(jsonResponse({
success: true,
data: {
approvals: [
{
approval_id: "approval-conflict-1",
title: "本地已同意审批",
status: "rejected",
updated_at: "2026-06-07T08:06:00.000Z",
payload: { workflow: { current_step_id: "step-1", decision_history: [{ decision: "rejected" }] } },
},
{
approval_id: "approval-remote-ok",
title: "新审批",
status: "pending",
updated_at: "2026-06-07T08:04:00.000Z",
},
],
},
}));
const { pullDigitalEmployeeApprovalUpdates } = await import("./syncService");
const result = await pullDigitalEmployeeApprovalUpdates({ force: true });
expect(result).toMatchObject({ ok: true, applied: 1, ignored: 0, conflicted: 1 });
expect(mockState.db?.approvals.get("approval-conflict-1")).toMatchObject({ status: "approved" });
const pulledEvent = Array.from(mockState.db?.events.values() ?? [])
.find((event) => event.kind === "digital_workday_approval_updates_pulled");
expect(JSON.parse(pulledEvent?.payload ?? "{}")).toMatchObject({
metadata: {
applied: 1,
ignored: 0,
conflicted: 1,
},
});
});
it("submits approval decisions to management and records submission events", async () => {
mockState.fetch.mockResolvedValue(jsonResponse({ success: true, data: { accepted: true } }));