test: clear canvas broad matchers · openclaw/openclaw@9d67ff8
shakkernerd
·
2026-05-10
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -58,14 +58,26 @@ describe("canvas CLI", () => {
|
58 | 58 | from: "user", |
59 | 59 | }); |
60 | 60 | |
| 61 | +expect(deps.callGatewayCli).toHaveBeenCalledTimes(1); |
61 | 62 | expect(deps.callGatewayCli).toHaveBeenCalledWith( |
62 | 63 | "node.invoke", |
63 | | -expect.objectContaining({ node: "ios-node" }), |
64 | | -expect.objectContaining({ |
| 64 | +{ |
| 65 | +node: "ios-node", |
| 66 | +format: "jpg", |
| 67 | +timeout: "10000", |
| 68 | +json: false, |
| 69 | +invokeTimeout: "20000", |
| 70 | +}, |
| 71 | +{ |
65 | 72 | nodeId: "ios-node", |
66 | 73 | command: "canvas.snapshot", |
67 | | -params: expect.objectContaining({ format: "jpeg" }), |
68 | | -}), |
| 74 | +params: { |
| 75 | +format: "jpeg", |
| 76 | +maxWidth: undefined, |
| 77 | +quality: undefined, |
| 78 | +}, |
| 79 | +timeoutMs: 20000, |
| 80 | +}, |
69 | 81 | ); |
70 | 82 | expect(writtenFiles).toHaveLength(1); |
71 | 83 | const [writtenFile] = writtenFiles; |
@@ -74,6 +86,9 @@ describe("canvas CLI", () => {
|
74 | 86 | } |
75 | 87 | expect(writtenFile.filePath).toMatch(/openclaw-canvas-snapshot-.*\.png$/); |
76 | 88 | expect(writtenFile.base64).toBe("aGk="); |
77 | | -expect(runtime.log).toHaveBeenCalledWith(expect.stringMatching(/^MEDIA:.*\.png$/)); |
| 89 | +expect(runtime.log).toHaveBeenCalledTimes(1); |
| 90 | +const mediaMessage = runtime.log.mock.calls[0]?.[0]; |
| 91 | +expect(mediaMessage?.startsWith("MEDIA:")).toBe(true); |
| 92 | +expect(mediaMessage?.endsWith(".png")).toBe(true); |
78 | 93 | }); |
79 | 94 | }); |
| Original file line number | Diff line number | Diff line change |
|---|
@@ -16,10 +16,11 @@ async function withCanvasTemp<T>(prefix: string, run: (dir: string) => Promise<T
|
16 | 16 | function expectResolvedFile( |
17 | 17 | result: Awaited<ReturnType<typeof resolveFileWithinRoot>>, |
18 | 18 | ): ResolvedFile { |
19 | | -expect(result).toEqual(expect.objectContaining({ handle: expect.any(Object) })); |
20 | 19 | if (result === null) { |
21 | 20 | throw new Error("Expected resolved file within root"); |
22 | 21 | } |
| 22 | +expect(typeof result.handle.close).toBe("function"); |
| 23 | +expect(typeof result.handle.readFile).toBe("function"); |
23 | 24 | return result; |
24 | 25 | } |
25 | 26 | |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -82,11 +82,18 @@ describe("Canvas tool", () => {
|
82 | 82 | |
83 | 83 | await tool.execute("tool-call-1", { action: "snapshot" }); |
84 | 84 | |
85 | | -expect(mocks.imageResultFromFile).toHaveBeenCalledWith( |
86 | | -expect.objectContaining({ |
87 | | -label: "canvas:snapshot", |
88 | | -imageSanitization: { maxDimensionPx: 1600 }, |
89 | | -}), |
90 | | -); |
| 85 | +expect(mocks.imageResultFromFile).toHaveBeenCalledTimes(1); |
| 86 | +const imageResultParams = mocks.imageResultFromFile.mock.calls[0]?.[0] as |
| 87 | +| { |
| 88 | +label?: string; |
| 89 | +path?: string; |
| 90 | +details?: unknown; |
| 91 | +imageSanitization?: unknown; |
| 92 | +} |
| 93 | +| undefined; |
| 94 | +expect(imageResultParams?.label).toBe("canvas:snapshot"); |
| 95 | +expect(imageResultParams?.path).toMatch(/openclaw-canvas-snapshot-.*\.png$/); |
| 96 | +expect(imageResultParams?.details).toEqual({ format: "png" }); |
| 97 | +expect(imageResultParams?.imageSanitization).toEqual({ maxDimensionPx: 1600 }); |
91 | 98 | }); |
92 | 99 | }); |
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。