

























@@ -20,6 +20,39 @@ beforeAll(async () => {
20202121installProviderHttpMockCleanup();
222223+function expectPostJsonRequest(
24+call: unknown,
25+expected: {
26+url: string;
27+body: Record<string, unknown>;
28+},
29+) {
30+if (!call || typeof call !== "object") {
31+throw new Error("expected postJsonRequest call object");
32+}
33+const request = call as {
34+url?: unknown;
35+headers?: unknown;
36+body?: unknown;
37+timeoutMs?: unknown;
38+fetchFn?: unknown;
39+allowPrivateNetwork?: unknown;
40+dispatcherPolicy?: unknown;
41+};
42+expect(request.url).toBe(expected.url);
43+expect(request.body).toEqual(expected.body);
44+expect(request.timeoutMs).toBe(120_000);
45+expect(request.fetchFn).toBe(globalThis.fetch);
46+expect(request.allowPrivateNetwork).toBe(false);
47+expect(request.dispatcherPolicy).toBeUndefined();
48+expect(request.headers).toBeInstanceOf(Headers);
49+expect(Array.from((request.headers as Headers).entries())).toEqual([
50+["authorization", "Bearer provider-key"],
51+["content-type", "application/json"],
52+["x-dashscope-async", "enable"],
53+]);
54+}
55+2356describe("qwen video generation provider", () => {
2457it("declares explicit mode capabilities", () => {
2558expectExplicitVideoGenerationCapabilities(buildQwenVideoGenerationProvider());
@@ -39,18 +72,21 @@ describe("qwen video generation provider", () => {
3972audio: true,
4073});
417442-expect(postJsonRequestMock).toHaveBeenCalledWith(
43-expect.objectContaining({
44-url: "https://dashscope-intl.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis",
45-body: expect.objectContaining({
46-model: "wan2.6-r2v-flash",
47-input: expect.objectContaining({
48-prompt: "animate this shot",
49-img_url: "https://example.com/ref.png",
50-}),
51-}),
52-}),
53-);
75+expect(postJsonRequestMock).toHaveBeenCalledTimes(1);
76+expectPostJsonRequest(postJsonRequestMock.mock.calls[0]?.[0], {
77+url: "https://dashscope-intl.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis",
78+body: {
79+model: "wan2.6-r2v-flash",
80+input: {
81+prompt: "animate this shot",
82+img_url: "https://example.com/ref.png",
83+},
84+parameters: {
85+duration: 6,
86+enable_audio: true,
87+},
88+},
89+});
5490expectDashscopeVideoTaskPoll(fetchWithTimeoutMock);
5591expectSuccessfulDashscopeVideoResult(result);
5692});
@@ -98,11 +134,19 @@ describe("qwen video generation provider", () => {
98134},
99135});
100136101-expect(postJsonRequestMock).toHaveBeenCalledWith(
102-expect.objectContaining({
103-url: "https://coding-intl.dashscope.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis",
104-}),
105-);
137+expect(postJsonRequestMock).toHaveBeenCalledTimes(1);
138+expectPostJsonRequest(postJsonRequestMock.mock.calls[0]?.[0], {
139+url: "https://coding-intl.dashscope.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis",
140+body: {
141+model: "wan2.6-t2v",
142+input: {
143+prompt: "animate this shot",
144+},
145+parameters: {
146+duration: 5,
147+},
148+},
149+});
106150expectDashscopeVideoTaskPoll(fetchWithTimeoutMock, {
107151baseUrl: "https://coding-intl.dashscope.aliyuncs.com",
108152taskId: "task-2",
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。