test: tighten qwen video request assertions

This commit is contained in:
Shakker
2026-05-11 02:56:23 +01:00
parent 85ab27a666
commit f915a84468

View File

@@ -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",