mirror of
https://github.com/modelstudioai/cli.git
synced 2026-09-14 19:49:23 +08:00
43abf0aca5
- 增加test:journey脚本,覆盖知识库跨命令全链路用户旅程测试 - 在文档中新增Journey E2E章节,详细说明用户旅程测试定位及断言机制 - 完善commands模块,新增知识库相关命令包括知识库列表、信息、创建、更新、删除 - 新增知识库文档相关命令,如文档列表、状态、上传、删除、打标签及OSS导入 - 添加知识服务管理命令,支持列表、创建、更新、部署、删除及复制 - 支持知识块增删查改命令,完善知识点的灵活操作能力 - 实现数据中心分类管理命令,支持分类增删查操作 - 优化knowledge chat命令,增加workspace-id统一解析及agent-version版本控制 - 重构与知识库相关命令的导出与注册,完善CLI整体能力覆盖 - 新增命令详尽的帮助文档,包含参数说明、使用示例及错误边界 - 实现批量删除知识块的自动分批处理逻辑,易于操作大规模数据 - 添加必要的输入校验与安全提示,确保操作安全且符合规范
43 lines
1.3 KiB
TypeScript
43 lines
1.3 KiB
TypeScript
import { describe, expect, test } from "vite-plus/test";
|
|
import { ExitCode } from "bailian-cli-core";
|
|
import { resolveWorkspaceId, truncateLine } from "../../src/commands/knowledge/shared.ts";
|
|
|
|
const identity = { binName: "kscli" };
|
|
|
|
describe("resolveWorkspaceId", () => {
|
|
test("flag 优先于 settings", () => {
|
|
const workspaceId = resolveWorkspaceId({
|
|
flags: { workspaceId: "ws_flag" },
|
|
settings: { workspaceId: "ws_cfg" },
|
|
identity,
|
|
});
|
|
expect(workspaceId).toBe("ws_flag");
|
|
});
|
|
|
|
test("无 flag 时回退 settings (env/config 已并入 settings)", () => {
|
|
const workspaceId = resolveWorkspaceId({
|
|
flags: {},
|
|
settings: { workspaceId: "ws_cfg" },
|
|
identity,
|
|
});
|
|
expect(workspaceId).toBe("ws_cfg");
|
|
});
|
|
|
|
test("均缺失时抛 USAGE 且 hint 含 binName", () => {
|
|
try {
|
|
resolveWorkspaceId({ flags: {}, settings: {}, identity });
|
|
expect.unreachable("should throw");
|
|
} catch (error) {
|
|
expect((error as { exitCode: number }).exitCode).toBe(ExitCode.USAGE);
|
|
expect((error as { hint?: string }).hint).toMatch(/kscli config set workspace_id/);
|
|
}
|
|
});
|
|
});
|
|
|
|
describe("truncateLine", () => {
|
|
test("非 TTY 下不截断", () => {
|
|
const longLine = "x".repeat(500);
|
|
expect(truncateLine(longLine)).toBe(longLine);
|
|
});
|
|
});
|