test: guard agent utility mock calls · openclaw/openclaw@e024362
steipete
·
2026-05-12
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -300,7 +300,7 @@ describe("loadEnabledBundlePiSettingsSnapshot", () => {
|
300 | 300 | expect(snapshot.hideThinkingBlock).toBe(true); |
301 | 301 | expect(pluginMetadataSnapshotMocks.getCurrentPluginMetadataSnapshot).toHaveBeenCalledOnce(); |
302 | 302 | const [snapshotLookup] = |
303 | | -pluginMetadataSnapshotMocks.getCurrentPluginMetadataSnapshot.mock.calls[0] ?? []; |
| 303 | +pluginMetadataSnapshotMocks.getCurrentPluginMetadataSnapshot.mock.calls.at(0) ?? []; |
304 | 304 | expect(snapshotLookup?.config?.plugins?.load).toEqual({ |
305 | 305 | paths: ["/tmp/changed-plugin-root"], |
306 | 306 | }); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -226,7 +226,7 @@ describe("after_tool_call fires exactly once in embedded runs", () => {
|
226 | 226 | |
227 | 227 | expect(hookMocks.runner.runAfterToolCall).toHaveBeenCalledTimes(1); |
228 | 228 | |
229 | | -const call = (hookMocks.runner.runAfterToolCall as ReturnType<typeof vi.fn>).mock.calls[0]; |
| 229 | +const call = (hookMocks.runner.runAfterToolCall as ReturnType<typeof vi.fn>).mock.calls.at(0); |
230 | 230 | const event = call?.[0] as { error?: unknown } | undefined; |
231 | 231 | expect(event?.error).toBe("tool failed"); |
232 | 232 | }); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -450,7 +450,7 @@ describe("createOpenClawCodingTools", () => {
|
450 | 450 | |
451 | 451 | expect(createOpenClawToolsMock).not.toHaveBeenCalled(); |
452 | 452 | expect(resolvePluginToolsSpy).toHaveBeenCalledTimes(1); |
453 | | -const pluginToolOptions = resolvePluginToolsSpy.mock.calls[0]?.[0].options; |
| 453 | +const pluginToolOptions = resolvePluginToolsSpy.mock.calls.at(0)?.[0].options; |
454 | 454 | expect(pluginToolOptions?.modelProvider).toBe("openrouter"); |
455 | 455 | expect(pluginToolOptions?.modelId).toBe("openrouter/auto"); |
456 | 456 | } finally { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -428,7 +428,7 @@ describe("normalizeToolParameters", () => {
|
428 | 428 | ); |
429 | 429 | |
430 | 430 | expect(streamCalls).toBe(2); |
431 | | -const executeCall = execute.mock.calls[0]; |
| 431 | +const executeCall = execute.mock.calls.at(0); |
432 | 432 | expect(executeCall?.[0]).toBe("call-null-args"); |
433 | 433 | expect(executeCall?.[1]).toEqual({}); |
434 | 434 | expect(executeCall?.[2]).toBeUndefined(); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -25,7 +25,7 @@ describe("AgentRuntimePlan tool diagnostics legacy fallback", () => {
|
25 | 25 | }); |
26 | 26 | |
27 | 27 | expect(mocks.logProviderToolSchemaDiagnostics).toHaveBeenCalledTimes(1); |
28 | | -expect(mocks.logProviderToolSchemaDiagnostics.mock.calls[0]?.[0]).toEqual({ |
| 28 | +expect(mocks.logProviderToolSchemaDiagnostics.mock.calls.at(0)?.[0]).toEqual({ |
29 | 29 | tools, |
30 | 30 | provider: "openai", |
31 | 31 | config: undefined, |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。