吸收数字员工日报产物闭环
This commit is contained in:
@@ -187,6 +187,83 @@ describe("digital employee state service", () => {
|
||||
expect(Array.from(mockState.db?.outbox.values() ?? []).filter((row) => row.entity_type === "artifact")).toHaveLength(1);
|
||||
});
|
||||
|
||||
it("records daily reports as syncable artifact and event history", async () => {
|
||||
const { recordDigitalEmployeeDailyReport } = await import("./stateService");
|
||||
|
||||
const first = recordDigitalEmployeeDailyReport({
|
||||
date: "2026-06-07",
|
||||
title: "2026-06-07 数字员工日报",
|
||||
summary: "今日完成任务汇总。",
|
||||
totals: {
|
||||
task_count: 2,
|
||||
execution_count: 3,
|
||||
success_count: 2,
|
||||
failure_count: 1,
|
||||
running_count: 0,
|
||||
},
|
||||
detailLines: ["09:00 任务 A:完成", "10:00 任务 B:异常"],
|
||||
artifactSources: [{ id: "artifact-1", name: "summary.csv" }],
|
||||
filename: "qimingclaw-digital-report-2026-06-07.txt",
|
||||
textContent: "日报正文",
|
||||
generatedAt: "2026-06-07T08:00:00.000Z",
|
||||
reportScheduleTime: "18:00",
|
||||
source: "qimingclaw",
|
||||
model: "qimingclaw-adapter",
|
||||
});
|
||||
const second = recordDigitalEmployeeDailyReport({
|
||||
date: "2026-06-07",
|
||||
title: "2026-06-07 数字员工日报",
|
||||
summary: "第二次生成。",
|
||||
totals: { task_count: 2, execution_count: 4, success_count: 3, failure_count: 1 },
|
||||
detailLines: ["18:00 重新生成日报"],
|
||||
filename: "qimingclaw-digital-report-2026-06-07.txt",
|
||||
textContent: "第二版日报正文",
|
||||
generatedAt: "2026-06-07T09:00:00.000Z",
|
||||
});
|
||||
|
||||
expect(first).toMatchObject({
|
||||
reportId: "daily-report:2026-06-07:2026-06-07T08-00-00-000Z",
|
||||
planId: "daily-report:2026-06-07",
|
||||
taskId: "daily-report:2026-06-07:generate",
|
||||
runId: "daily-report:2026-06-07:2026-06-07T08-00-00-000Z",
|
||||
artifactId: "daily-report:2026-06-07:2026-06-07T08-00-00-000Z:artifact:text",
|
||||
eventId: "daily-report:2026-06-07:2026-06-07T08-00-00-000Z:event:generated",
|
||||
});
|
||||
expect(second?.reportId).toBe("daily-report:2026-06-07:2026-06-07T09-00-00-000Z");
|
||||
expect(mockState.db?.plans.get("daily-report:2026-06-07")).toMatchObject({ status: "completed" });
|
||||
expect(mockState.db?.tasks.get("daily-report:2026-06-07:generate")).toMatchObject({
|
||||
status: "completed",
|
||||
assigned_skill_id: "qimingclaw-artifact-report",
|
||||
});
|
||||
expect(mockState.db?.runs.get(first!.runId)).toMatchObject({
|
||||
status: "completed",
|
||||
finished_at: "2026-06-07T08:00:00.000Z",
|
||||
});
|
||||
expect(Array.from(mockState.db?.artifacts.values() ?? []).filter((row) => row.kind === "daily_report")).toHaveLength(2);
|
||||
expect(mockState.db?.events.get(first!.eventId)).toMatchObject({
|
||||
kind: "daily_report_generated",
|
||||
message: "数字员工日报已生成:2026-06-07",
|
||||
run_id: first!.runId,
|
||||
});
|
||||
expect(JSON.parse(mockState.db?.artifacts.get(first!.artifactId)?.payload ?? "{}")).toMatchObject({
|
||||
report_id: first!.reportId,
|
||||
date: "2026-06-07",
|
||||
filename: "qimingclaw-digital-report-2026-06-07.txt",
|
||||
format: "text",
|
||||
text_content: "日报正文",
|
||||
totals: { task_count: 2, execution_count: 3 },
|
||||
artifact_sources: [{ id: "artifact-1", name: "summary.csv" }],
|
||||
});
|
||||
expect(mockState.db?.outbox.get(`artifact:upsert:${first!.artifactId}`)).toMatchObject({
|
||||
entity_type: "artifact",
|
||||
status: "pending",
|
||||
});
|
||||
expect(mockState.db?.outbox.get(`event:insert:${first!.eventId}`)).toMatchObject({
|
||||
entity_type: "event",
|
||||
status: "pending",
|
||||
});
|
||||
});
|
||||
|
||||
it("records and lists route decisions as syncable events", async () => {
|
||||
const {
|
||||
listDigitalEmployeeRouteDecisions,
|
||||
|
||||
Reference in New Issue
Block a user