mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-18 13:44:47 +00:00
test: tighten qwen video request assertions
This commit is contained in:
@@ -20,6 +20,39 @@ beforeAll(async () => {
|
||||
|
||||
installProviderHttpMockCleanup();
|
||||
|
||||
function expectPostJsonRequest(
|
||||
call: unknown,
|
||||
expected: {
|
||||
url: string;
|
||||
body: Record<string, unknown>;
|
||||
},
|
||||
) {
|
||||
if (!call || typeof call !== "object") {
|
||||
throw new Error("expected postJsonRequest call object");
|
||||
}
|
||||
const request = call as {
|
||||
url?: unknown;
|
||||
headers?: unknown;
|
||||
body?: unknown;
|
||||
timeoutMs?: unknown;
|
||||
fetchFn?: unknown;
|
||||
allowPrivateNetwork?: unknown;
|
||||
dispatcherPolicy?: unknown;
|
||||
};
|
||||
expect(request.url).toBe(expected.url);
|
||||
expect(request.body).toEqual(expected.body);
|
||||
expect(request.timeoutMs).toBe(120_000);
|
||||
expect(request.fetchFn).toBe(globalThis.fetch);
|
||||
expect(request.allowPrivateNetwork).toBe(false);
|
||||
expect(request.dispatcherPolicy).toBeUndefined();
|
||||
expect(request.headers).toBeInstanceOf(Headers);
|
||||
expect(Array.from((request.headers as Headers).entries())).toEqual([
|
||||
["authorization", "Bearer provider-key"],
|
||||
["content-type", "application/json"],
|
||||
["x-dashscope-async", "enable"],
|
||||
]);
|
||||
}
|
||||
|
||||
describe("qwen video generation provider", () => {
|
||||
it("declares explicit mode capabilities", () => {
|
||||
expectExplicitVideoGenerationCapabilities(buildQwenVideoGenerationProvider());
|
||||
@@ -39,18 +72,21 @@ describe("qwen video generation provider", () => {
|
||||
audio: true,
|
||||
});
|
||||
|
||||
expect(postJsonRequestMock).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
url: "https://dashscope-intl.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis",
|
||||
body: expect.objectContaining({
|
||||
model: "wan2.6-r2v-flash",
|
||||
input: expect.objectContaining({
|
||||
prompt: "animate this shot",
|
||||
img_url: "https://example.com/ref.png",
|
||||
}),
|
||||
}),
|
||||
}),
|
||||
);
|
||||
expect(postJsonRequestMock).toHaveBeenCalledTimes(1);
|
||||
expectPostJsonRequest(postJsonRequestMock.mock.calls[0]?.[0], {
|
||||
url: "https://dashscope-intl.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis",
|
||||
body: {
|
||||
model: "wan2.6-r2v-flash",
|
||||
input: {
|
||||
prompt: "animate this shot",
|
||||
img_url: "https://example.com/ref.png",
|
||||
},
|
||||
parameters: {
|
||||
duration: 6,
|
||||
enable_audio: true,
|
||||
},
|
||||
},
|
||||
});
|
||||
expectDashscopeVideoTaskPoll(fetchWithTimeoutMock);
|
||||
expectSuccessfulDashscopeVideoResult(result);
|
||||
});
|
||||
@@ -98,11 +134,19 @@ describe("qwen video generation provider", () => {
|
||||
},
|
||||
});
|
||||
|
||||
expect(postJsonRequestMock).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
url: "https://coding-intl.dashscope.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis",
|
||||
}),
|
||||
);
|
||||
expect(postJsonRequestMock).toHaveBeenCalledTimes(1);
|
||||
expectPostJsonRequest(postJsonRequestMock.mock.calls[0]?.[0], {
|
||||
url: "https://coding-intl.dashscope.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis",
|
||||
body: {
|
||||
model: "wan2.6-t2v",
|
||||
input: {
|
||||
prompt: "animate this shot",
|
||||
},
|
||||
parameters: {
|
||||
duration: 5,
|
||||
},
|
||||
},
|
||||
});
|
||||
expectDashscopeVideoTaskPoll(fetchWithTimeoutMock, {
|
||||
baseUrl: "https://coding-intl.dashscope.aliyuncs.com",
|
||||
taskId: "task-2",
|
||||
|
||||
Reference in New Issue
Block a user