test: tighten task cancellation timestamp assertions · openclaw/openclaw@03c8eb7
steipete
·
2026-05-09
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -120,6 +120,16 @@ function requireCreatedFlowTask(
|
120 | 120 | return result.task; |
121 | 121 | } |
122 | 122 | |
| 123 | +function expectCancelRequestedAt(value: unknown): number { |
| 124 | +expect(typeof value).toBe("number"); |
| 125 | +if (typeof value !== "number") { |
| 126 | +throw new Error("Expected numeric cancelRequestedAt"); |
| 127 | +} |
| 128 | +expect(Number.isInteger(value)).toBe(true); |
| 129 | +expect(value).toBeGreaterThan(0); |
| 130 | +return value; |
| 131 | +} |
| 132 | + |
123 | 133 | function createRunningAcpChildTaskRun( |
124 | 134 | overrides: Partial<Parameters<typeof createRunningTaskRun>[0]> = {}, |
125 | 135 | ) { |
@@ -581,10 +591,10 @@ describe("task-executor", () => {
|
581 | 591 | reason: "One or more child tasks are still active.", |
582 | 592 | flow: expect.objectContaining({ |
583 | 593 | flowId: flow.flowId, |
584 | | -cancelRequestedAt: expect.any(Number), |
585 | 594 | status: "queued", |
586 | 595 | }), |
587 | 596 | }); |
| 597 | +const cancelRequestedAt = expectCancelRequestedAt(cancelled.flow?.cancelRequestedAt); |
588 | 598 | |
589 | 599 | failTaskRunByRunId({ |
590 | 600 | runId: "run-flow-sticky-cancel", |
@@ -600,7 +610,7 @@ describe("task-executor", () => {
|
600 | 610 | }); |
601 | 611 | expect(getTaskFlowById(flow.flowId)).toMatchObject({ |
602 | 612 | flowId: flow.flowId, |
603 | | -cancelRequestedAt: expect.any(Number), |
| 613 | + cancelRequestedAt, |
604 | 614 | status: "cancelled", |
605 | 615 | endedAt: 50, |
606 | 616 | }); |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。