test: tighten command assertions · openclaw/openclaw@8aa2864
steipete
·
2026-05-11
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -336,10 +336,15 @@ describe("acp translator stable lifecycle handlers", () => {
|
336 | 336 | const result = await agent.resumeSession(createResumeSessionRequest("agent:main:work")); |
337 | 337 | |
338 | 338 | expect(result.modes?.currentModeId).toBe("adaptive"); |
| 339 | +expect(result.configOptions).toBeDefined(); |
| 340 | +if (!result.configOptions) { |
| 341 | +throw new Error("expected resume session config options"); |
| 342 | +} |
339 | 343 | const thoughtLevelOption = result.configOptions.find((option) => option.id === "thought_level"); |
340 | 344 | expect(thoughtLevelOption?.currentValue).toBe("adaptive"); |
341 | 345 | expect(sessionStore.getSession("agent:main:work")?.sessionKey).toBe("agent:main:work"); |
342 | | -expect(request.mock.calls.map((call) => call[0])).not.toContain("sessions.get"); |
| 346 | +const requestCalls = (request as unknown as { mock: { calls: Array<[string]> } }).mock.calls; |
| 347 | +expect(requestCalls.map((call) => call[0])).not.toContain("sessions.get"); |
343 | 348 | expect(sessionUpdate).toHaveBeenCalledWith({ |
344 | 349 | sessionId: "agent:main:work", |
345 | 350 | update: { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -207,11 +207,7 @@ function expectSetupSnapshotDoesNotScopeToPlugin(params: {
|
207 | 207 | workspaceDir: "/tmp/openclaw-workspace", |
208 | 208 | }); |
209 | 209 | |
210 | | -expect(loadOpenClawPlugins).toHaveBeenCalledWith( |
211 | | -expect.not.objectContaining({ |
212 | | -onlyPluginIds: [params.pluginId], |
213 | | -}), |
214 | | -); |
| 210 | +expect(loadOpenClawPlugins).toHaveBeenCalledTimes(1); |
215 | 211 | const firstLoadCall = vi.mocked(loadOpenClawPlugins).mock.calls[0]?.[0] as |
216 | 212 | | { onlyPluginIds?: string[] } |
217 | 213 | | undefined; |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -1455,11 +1455,9 @@ describe("doctor config flow", () => {
|
1455 | 1455 | }); |
1456 | 1456 | |
1457 | 1457 | expect(noteImplicitFallbackClobberWarningsMock).toHaveBeenCalledTimes(1); |
1458 | | -expect(noteImplicitFallbackClobberWarningsMock).toHaveBeenCalledWith( |
1459 | | -expect.objectContaining({ |
1460 | | -agents: config.agents, |
1461 | | -}), |
1462 | | -); |
| 1458 | +const [[warningParams]] = noteImplicitFallbackClobberWarningsMock.mock |
| 1459 | +.calls as unknown as Array<[{ agents?: unknown }]>; |
| 1460 | +expect(warningParams.agents).toStrictEqual(config.agents); |
1463 | 1461 | const doctorWarnings = terminalNoteMock.mock.calls |
1464 | 1462 | .filter(([, title]) => title === "Doctor warnings") |
1465 | 1463 | .map(([message]) => message); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -398,18 +398,20 @@ describe("gateway-status command", () => {
|
398 | 398 | expect(runtimeErrors).toHaveLength(0); |
399 | 399 | const parsed = JSON.parse(runtimeLogs.join("\n")) as { |
400 | 400 | degraded?: boolean; |
401 | | -warnings?: Array<{ code?: string; message?: string }>; |
| 401 | +warnings?: Array<{ code?: string; message?: string; targetIds?: string[] }>; |
402 | 402 | }; |
403 | 403 | expect(parsed.degraded).toBe(true); |
404 | | -expect(parsed.warnings).toEqual( |
405 | | -expect.arrayContaining([ |
406 | | -expect.objectContaining({ |
407 | | -code: "model_pricing_degraded", |
408 | | -message: |
409 | | -"Model pricing degraded: OpenRouter pricing fetch failed: TypeError: fetch failed", |
410 | | -}), |
411 | | -]), |
412 | | -); |
| 404 | +const pricingWarnings = |
| 405 | +parsed.warnings?.filter((warning) => warning.code === "model_pricing_degraded") ?? []; |
| 406 | +expect(pricingWarnings).toHaveLength(2); |
| 407 | +expect(pricingWarnings.map((warning) => warning.message)).toEqual([ |
| 408 | +"Model pricing degraded: OpenRouter pricing fetch failed: TypeError: fetch failed", |
| 409 | +"Model pricing degraded: OpenRouter pricing fetch failed: TypeError: fetch failed", |
| 410 | +]); |
| 411 | +expect(pricingWarnings.map((warning) => warning.targetIds)).toEqual([ |
| 412 | +["sshTunnel"], |
| 413 | +["configRemote"], |
| 414 | +]); |
413 | 415 | }); |
414 | 416 | |
415 | 417 | it("includes diagnostic next steps when no gateway is reachable or discoverable", async () => { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -209,11 +209,10 @@ describe("status-json-payload", () => {
|
209 | 209 | secretDiagnostics: [], |
210 | 210 | }); |
211 | 211 | |
212 | | -expect(payload.gateway).toMatchObject({ |
213 | | -modelPricing: { |
214 | | -state: "degraded", |
215 | | -detail: "OpenRouter pricing fetch failed: TypeError: fetch failed", |
216 | | -}, |
217 | | -}); |
| 212 | +const modelPricing = payload.gateway.modelPricing as |
| 213 | +| { state?: string; detail?: string } |
| 214 | +| undefined; |
| 215 | +expect(modelPricing?.state).toBe("degraded"); |
| 216 | +expect(modelPricing?.detail).toBe("OpenRouter pricing fetch failed: TypeError: fetch failed"); |
218 | 217 | }); |
219 | 218 | }); |
| Original file line number | Diff line number | Diff line change |
|---|
@@ -85,13 +85,9 @@ describe("buildStatusCommandReportData", () => {
|
85 | 85 | }), |
86 | 86 | ); |
87 | 87 | |
88 | | -expect(result.overviewRows).toEqual( |
89 | | -expect.arrayContaining([ |
90 | | -{ |
91 | | -Item: "Model pricing", |
92 | | -Value: "warn(degraded · OpenRouter pricing fetch failed: TypeError: fetch failed)", |
93 | | -}, |
94 | | -]), |
95 | | -); |
| 88 | +expect(result.overviewRows).toContainEqual({ |
| 89 | +Item: "Model pricing", |
| 90 | +Value: "warn(degraded · OpenRouter pricing fetch failed: TypeError: fetch failed)", |
| 91 | +}); |
96 | 92 | }); |
97 | 93 | }); |
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。