test: tighten gateway send assertions · openclaw/openclaw@cca6c4c
steipete
·
2026-05-11
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -319,15 +319,20 @@ describe("sanitizeSystemRunParamsForForwarding", () => {
|
319 | 319 | const forwarded = result.params as Record<string, unknown>; |
320 | 320 | expect(forwarded.command).toEqual(["/usr/bin/echo", "SAFE"]); |
321 | 321 | expect(forwarded.rawCommand).toBe("/usr/bin/echo SAFE"); |
322 | | -expect(forwarded.systemRunPlan).toEqual( |
323 | | -expect.objectContaining({ |
324 | | -argv: ["/usr/bin/echo", "SAFE"], |
325 | | -cwd: "/real/cwd", |
326 | | -commandText: "/usr/bin/echo SAFE", |
327 | | -agentId: "main", |
328 | | -sessionKey: "agent:main:main", |
329 | | -}), |
330 | | -); |
| 322 | +const systemRunPlan = forwarded.systemRunPlan as |
| 323 | +| { |
| 324 | +argv?: string[]; |
| 325 | +cwd?: string; |
| 326 | +commandText?: string; |
| 327 | +agentId?: string; |
| 328 | +sessionKey?: string; |
| 329 | +} |
| 330 | +| undefined; |
| 331 | +expect(systemRunPlan?.argv).toEqual(["/usr/bin/echo", "SAFE"]); |
| 332 | +expect(systemRunPlan?.cwd).toBe("/real/cwd"); |
| 333 | +expect(systemRunPlan?.commandText).toBe("/usr/bin/echo SAFE"); |
| 334 | +expect(systemRunPlan?.agentId).toBe("main"); |
| 335 | +expect(systemRunPlan?.sessionKey).toBe("agent:main:main"); |
331 | 336 | expect(forwarded.cwd).toBe("/real/cwd"); |
332 | 337 | expect(forwarded.agentId).toBe("main"); |
333 | 338 | expect(forwarded.sessionKey).toBe("agent:main:main"); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -332,12 +332,8 @@ describe("config shared auth disconnects", () => {
|
332 | 332 | |
333 | 333 | await configHandlers["config.patch"](options); |
334 | 334 | |
335 | | -expect(restartSentinelMocks.writeRestartSentinel).toHaveBeenCalledWith( |
336 | | -expect.objectContaining({ |
337 | | -sessionKey: "agent:main:main", |
338 | | -}), |
339 | | -); |
340 | 335 | const payload = restartSentinelMocks.writeRestartSentinel.mock.calls.at(-1)?.[0]; |
| 336 | +expect(payload?.sessionKey).toBe("agent:main:main"); |
341 | 337 | expect(payload?.continuation).toBeUndefined(); |
342 | 338 | }); |
343 | 339 | }); |
| Original file line number | Diff line number | Diff line change |
|---|
@@ -787,13 +787,10 @@ describe("gateway send mirroring", () => {
|
787 | 787 | idempotencyKey: "idem-send-options", |
788 | 788 | }); |
789 | 789 | |
790 | | -expect(mocks.deliverOutboundPayloads).toHaveBeenCalledWith( |
791 | | -expect.objectContaining({ |
792 | | -forceDocument: true, |
793 | | -silent: true, |
794 | | -formatting: { parseMode: "HTML" }, |
795 | | -}), |
796 | | -); |
| 790 | +const options = mocks.deliverOutboundPayloads.mock.calls[0]?.[0]; |
| 791 | +expect(options?.forceDocument).toBe(true); |
| 792 | +expect(options?.silent).toBe(true); |
| 793 | +expect(options?.formatting).toEqual({ parseMode: "HTML" }); |
797 | 794 | }); |
798 | 795 | |
799 | 796 | it("updates mirror session keys and delivery thread ids when Slack routing derives a thread", async () => { |
@@ -1098,7 +1095,7 @@ describe("gateway send mirroring", () => {
|
1098 | 1095 | }); |
1099 | 1096 | |
1100 | 1097 | expect(firstRespondCall(respond)?.[0]).toBe(true); |
1101 | | -expect(capturedMediaLocalRoots).toEqual(expect.arrayContaining([TEST_AGENT_WORKSPACE])); |
| 1098 | +expect(capturedMediaLocalRoots).toContain(TEST_AGENT_WORKSPACE); |
1102 | 1099 | }); |
1103 | 1100 | |
1104 | 1101 | it("forces senderIsOwner=false for narrowly-scoped callers but honors it for full operators", async () => { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -2303,13 +2303,23 @@ describe("gateway healthHandlers.health cache freshness", () => {
|
2303 | 2303 | isWebchatConnect: () => false, |
2304 | 2304 | }); |
2305 | 2305 | |
2306 | | -expect(mockCallArg(respond, 0, 1)).toMatchObject({ |
2307 | | -modelPricing: { |
2308 | | -state: "degraded", |
2309 | | -detail: "OpenRouter pricing fetch failed: TypeError: fetch failed", |
2310 | | -sources: [{ source: "openrouter", state: "degraded", lastFailureAt: 123 }], |
2311 | | -}, |
2312 | | -}); |
| 2306 | +const payload = mockCallArg(respond, 0, 1) as |
| 2307 | +| { |
| 2308 | +modelPricing?: { |
| 2309 | +state?: string; |
| 2310 | +detail?: string; |
| 2311 | +sources?: Array<{ source?: string; state?: string; lastFailureAt?: number }>; |
| 2312 | +}; |
| 2313 | +} |
| 2314 | +| undefined; |
| 2315 | +expect(payload?.modelPricing?.state).toBe("degraded"); |
| 2316 | +expect(payload?.modelPricing?.detail).toBe( |
| 2317 | +"OpenRouter pricing fetch failed: TypeError: fetch failed", |
| 2318 | +); |
| 2319 | +expect(payload?.modelPricing?.sources).toHaveLength(1); |
| 2320 | +expect(payload?.modelPricing?.sources?.[0]?.source).toBe("openrouter"); |
| 2321 | +expect(payload?.modelPricing?.sources?.[0]?.state).toBe("degraded"); |
| 2322 | +expect(payload?.modelPricing?.sources?.[0]?.lastFailureAt).toBe(123); |
2313 | 2323 | expect(mockCallArg(respond, 0, 3)).toEqual({ cached: true }); |
2314 | 2324 | expect(refreshHealthSnapshot).toHaveBeenCalledWith({ |
2315 | 2325 | probe: false, |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -151,10 +151,8 @@ describe("sessions_send gateway loopback", () => {
|
151 | 151 | | { lane?: string; inputProvenance?: { kind?: string; sourceTool?: string } } |
152 | 152 | | undefined; |
153 | 153 | expect(firstCall?.lane).toMatch(/^nested(?::|$)/); |
154 | | -expect(firstCall?.inputProvenance).toMatchObject({ |
155 | | -kind: "inter_session", |
156 | | -sourceTool: "sessions_send", |
157 | | -}); |
| 154 | +expect(firstCall?.inputProvenance?.kind).toBe("inter_session"); |
| 155 | +expect(firstCall?.inputProvenance?.sourceTool).toBe("sessions_send"); |
158 | 156 | }); |
159 | 157 | }); |
160 | 158 | |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。