test: guard embedded runner mock calls · openclaw/openclaw@16adcc7
steipete
·
2026-05-12
·
via Recent Commits to openclaw:main
File tree
src/agents/pi-embedded-runner
| Original file line number | Diff line number | Diff line change |
|---|
@@ -1245,7 +1245,7 @@ describe("compactEmbeddedPiSession hooks (ownsCompaction engine)", () => {
|
1245 | 1245 | |
1246 | 1246 | expect(result.ok).toBe(true); |
1247 | 1247 | const runtimeContext = ( |
1248 | | -maintain.mock.calls[0]?.[0] as { runtimeContext?: Record<string, unknown> } | undefined |
| 1248 | +maintain.mock.calls.at(0)?.[0] as { runtimeContext?: Record<string, unknown> } | undefined |
1249 | 1249 | )?.runtimeContext; |
1250 | 1250 | expectRecordFields(mockCallArg(maintain), { |
1251 | 1251 | sessionKey: TEST_SESSION_KEY, |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -300,7 +300,7 @@ describe("google prompt cache", () => {
|
300 | 300 | ); |
301 | 301 | |
302 | 302 | expect(fetchMock).toHaveBeenCalledTimes(1); |
303 | | -expect(String(fetchMock.mock.calls[0]?.[0])).toBe( |
| 303 | +expect(String(fetchMock.mock.calls.at(0)?.[0])).toBe( |
304 | 304 | "https://generativelanguage.googleapis.com/v1beta/cachedContents/system-cache-3?updateMask=ttl", |
305 | 305 | ); |
306 | 306 | expect(fetchInit(fetchMock).method).toBe("PATCH"); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -52,7 +52,7 @@ let resolveModelAsync: typeof import("./model.js").resolveModelAsync;
|
52 | 52 | |
53 | 53 | function expectWorkspaceHookCall(mock: { mock: { calls: unknown[][] } }) { |
54 | 54 | expect(mock.mock.calls).toHaveLength(1); |
55 | | -const [arg] = mock.mock.calls[0] ?? []; |
| 55 | +const [arg] = mock.mock.calls.at(0) ?? []; |
56 | 56 | if (!arg || typeof arg !== "object") { |
57 | 57 | throw new Error("Expected runtime hook call argument"); |
58 | 58 | } |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -223,7 +223,9 @@ describe("embedded attempt context injection", () => {
|
223 | 223 | modelId: "gpt-test", |
224 | 224 | }); |
225 | 225 | |
226 | | -const assembleInput = assemble.mock.calls[0]?.[0] as { messages?: AgentMessage[] } | undefined; |
| 226 | +const assembleInput = assemble.mock.calls.at(0)?.[0] as |
| 227 | +| { messages?: AgentMessage[] } |
| 228 | +| undefined; |
227 | 229 | const projectedMessages = assembleInput?.messages?.map((message) => ({ |
228 | 230 | role: message.role, |
229 | 231 | content: (message as { content?: unknown }).content, |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -179,7 +179,7 @@ describe("createEmbeddedRunAuthController", () => {
|
179 | 179 | |
180 | 180 | await controller.initializeAuthProfile(); |
181 | 181 | |
182 | | -const apiKeyParams = mocks.getApiKeyForModel.mock.calls[0]?.[0] as |
| 182 | +const apiKeyParams = mocks.getApiKeyForModel.mock.calls.at(0)?.[0] as |
183 | 183 | | { agentDir?: string; workspaceDir?: string } |
184 | 184 | | undefined; |
185 | 185 | expect(apiKeyParams?.agentDir).toBe("/tmp/agent"); |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。