mirror of
https://github.com/modelstudioai/cli.git
synced 2026-09-14 19:49:23 +08:00
1c38c381e5
Align text chat, pipeline, config UI, login validation, and Token Plan text presets, and update README, skill reference, and related tests.
70 lines
2.2 KiB
TypeScript
70 lines
2.2 KiB
TypeScript
import { describe, expect, test } from "vite-plus/test";
|
||
import { isDashScopeE2EReady, parseStdoutJson, runCommandE2e } from "./helpers.ts";
|
||
import { TEXT_CHAT_ROUTES } from "./topic-routes.ts";
|
||
|
||
/**
|
||
* Text chat:help / 分组不依赖密钥;对话需 DashScope。
|
||
*/
|
||
|
||
describe("e2e: text chat", () => {
|
||
test("text chat --help 正常退出", async () => {
|
||
const { stderr, exitCode } = await runCommandE2e(TEXT_CHAT_ROUTES, ["text", "chat", "--help"]);
|
||
expect(exitCode, stderr).toBe(0);
|
||
expect(stderr).toMatch(/chat|--message|model|stream/i);
|
||
});
|
||
});
|
||
|
||
describe.skipIf(!isDashScopeE2EReady())("e2e: text chat(DashScope)", () => {
|
||
test("text chat 缺少 --message 时报用法错误并退出 (2)", async () => {
|
||
const { stderr, exitCode } = await runCommandE2e(TEXT_CHAT_ROUTES, [
|
||
"text",
|
||
"chat",
|
||
"--model",
|
||
"qwen3.8-max",
|
||
]);
|
||
expect(exitCode).toBe(2);
|
||
expect(stderr).toMatch(/--message|Usage:/i);
|
||
});
|
||
|
||
test("text chat --dry-run 仅输出 request 且不调对话接口", async () => {
|
||
const { stdout, stderr, exitCode } = await runCommandE2e(TEXT_CHAT_ROUTES, [
|
||
"text",
|
||
"chat",
|
||
"--dry-run",
|
||
"--model",
|
||
"qwen3.8-max",
|
||
"--message",
|
||
"干跑",
|
||
"--max-tokens",
|
||
"8",
|
||
"--output",
|
||
"json",
|
||
]);
|
||
expect(exitCode, stderr).toBe(0);
|
||
const data = parseStdoutJson<{
|
||
request?: { model?: string; messages?: Array<{ content?: string }> };
|
||
}>(stdout);
|
||
expect(data.request?.model).toBe("qwen3.8-max");
|
||
expect(data.request?.messages?.some((m) => m.content === "干跑")).toBe(true);
|
||
});
|
||
|
||
test("【qwen3.8-max】文本对话", async () => {
|
||
const { stdout, stderr, exitCode } = await runCommandE2e(TEXT_CHAT_ROUTES, [
|
||
"text",
|
||
"chat",
|
||
"--model",
|
||
"qwen3.8-max",
|
||
"--message",
|
||
"只回复一个字:好",
|
||
"--max-tokens",
|
||
"32",
|
||
"--output",
|
||
"json",
|
||
]);
|
||
expect(exitCode, stderr).toBe(0);
|
||
const data = parseStdoutJson<{ choices?: Array<{ message?: { content?: string } }> }>(stdout);
|
||
const text = data.choices?.[0]?.message?.content ?? "";
|
||
expect(text.length).toBeGreaterThan(0);
|
||
}, 120_000);
|
||
});
|