test: guard extension app mock calls · openclaw/openclaw@04139a7
steipete
·
2026-05-12
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -71,7 +71,7 @@ describe("azure speech tts", () => {
|
71 | 71 | |
72 | 72 | expect(result).toEqual(Buffer.from("mp3")); |
73 | 73 | expect(fetchMock).toHaveBeenCalledOnce(); |
74 | | -const [url, init] = fetchMock.mock.calls[0] as [string, RequestInit]; |
| 74 | +const [url, init] = fetchMock.mock.calls.at(0) as [string, RequestInit]; |
75 | 75 | expect(url).toBe("https://eastus.tts.speech.microsoft.com/cognitiveservices/v1"); |
76 | 76 | expect(init.method).toBe("POST"); |
77 | 77 | const headers = new Headers(init.headers); |
@@ -109,7 +109,7 @@ describe("azure speech tts", () => {
|
109 | 109 | }); |
110 | 110 | |
111 | 111 | expect(fetchMock).toHaveBeenCalledOnce(); |
112 | | -const [url, init] = fetchMock.mock.calls[0] as [string, RequestInit]; |
| 112 | +const [url, init] = fetchMock.mock.calls.at(0) as [string, RequestInit]; |
113 | 113 | expect(url).toBe("https://custom.example.com/cognitiveservices/voices/list"); |
114 | 114 | expect(new Headers(init.headers).get("Ocp-Apim-Subscription-Key")).toBe("speech-key"); |
115 | 115 | expect(init.signal).toBeInstanceOf(AbortSignal); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -127,14 +127,14 @@ describe("handleClickClackInbound", () => {
|
127 | 127 | |
128 | 128 | expect(runtime.channel.turn.runPrepared).not.toHaveBeenCalled(); |
129 | 129 | expect(runtime.agent.runEmbeddedPiAgent).not.toHaveBeenCalled(); |
130 | | -const completionRequest = (runtime.llm.complete as LlmCompleteMock).mock.calls[0]?.[0]; |
| 130 | +const completionRequest = (runtime.llm.complete as LlmCompleteMock).mock.calls.at(0)?.[0]; |
131 | 131 | expect(completionRequest?.agentId).toBe("service-bot"); |
132 | 132 | expect(completionRequest?.model).toBe("openai/gpt-5.4-mini"); |
133 | 133 | expect(completionRequest?.maxTokens).toBe(96); |
134 | 134 | expect(completionRequest?.purpose).toBe("clickclack bot reply"); |
135 | 135 | expect(completionRequest?.messages).toEqual([{ role: "user", content: "hello bot" }]); |
136 | 136 | |
137 | | -const sendRequest = sendClickClackTextMock.mock.calls[0]?.[0]; |
| 137 | +const sendRequest = sendClickClackTextMock.mock.calls.at(0)?.[0]; |
138 | 138 | expect(sendRequest?.accountId).toBe("service"); |
139 | 139 | expect(sendRequest?.to).toBe("channel:chn_1"); |
140 | 140 | expect(sendRequest?.text).toBe("service bot online"); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -57,8 +57,8 @@ describe("CodexAppServerClient", () => {
|
57 | 57 | harness.process.stdout.write('{"token":"secret-value"} trailing\n'); |
58 | 58 | |
59 | 59 | await vi.waitFor(() => expect(warn).toHaveBeenCalledTimes(1)); |
60 | | -expect(warn.mock.calls[0]?.[0]).toBe("failed to parse codex app-server message"); |
61 | | -const metadata = warn.mock.calls[0]?.[1] as |
| 60 | +expect(warn.mock.calls.at(0)?.[0]).toBe("failed to parse codex app-server message"); |
| 61 | +const metadata = warn.mock.calls.at(0)?.[1] as |
62 | 62 | | { |
63 | 63 | error?: unknown; |
64 | 64 | errorMessage?: string; |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -229,7 +229,7 @@ describe("maybeCompactCodexAppServerSession", () => {
|
229 | 229 | expect(nativeDetails?.details?.backend).toBe("codex-app-server"); |
230 | 230 | expect(nativeDetails?.details?.threadId).toBe("thread-1"); |
231 | 231 | expect(compact).toHaveBeenCalledTimes(1); |
232 | | -const [compactCall] = compact.mock.calls[0] ?? []; |
| 232 | +const [compactCall] = compact.mock.calls.at(0) ?? []; |
233 | 233 | expect(compactCall).toStrictEqual({ |
234 | 234 | sessionId: "session-1", |
235 | 235 | sessionKey: "agent:main:session-1", |
@@ -242,7 +242,7 @@ describe("maybeCompactCodexAppServerSession", () => {
|
242 | 242 | runtimeContext: { workspaceDir: tempDir, provider: "codex" }, |
243 | 243 | }); |
244 | 244 | expect(maintain).toHaveBeenCalledTimes(1); |
245 | | -const [maintainCall] = maintain.mock.calls[0] ?? []; |
| 245 | +const [maintainCall] = maintain.mock.calls.at(0) ?? []; |
246 | 246 | const maintainParams = maintainCall as |
247 | 247 | | { |
248 | 248 | sessionId?: string; |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -67,7 +67,7 @@ describe("CodexNativeSubagentTaskMirror", () => {
|
67 | 67 | progressSummary: "Codex native subagent started.", |
68 | 68 | }), |
69 | 69 | ); |
70 | | -expect(vi.mocked(runtime.createRunningTaskRun).mock.calls[0]?.[0]).not.toHaveProperty( |
| 70 | +expect(vi.mocked(runtime.createRunningTaskRun).mock.calls.at(0)?.[0]).not.toHaveProperty( |
71 | 71 | "childSessionKey", |
72 | 72 | ); |
73 | 73 | expect(runtime.recordTaskRunProgressByRunId).toHaveBeenCalledWith( |
@@ -251,7 +251,7 @@ describe("CodexNativeSubagentTaskMirror", () => {
|
251 | 251 | deliveryStatus: "not_applicable", |
252 | 252 | }), |
253 | 253 | ); |
254 | | -expect(vi.mocked(runtime.createRunningTaskRun).mock.calls[0]?.[0]).not.toHaveProperty( |
| 254 | +expect(vi.mocked(runtime.createRunningTaskRun).mock.calls.at(0)?.[0]).not.toHaveProperty( |
255 | 255 | "childSessionKey", |
256 | 256 | ); |
257 | 257 | expect(runtime.recordTaskRunProgressByRunId).toHaveBeenCalledWith( |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -74,7 +74,7 @@ describe("registerFeishuChatTools", () => {
|
74 | 74 | ); |
75 | 75 | |
76 | 76 | expect(registerTool).toHaveBeenCalledTimes(1); |
77 | | -const tool = registerTool.mock.calls[0]?.[0]; |
| 77 | +const tool = registerTool.mock.calls.at(0)?.[0]; |
78 | 78 | expect(tool?.name).toBe("feishu_chat"); |
79 | 79 | |
80 | 80 | chatGetMock.mockResolvedValueOnce({ |
@@ -205,7 +205,7 @@ describe("registerFeishuChatTools", () => {
|
205 | 205 | }), |
206 | 206 | ); |
207 | 207 | |
208 | | -const tool = registerTool.mock.calls[0]?.[0]; |
| 208 | +const tool = registerTool.mock.calls.at(0)?.[0]; |
209 | 209 | contactUserGetMock.mockRejectedValueOnce( |
210 | 210 | Object.assign(new Error("Request failed with status code 400"), { |
211 | 211 | response: { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -63,8 +63,8 @@ describe("feishu_doc account selection", () => {
|
63 | 63 | await docToolB.execute("call-b", { action: "list_blocks", doc_token: "d" }); |
64 | 64 | |
65 | 65 | expect(createFeishuClientMock).toHaveBeenCalledTimes(2); |
66 | | -expect(createFeishuClientMock.mock.calls[0]?.[0]?.appId).toBe("app-a"); |
67 | | -expect(createFeishuClientMock.mock.calls[1]?.[0]?.appId).toBe("app-b"); |
| 66 | +expect(createFeishuClientMock.mock.calls.at(0)?.[0]?.appId).toBe("app-a"); |
| 67 | +expect(createFeishuClientMock.mock.calls.at(1)?.[0]?.appId).toBe("app-b"); |
68 | 68 | }); |
69 | 69 | |
70 | 70 | test("explicit accountId param overrides agentAccountId context", async () => { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -233,7 +233,7 @@ describe("feishu_doc image fetch hardening", () => {
|
233 | 233 | }); |
234 | 234 | |
235 | 235 | expect(blockDescendantCreateMock).toHaveBeenCalledTimes(1); |
236 | | -const call = blockDescendantCreateMock.mock.calls[0]?.[0]; |
| 236 | +const call = blockDescendantCreateMock.mock.calls.at(0)?.[0]; |
237 | 237 | expect(call?.data.children_id).toEqual(["h1", "t1", "h2"]); |
238 | 238 | for (const block of blocks) { |
239 | 239 | expect(call?.data.descendants).toContainEqual(block); |
@@ -275,7 +275,7 @@ describe("feishu_doc image fetch hardening", () => {
|
275 | 275 | content: "tree reorder", |
276 | 276 | }); |
277 | 277 | |
278 | | -const call = blockDescendantCreateMock.mock.calls[0]?.[0]; |
| 278 | +const call = blockDescendantCreateMock.mock.calls.at(0)?.[0]; |
279 | 279 | expect(call?.data.children_id).toEqual(["h1", "p1", "h2", "list1"]); |
280 | 280 | expect((call?.data.descendants as Array<{ block_id: string }>).map((b) => b.block_id)).toEqual([ |
281 | 281 | "h1", |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -828,7 +828,7 @@ describe("drive.notice.comment_add_v1 monitor handler", () => {
|
828 | 828 | await onComment(makeDriveCommentEvent()); |
829 | 829 | |
830 | 830 | expect(handleFeishuCommentEventMock).toHaveBeenCalledTimes(1); |
831 | | -const handleArgs = handleFeishuCommentEventMock.mock.calls[0]?.[0] as |
| 831 | +const handleArgs = handleFeishuCommentEventMock.mock.calls.at(0)?.[0] as |
832 | 832 | | { |
833 | 833 | accountId?: string; |
834 | 834 | botOpenId?: string; |
@@ -918,7 +918,7 @@ describe("drive.notice.comment_add_v1 monitor handler", () => {
|
918 | 918 | ); |
919 | 919 | }); |
920 | 920 | const [recordedMessageId, recordedNamespace, recordedLogger] = |
921 | | -(dedup.recordProcessedFeishuMessage as ReturnType<typeof vi.fn>).mock.calls[0] ?? []; |
| 921 | +(dedup.recordProcessedFeishuMessage as ReturnType<typeof vi.fn>).mock.calls.at(0) ?? []; |
922 | 922 | expect(recordedMessageId).toBe("drive-comment:10d9d60b990db39f96a4c2fd357fb877"); |
923 | 923 | expect(recordedNamespace).toBe("default"); |
924 | 924 | expect(typeof recordedLogger).toBe("function"); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -140,8 +140,8 @@ describe("feishu tool account routing", () => {
|
140 | 140 | await tool.execute("call-ctx", { url: "invalid-url" }); |
141 | 141 | await tool.execute("call-override", { url: "invalid-url", accountId: "a" }); |
142 | 142 | |
143 | | -expect(createFeishuClientMock.mock.calls[0]?.[0]?.appId).toBe("app-b"); |
144 | | -expect(createFeishuClientMock.mock.calls[1]?.[0]?.appId).toBe("app-a"); |
| 143 | +expect(createFeishuClientMock.mock.calls.at(0)?.[0]?.appId).toBe("app-b"); |
| 144 | +expect(createFeishuClientMock.mock.calls.at(1)?.[0]?.appId).toBe("app-a"); |
145 | 145 | }); |
146 | 146 | |
147 | 147 | test("falls back to the configured Feishu default selection when agentAccountId is not a real account", async () => { |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。