test: guard agent tool mock calls · openclaw/openclaw@84b0c62
steipete
·
2026-05-12
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -22,7 +22,7 @@ const {
|
22 | 22 | } = await import("./music-generate-background.js"); |
23 | 23 | |
24 | 24 | function getDeliveredInternalEvents(): Array<Record<string, unknown>> { |
25 | | -const params = announceDeliveryMocks.deliverSubagentAnnouncement.mock.calls[0]?.[0] as |
| 25 | +const params = announceDeliveryMocks.deliverSubagentAnnouncement.mock.calls.at(0)?.[0] as |
26 | 26 | | { internalEvents?: unknown } |
27 | 27 | | undefined; |
28 | 28 | if (!Array.isArray(params?.internalEvents)) { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -152,11 +152,12 @@ describe("createNodesTool screen_record duration guardrails", () => {
|
152 | 152 | }); |
153 | 153 | |
154 | 154 | expect(gatewayMocks.callGatewayTool).toHaveBeenCalledTimes(1); |
155 | | -const call = gatewayMocks.callGatewayTool.mock.calls[0] as [ |
156 | | -string, |
157 | | -unknown, |
158 | | -{ params?: { durationMs?: unknown } }, |
159 | | -]; |
| 155 | +const call = gatewayMocks.callGatewayTool.mock.calls.at(0) as |
| 156 | +| [string, unknown, { params?: { durationMs?: unknown } }] |
| 157 | +| undefined; |
| 158 | +if (!call) { |
| 159 | +throw new Error("expected callGatewayTool to be called"); |
| 160 | +} |
160 | 161 | expect(call[0]).toBe("node.invoke"); |
161 | 162 | expect(call[1]).toStrictEqual({}); |
162 | 163 | expect(call[2].params?.durationMs).toBe(300_000); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -208,7 +208,7 @@ describe("web_fetch provider fallback normalization", () => {
|
208 | 208 | expect(details.wrappedLength).toBeGreaterThan(200); |
209 | 209 | expect(details.wrappedLength).toBeLessThanOrEqual(640); |
210 | 210 | expect(details.externalContent?.provider).toBe("firecrawl"); |
211 | | -const definitionInput = resolveWebFetchDefinitionMock.mock.calls[0]?.[0] as |
| 211 | +const definitionInput = resolveWebFetchDefinitionMock.mock.calls.at(0)?.[0] as |
212 | 212 | | { |
213 | 213 | config?: OpenClawConfig; |
214 | 214 | runtimeWebFetch?: { selectedProvider?: string }; |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -31,10 +31,13 @@ describe("web_search redirect resolution hardening", () => {
|
31 | 31 | const resolved = await resolveCitationRedirectUrl("https://example.com/start"); |
32 | 32 | expect(resolved).toBe("https://example.com/final"); |
33 | 33 | expect(withStrictWebToolsEndpointMock).toHaveBeenCalledTimes(1); |
34 | | -const [params, run] = withStrictWebToolsEndpointMock.mock.calls[0] as [ |
35 | | -{ url?: unknown; timeoutMs?: unknown; init?: { method?: unknown } }, |
36 | | -unknown, |
37 | | -]; |
| 34 | +const call = withStrictWebToolsEndpointMock.mock.calls.at(0) as |
| 35 | +| [{ url?: unknown; timeoutMs?: unknown; init?: { method?: unknown } }, unknown] |
| 36 | +| undefined; |
| 37 | +if (!call) { |
| 38 | +throw new Error("expected withStrictWebToolsEndpoint to be called"); |
| 39 | +} |
| 40 | +const [params, run] = call; |
38 | 41 | expect(params.url).toBe("https://example.com/start"); |
39 | 42 | expect(params.timeoutMs).toBe(5000); |
40 | 43 | expect(params.init?.method).toBe("HEAD"); |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。