Skip to content

Commit 8360a9f

Browse files
committed
feat(e2e): add tests for video generation with --file option and mutual exclusivity checks
1 parent 18fd2ed commit 8360a9f

1 file changed

Lines changed: 176 additions & 0 deletions

File tree

packages/commands/tests/e2e/video-generate-i2v.e2e.test.ts

Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,182 @@ describe("e2e: video generate (i2v)", () => {
169169
expect(data.request?.input?.img_url).toBeUndefined();
170170
}
171171
});
172+
173+
test("video generate --dry-run --file 走 media file 字段", async () => {
174+
const configDir = makeE2eOutputDir("video-generate-file-url");
175+
writeFileSync(
176+
join(configDir, "config.json"),
177+
JSON.stringify({
178+
"token-plan": {
179+
api_key: "sk-sp-e2e-placeholder",
180+
base_url: "https://token-plan.cn-beijing.maas.aliyuncs.com",
181+
},
182+
}),
183+
);
184+
185+
const { stdout, stderr, exitCode } = await runCommandE2e(
186+
VIDEO_ROUTES,
187+
[
188+
"video",
189+
"generate",
190+
"--config",
191+
"token-plan",
192+
"--dry-run",
193+
"--model",
194+
"wan3.0-video",
195+
"--file",
196+
"https://example.com/reference.pdf",
197+
"--prompt",
198+
"文件生视频干跑",
199+
"--output",
200+
"json",
201+
],
202+
{
203+
BAILIAN_CONFIG_DIR: configDir,
204+
DASHSCOPE_API_KEY: "",
205+
DASHSCOPE_BASE_URL: "",
206+
},
207+
);
208+
expect(exitCode, stderr).toBe(0);
209+
const data = parseStdoutJson<{
210+
request?: {
211+
model?: string;
212+
input?: {
213+
media?: Array<{ type?: string; url?: string }>;
214+
img_url?: string;
215+
first_frame_url?: string;
216+
};
217+
};
218+
}>(stdout);
219+
expect(data.request?.model).toBe("wan3.0-video");
220+
expect(data.request?.input?.media?.[0]?.type).toBe("file");
221+
expect(data.request?.input?.media?.[0]?.url).toBe("https://example.com/reference.pdf");
222+
expect(data.request?.input?.img_url).toBeUndefined();
223+
expect(data.request?.input?.first_frame_url).toBeUndefined();
224+
});
225+
226+
test("--file 与 --image 互斥时报用法错误并退出 (2)", async () => {
227+
const configDir = makeE2eOutputDir("video-generate-file-mutex-image");
228+
writeFileSync(
229+
join(configDir, "config.json"),
230+
JSON.stringify({
231+
"token-plan": {
232+
api_key: "sk-sp-e2e-placeholder",
233+
base_url: "https://token-plan.cn-beijing.maas.aliyuncs.com",
234+
},
235+
}),
236+
);
237+
238+
const { stderr, exitCode } = await runCommandE2e(
239+
VIDEO_ROUTES,
240+
[
241+
"video",
242+
"generate",
243+
"--config",
244+
"token-plan",
245+
"--dry-run",
246+
"--model",
247+
"wan3.0-video",
248+
"--file",
249+
"https://example.com/reference.pdf",
250+
"--image",
251+
"https://example.com/placeholder.png",
252+
"--prompt",
253+
"互斥校验",
254+
"--output",
255+
"json",
256+
],
257+
{
258+
BAILIAN_CONFIG_DIR: configDir,
259+
DASHSCOPE_API_KEY: "",
260+
DASHSCOPE_BASE_URL: "",
261+
},
262+
);
263+
expect(exitCode).toBe(2);
264+
expect(stderr).toMatch(/--file.*mutually exclusive|--file.*|mutually exclusive/i);
265+
});
266+
267+
test("--file 与 --last-frame 互斥时报用法错误并退出 (2)", async () => {
268+
const configDir = makeE2eOutputDir("video-generate-file-mutex-lastframe");
269+
writeFileSync(
270+
join(configDir, "config.json"),
271+
JSON.stringify({
272+
"token-plan": {
273+
api_key: "sk-sp-e2e-placeholder",
274+
base_url: "https://token-plan.cn-beijing.maas.aliyuncs.com",
275+
},
276+
}),
277+
);
278+
279+
const { stderr, exitCode } = await runCommandE2e(
280+
VIDEO_ROUTES,
281+
[
282+
"video",
283+
"generate",
284+
"--config",
285+
"token-plan",
286+
"--dry-run",
287+
"--model",
288+
"wan3.0-video",
289+
"--file",
290+
"https://example.com/reference.pdf",
291+
"--last-frame",
292+
"https://example.com/last-frame.png",
293+
"--prompt",
294+
"互斥校验",
295+
"--output",
296+
"json",
297+
],
298+
{
299+
BAILIAN_CONFIG_DIR: configDir,
300+
DASHSCOPE_API_KEY: "",
301+
DASHSCOPE_BASE_URL: "",
302+
},
303+
);
304+
expect(exitCode).toBe(2);
305+
expect(stderr).toMatch(/--file.*mutually exclusive|--file.*|mutually exclusive/i);
306+
});
307+
308+
test("非 wan3.0 模型使用 --file 时报用法错误并退出 (2)", async () => {
309+
const configDir = makeE2eOutputDir("video-generate-file-model-restricted");
310+
writeFileSync(
311+
join(configDir, "config.json"),
312+
JSON.stringify({
313+
"token-plan": {
314+
api_key: "sk-sp-e2e-placeholder",
315+
base_url: "https://token-plan.cn-beijing.maas.aliyuncs.com",
316+
},
317+
}),
318+
);
319+
320+
const { stderr, exitCode } = await runCommandE2e(
321+
VIDEO_ROUTES,
322+
[
323+
"video",
324+
"generate",
325+
"--config",
326+
"token-plan",
327+
"--dry-run",
328+
"--model",
329+
"wan2.6-i2v",
330+
"--file",
331+
"https://example.com/reference.pdf",
332+
"--prompt",
333+
"模型限制校验",
334+
"--output",
335+
"json",
336+
],
337+
{
338+
BAILIAN_CONFIG_DIR: configDir,
339+
DASHSCOPE_API_KEY: "",
340+
DASHSCOPE_BASE_URL: "",
341+
},
342+
);
343+
expect(exitCode).toBe(2);
344+
expect(stderr).toMatch(
345+
/--file.*only supported by wan3\.0-video|--file.*.*wan3\.0-video|only supported by wan3\.0-video/i,
346+
);
347+
});
172348
});
173349

174350
describe.skipIf(!isBailianE2EVideoEnabled() || !isDashScopeE2EReady())(

0 commit comments

Comments
 (0)