test: tighten openclaw tools assertions · openclaw/openclaw@f18e072
steipete
·
2026-05-09
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -44,10 +44,9 @@ describe("agents_list", () => {
|
44 | 44 | }; |
45 | 45 | const tool = createTool(); |
46 | 46 | const result = await tool.execute("call1", {}); |
47 | | -expect(result.details).toMatchObject({ |
48 | | -requester: "main", |
49 | | -allowAny: false, |
50 | | -}); |
| 47 | +const details = result.details as { requester?: string; allowAny?: boolean }; |
| 48 | +expect(details.requester).toBe("main"); |
| 49 | +expect(details.allowAny).toBe(false); |
51 | 50 | const agents = readAgentList(result); |
52 | 51 | expect(agents?.map((agent) => agent.id)).toEqual(["main"]); |
53 | 52 | }); |
@@ -121,9 +120,8 @@ describe("agents_list", () => {
|
121 | 120 | |
122 | 121 | const tool = createTool(); |
123 | 122 | const result = await tool.execute("call3", {}); |
124 | | -expect(result.details).toMatchObject({ |
125 | | -allowAny: true, |
126 | | -}); |
| 123 | +const details = result.details as { allowAny?: boolean }; |
| 124 | +expect(details.allowAny).toBe(true); |
127 | 125 | const agents = readAgentList(result); |
128 | 126 | expect(agents?.map((agent) => agent.id)).toEqual(["main", "coder", "research"]); |
129 | 127 | }); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -134,11 +134,8 @@ describe("createOpenClawTools browser plugin integration", () => {
|
134 | 134 | resolvedConfig: config, |
135 | 135 | }); |
136 | 136 | |
137 | | -expect(hoisted.resolvePluginTools).toHaveBeenCalledWith( |
138 | | -expect.objectContaining({ |
139 | | -allowGatewaySubagentBinding: true, |
140 | | -}), |
141 | | -); |
| 137 | +expect(hoisted.resolvePluginTools).toHaveBeenCalledTimes(1); |
| 138 | +expect(hoisted.resolvePluginTools.mock.calls[0]?.[0]?.allowGatewaySubagentBinding).toBe(true); |
142 | 139 | }); |
143 | 140 | |
144 | 141 | it("forwards plugin tool deny policy to plugin resolution", () => { |
@@ -158,12 +155,9 @@ describe("createOpenClawTools browser plugin integration", () => {
|
158 | 155 | resolvedConfig: config, |
159 | 156 | }); |
160 | 157 | |
161 | | -expect(hoisted.resolvePluginTools).toHaveBeenCalledWith( |
162 | | -expect.objectContaining({ |
163 | | -toolAllowlist: ["*"], |
164 | | -toolDenylist: ["browser"], |
165 | | -}), |
166 | | -); |
| 158 | +expect(hoisted.resolvePluginTools).toHaveBeenCalledTimes(1); |
| 159 | +expect(hoisted.resolvePluginTools.mock.calls[0]?.[0]?.toolAllowlist).toEqual(["*"]); |
| 160 | +expect(hoisted.resolvePluginTools.mock.calls[0]?.[0]?.toolDenylist).toEqual(["browser"]); |
167 | 161 | }); |
168 | 162 | |
169 | 163 | it("does not pass a stale active snapshot as plugin runtime config for a resolved run config", () => { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -64,12 +64,16 @@ describe("openclaw-tools: subagents steer failure", () => {
|
64 | 64 | message: "new direction", |
65 | 65 | }); |
66 | 66 | |
67 | | -expect(result.details).toMatchObject({ |
68 | | -status: "error", |
69 | | -action: "steer", |
70 | | -runId: expect.any(String), |
71 | | -error: "dispatch failed", |
72 | | -}); |
| 67 | +const details = result.details as { |
| 68 | +status?: string; |
| 69 | +action?: string; |
| 70 | +runId?: unknown; |
| 71 | +error?: string; |
| 72 | +}; |
| 73 | +expect(details.status).toBe("error"); |
| 74 | +expect(details.action).toBe("steer"); |
| 75 | +expect(details.runId).toBeTypeOf("string"); |
| 76 | +expect(details.error).toBe("dispatch failed"); |
73 | 77 | |
74 | 78 | const runs = listSubagentRunsForRequester("agent:main:main"); |
75 | 79 | expect(runs).toHaveLength(1); |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。