mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-18 22:34:45 +00:00
test: tighten media understanding assertions
This commit is contained in:
@@ -287,17 +287,26 @@ describe("media-understanding runtime", () => {
|
||||
});
|
||||
|
||||
expect(mocks.normalizeMediaProviderId).toHaveBeenCalledWith("gemini");
|
||||
expect(describeImage).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
buffer: Buffer.from("image-bytes"),
|
||||
fileName: "sample.jpg",
|
||||
mime: "image/jpeg",
|
||||
provider: "gemini",
|
||||
model: "vision-v1",
|
||||
prompt: "Describe the sample.",
|
||||
agentDir: "/tmp/agent",
|
||||
}),
|
||||
);
|
||||
const [[describeImageOptions]] = describeImage.mock.calls as unknown as Array<
|
||||
[
|
||||
{
|
||||
buffer?: Buffer;
|
||||
fileName?: string;
|
||||
mime?: string;
|
||||
provider?: string;
|
||||
model?: string;
|
||||
prompt?: string;
|
||||
agentDir?: string;
|
||||
},
|
||||
]
|
||||
>;
|
||||
expect(describeImageOptions?.buffer).toEqual(Buffer.from("image-bytes"));
|
||||
expect(describeImageOptions?.fileName).toBe("sample.jpg");
|
||||
expect(describeImageOptions?.mime).toBe("image/jpeg");
|
||||
expect(describeImageOptions?.provider).toBe("gemini");
|
||||
expect(describeImageOptions?.model).toBe("vision-v1");
|
||||
expect(describeImageOptions?.prompt).toBe("Describe the sample.");
|
||||
expect(describeImageOptions?.agentDir).toBe("/tmp/agent");
|
||||
});
|
||||
|
||||
it("routes structured extraction to a provider by id and model", async () => {
|
||||
@@ -347,27 +356,38 @@ describe("media-understanding runtime", () => {
|
||||
"Vision-Plugin",
|
||||
providerRegistry,
|
||||
);
|
||||
expect(extractStructured).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
input: [
|
||||
{ type: "text", text: "Extract the fact." },
|
||||
{
|
||||
type: "image",
|
||||
buffer: Buffer.from("image-bytes"),
|
||||
fileName: "fact.png",
|
||||
mime: "image/png",
|
||||
},
|
||||
],
|
||||
instructions: "Return JSON.",
|
||||
provider: "Vision-Plugin",
|
||||
model: "vision-json",
|
||||
profile: "work",
|
||||
preferredProfile: "preferred-work",
|
||||
authStore,
|
||||
timeoutMs: 45_000,
|
||||
agentDir: "/tmp/agent",
|
||||
}),
|
||||
);
|
||||
const [[extractOptions]] = extractStructured.mock.calls as unknown as Array<
|
||||
[
|
||||
{
|
||||
input?: unknown;
|
||||
instructions?: string;
|
||||
provider?: string;
|
||||
model?: string;
|
||||
profile?: string;
|
||||
preferredProfile?: string;
|
||||
authStore?: AuthProfileStore;
|
||||
timeoutMs?: number;
|
||||
agentDir?: string;
|
||||
},
|
||||
]
|
||||
>;
|
||||
expect(extractOptions?.input).toEqual([
|
||||
{ type: "text", text: "Extract the fact." },
|
||||
{
|
||||
type: "image",
|
||||
buffer: Buffer.from("image-bytes"),
|
||||
fileName: "fact.png",
|
||||
mime: "image/png",
|
||||
},
|
||||
]);
|
||||
expect(extractOptions?.instructions).toBe("Return JSON.");
|
||||
expect(extractOptions?.provider).toBe("Vision-Plugin");
|
||||
expect(extractOptions?.model).toBe("vision-json");
|
||||
expect(extractOptions?.profile).toBe("work");
|
||||
expect(extractOptions?.preferredProfile).toBe("preferred-work");
|
||||
expect(extractOptions?.authStore).toBe(authStore);
|
||||
expect(extractOptions?.timeoutMs).toBe(45_000);
|
||||
expect(extractOptions?.agentDir).toBe("/tmp/agent");
|
||||
});
|
||||
|
||||
it("rejects text-only structured extraction before provider lookup", async () => {
|
||||
|
||||
Reference in New Issue
Block a user