

















@@ -15,6 +15,23 @@ vi.mock("../media/fetch.js", async () => {
1515};
1616});
171718+function requireFetchRemoteMediaInput(): {
19+url?: unknown;
20+fetchImpl?: unknown;
21+maxBytes?: unknown;
22+ssrfPolicy?: unknown;
23+} {
24+const [call] = fetchRemoteMediaMock.mock.calls;
25+if (!call) {
26+throw new Error("expected fetchRemoteMedia call");
27+}
28+const [input] = call;
29+if (typeof input !== "object" || input === null || Array.isArray(input)) {
30+throw new Error("expected fetchRemoteMedia input to be an object");
31+}
32+return input;
33+}
34+1835async function withBlockedLocalAttachmentFallback(
1936prefix: string,
2037run: (params: { cache: MediaAttachmentCache; fallbackUrl: string }) => Promise<void>,
@@ -65,10 +82,8 @@ describe("media understanding attachment URL fallback", () => {
6582expect(path.basename(result.path).startsWith("openclaw-media-")).toBe(true);
6683expect(path.extname(result.path)).toBe(".jpg");
6784expect(fetchRemoteMediaMock).toHaveBeenCalledTimes(1);
68-const fetchInput = fetchRemoteMediaMock.mock.calls[0]?.[0] as
69-| { url?: unknown; fetchImpl?: unknown; maxBytes?: unknown; ssrfPolicy?: unknown }
70-| undefined;
71-const fetchImpl = fetchInput?.fetchImpl;
85+const fetchInput = requireFetchRemoteMediaInput();
86+const fetchImpl = fetchInput.fetchImpl;
7287expect(fetchInput).toStrictEqual({
7388url: fallbackUrl,
7489 fetchImpl,
@@ -95,10 +110,8 @@ describe("media understanding attachment URL fallback", () => {
95110});
96111expect(result.buffer.toString()).toBe("fallback-buffer");
97112expect(fetchRemoteMediaMock).toHaveBeenCalledTimes(1);
98-const fetchInput = fetchRemoteMediaMock.mock.calls[0]?.[0] as
99-| { url?: unknown; fetchImpl?: unknown; maxBytes?: unknown; ssrfPolicy?: unknown }
100-| undefined;
101-const fetchImpl = fetchInput?.fetchImpl;
113+const fetchInput = requireFetchRemoteMediaInput();
114+const fetchImpl = fetchInput.fetchImpl;
102115expect(fetchInput).toStrictEqual({
103116url: fallbackUrl,
104117 fetchImpl,
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。