test: guard extension provider mock calls · openclaw/openclaw@ea05be1
steipete
·
2026-05-12
·
via Recent Commits to openclaw:main
File tree
mattermost/src/mattermost
| Original file line number | Diff line number | Diff line change |
|---|
@@ -491,7 +491,7 @@ describe("fetchCopilotModelCatalog", () => {
|
491 | 491 | }); |
492 | 492 | |
493 | 493 | expect(fetchImpl).toHaveBeenCalledTimes(1); |
494 | | -const [calledUrl, calledInit] = fetchImpl.mock.calls[0]; |
| 494 | +const [calledUrl, calledInit] = fetchImpl.mock.calls.at(0) ?? []; |
495 | 495 | expect(calledUrl).toBe("https://api.githubcopilot.com/models"); |
496 | 496 | expect((calledInit as RequestInit).method).toBe("GET"); |
497 | 497 | expect(((calledInit as RequestInit).headers as Record<string, string>).Authorization).toBe( |
@@ -539,7 +539,7 @@ describe("fetchCopilotModelCatalog", () => {
|
539 | 539 | fetchImpl: fetchImpl as unknown as typeof fetch, |
540 | 540 | }); |
541 | 541 | |
542 | | -expect(fetchImpl.mock.calls[0][0]).toBe("https://api.githubcopilot.com/models"); |
| 542 | +expect(fetchImpl.mock.calls.at(0)?.[0]).toBe("https://api.githubcopilot.com/models"); |
543 | 543 | }); |
544 | 544 | |
545 | 545 | it("dedupes by id when API returns duplicates", async () => { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -811,7 +811,7 @@ describe("google-meet CLI", () => {
|
811 | 811 | ], |
812 | 812 | { from: "user" }, |
813 | 813 | ); |
814 | | -const gatewayCall = callGatewayFromCli.mock.calls[0] as unknown as |
| 814 | +const gatewayCall = callGatewayFromCli.mock.calls.at(0) as unknown as |
815 | 815 | | [ |
816 | 816 | string, |
817 | 817 | { json?: boolean; timeout?: unknown }, |
@@ -1144,7 +1144,7 @@ describe("google-meet CLI", () => {
|
1144 | 1144 | expectFields(checks[0], { id: "oauth-config", ok: true }); |
1145 | 1145 | expectFields(checks[1], { id: "oauth-token", ok: true }); |
1146 | 1146 | expect(ensureRuntime).not.toHaveBeenCalled(); |
1147 | | -const body = fetchMock.mock.calls[0]?.[1]?.body as URLSearchParams; |
| 1147 | +const body = fetchMock.mock.calls.at(0)?.[1]?.body as URLSearchParams; |
1148 | 1148 | expect(body.get("grant_type")).toBe("refresh_token"); |
1149 | 1149 | } finally { |
1150 | 1150 | stdout.restore(); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -109,7 +109,7 @@ describe("monitorIMessageProvider watch.subscribe startup retry", () => {
|
109 | 109 | { timeoutMs: 10_000 }, |
110 | 110 | ); |
111 | 111 | expect(runtime.log).toHaveBeenCalledTimes(1); |
112 | | -expect(String(runtime.log.mock.calls[0][0])).toContain( |
| 112 | +expect(String(runtime.log.mock.calls.at(0)?.[0])).toContain( |
113 | 113 | "imessage: watch.subscribe startup failed (attempt 1/3): Error: imsg rpc timeout (watch.subscribe); retrying", |
114 | 114 | ); |
115 | 115 | expect( |
@@ -141,7 +141,7 @@ describe("monitorIMessageProvider watch.subscribe startup retry", () => {
|
141 | 141 | expect((monitorError as Error).message).toContain("imsg rpc timeout (watch.subscribe)"); |
142 | 142 | expect(createIMessageRpcClientMock).toHaveBeenCalledTimes(3); |
143 | 143 | expect(runtime.error).toHaveBeenCalledTimes(1); |
144 | | -expect(String(runtime.error.mock.calls[0][0])).toContain( |
| 144 | +expect(String(runtime.error.mock.calls.at(0)?.[0])).toContain( |
145 | 145 | "imessage: monitor failed: Error: imsg rpc timeout (watch.subscribe)", |
146 | 146 | ); |
147 | 147 | }); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -266,7 +266,7 @@ describe("uploadRichMenuImage", () => {
|
266 | 266 | |
267 | 267 | expect(MessagingApiBlobClientMock).toHaveBeenCalledWith({ channelAccessToken: "line-token" }); |
268 | 268 | expect(setRichMenuImageMock).toHaveBeenCalledOnce(); |
269 | | -const [richMenuId, blob] = setRichMenuImageMock.mock.calls[0] ?? []; |
| 269 | +const [richMenuId, blob] = setRichMenuImageMock.mock.calls.at(0) ?? []; |
270 | 270 | expect(richMenuId).toBe("rich-menu-1"); |
271 | 271 | expect(blob).toBeInstanceOf(Blob); |
272 | 272 | expect((blob as Blob).type).toBe("image/png"); |
@@ -306,7 +306,7 @@ describe("uploadRichMenuImage", () => {
|
306 | 306 | }); |
307 | 307 | |
308 | 308 | expect(setRichMenuImageMock).toHaveBeenCalledOnce(); |
309 | | -const blob = setRichMenuImageMock.mock.calls[0]?.[1] as Blob; |
| 309 | +const blob = setRichMenuImageMock.mock.calls.at(0)?.[1] as Blob; |
310 | 310 | expect(blob.type).toBe("image/jpeg"); |
311 | 311 | await expect(blob.arrayBuffer()).resolves.toEqual( |
312 | 312 | imageBytes.buffer.slice(imageBytes.byteOffset, imageBytes.byteOffset + imageBytes.byteLength), |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -88,7 +88,7 @@ function resetRunnerMocks() {
|
88 | 88 | async function executeEmbeddedRun(input: Record<string, unknown>) { |
89 | 89 | const tool = createLlmTaskTool(fakeApi()); |
90 | 90 | await tool.execute("id", input); |
91 | | -return (runEmbeddedPiAgent as any).mock.calls[0]?.[0]; |
| 91 | +return (runEmbeddedPiAgent as any).mock.calls.at(0)?.[0]; |
92 | 92 | } |
93 | 93 | |
94 | 94 | describe("llm-task tool (json-only)", () => { |
@@ -238,7 +238,7 @@ describe("llm-task tool (json-only)", () => {
|
238 | 238 | |
239 | 239 | await tool.execute("id", { prompt: "x", model: "gemini-flash" }); |
240 | 240 | |
241 | | -const call = (runEmbeddedPiAgent as any).mock.calls[0]?.[0]; |
| 241 | +const call = (runEmbeddedPiAgent as any).mock.calls.at(0)?.[0]; |
242 | 242 | expect(call.provider).toBe("google"); |
243 | 243 | expect(call.model).toBe("gemini-3-flash-preview"); |
244 | 244 | }); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -349,7 +349,7 @@ describe("createMatrixDraftStream", () => {
|
349 | 349 | await stream.stop(); |
350 | 350 | |
351 | 351 | expect(sendMessageMock).toHaveBeenCalledTimes(1); |
352 | | -expect(sendMessageMock.mock.calls[0]?.[1]).toHaveProperty("org.matrix.msc4357.live"); |
| 352 | +expect(sendMessageMock.mock.calls.at(0)?.[1]).toHaveProperty("org.matrix.msc4357.live"); |
353 | 353 | }); |
354 | 354 | |
355 | 355 | it("finalizeLive clears the live marker at most once", async () => { |
@@ -367,7 +367,7 @@ describe("createMatrixDraftStream", () => {
|
367 | 367 | await stream.finalizeLive(); |
368 | 368 | |
369 | 369 | expect(sendMessageMock).toHaveBeenCalledTimes(2); |
370 | | -expect(sendMessageMock.mock.calls[1]?.[1]).not.toHaveProperty("org.matrix.msc4357.live"); |
| 370 | +expect(sendMessageMock.mock.calls.at(1)?.[1]).not.toHaveProperty("org.matrix.msc4357.live"); |
371 | 371 | }); |
372 | 372 | |
373 | 373 | it("marks live finalize failures for normal final delivery fallback", async () => { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -14,7 +14,7 @@ function requireRecord(value: unknown, label: string): Record<string, unknown> {
|
14 | 14 | } |
15 | 15 | |
16 | 16 | function readFirstMockArg(fn: unknown): unknown { |
17 | | -return (fn as { mock: { calls: unknown[][] } }).mock.calls[0]?.[0]; |
| 17 | +return (fn as { mock: { calls: unknown[][] } }).mock.calls.at(0)?.[0]; |
18 | 18 | } |
19 | 19 | |
20 | 20 | describe("createMatrixRoomMessageHandler thread root media", () => { |
@@ -79,7 +79,7 @@ describe("createMatrixRoomMessageHandler thread root media", () => {
|
79 | 79 | |
80 | 80 | expect(formatAgentEnvelope).toHaveBeenCalledTimes(1); |
81 | 81 | const envelope = requireRecord( |
82 | | -formatAgentEnvelope.mock.calls[0]?.[0], |
| 82 | +formatAgentEnvelope.mock.calls.at(0)?.[0], |
83 | 83 | "format agent envelope params", |
84 | 84 | ); |
85 | 85 | expect(String(envelope.body)).toContain("replying"); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -1678,7 +1678,7 @@ describe("MatrixClient crypto bootstrapping", () => {
|
1678 | 1678 | |
1679 | 1679 | await client.start(); |
1680 | 1680 | |
1681 | | -const startOpts = matrixJsClient.startClient.mock.calls[0]?.[0] as |
| 1681 | +const startOpts = matrixJsClient.startClient.mock.calls.at(0)?.[0] as |
1682 | 1682 | | { filter?: { getDefinition?: () => unknown } } |
1683 | 1683 | | undefined; |
1684 | 1684 | expect(startOpts?.filter?.getDefinition?.()).toEqual({ |
@@ -1703,7 +1703,7 @@ describe("MatrixClient crypto bootstrapping", () => {
|
1703 | 1703 | await client.start(); |
1704 | 1704 | |
1705 | 1705 | expect(databasesSpy).toHaveBeenCalled(); |
1706 | | -const intervalCall = setIntervalSpy.mock.calls[0] as unknown[]; |
| 1706 | +const intervalCall = setIntervalSpy.mock.calls.at(0) as unknown[]; |
1707 | 1707 | expect(intervalCall[0]).toBeTypeOf("function"); |
1708 | 1708 | expect(intervalCall[1]).toBe(60_000); |
1709 | 1709 | client.stop(); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -414,7 +414,7 @@ describe("mattermost inbound user posts", () => {
|
414 | 414 | |
415 | 415 | expect(mockState.enqueueSystemEvent).not.toHaveBeenCalled(); |
416 | 416 | expect(mockState.dispatchReplyFromConfig).toHaveBeenCalledTimes(1); |
417 | | -const ctx = mockState.dispatchReplyFromConfig.mock.calls[0]?.[0].ctx; |
| 417 | +const ctx = mockState.dispatchReplyFromConfig.mock.calls.at(0)?.[0].ctx; |
418 | 418 | expect(ctx?.BodyForAgent).toBe("hello from mattermost"); |
419 | 419 | expect(ctx?.ConversationLabel).toBe("Town Square id:chan-1"); |
420 | 420 | expect(ctx?.MessageSid).toBe("post-1"); |
@@ -484,7 +484,7 @@ describe("mattermost inbound user posts", () => {
|
484 | 484 | await monitor; |
485 | 485 | |
486 | 486 | expect(runtimeCore.channel.session.recordInboundSession).toHaveBeenCalledTimes(1); |
487 | | -const [recordCall] = runtimeCore.channel.session.recordInboundSession.mock.calls[0] ?? []; |
| 487 | +const [recordCall] = runtimeCore.channel.session.recordInboundSession.mock.calls.at(0) ?? []; |
488 | 488 | expect(recordCall?.storePath).toBe("/tmp/openclaw-test-sessions.json"); |
489 | 489 | expect(recordCall?.sessionKey).toBe("mattermost:default:channel:chan-1"); |
490 | 490 | const updateLastRoute = recordCall?.updateLastRoute; |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -114,7 +114,7 @@ describe("mattermost mention gating", () => {
|
114 | 114 | expect(decision.dropReason).toBeNull(); |
115 | 115 | expect(decision.shouldRequireMention).toBe(false); |
116 | 116 | expect(resolver).toHaveBeenCalledTimes(1); |
117 | | -const [resolverCall] = resolver.mock.calls[0] ?? []; |
| 117 | +const [resolverCall] = resolver.mock.calls.at(0) ?? []; |
118 | 118 | expect(resolverCall).toStrictEqual({ |
119 | 119 | cfg, |
120 | 120 | channel: "mattermost", |
@@ -493,7 +493,8 @@ describe("deliverMattermostReplyWithDraftPreview", () => {
|
493 | 493 | }); |
494 | 494 | |
495 | 495 | expect(updateMattermostPostSpy).toHaveBeenCalledTimes(1); |
496 | | -const [updateClient, updatePostId, updateParams] = updateMattermostPostSpy.mock.calls[0] ?? []; |
| 496 | +const [updateClient, updatePostId, updateParams] = |
| 497 | +updateMattermostPostSpy.mock.calls.at(0) ?? []; |
497 | 498 | expect(updateClient).toBe(client); |
498 | 499 | expect(updatePostId).toBe("preview-post-1"); |
499 | 500 | expect(updateParams).toStrictEqual({ message: "Final answer" }); |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。