mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 13:30:42 +00:00
test: tighten image completion call assertions
This commit is contained in:
@@ -382,8 +382,12 @@ describe("describeImageWithModel", () => {
|
||||
}),
|
||||
expect.any(Object),
|
||||
);
|
||||
const [, context] = completeMock.mock.calls[0] ?? [];
|
||||
expect(context?.messages?.[0]?.content).toHaveLength(1);
|
||||
const firstCall = completeMock.mock.calls[0];
|
||||
if (!firstCall) {
|
||||
throw new Error("Expected image completion call");
|
||||
}
|
||||
const [, context] = firstCall;
|
||||
expect(context.messages[0]?.content).toHaveLength(1);
|
||||
});
|
||||
|
||||
it("places OpenRouter image prompts in user content before images", async () => {
|
||||
@@ -422,9 +426,13 @@ describe("describeImageWithModel", () => {
|
||||
text: "openrouter ok",
|
||||
model: "google/gemini-2.5-flash",
|
||||
});
|
||||
const [, context] = completeMock.mock.calls[0] ?? [];
|
||||
expect(context?.systemPrompt).toBeUndefined();
|
||||
expect(context?.messages?.[0]?.content).toEqual([
|
||||
const firstCall = completeMock.mock.calls[0];
|
||||
if (!firstCall) {
|
||||
throw new Error("Expected OpenRouter image completion call");
|
||||
}
|
||||
const [, context] = firstCall;
|
||||
expect(context.systemPrompt).toBeUndefined();
|
||||
expect(context.messages[0]?.content).toEqual([
|
||||
{ type: "text", text: "Describe the image." },
|
||||
expect.objectContaining({
|
||||
type: "image",
|
||||
@@ -536,7 +544,11 @@ describe("describeImageWithModel", () => {
|
||||
model: model.id,
|
||||
});
|
||||
expect(completeMock).toHaveBeenCalledTimes(2);
|
||||
const [, , retryOptions] = completeMock.mock.calls[1] ?? [];
|
||||
const retryCall = completeMock.mock.calls[1];
|
||||
if (!retryCall) {
|
||||
throw new Error("Expected retry image completion call");
|
||||
}
|
||||
const [retryModel, , retryOptions] = retryCall;
|
||||
if (!retryOptions?.onPayload) {
|
||||
throw new Error("expected retry payload mapper");
|
||||
}
|
||||
@@ -546,7 +558,7 @@ describe("describeImageWithModel", () => {
|
||||
reasoning_effort: "high",
|
||||
include: ["reasoning.encrypted_content"],
|
||||
},
|
||||
completeMock.mock.calls[1]?.[0],
|
||||
retryModel,
|
||||
);
|
||||
expect(retryPayload).toEqual(expectedRetryPayload);
|
||||
},
|
||||
@@ -580,9 +592,16 @@ describe("describeImageWithModel", () => {
|
||||
const assertion = expect(result).rejects.toThrow("image description timed out after 25ms");
|
||||
await vi.advanceTimersByTimeAsync(25);
|
||||
await assertion;
|
||||
const [, , options] = completeMock.mock.calls[0] ?? [];
|
||||
expect(options?.signal?.aborted).toBe(true);
|
||||
expect(options?.timeoutMs).toBe(25);
|
||||
const firstCall = completeMock.mock.calls[0];
|
||||
if (!firstCall) {
|
||||
throw new Error("Expected timed image completion call");
|
||||
}
|
||||
const [, , options] = firstCall;
|
||||
if (!options?.signal) {
|
||||
throw new Error("Expected image completion abort signal");
|
||||
}
|
||||
expect(options.signal.aborted).toBe(true);
|
||||
expect(options.timeoutMs).toBe(25);
|
||||
});
|
||||
|
||||
it("rejects when image runtime setup exceeds the request timeout", async () => {
|
||||
|
||||
Reference in New Issue
Block a user