From 75ed635bfacd1a36b2bfe20f53ae1c44ffc9616b Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Mon, 11 May 2026 00:12:43 +0100 Subject: [PATCH] test: tighten runtime taskflow assertions --- src/plugins/runtime/runtime-taskflow.test.ts | 63 ++++++++------------ 1 file changed, 26 insertions(+), 37 deletions(-) diff --git a/src/plugins/runtime/runtime-taskflow.test.ts b/src/plugins/runtime/runtime-taskflow.test.ts index 6d3a894de68..4f6a0b7d46f 100644 --- a/src/plugins/runtime/runtime-taskflow.test.ts +++ b/src/plugins/runtime/runtime-taskflow.test.ts @@ -33,16 +33,12 @@ describe("runtime TaskFlow", () => { stateJson: { lane: "inbox" }, }); - expect(created).toMatchObject({ - syncMode: "managed", - ownerKey: "agent:main:main", - controllerId: "tests/runtime-taskflow", - requesterOrigin: { - channel: "telegram", - to: "telegram:123", - }, - goal: "Triage inbox", - }); + expect(created.syncMode).toBe("managed"); + expect(created.ownerKey).toBe("agent:main:main"); + expect(created.controllerId).toBe("tests/runtime-taskflow"); + expect(created.requesterOrigin?.channel).toBe("telegram"); + expect(created.requesterOrigin?.to).toBe("telegram:123"); + expect(created.goal).toBe("Triage inbox"); expect(taskFlow.get(created.flowId)?.flowId).toBe(created.flowId); expect(taskFlow.findLatest()?.flowId).toBe(created.flowId); expect(taskFlow.resolve("agent:main:main")?.flowId).toBe(created.flowId); @@ -64,11 +60,9 @@ describe("runtime TaskFlow", () => { goal: "Review queue", }); - expect(created.requesterOrigin).toMatchObject({ - channel: "discord", - to: "channel:123", - threadId: "thread:456", - }); + expect(created.requesterOrigin?.channel).toBe("discord"); + expect(created.requesterOrigin?.to).toBe("channel:123"); + expect(created.requesterOrigin?.threadId).toBe("thread:456"); }); it("rejects tool contexts without a bound session key", () => { @@ -109,30 +103,25 @@ describe("runtime TaskFlow", () => { lastEventAt: 10, }); - expect(child).toMatchObject({ - created: true, - flow: expect.objectContaining({ - flowId: created.flowId, - }), - task: expect.objectContaining({ - parentFlowId: created.flowId, - ownerKey: "agent:main:main", - runId: "runtime-taskflow-child", - }), - }); + expect(child.created).toBe(true); if (!child.created) { throw new Error("expected child task creation to succeed"); } - expect(getTaskById(child.task.taskId)).toMatchObject({ - parentFlowId: created.flowId, - ownerKey: "agent:main:main", - }); - expect(getTaskFlowById(created.flowId)).toMatchObject({ - flowId: created.flowId, - }); - expect(ownerTaskFlow.getTaskSummary(created.flowId)).toMatchObject({ - total: 1, - active: 1, - }); + expect(child.flow.flowId).toBe(created.flowId); + expect(child.task.parentFlowId).toBe(created.flowId); + expect(child.task.ownerKey).toBe("agent:main:main"); + expect(child.task.runId).toBe("runtime-taskflow-child"); + + const storedTask = getTaskById(child.task.taskId); + expect(storedTask?.parentFlowId).toBe(created.flowId); + expect(storedTask?.ownerKey).toBe("agent:main:main"); + expect(getTaskFlowById(created.flowId)?.flowId).toBe(created.flowId); + const summary = ownerTaskFlow.getTaskSummary(created.flowId); + expect(summary).toBeDefined(); + if (!summary) { + throw new Error("expected task summary for created flow"); + } + expect(summary.total).toBe(1); + expect(summary.active).toBe(1); }); });