




















@@ -59,6 +59,10 @@ describe("normalizeWebchatReplyMediaPathsForDisplay", () => {
5959return value;
6060}
616162+async function expectPathMissing(targetPath: string): Promise<void> {
63+await expect(fs.stat(targetPath)).rejects.toMatchObject({ code: "ENOENT" });
64+}
65+6266it("stages Codex-home image paths before Gateway managed-image display", async () => {
6367const stateDir = process.env.OPENCLAW_STATE_DIR ?? "";
6468const agentDir = path.join(stateDir, "agents", "main", "agent");
@@ -121,7 +125,7 @@ describe("normalizeWebchatReplyMediaPathsForDisplay", () => {
121125122126expect(payload?.mediaUrl).toBeUndefined();
123127expect(payload?.mediaUrls).toEqual([sourcePath]);
124-await expect(fs.stat(path.join(stateDir, "media", "outbound"))).rejects.toThrow();
128+await expectPathMissing(path.join(stateDir, "media", "outbound"));
125129});
126130127131it("preserves inline data image replies for WebChat rendering", async () => {
@@ -140,7 +144,7 @@ describe("normalizeWebchatReplyMediaPathsForDisplay", () => {
140144141145expect(payload?.mediaUrl).toBeUndefined();
142146expect(payload?.mediaUrls).toEqual([dataUrl]);
143-await expect(fs.stat(path.join(stateDir, "media", "outbound"))).rejects.toThrow();
147+await expectPathMissing(path.join(stateDir, "media", "outbound"));
144148});
145149146150it("preserves local audio paths for WebChat audio embedding", async () => {
@@ -163,7 +167,7 @@ describe("normalizeWebchatReplyMediaPathsForDisplay", () => {
163167expect(payload?.mediaUrls).toEqual([audioPath]);
164168expect(payload?.trustedLocalMedia).toBe(true);
165169expect(payload?.audioAsVoice).toBe(true);
166-await expect(fs.stat(path.join(stateDir, "media", "outbound"))).rejects.toThrow();
170+await expectPathMissing(path.join(stateDir, "media", "outbound"));
167171});
168172169173it("preserves data images while staging mixed local image replies", async () => {
@@ -215,6 +219,6 @@ describe("normalizeWebchatReplyMediaPathsForDisplay", () => {
215219expect(payload?.text).toBeUndefined();
216220expect(payload?.mediaUrl).toBe(dataUrl);
217221expect(payload?.mediaUrls).toEqual([dataUrl]);
218-await expect(fs.stat(path.join(stateDir, "media", "outbound"))).rejects.toThrow();
222+await expectPathMissing(path.join(stateDir, "media", "outbound"));
219223});
220224});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。