test: tighten subagent assertions · openclaw/openclaw@8afbe42
steipete
·
2026-05-09
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -336,7 +336,14 @@ describe("subagent registry archive behavior", () => {
|
336 | 336 | |
337 | 337 | expect(replaced).toBe(true); |
338 | 338 | await vi.waitFor(async () => { |
339 | | -await expect(fs.access(attachmentsDir)).rejects.toMatchObject({ code: "ENOENT" }); |
| 339 | +let err: unknown; |
| 340 | +try { |
| 341 | +await fs.access(attachmentsDir); |
| 342 | +} catch (caught) { |
| 343 | +err = caught; |
| 344 | +} |
| 345 | +expect(err).toBeInstanceOf(Error); |
| 346 | +expect((err as NodeJS.ErrnoException).code).toBe("ENOENT"); |
340 | 347 | }); |
341 | 348 | }); |
342 | 349 | |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -205,18 +205,14 @@ describe("subagent registry persistence resume", () => {
|
205 | 205 | outcome?: { status?: string }; |
206 | 206 | } |
207 | 207 | | undefined; |
208 | | -expect(announce).toMatchObject({ |
209 | | -childRunId: "run-1", |
210 | | -childSessionKey: "agent:main:subagent:test", |
211 | | -requesterSessionKey: "agent:main:main", |
212 | | -requesterOrigin: { |
213 | | -channel: "whatsapp", |
214 | | -accountId: "acct-main", |
215 | | -}, |
216 | | -task: "do the thing", |
217 | | -cleanup: "keep", |
218 | | -outcome: { status: "ok" }, |
219 | | -}); |
| 208 | +expect(announce?.childRunId).toBe("run-1"); |
| 209 | +expect(announce?.childSessionKey).toBe("agent:main:subagent:test"); |
| 210 | +expect(announce?.requesterSessionKey).toBe("agent:main:main"); |
| 211 | +expect(announce?.requesterOrigin?.channel).toBe("whatsapp"); |
| 212 | +expect(announce?.requesterOrigin?.accountId).toBe("acct-main"); |
| 213 | +expect(announce?.task).toBe("do the thing"); |
| 214 | +expect(announce?.cleanup).toBe("keep"); |
| 215 | +expect(announce?.outcome?.status).toBe("ok"); |
220 | 216 | |
221 | 217 | const restored = mod.listSubagentRunsForRequester("agent:main:main")[0]; |
222 | 218 | expect(restored?.childSessionKey).toBe("agent:main:subagent:test"); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -216,10 +216,15 @@ describe("spawnSubagentDirect filename validation", () => {
|
216 | 216 | : []; |
217 | 217 | expect(retainedDirs).toHaveLength(0); |
218 | 218 | const deleteCall = calls.find((entry) => entry.method === "sessions.delete"); |
219 | | -expect(deleteCall?.params).toMatchObject({ |
220 | | -key: expect.stringMatching(/^agent:main:subagent:/), |
221 | | -deleteTranscript: true, |
222 | | -emitLifecycleHooks: false, |
223 | | -}); |
| 219 | +const deleteParams = deleteCall?.params as |
| 220 | +| { |
| 221 | +key?: string; |
| 222 | +deleteTranscript?: boolean; |
| 223 | +emitLifecycleHooks?: boolean; |
| 224 | +} |
| 225 | +| undefined; |
| 226 | +expect(deleteParams?.key).toMatch(/^agent:main:subagent:/); |
| 227 | +expect(deleteParams?.deleteTranscript).toBe(true); |
| 228 | +expect(deleteParams?.emitLifecycleHooks).toBe(false); |
224 | 229 | }); |
225 | 230 | }); |
| Original file line number | Diff line number | Diff line change |
|---|
@@ -79,10 +79,8 @@ describe("spawnSubagentDirect runtime model persistence", () => {
|
79 | 79 | }, |
80 | 80 | ); |
81 | 81 | |
82 | | -expect(result).toMatchObject({ |
83 | | -status: "accepted", |
84 | | -modelApplied: true, |
85 | | -}); |
| 82 | +expect(result.status).toBe("accepted"); |
| 83 | +expect(result.modelApplied).toBe(true); |
86 | 84 | expect(updateSessionStoreMock).toHaveBeenCalledTimes(3); |
87 | 85 | expectPersistedRuntimeModel({ |
88 | 86 | persistedStore, |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。