Skip to content

Commit 1864802

Browse files
committed
fix(agents): add arrayBuffer to mock Responses for MiniMax VLM bounded reader
1 parent 172aafa commit 1864802

2 files changed

Lines changed: 15 additions & 8 deletions

File tree

src/agents/tools/image-tool.test.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -472,31 +472,32 @@ function registerImageToolEnvReset(priorFetch: typeof global.fetch, keys: string
472472
}
473473

474474
function stubMinimaxOkFetch() {
475+
const body = JSON.stringify({
476+
content: "ok",
477+
base_resp: { status_code: 0, status_msg: "" },
478+
});
475479
const fetch = vi.fn().mockResolvedValue({
476480
ok: true,
477481
status: 200,
478482
statusText: "OK",
479483
headers: new Headers(),
480-
json: async () => ({
481-
content: "ok",
482-
base_resp: { status_code: 0, status_msg: "" },
483-
}),
484+
json: async () => JSON.parse(body),
485+
arrayBuffer: async () => new TextEncoder().encode(body).buffer,
484486
});
485487
global.fetch = withFetchPreconnect(fetch);
486488
vi.stubEnv("MINIMAX_API_KEY", "minimax-test");
487489
return fetch;
488490
}
489491

490492
function stubMinimaxFetch(baseResp: { status_code: number; status_msg: string }, content = "ok") {
493+
const body = JSON.stringify({ content, base_resp: baseResp });
491494
const fetch = vi.fn().mockResolvedValue({
492495
ok: true,
493496
status: 200,
494497
statusText: "OK",
495498
headers: new Headers(),
496-
json: async () => ({
497-
content,
498-
base_resp: baseResp,
499-
}),
499+
json: async () => JSON.parse(body),
500+
arrayBuffer: async () => new TextEncoder().encode(body).buffer,
500501
});
501502
global.fetch = withFetchPreconnect(fetch);
502503
return fetch;

src/media-understanding/image.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,12 @@ describe("describeImageWithModel", () => {
154154
base_resp: { status_code: 0 },
155155
content: "portal ok",
156156
})),
157+
arrayBuffer: vi.fn(
158+
async () =>
159+
new TextEncoder().encode(
160+
JSON.stringify({ base_resp: { status_code: 0 }, content: "portal ok" }),
161+
).buffer,
162+
),
157163
text: vi.fn(async () => ""),
158164
});
159165
discoverModelsMock.mockReturnValue({

0 commit comments

Comments
 (0)