diff --git a/packages/commands/tests/e2e/video-generate-i2v.e2e.test.ts b/packages/commands/tests/e2e/video-generate-i2v.e2e.test.ts index 0cc5a55..2b5f2fd 100644 --- a/packages/commands/tests/e2e/video-generate-i2v.e2e.test.ts +++ b/packages/commands/tests/e2e/video-generate-i2v.e2e.test.ts @@ -169,6 +169,182 @@ describe("e2e: video generate (i2v)", () => { expect(data.request?.input?.img_url).toBeUndefined(); } }); + + test("video generate --dry-run --file 走 media file 字段", async () => { + const configDir = makeE2eOutputDir("video-generate-file-url"); + writeFileSync( + join(configDir, "config.json"), + JSON.stringify({ + "token-plan": { + api_key: "sk-sp-e2e-placeholder", + base_url: "https://token-plan.cn-beijing.maas.aliyuncs.com", + }, + }), + ); + + const { stdout, stderr, exitCode } = await runCommandE2e( + VIDEO_ROUTES, + [ + "video", + "generate", + "--config", + "token-plan", + "--dry-run", + "--model", + "wan3.0-video", + "--file", + "https://example.com/reference.pdf", + "--prompt", + "文件生视频干跑", + "--output", + "json", + ], + { + BAILIAN_CONFIG_DIR: configDir, + DASHSCOPE_API_KEY: "", + DASHSCOPE_BASE_URL: "", + }, + ); + expect(exitCode, stderr).toBe(0); + const data = parseStdoutJson<{ + request?: { + model?: string; + input?: { + media?: Array<{ type?: string; url?: string }>; + img_url?: string; + first_frame_url?: string; + }; + }; + }>(stdout); + expect(data.request?.model).toBe("wan3.0-video"); + expect(data.request?.input?.media?.[0]?.type).toBe("file"); + expect(data.request?.input?.media?.[0]?.url).toBe("https://example.com/reference.pdf"); + expect(data.request?.input?.img_url).toBeUndefined(); + expect(data.request?.input?.first_frame_url).toBeUndefined(); + }); + + test("--file 与 --image 互斥时报用法错误并退出 (2)", async () => { + const configDir = makeE2eOutputDir("video-generate-file-mutex-image"); + writeFileSync( + join(configDir, "config.json"), + JSON.stringify({ + "token-plan": { + api_key: "sk-sp-e2e-placeholder", + base_url: "https://token-plan.cn-beijing.maas.aliyuncs.com", + }, + }), + ); + + const { stderr, exitCode } = await runCommandE2e( + VIDEO_ROUTES, + [ + "video", + "generate", + "--config", + "token-plan", + "--dry-run", + "--model", + "wan3.0-video", + "--file", + "https://example.com/reference.pdf", + "--image", + "https://example.com/placeholder.png", + "--prompt", + "互斥校验", + "--output", + "json", + ], + { + BAILIAN_CONFIG_DIR: configDir, + DASHSCOPE_API_KEY: "", + DASHSCOPE_BASE_URL: "", + }, + ); + expect(exitCode).toBe(2); + expect(stderr).toMatch(/--file.*mutually exclusive|--file.*互斥|mutually exclusive/i); + }); + + test("--file 与 --last-frame 互斥时报用法错误并退出 (2)", async () => { + const configDir = makeE2eOutputDir("video-generate-file-mutex-lastframe"); + writeFileSync( + join(configDir, "config.json"), + JSON.stringify({ + "token-plan": { + api_key: "sk-sp-e2e-placeholder", + base_url: "https://token-plan.cn-beijing.maas.aliyuncs.com", + }, + }), + ); + + const { stderr, exitCode } = await runCommandE2e( + VIDEO_ROUTES, + [ + "video", + "generate", + "--config", + "token-plan", + "--dry-run", + "--model", + "wan3.0-video", + "--file", + "https://example.com/reference.pdf", + "--last-frame", + "https://example.com/last-frame.png", + "--prompt", + "互斥校验", + "--output", + "json", + ], + { + BAILIAN_CONFIG_DIR: configDir, + DASHSCOPE_API_KEY: "", + DASHSCOPE_BASE_URL: "", + }, + ); + expect(exitCode).toBe(2); + expect(stderr).toMatch(/--file.*mutually exclusive|--file.*互斥|mutually exclusive/i); + }); + + test("非 wan3.0 模型使用 --file 时报用法错误并退出 (2)", async () => { + const configDir = makeE2eOutputDir("video-generate-file-model-restricted"); + writeFileSync( + join(configDir, "config.json"), + JSON.stringify({ + "token-plan": { + api_key: "sk-sp-e2e-placeholder", + base_url: "https://token-plan.cn-beijing.maas.aliyuncs.com", + }, + }), + ); + + const { stderr, exitCode } = await runCommandE2e( + VIDEO_ROUTES, + [ + "video", + "generate", + "--config", + "token-plan", + "--dry-run", + "--model", + "wan2.6-i2v", + "--file", + "https://example.com/reference.pdf", + "--prompt", + "模型限制校验", + "--output", + "json", + ], + { + BAILIAN_CONFIG_DIR: configDir, + DASHSCOPE_API_KEY: "", + DASHSCOPE_BASE_URL: "", + }, + ); + expect(exitCode).toBe(2); + expect(stderr).toMatch( + /--file.*only supported by wan3\.0-video|--file.*仅.*wan3\.0-video|only supported by wan3\.0-video/i, + ); + }); }); describe.skipIf(!isBailianE2EVideoEnabled() || !isDashScopeE2EReady())(