




























@@ -90,15 +90,14 @@ describe("task-flow-registry store runtime", () => {
9090},
9191});
929293-expect(getTaskFlowById("flow-restored")).toMatchObject({
94-flowId: "flow-restored",
95-syncMode: "managed",
96-controllerId: "tests/restored-controller",
97-revision: 4,
98-stateJson: { lane: "triage", done: 3 },
99-waitJson: { kind: "task", taskId: "task-restored" },
100-cancelRequestedAt: 115,
101-});
93+const restored = getTaskFlowById("flow-restored");
94+expect(restored?.flowId).toBe("flow-restored");
95+expect(restored?.syncMode).toBe("managed");
96+expect(restored?.controllerId).toBe("tests/restored-controller");
97+expect(restored?.revision).toBe(4);
98+expect(restored?.stateJson).toEqual({ lane: "triage", done: 3 });
99+expect(restored?.waitJson).toEqual({ kind: "task", taskId: "task-restored" });
100+expect(restored?.cancelRequestedAt).toBe(115);
102101expect(loadSnapshot).toHaveBeenCalledTimes(1);
103102104103createManagedTaskFlow({
@@ -145,31 +144,29 @@ describe("task-flow-registry store runtime", () => {
145144stateJson: { phase: "ask_user" },
146145waitJson: { kind: "external_event", topic: "forum" },
147146});
148-expect(waiting).toMatchObject({
149-applied: true,
150-});
147+expect(waiting.applied).toBe(true);
148+if (!waiting.applied) {
149+throw new Error("Expected wait state update to apply");
150+}
151151const cancelRequested = requestFlowCancel({
152152flowId: created.flowId,
153-expectedRevision: waiting.applied ? waiting.flow.revision : -1,
153+expectedRevision: waiting.flow.revision,
154154cancelRequestedAt: 444,
155155});
156-expect(cancelRequested).toMatchObject({
157-applied: true,
158-});
156+expect(cancelRequested.applied).toBe(true);
159157160158resetTaskFlowRegistryForTests({ persist: false });
161159162-expect(getTaskFlowById(created.flowId)).toMatchObject({
163-flowId: created.flowId,
164-syncMode: "managed",
165-controllerId: "tests/persisted-flow",
166-revision: 2,
167-status: "waiting",
168-currentStep: "ask_user",
169-stateJson: { phase: "ask_user" },
170-waitJson: { kind: "external_event", topic: "forum" },
171-cancelRequestedAt: 444,
172-});
160+const restored = getTaskFlowById(created.flowId);
161+expect(restored?.flowId).toBe(created.flowId);
162+expect(restored?.syncMode).toBe("managed");
163+expect(restored?.controllerId).toBe("tests/persisted-flow");
164+expect(restored?.revision).toBe(2);
165+expect(restored?.status).toBe("waiting");
166+expect(restored?.currentStep).toBe("ask_user");
167+expect(restored?.stateJson).toEqual({ phase: "ask_user" });
168+expect(restored?.waitJson).toEqual({ kind: "external_event", topic: "forum" });
169+expect(restored?.cancelRequestedAt).toBe(444);
173170});
174171});
175172@@ -188,11 +185,10 @@ describe("task-flow-registry store runtime", () => {
188185189186resetTaskFlowRegistryForTests({ persist: false });
190187191-expect(getTaskFlowById(created.flowId)).toMatchObject({
192-flowId: created.flowId,
193-stateJson: null,
194-waitJson: null,
195-});
188+const restored = getTaskFlowById(created.flowId);
189+expect(restored?.flowId).toBe(created.flowId);
190+expect(restored?.stateJson).toBeNull();
191+expect(restored?.waitJson).toBeNull();
196192});
197193});
198194此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。