Files
modelstudioai__cli/packages/commands/tests/e2e/video-task-get.e2e.test.ts
T
clh02467605 d646a4e780 refactor(e2e): update test routes and streamline command handling
- Replaced hardcoded command paths with dynamic route mappings in E2E tests.
- Enhanced documentation for command testing, specifying minimum route requirements.
- Consolidated command path management into `topic-routes.ts` for better maintainability.
- Updated various E2E test cases to utilize the new routing structure, ensuring consistency across tests.
- Removed redundant helper functions and improved test clarity by directly referencing route exports.
2026-07-10 15:55:53 +08:00

79 lines
2.3 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { describe, expect, test } from "vite-plus/test";
import {
isBailianE2EEnabled,
isDashScopeE2EReady,
parseStdoutJson,
runCommandE2e,
} from "./helpers.ts";
import { VIDEO_ROUTES } from "./topic-routes.ts";
const taskId = process.env.BAILIAN_E2E_VIDEO_TASK_ID?.trim();
/**
* Video task gethelp / 分组不依赖密钥;查询需 E2E + task_id + DashScope。
*/
describe("e2e: video task get", () => {
test("video task get --help 正常退出", async () => {
const { stderr, exitCode } = await runCommandE2e(VIDEO_ROUTES, [
"video",
"task",
"get",
"--help",
]);
expect(exitCode, stderr).toBe(0);
expect(stderr).toMatch(/task|get|--task-id/i);
});
});
describe.skipIf(!isBailianE2EEnabled() || !taskId || !isDashScopeE2EReady())(
"e2e: video task getDashScope",
() => {
test("video task get 缺少 --task-id 时报用法错误并退出 (2)", async () => {
const { stderr, exitCode } = await runCommandE2e(VIDEO_ROUTES, [
"video",
"task",
"get",
"--output",
"json",
]);
expect(exitCode).toBe(2);
const err = JSON.parse(stderr.trim()) as { error?: { code?: number; message?: string } };
expect(err.error?.code).toBe(2);
expect(err.error?.message).toMatch(/--task-id/i);
});
test("video task get --dry-run 仅回显 task_id 且不调任务接口", async () => {
const { stdout, stderr, exitCode } = await runCommandE2e(VIDEO_ROUTES, [
"video",
"task",
"get",
"--dry-run",
"--task-id",
taskId!,
"--output",
"json",
]);
expect(exitCode, stderr).toBe(0);
const data = parseStdoutJson<{ task_id?: string }>(stdout);
expect(data.task_id).toBe(taskId);
});
test("根据 task_id 查询任务状态", async () => {
const { stdout, stderr, exitCode } = await runCommandE2e(VIDEO_ROUTES, [
"video",
"task",
"get",
"--task-id",
taskId!,
"--output",
"json",
]);
expect(exitCode, stderr).toBe(0);
const data = parseStdoutJson<{ task_status?: string; task_id?: string }>(stdout);
expect(data.task_id).toBe(taskId);
expect(data.task_status?.length ?? 0).toBeGreaterThan(0);
}, 60_000);
},
);