test: guard auto reply mock calls · openclaw/openclaw@8e045f6
steipete
·
2026-05-12
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -316,7 +316,7 @@ describe("runReplyAgent runtime config", () => {
|
316 | 316 | |
317 | 317 | expect(resolveQueuedReplyExecutionConfigMock).not.toHaveBeenCalled(); |
318 | 318 | expect(enqueueFollowupRunMock).toHaveBeenCalledTimes(1); |
319 | | -const enqueueCall = enqueueFollowupRunMock.mock.calls[0]; |
| 319 | +const enqueueCall = enqueueFollowupRunMock.mock.calls.at(0); |
320 | 320 | expect(enqueueCall?.[0]).toBe("main"); |
321 | 321 | expect(enqueueCall?.[1]).toBe(followupRun); |
322 | 322 | expect(enqueueCall?.[2]).toBe(resolvedQueue); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -211,7 +211,7 @@ describe("runReplyAgent media path normalization", () => {
|
211 | 211 | } |
212 | 212 | expect(result.mediaUrl).toBe("/tmp/outbound-media/generated.png"); |
213 | 213 | expect(result.mediaUrls).toEqual(["/tmp/outbound-media/generated.png"]); |
214 | | -const outboundAttachmentCall = resolveOutboundAttachmentFromUrlMock.mock.calls[0]; |
| 214 | +const outboundAttachmentCall = resolveOutboundAttachmentFromUrlMock.mock.calls.at(0); |
215 | 215 | expect(outboundAttachmentCall?.[0]).toBe(path.join("/tmp/workspace", "out", "generated.png")); |
216 | 216 | expect(outboundAttachmentCall?.[1]).toBe(5 * 1024 * 1024); |
217 | 217 | const outboundAttachmentOptions = outboundAttachmentCall?.[2] as |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -723,7 +723,7 @@ describe("runReplyAgent typing (heartbeat)", () => {
|
723 | 723 | |
724 | 724 | expect(typing.startTypingOnText).toHaveBeenCalledWith("chunk"); |
725 | 725 | expect(onBlockReply).toHaveBeenCalled(); |
726 | | -const [blockPayload, blockOpts] = onBlockReply.mock.calls[0] ?? []; |
| 726 | +const [blockPayload, blockOpts] = onBlockReply.mock.calls.at(0) ?? []; |
727 | 727 | const blockPayloadRecord = requireRecord(blockPayload, "block payload"); |
728 | 728 | expect(blockPayloadRecord.text).toBe("chunk"); |
729 | 729 | expect(blockPayloadRecord.audioAsVoice).toBe(false); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -117,7 +117,7 @@ function requireFirstArg(
|
117 | 117 | mockFn: { mock: { calls: unknown[][] } }, |
118 | 118 | label: string, |
119 | 119 | ): Record<string, unknown> { |
120 | | -const arg = mockFn.mock.calls[0]?.[0] as Record<string, unknown> | undefined; |
| 120 | +const arg = mockFn.mock.calls.at(0)?.[0] as Record<string, unknown> | undefined; |
121 | 121 | if (!arg) { |
122 | 122 | throw new Error(`expected ${label} to be called`); |
123 | 123 | } |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -1331,7 +1331,7 @@ describe("createFollowupRunner messaging delivery and dedupe", () => {
|
1331 | 1331 | ).resolves.toBeUndefined(); |
1332 | 1332 | |
1333 | 1333 | expect(requireMockCallArg(persistSpy, 0).providerUsed).toBe("anthropic"); |
1334 | | -expect(persistSpy.mock.calls[0]?.[0]?.usageIsContextSnapshot).toBeUndefined(); |
| 1334 | +expect(persistSpy.mock.calls.at(0)?.[0]?.usageIsContextSnapshot).toBeUndefined(); |
1335 | 1335 | persistSpy.mockRestore(); |
1336 | 1336 | }); |
1337 | 1337 | |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -159,7 +159,7 @@ export function expectResolvedTelegramTimezone(
|
159 | 159 | userTimezone = "America/New_York", |
160 | 160 | ): void { |
161 | 161 | expect(resolveReplyDirectives).toHaveBeenCalledTimes(1); |
162 | | -const call = resolveReplyDirectives.mock.calls[0]?.[0] as |
| 162 | +const call = resolveReplyDirectives.mock.calls.at(0)?.[0] as |
163 | 163 | | { |
164 | 164 | cfg?: { |
165 | 165 | channels?: { telegram?: { botToken?: unknown } }; |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。