1994 lines
61 KiB
TypeScript
1994 lines
61 KiB
TypeScript
import { describe, expect, it, spyOn, afterEach } from "bun:test";
|
|
import { handleWorkflowCommand } from "./workflow/index.js";
|
|
import * as helpers from "../helpers.js";
|
|
import type { CliRuntime } from "../types.js";
|
|
import type { CorpConfig } from "../../core/config/types.js";
|
|
|
|
const mockCorp: CorpConfig = {
|
|
id: "test-corp",
|
|
name: "测试企业",
|
|
baseUrl: "https://app.ekuaibao.com",
|
|
source: "openapi",
|
|
credentials: {
|
|
accessToken: "mock-token",
|
|
corpId: "test-corp",
|
|
staffId: "test-corp:STAFF_TEST",
|
|
appKey: "test-key",
|
|
appSecurity: "test-security",
|
|
},
|
|
};
|
|
|
|
const mockRuntime: CliRuntime = {
|
|
corpContext: {
|
|
listCorps: () => [mockCorp],
|
|
getCurrent: () => mockCorp,
|
|
switchCorp: () => true,
|
|
resolve: () => mockCorp,
|
|
} as any,
|
|
selectedCorp: mockCorp,
|
|
jsonMode: false,
|
|
outputOptions: {},
|
|
};
|
|
|
|
describe("CLI - workflow job 执行详情与异常精准透视", () => {
|
|
let spies: ReturnType<typeof spyOn>[] = [];
|
|
|
|
afterEach(() => {
|
|
for (const spy of spies) {
|
|
spy.mockRestore();
|
|
}
|
|
spies = [];
|
|
});
|
|
|
|
it("fails when no corp is selected", async () => {
|
|
const res = await handleWorkflowCommand(
|
|
{
|
|
area: "workflow",
|
|
action: "job",
|
|
args: ["job_123"],
|
|
options: {},
|
|
raw: ["workflow", "job", "job_123"],
|
|
},
|
|
{ ...mockRuntime, selectedCorp: null }
|
|
);
|
|
expect(res.exitCode).toBe(1);
|
|
expect(res.stderr).toContain("未选中企业");
|
|
});
|
|
|
|
it("fails when no jobId is provided", async () => {
|
|
const res = await handleWorkflowCommand(
|
|
{
|
|
area: "workflow",
|
|
action: "job",
|
|
args: [],
|
|
options: {},
|
|
raw: ["workflow", "job"],
|
|
},
|
|
mockRuntime
|
|
);
|
|
expect(res.exitCode).toBe(1);
|
|
expect(res.stderr).toContain("用法: hose-use workflow job <jobId>");
|
|
});
|
|
|
|
it("handles workflow job --failed with deep error inspection and inputs/outputs", async () => {
|
|
const mockPiperClient = {
|
|
get: (url: string) => {
|
|
let payload: any = {};
|
|
if (url.includes("/execution/level/failed")) {
|
|
payload = { number: 1, size: 100, totalPages: 0, totalItems: 0, items: [] };
|
|
} else if (url.includes("/execution")) {
|
|
payload = [
|
|
{
|
|
id: "exec_1",
|
|
name: "auto_approve",
|
|
displayName: "资金调拨自动审批",
|
|
type: "flow-approval",
|
|
status: "FAILED",
|
|
executionTime: 350,
|
|
error: { message: "400: 无待办审批事项" },
|
|
inputs: { formId: "ZJ-20261014-001368", action: "agree" },
|
|
outputs: { code: 400, message: "无待办审批事项" },
|
|
},
|
|
];
|
|
} else if (url.includes("/jobs/job_err")) {
|
|
payload = {
|
|
id: "job_err",
|
|
pipelineId: "pipe_1",
|
|
state: "FAILED",
|
|
startTime: "2026-10-14 10:00:00",
|
|
durationTime: 1200,
|
|
};
|
|
}
|
|
return new Response(JSON.stringify({ code: 200, data: payload }), {
|
|
status: 200,
|
|
headers: { "content-type": "application/json" },
|
|
});
|
|
},
|
|
};
|
|
|
|
spies.push(
|
|
spyOn(helpers, "createClientsForCorp").mockResolvedValue({
|
|
ekbClient: {
|
|
get: () => ({ json: async () => [{ id: "plat_1", active: true }] }),
|
|
},
|
|
easoClient: mockPiperClient,
|
|
} as any)
|
|
);
|
|
spies.push(spyOn(helpers, "createPiperClientForCorp").mockResolvedValue(mockPiperClient as any));
|
|
|
|
// 文本输出测试
|
|
const res = await handleWorkflowCommand(
|
|
{
|
|
area: "workflow",
|
|
action: "job",
|
|
args: ["job_err"],
|
|
options: { failed: true },
|
|
raw: ["workflow", "job", "job_err", "--failed"],
|
|
},
|
|
mockRuntime
|
|
);
|
|
|
|
expect(res.exitCode).toBe(0);
|
|
expect(res.stdout).toContain("Job 异常/失败执行节点透视");
|
|
expect(res.stdout).toContain("资金调拨自动审批");
|
|
expect(res.stdout).toContain("400: 无待办审批事项");
|
|
expect(res.stdout).toContain("ZJ-20261014-001368");
|
|
|
|
// --json 模式测试
|
|
const jsonRes = await handleWorkflowCommand(
|
|
{
|
|
area: "workflow",
|
|
action: "job",
|
|
args: ["job_err"],
|
|
options: { failed: true, json: true },
|
|
raw: ["workflow", "job", "job_err", "--failed", "--json"],
|
|
},
|
|
{ ...mockRuntime, jsonMode: true }
|
|
);
|
|
|
|
expect(jsonRes.exitCode).toBe(0);
|
|
const parsed = JSON.parse(jsonRes.stdout);
|
|
expect(parsed.totalFailed).toBe(1);
|
|
expect(parsed.failedNodes[0].id).toBe("exec_1");
|
|
expect(parsed.failedNodes[0].error.message).toBe("400: 无待办审批事项");
|
|
expect(parsed.failedNodes[0].inputs.formId).toBe("ZJ-20261014-001368");
|
|
});
|
|
|
|
it("handles workflow job --node=<name|id> targeting specific execution node", async () => {
|
|
const mockPiperClient = {
|
|
get: (url: string) => {
|
|
let payload: any = {};
|
|
if (url.includes("/execution")) {
|
|
payload = [
|
|
{
|
|
id: "node_code",
|
|
name: "codeRunner_1",
|
|
displayName: "MVEL计算节点",
|
|
type: "code",
|
|
status: "COMPLETED",
|
|
executionTime: 85,
|
|
inputs: { expression: "pvTotal * dailyRate" },
|
|
outputs: { result: 78787.55 },
|
|
},
|
|
];
|
|
}
|
|
return new Response(JSON.stringify({ code: 200, data: payload }), {
|
|
status: 200,
|
|
headers: { "content-type": "application/json" },
|
|
});
|
|
},
|
|
};
|
|
|
|
spies.push(
|
|
spyOn(helpers, "createClientsForCorp").mockResolvedValue({
|
|
ekbClient: {
|
|
get: () => ({ json: async () => [{ id: "plat_1", active: true }] }),
|
|
},
|
|
easoClient: mockPiperClient,
|
|
} as any)
|
|
);
|
|
spies.push(spyOn(helpers, "createPiperClientForCorp").mockResolvedValue(mockPiperClient as any));
|
|
|
|
const res = await handleWorkflowCommand(
|
|
{
|
|
area: "workflow",
|
|
action: "job",
|
|
args: ["job_single"],
|
|
options: { node: "MVEL计算" },
|
|
raw: ["workflow", "job", "job_single", "--node=MVEL计算"],
|
|
},
|
|
mockRuntime
|
|
);
|
|
|
|
expect(res.exitCode).toBe(0);
|
|
expect(res.stdout).toContain("工作流节点执行详情 [node_code]");
|
|
expect(res.stdout).toContain("MVEL计算节点");
|
|
expect(res.stdout).toContain("pvTotal * dailyRate");
|
|
expect(res.stdout).toContain("78787.55");
|
|
|
|
// 节点不存在时的错误提示拦截
|
|
const notFoundRes = await handleWorkflowCommand(
|
|
{
|
|
area: "workflow",
|
|
action: "job",
|
|
args: ["job_single"],
|
|
options: { node: "不存在的节点" },
|
|
raw: ["workflow", "job", "job_single", "--node=不存在的节点"],
|
|
},
|
|
mockRuntime
|
|
);
|
|
expect(notFoundRes.exitCode).toBe(1);
|
|
expect(notFoundRes.stderr).toContain("未在 Job [job_single] 的执行树中找到匹配 \"不存在的节点\" 的节点");
|
|
});
|
|
|
|
it("handles workflow diff <snapshot1> <snapshot2> comparing code and node changes", async () => {
|
|
const snap1 = {
|
|
id: "snap_v1",
|
|
pipelineId: "pipe_1",
|
|
version: "1.0.1",
|
|
updateTime: "2026-10-13 14:00:00",
|
|
staffName: "张三",
|
|
tasks: [
|
|
{
|
|
name: "fetch_contract",
|
|
type: "ekuaibao-datalink-filter",
|
|
displayName: "获取合同台账",
|
|
groupName: "action",
|
|
orderIndex: 0,
|
|
levelIndex: [0],
|
|
status: "ENABLE",
|
|
combineFilters: { condition: "AND", filters: [{ key: "state", compare: "EQUAL", value: "OPEN" }] },
|
|
},
|
|
{
|
|
name: "mvel_calc",
|
|
type: "code",
|
|
displayName: "MVEL计算节点",
|
|
groupName: "action",
|
|
orderIndex: 1,
|
|
levelIndex: [1],
|
|
status: "ENABLE",
|
|
code: "double dailyRate = 0.05;\nreturn pvTotal * dailyRate;",
|
|
},
|
|
],
|
|
};
|
|
|
|
const snap2 = {
|
|
id: "snap_v2",
|
|
pipelineId: "pipe_1",
|
|
version: "1.0.2",
|
|
updateTime: "2026-10-14 09:30:00",
|
|
staffName: "李四",
|
|
tasks: [
|
|
{
|
|
name: "fetch_contract",
|
|
type: "ekuaibao-datalink-filter",
|
|
displayName: "获取合同台账",
|
|
groupName: "action",
|
|
orderIndex: 0,
|
|
levelIndex: [0],
|
|
status: "ENABLE",
|
|
combineFilters: { condition: "AND", filters: [{ key: "state", compare: "EQUAL", value: "APPROVING" }] },
|
|
},
|
|
{
|
|
name: "mvel_calc",
|
|
type: "code",
|
|
displayName: "MVEL计算节点",
|
|
groupName: "action",
|
|
orderIndex: 1,
|
|
levelIndex: [1],
|
|
status: "ENABLE",
|
|
code: "double dailyRate = 0.05;\nif (pvTotal <= 0) throw new RuntimeException('金额非法');\nreturn pvTotal * dailyRate;",
|
|
},
|
|
{
|
|
name: "notify_audit",
|
|
type: "webhook",
|
|
displayName: "审计通知",
|
|
groupName: "action",
|
|
orderIndex: 2,
|
|
levelIndex: [2],
|
|
status: "ENABLE",
|
|
},
|
|
],
|
|
};
|
|
|
|
const mockPiperClient = {
|
|
get: (url: string) => {
|
|
let payload: any = {};
|
|
if (url.includes("snap_v1")) payload = snap1;
|
|
else if (url.includes("snap_v2")) payload = snap2;
|
|
return new Response(JSON.stringify({ code: 200, data: payload }), {
|
|
status: 200,
|
|
headers: { "content-type": "application/json" },
|
|
});
|
|
},
|
|
};
|
|
|
|
spies.push(
|
|
spyOn(helpers, "createClientsForCorp").mockResolvedValue({
|
|
ekbClient: { get: () => ({ json: async () => [{ id: "plat_1", active: true }] }) },
|
|
easoClient: mockPiperClient,
|
|
} as any)
|
|
);
|
|
spies.push(spyOn(helpers, "createPiperClientForCorp").mockResolvedValue(mockPiperClient as any));
|
|
|
|
// 1. 文本输出模式
|
|
const res = await handleWorkflowCommand(
|
|
{
|
|
area: "workflow",
|
|
action: "diff",
|
|
args: ["snap_v1", "snap_v2"],
|
|
options: {},
|
|
raw: ["workflow", "diff", "snap_v1", "snap_v2"],
|
|
},
|
|
mockRuntime
|
|
);
|
|
|
|
expect(res.exitCode).toBe(0);
|
|
expect(res.stdout).toContain("工作流快照比对 [1.0.1 -> 1.0.2]");
|
|
expect(res.stdout).toContain("新增节点 (1 个)");
|
|
expect(res.stdout).toContain("notify_audit");
|
|
expect(res.stdout).toContain("mvel_calc");
|
|
expect(res.stdout).toContain("金额非法");
|
|
expect(res.stdout).toContain("过滤/触发条件变动");
|
|
|
|
// 2. JSON 模式
|
|
const jsonRes = await handleWorkflowCommand(
|
|
{
|
|
area: "workflow",
|
|
action: "diff",
|
|
args: ["snap_v1", "snap_v2"],
|
|
options: { json: true },
|
|
raw: ["workflow", "diff", "snap_v1", "snap_v2", "--json"],
|
|
},
|
|
{ ...mockRuntime, jsonMode: true }
|
|
);
|
|
|
|
expect(jsonRes.exitCode).toBe(0);
|
|
const parsed = JSON.parse(jsonRes.stdout);
|
|
expect(parsed.addedTasks).toContain("notify_audit");
|
|
expect(parsed.modifiedTasks.find((t: any) => t.taskName === "mvel_calc")).toBeDefined();
|
|
|
|
// 3. 缺少参数
|
|
const errRes = await handleWorkflowCommand(
|
|
{
|
|
area: "workflow",
|
|
action: "diff",
|
|
args: ["snap_v1"],
|
|
options: {},
|
|
raw: ["workflow", "diff", "snap_v1"],
|
|
},
|
|
mockRuntime
|
|
);
|
|
expect(errRes.exitCode).toBe(1);
|
|
expect(errRes.stderr).toContain("用法: hose-use workflow diff");
|
|
});
|
|
|
|
it("handles workflow diff-job <job1> <job2> comparing execution branch and error divergence", async () => {
|
|
const jobA = {
|
|
id: "job_success",
|
|
pipelineId: "pipe_1",
|
|
state: "COMPLETED",
|
|
startTime: "2026-10-14 10:00:00",
|
|
durationTime: 450,
|
|
hasError: false,
|
|
errorTaskCount: 0,
|
|
};
|
|
|
|
const treeA = [
|
|
{
|
|
id: "ex_1",
|
|
name: "get_bill",
|
|
displayName: "获取单据",
|
|
type: "flow-detail",
|
|
status: "COMPLETED",
|
|
executionTime: 120,
|
|
inputs: { billCode: "ZJ-20261014-001" },
|
|
outputs: { state: "APPROVING" },
|
|
},
|
|
{
|
|
id: "ex_2",
|
|
name: "auto_approve",
|
|
displayName: "自动审批",
|
|
type: "flow-approval",
|
|
status: "COMPLETED",
|
|
executionTime: 330,
|
|
inputs: { action: "agree" },
|
|
outputs: { code: 200, success: true },
|
|
},
|
|
];
|
|
|
|
const jobB = {
|
|
id: "job_failed",
|
|
pipelineId: "pipe_1",
|
|
state: "FAILED",
|
|
startTime: "2026-10-14 11:00:00",
|
|
durationTime: 320,
|
|
hasError: true,
|
|
errorTaskCount: 1,
|
|
};
|
|
|
|
const treeB = [
|
|
{
|
|
id: "ex_1b",
|
|
name: "get_bill",
|
|
displayName: "获取单据",
|
|
type: "flow-detail",
|
|
status: "COMPLETED",
|
|
executionTime: 100,
|
|
inputs: { billCode: "ZJ-20261014-002" },
|
|
outputs: { state: "PAYING" },
|
|
},
|
|
{
|
|
id: "ex_2b",
|
|
name: "auto_approve",
|
|
displayName: "自动审批",
|
|
type: "flow-approval",
|
|
status: "FAILED",
|
|
executionTime: 220,
|
|
error: { message: "400: 无待办审批事项" },
|
|
inputs: { action: "agree" },
|
|
outputs: { code: 400, message: "无待办审批事项" },
|
|
},
|
|
];
|
|
|
|
const mockPiperClient = {
|
|
get: (url: string) => {
|
|
let payload: any = {};
|
|
if (url.includes("job_success/execution")) payload = treeA;
|
|
else if (url.includes("job_failed/execution")) payload = treeB;
|
|
else if (url.includes("job_success")) payload = jobA;
|
|
else if (url.includes("job_failed")) payload = jobB;
|
|
return new Response(JSON.stringify({ code: 200, data: payload }), {
|
|
status: 200,
|
|
headers: { "content-type": "application/json" },
|
|
});
|
|
},
|
|
};
|
|
|
|
spies.push(
|
|
spyOn(helpers, "createClientsForCorp").mockResolvedValue({
|
|
ekbClient: { get: () => ({ json: async () => [{ id: "plat_1", active: true }] }) },
|
|
easoClient: mockPiperClient,
|
|
} as any)
|
|
);
|
|
spies.push(spyOn(helpers, "createPiperClientForCorp").mockResolvedValue(mockPiperClient as any));
|
|
|
|
// 1. 文本输出模式
|
|
const res = await handleWorkflowCommand(
|
|
{
|
|
area: "workflow",
|
|
action: "diff-job",
|
|
args: ["job_success", "job_failed"],
|
|
options: {},
|
|
raw: ["workflow", "diff-job", "job_success", "job_failed"],
|
|
},
|
|
mockRuntime
|
|
);
|
|
|
|
expect(res.exitCode).toBe(0);
|
|
expect(res.stdout).toContain("工作流 Job 执行比对 [job_success vs job_failed]");
|
|
expect(res.stdout).toContain("auto_approve");
|
|
expect(res.stdout).toContain("400: 无待办审批事项");
|
|
expect(res.stdout).toContain("ZJ-20261014-001");
|
|
expect(res.stdout).toContain("ZJ-20261014-002");
|
|
|
|
// 2. JSON 模式
|
|
const jsonRes = await handleWorkflowCommand(
|
|
{
|
|
area: "workflow",
|
|
action: "diff-job",
|
|
args: ["job_success", "job_failed"],
|
|
options: { json: true },
|
|
raw: ["workflow", "diff-job", "job_success", "job_failed", "--json"],
|
|
},
|
|
{ ...mockRuntime, jsonMode: true }
|
|
);
|
|
|
|
expect(jsonRes.exitCode).toBe(0);
|
|
const parsed = JSON.parse(jsonRes.stdout);
|
|
expect(parsed.jobA.id).toBe("job_success");
|
|
expect(parsed.jobB.id).toBe("job_failed");
|
|
expect(parsed.summary.statusDiffCount).toBe(1);
|
|
expect(parsed.nodes.find((n: any) => n.taskName === "auto_approve").statusB).toBe("FAILED");
|
|
});
|
|
|
|
it("handles workflow test without pipelineId", async () => {
|
|
const res = await handleWorkflowCommand(
|
|
{
|
|
area: "workflow",
|
|
action: "test",
|
|
args: [],
|
|
options: {},
|
|
raw: ["workflow", "test"],
|
|
},
|
|
mockRuntime
|
|
);
|
|
expect(res.exitCode).toBe(1);
|
|
expect(res.stderr).toContain("用法: hose-use workflow test");
|
|
});
|
|
|
|
it("handles workflow test without --flow by listing candidate sources", async () => {
|
|
const mockClient = {
|
|
post: (url: string) => ({
|
|
json: async () => ({
|
|
code: 200,
|
|
data: {
|
|
type: "flowForm",
|
|
total: 1,
|
|
label: "我的单据",
|
|
items: [
|
|
{ id: "ZJ-20261015-001387", title: "资金调拨测试单", flowState: "审批中" },
|
|
],
|
|
fields: [
|
|
{ key: "id", label: "单号" },
|
|
{ key: "title", label: "标题" },
|
|
],
|
|
},
|
|
}),
|
|
}),
|
|
get: (url: string) => {
|
|
if (url.includes("platform")) {
|
|
return { json: async () => ({ items: [] }) };
|
|
}
|
|
return { json: async () => ({ code: 200, data: [] }) };
|
|
},
|
|
};
|
|
|
|
spies.push(
|
|
spyOn(helpers, "createClientsForCorp").mockResolvedValue({
|
|
ekbClient: mockClient as any,
|
|
easoClient: mockClient as any,
|
|
corp: mockCorp,
|
|
} as any)
|
|
);
|
|
spies.push(
|
|
spyOn(helpers, "createPiperClientForCorp").mockResolvedValue(mockClient as any)
|
|
);
|
|
|
|
const res = await handleWorkflowCommand(
|
|
{
|
|
area: "workflow",
|
|
action: "test",
|
|
args: ["wf_test_1"],
|
|
options: { platformId: "p1" },
|
|
raw: ["workflow", "test", "wf_test_1", "--platform-id=p1"],
|
|
},
|
|
mockRuntime
|
|
);
|
|
|
|
expect(res.exitCode).toBe(1);
|
|
expect(res.stdout).toContain("未指定测试单号");
|
|
expect(res.stdout).toContain("ZJ-20261015-001387");
|
|
expect(res.stdout).toContain("资金调拨测试单");
|
|
});
|
|
|
|
it("handles workflow test end-to-end with --flow parameter", async () => {
|
|
const mockClient = {
|
|
post: (url: string) => {
|
|
if (url.includes("debugSource")) {
|
|
return {
|
|
json: async () => ({
|
|
code: 200,
|
|
data: {
|
|
type: "flowForm",
|
|
total: 1,
|
|
items: [{ id: "ZJ-20261015-001387", title: "资金调拨", flowState: "审批中" }],
|
|
},
|
|
}),
|
|
};
|
|
}
|
|
if (url.includes("api/easo/jobs")) {
|
|
return {
|
|
json: async () => ({
|
|
code: 200,
|
|
data: "job_debug_888",
|
|
}),
|
|
};
|
|
}
|
|
return { json: async () => ({ code: 200, data: null }) };
|
|
},
|
|
get: (url: string) => {
|
|
if (url.includes("/level/failed")) return { json: async () => ({ code: 200, data: [] }) };
|
|
if (url.includes("execution")) {
|
|
return {
|
|
json: async () => ({
|
|
code: 200,
|
|
data: [
|
|
{
|
|
id: "e1",
|
|
name: "trigger_1",
|
|
label: "触发器",
|
|
type: "ekuaibao-flowform-trigger",
|
|
status: "COMPLETED",
|
|
executionTime: 10,
|
|
},
|
|
{
|
|
id: "e2",
|
|
name: "control_1",
|
|
label: "条件节点",
|
|
type: "condition",
|
|
status: "COMPLETED",
|
|
executionTime: 5,
|
|
tasks: [{ name: "action_auto", label: "自动审批", type: "http" }],
|
|
},
|
|
{
|
|
id: "e3",
|
|
name: "action_stop",
|
|
label: "终止节点",
|
|
type: "stop",
|
|
status: "COMPLETED",
|
|
executionTime: 2,
|
|
},
|
|
],
|
|
}),
|
|
};
|
|
}
|
|
if (url.includes("api/easo/pipelines/")) {
|
|
return {
|
|
json: async () => ({
|
|
code: 200,
|
|
data: {
|
|
id: "wf_test_1",
|
|
label: "测试工作流",
|
|
state: 0,
|
|
},
|
|
}),
|
|
};
|
|
}
|
|
return {
|
|
json: async () => ({
|
|
code: 200,
|
|
data: {
|
|
id: "job_debug_888",
|
|
pipelineId: "wf_test_1",
|
|
status: "COMPLETED",
|
|
runType: "DEBUG",
|
|
durationTime: 17,
|
|
},
|
|
}),
|
|
};
|
|
},
|
|
};
|
|
|
|
spies.push(
|
|
spyOn(helpers, "createClientsForCorp").mockResolvedValue({
|
|
ekbClient: mockClient as any,
|
|
easoClient: mockClient as any,
|
|
corp: mockCorp,
|
|
} as any)
|
|
);
|
|
spies.push(
|
|
spyOn(helpers, "createPiperClientForCorp").mockResolvedValue(mockClient as any)
|
|
);
|
|
|
|
const res = await handleWorkflowCommand(
|
|
{
|
|
area: "workflow",
|
|
action: "test",
|
|
args: ["wf_test_1"],
|
|
options: { flow: "ZJ-20261015-001387", platformId: "p1", yes: true },
|
|
raw: ["workflow", "test", "wf_test_1", "--flow=ZJ-20261015-001387", "--platform-id=p1"],
|
|
},
|
|
mockRuntime
|
|
);
|
|
|
|
expect(res.exitCode).toBe(0);
|
|
expect(res.stdout).toContain("工作流自动化调测报告 [wf_test_1]");
|
|
expect(res.stdout).toContain("job_debug_888");
|
|
expect(res.stdout).toContain("ZJ-20261015-001387");
|
|
expect(res.stdout).toContain("control_1");
|
|
});
|
|
|
|
it("allows workflow test when pipeline is enabled in production with full security prompt", async () => {
|
|
const mockClient = {
|
|
get: (url: string) => {
|
|
if (url.includes("/level/failed")) return { json: async () => ({ code: 200, data: [] }) };
|
|
if (url.includes("api/easo/pipelines/")) {
|
|
return {
|
|
json: async () => ({
|
|
code: 200,
|
|
data: {
|
|
id: "wf_prod_1",
|
|
label: "生产自动审批工作流",
|
|
state: 1, // 生产启用中
|
|
},
|
|
}),
|
|
};
|
|
}
|
|
if (url.includes("execution")) {
|
|
return {
|
|
json: async () => ({
|
|
code: 200,
|
|
data: [
|
|
{
|
|
id: "e1",
|
|
name: "trigger_1",
|
|
label: "触发器",
|
|
type: "ekuaibao-flowform-trigger",
|
|
status: "COMPLETED",
|
|
},
|
|
],
|
|
}),
|
|
};
|
|
}
|
|
return {
|
|
json: async () => ({
|
|
code: 200,
|
|
data: {
|
|
id: "job_prod_999",
|
|
pipelineId: "wf_prod_1",
|
|
status: "COMPLETED",
|
|
runType: "DEBUG",
|
|
},
|
|
}),
|
|
};
|
|
},
|
|
post: () => ({ json: async () => ({ code: 200, data: "job_prod_999" }) }),
|
|
};
|
|
|
|
spies.push(
|
|
spyOn(helpers, "createClientsForCorp").mockResolvedValue({
|
|
ekbClient: mockClient as any,
|
|
easoClient: mockClient as any,
|
|
corp: mockCorp,
|
|
} as any)
|
|
);
|
|
spies.push(
|
|
spyOn(helpers, "createPiperClientForCorp").mockResolvedValue(mockClient as any)
|
|
);
|
|
|
|
const res = await handleWorkflowCommand(
|
|
{
|
|
area: "workflow",
|
|
action: "test",
|
|
args: ["wf_prod_1"],
|
|
options: { flow: "ZJ-20261015-001387", platformId: "p1", yes: true },
|
|
raw: ["workflow", "test", "wf_prod_1", "--flow=ZJ-20261015-001387", "--platform-id=p1"],
|
|
},
|
|
mockRuntime
|
|
);
|
|
|
|
expect(res.exitCode).toBe(0);
|
|
expect(res.stdout).toContain("生产启用态调试安全提醒");
|
|
expect(res.stdout).toContain("特权调测通道");
|
|
expect(res.stdout).toContain("job_prod_999");
|
|
});
|
|
|
|
it("handles workflow test for clock trigger without requiring --flow", async () => {
|
|
const mockClient = {
|
|
get: (url: string) => {
|
|
if (url.includes("/level/failed")) return { json: async () => ({ code: 200, data: [] }) };
|
|
if (url.includes("api/easo/pipelines/")) {
|
|
return {
|
|
json: async () => ({
|
|
code: 200,
|
|
data: {
|
|
id: "wf_clock_1",
|
|
label: "定时摊销工作流",
|
|
state: 0,
|
|
tasks: [
|
|
{ id: "t1", name: "trigger_1", label: "定时触发", type: "clock" },
|
|
],
|
|
},
|
|
}),
|
|
};
|
|
}
|
|
if (url.includes("execution")) {
|
|
return {
|
|
json: async () => ({
|
|
code: 200,
|
|
data: [
|
|
{
|
|
id: "e1",
|
|
name: "trigger_1",
|
|
label: "定时触发",
|
|
type: "clock",
|
|
status: "COMPLETED",
|
|
},
|
|
],
|
|
}),
|
|
};
|
|
}
|
|
return {
|
|
json: async () => ({
|
|
code: 200,
|
|
data: {
|
|
id: "job_clock_101",
|
|
pipelineId: "wf_clock_1",
|
|
status: "COMPLETED",
|
|
runType: "DEBUG",
|
|
},
|
|
}),
|
|
};
|
|
},
|
|
post: () => ({ json: async () => ({ code: 200, data: "job_clock_101" }) }),
|
|
};
|
|
|
|
spies.push(
|
|
spyOn(helpers, "createClientsForCorp").mockResolvedValue({
|
|
ekbClient: mockClient as any,
|
|
easoClient: mockClient as any,
|
|
corp: mockCorp,
|
|
} as any)
|
|
);
|
|
spies.push(
|
|
spyOn(helpers, "createPiperClientForCorp").mockResolvedValue(mockClient as any)
|
|
);
|
|
|
|
// 未传 --flow,也无需报错,直接派发执行
|
|
const res = await handleWorkflowCommand(
|
|
{
|
|
area: "workflow",
|
|
action: "test",
|
|
args: ["wf_clock_1"],
|
|
options: { platformId: "p1", yes: true },
|
|
raw: ["workflow", "test", "wf_clock_1", "--platform-id=p1"],
|
|
},
|
|
mockRuntime
|
|
);
|
|
|
|
expect(res.exitCode).toBe(0);
|
|
expect(res.stdout).toContain("[SCHEDULE]");
|
|
expect(res.stdout).toContain("定时调度模拟触发");
|
|
expect(res.stdout).toContain("job_clock_101");
|
|
});
|
|
|
|
it("handles workflow test for webhook trigger requiring body or empty", async () => {
|
|
const mockClient = {
|
|
get: (url: string) => {
|
|
if (url.includes("/level/failed")) return { json: async () => ({ code: 200, data: [] }) };
|
|
if (url.includes("api/easo/pipelines/")) {
|
|
return {
|
|
json: async () => ({
|
|
code: 200,
|
|
data: {
|
|
id: "wf_webhook_1",
|
|
label: "外部回调工作流",
|
|
state: 0,
|
|
tasks: [
|
|
{ id: "t1", name: "trigger_1", label: "Webhook触发器", type: "webhook" },
|
|
],
|
|
},
|
|
}),
|
|
};
|
|
}
|
|
if (url.includes("execution")) {
|
|
return {
|
|
json: async () => ({
|
|
code: 200,
|
|
data: [
|
|
{
|
|
id: "e1",
|
|
name: "trigger_1",
|
|
label: "Webhook触发器",
|
|
type: "webhook",
|
|
status: "COMPLETED",
|
|
},
|
|
],
|
|
}),
|
|
};
|
|
}
|
|
return {
|
|
json: async () => ({
|
|
code: 200,
|
|
data: {
|
|
id: "job_webhook_202",
|
|
pipelineId: "wf_webhook_1",
|
|
status: "COMPLETED",
|
|
runType: "DEBUG",
|
|
},
|
|
}),
|
|
};
|
|
},
|
|
post: (url: string) => {
|
|
if (url && url.includes("sampleData")) {
|
|
return {
|
|
json: async () => ({
|
|
code: 200,
|
|
data: {
|
|
records: [
|
|
{
|
|
id: "sample_001",
|
|
pipelineId: "wf_webhook_1",
|
|
dataJson: JSON.stringify({ code: "SAMPLE-PAYLOAD-001" }),
|
|
createTime: 1792047100000,
|
|
},
|
|
],
|
|
},
|
|
}),
|
|
};
|
|
}
|
|
return { json: async () => ({ code: 200, data: "job_webhook_202" }) };
|
|
},
|
|
};
|
|
|
|
spies.push(
|
|
spyOn(helpers, "createClientsForCorp").mockResolvedValue({
|
|
ekbClient: mockClient as any,
|
|
easoClient: mockClient as any,
|
|
corp: mockCorp,
|
|
} as any)
|
|
);
|
|
spies.push(
|
|
spyOn(helpers, "createPiperClientForCorp").mockResolvedValue(mockClient as any)
|
|
);
|
|
|
|
// 1. 未传 body 时提示参数说明与服务器历史样本
|
|
const noBodyRes = await handleWorkflowCommand(
|
|
{
|
|
area: "workflow",
|
|
action: "test",
|
|
args: ["wf_webhook_1"],
|
|
options: { platformId: "p1" },
|
|
raw: ["workflow", "test", "wf_webhook_1", "--platform-id=p1"],
|
|
},
|
|
mockRuntime
|
|
);
|
|
expect(noBodyRes.exitCode).toBe(1);
|
|
expect(noBodyRes.stdout).toContain("外部事件触发器");
|
|
expect(noBodyRes.stdout).toContain("服务器最近接收的数据样本");
|
|
expect(noBodyRes.stdout).toContain("sample_001");
|
|
expect(noBodyRes.stdout).toContain("--sample");
|
|
|
|
// 2. 传入 --sample=1 成功提取样本发起测试
|
|
const withSampleRes = await handleWorkflowCommand(
|
|
{
|
|
area: "workflow",
|
|
action: "test",
|
|
args: ["wf_webhook_1"],
|
|
options: { sample: "1", platformId: "p1", yes: true },
|
|
raw: ["workflow", "test", "wf_webhook_1", "--sample=1", "--platform-id=p1", "--yes"],
|
|
},
|
|
mockRuntime
|
|
);
|
|
expect(withSampleRes.exitCode).toBe(0);
|
|
expect(withSampleRes.stdout).toContain("[WEBHOOK]");
|
|
expect(withSampleRes.stdout).toContain("Webhook Payload: code");
|
|
|
|
// 3. 传入 --body 成功派发
|
|
const withBodyRes = await handleWorkflowCommand(
|
|
{
|
|
area: "workflow",
|
|
action: "test",
|
|
args: ["wf_webhook_1"],
|
|
options: { body: '{"code":"XM-001"}', platformId: "p1", yes: true },
|
|
raw: ["workflow", "test", "wf_webhook_1", '--body={"code":"XM-001"}', "--platform-id=p1"],
|
|
},
|
|
mockRuntime
|
|
);
|
|
expect(withBodyRes.exitCode).toBe(0);
|
|
expect(withBodyRes.stdout).toContain("[WEBHOOK]");
|
|
expect(withBodyRes.stdout).toContain("Webhook Payload");
|
|
});
|
|
|
|
it("handles workflow test for datalink trigger displaying dynamic fields", async () => {
|
|
const mockClient = {
|
|
get: (url: string) => {
|
|
if (url.includes("/level/failed")) return { json: async () => ({ code: 200, data: [] }) };
|
|
if (url.includes("api/easo/pipelines/")) {
|
|
return {
|
|
json: async () => ({
|
|
code: 200,
|
|
data: {
|
|
id: "wf_datalink_1",
|
|
label: "合同台账生成单据",
|
|
state: 0,
|
|
tasks: [
|
|
{ id: "t1", name: "trigger_1", label: "新增业务对象数据时触发", type: "ekuaibao-datalink-create-trigger" },
|
|
],
|
|
},
|
|
}),
|
|
};
|
|
}
|
|
return { json: async () => ({ code: 200, data: null }) };
|
|
},
|
|
post: (url: string) => {
|
|
if (url.includes("debugSource")) {
|
|
return {
|
|
json: async () => ({
|
|
code: 200,
|
|
data: {
|
|
type: "dataLink",
|
|
total: 1,
|
|
label: "合同台账",
|
|
fields: [
|
|
{ key: "contractName", label: "合同名称" },
|
|
{ key: "owner", label: "负责人" },
|
|
],
|
|
items: [
|
|
{ id: "rec_123", contractName: "年度办公租赁合同", owner: "张三" },
|
|
],
|
|
},
|
|
}),
|
|
};
|
|
}
|
|
return { json: async () => ({ code: 200, data: null }) };
|
|
},
|
|
};
|
|
|
|
spies.push(
|
|
spyOn(helpers, "createClientsForCorp").mockResolvedValue({
|
|
ekbClient: mockClient as any,
|
|
easoClient: mockClient as any,
|
|
corp: mockCorp,
|
|
} as any)
|
|
);
|
|
spies.push(
|
|
spyOn(helpers, "createPiperClientForCorp").mockResolvedValue(mockClient as any)
|
|
);
|
|
|
|
const res = await handleWorkflowCommand(
|
|
{
|
|
area: "workflow",
|
|
action: "test",
|
|
args: ["wf_datalink_1"],
|
|
options: { platformId: "p1" },
|
|
raw: ["workflow", "test", "wf_datalink_1", "--platform-id=p1"],
|
|
},
|
|
mockRuntime
|
|
);
|
|
|
|
expect(res.exitCode).toBe(1);
|
|
expect(res.stdout).toContain("合同台账");
|
|
expect(res.stdout).toContain("合同名称");
|
|
expect(res.stdout).toContain("年度办公租赁合同");
|
|
expect(res.stdout).toContain("张三");
|
|
expect(res.stdout).toContain("--record=");
|
|
});
|
|
|
|
it("handles workflow copy: requires pipelineId, confirmation, dry-run, execution, and json mode", async () => {
|
|
// 1. Missing pipelineId
|
|
const noArgRes = await handleWorkflowCommand(
|
|
{
|
|
area: "workflow",
|
|
action: "copy",
|
|
args: [],
|
|
options: {},
|
|
raw: ["workflow", "copy"],
|
|
},
|
|
mockRuntime
|
|
);
|
|
expect(noArgRes.exitCode).toBe(1);
|
|
expect(noArgRes.stderr).toContain("用法: hose-use workflow copy");
|
|
|
|
// 2. Missing mutation confirmation
|
|
await expect(
|
|
handleWorkflowCommand(
|
|
{
|
|
area: "workflow",
|
|
action: "copy",
|
|
args: ["pipe_orig"],
|
|
options: {},
|
|
raw: ["workflow", "copy", "pipe_orig"],
|
|
},
|
|
mockRuntime
|
|
)
|
|
).rejects.toThrow("请先使用 --dry-run");
|
|
|
|
// 3. Dry-run preview
|
|
let copiedPayload: any = null;
|
|
const mockClient = {
|
|
get: (url: string) => {
|
|
if (url.includes("api/easo/pipelines/pipe_orig")) {
|
|
return {
|
|
json: async () => ({
|
|
code: 200,
|
|
data: {
|
|
id: "pipe_orig",
|
|
label: "风险发票实时监控",
|
|
platformId: "app_orig",
|
|
state: 1,
|
|
tasks: [
|
|
{
|
|
id: "t1",
|
|
name: "webhook_1",
|
|
label: "发票数据接入",
|
|
type: "webhook",
|
|
urlPath: "old-path-uuid",
|
|
sampleId: "old-sample-id",
|
|
},
|
|
],
|
|
},
|
|
}),
|
|
};
|
|
}
|
|
return { json: async () => ({ code: 200, data: null }) };
|
|
},
|
|
put: (url: string, opts: any) => {
|
|
if (url.includes("api/easo/pipelines/pipe_orig/copy")) {
|
|
copiedPayload = opts.json;
|
|
return {
|
|
json: async () => ({
|
|
code: 200,
|
|
data: {
|
|
id: "pipe_cloned_888",
|
|
label: opts.json.label,
|
|
platformId: opts.json.platformId || "app_orig",
|
|
state: 0,
|
|
version: "26.10.1",
|
|
tasks: opts.json.tasks,
|
|
},
|
|
}),
|
|
};
|
|
}
|
|
return { json: async () => ({ code: 200, data: null }) };
|
|
},
|
|
};
|
|
|
|
spies.push(
|
|
spyOn(helpers, "createClientsForCorp").mockResolvedValue({
|
|
ekbClient: mockClient as any,
|
|
easoClient: mockClient as any,
|
|
corp: mockCorp,
|
|
} as any)
|
|
);
|
|
spies.push(
|
|
spyOn(helpers, "createPiperClientForCorp").mockResolvedValue(mockClient as any)
|
|
);
|
|
|
|
const dryRunRes = await handleWorkflowCommand(
|
|
{
|
|
area: "workflow",
|
|
action: "copy",
|
|
args: ["pipe_orig"],
|
|
options: { "dry-run": true },
|
|
raw: ["workflow", "copy", "pipe_orig", "--dry-run"],
|
|
},
|
|
mockRuntime
|
|
);
|
|
expect(dryRunRes.exitCode).toBe(0);
|
|
expect(dryRunRes.stdout).toContain("[DRY-RUN]");
|
|
expect(dryRunRes.stdout).toContain("pipe_orig");
|
|
expect(dryRunRes.stdout).toContain("风险发票实时监控 副本");
|
|
expect(copiedPayload).toBeNull();
|
|
|
|
// 4. Confirmed execution with custom name and platform
|
|
const copyRes = await handleWorkflowCommand(
|
|
{
|
|
area: "workflow",
|
|
action: "copy",
|
|
args: ["pipe_orig"],
|
|
options: { name: "发票监控克隆版", "platform-id": "app_custom", yes: true },
|
|
raw: ["workflow", "copy", "pipe_orig", "--name=发票监控克隆版", "--platform-id=app_custom", "--yes"],
|
|
},
|
|
mockRuntime
|
|
);
|
|
expect(copyRes.exitCode).toBe(0);
|
|
expect(copyRes.stdout).toContain("工作流复制成功");
|
|
expect(copyRes.stdout).toContain("pipe_cloned_888");
|
|
expect(copyRes.stdout).toContain("发票监控克隆版");
|
|
expect(copyRes.stdout).toContain("草稿未发布");
|
|
|
|
// Verify webhook payload transformation
|
|
expect(copiedPayload).not.toBeNull();
|
|
expect(copiedPayload.label).toBe("发票监控克隆版");
|
|
expect(copiedPayload.platformId).toBe("app_custom");
|
|
expect(copiedPayload.tasks[0].urlPath).not.toBe("old-path-uuid");
|
|
expect(copiedPayload.tasks[0].sampleId).toBeUndefined();
|
|
|
|
// 5. JSON mode via alias "cp"
|
|
const jsonRes = await handleWorkflowCommand(
|
|
{
|
|
area: "workflow",
|
|
action: "cp",
|
|
args: ["pipe_orig"],
|
|
options: { yes: true },
|
|
raw: ["workflow", "cp", "pipe_orig", "--yes"],
|
|
},
|
|
{ ...mockRuntime, jsonMode: true }
|
|
);
|
|
expect(jsonRes.exitCode).toBe(0);
|
|
const parsedJson = JSON.parse(jsonRes.stdout);
|
|
expect(parsedJson.id).toBe("pipe_cloned_888");
|
|
expect(parsedJson.state).toBe(0);
|
|
});
|
|
|
|
it("handles workflow delete: requires pipelineId, confirmation, dry-run, execution, and json mode", async () => {
|
|
// 1. Missing pipelineId
|
|
const noArgRes = await handleWorkflowCommand(
|
|
{
|
|
area: "workflow",
|
|
action: "delete",
|
|
args: [],
|
|
options: {},
|
|
raw: ["workflow", "delete"],
|
|
},
|
|
mockRuntime
|
|
);
|
|
expect(noArgRes.exitCode).toBe(1);
|
|
expect(noArgRes.stderr).toContain("用法: hose-use workflow delete");
|
|
|
|
// 2. Missing mutation confirmation
|
|
await expect(
|
|
handleWorkflowCommand(
|
|
{
|
|
area: "workflow",
|
|
action: "delete",
|
|
args: ["pipe_del_999"],
|
|
options: {},
|
|
raw: ["workflow", "delete", "pipe_del_999"],
|
|
},
|
|
mockRuntime
|
|
)
|
|
).rejects.toThrow("请先使用 --dry-run");
|
|
|
|
let deletedUrl: string | null = null;
|
|
const mockClient = {
|
|
get: (url: string) => {
|
|
if (url.includes("api/easo/pipelines/pipe_del_999")) {
|
|
return {
|
|
json: async () => ({
|
|
code: 200,
|
|
data: {
|
|
id: "pipe_del_999",
|
|
label: "待删除工作流",
|
|
state: 0,
|
|
},
|
|
}),
|
|
};
|
|
}
|
|
return { json: async () => ({ code: 200, data: null }) };
|
|
},
|
|
delete: (url: string) => {
|
|
deletedUrl = url;
|
|
return {
|
|
text: async () => "",
|
|
};
|
|
},
|
|
};
|
|
|
|
spies.push(
|
|
spyOn(helpers, "createClientsForCorp").mockResolvedValue({
|
|
ekbClient: mockClient as any,
|
|
easoClient: mockClient as any,
|
|
corp: mockCorp,
|
|
} as any)
|
|
);
|
|
spies.push(
|
|
spyOn(helpers, "createPiperClientForCorp").mockResolvedValue(mockClient as any)
|
|
);
|
|
|
|
// 3. Dry-run preview
|
|
const dryRunRes = await handleWorkflowCommand(
|
|
{
|
|
area: "workflow",
|
|
action: "delete",
|
|
args: ["pipe_del_999"],
|
|
options: { "dry-run": true },
|
|
raw: ["workflow", "delete", "pipe_del_999", "--dry-run"],
|
|
},
|
|
mockRuntime
|
|
);
|
|
expect(dryRunRes.exitCode).toBe(0);
|
|
expect(dryRunRes.stdout).toContain("[DRY-RUN]");
|
|
expect(dryRunRes.stdout).toContain("pipe_del_999");
|
|
expect(dryRunRes.stdout).toContain("待删除工作流");
|
|
expect(deletedUrl).toBeNull();
|
|
|
|
// 4. Confirmed execution via alias "rm"
|
|
const delRes = await handleWorkflowCommand(
|
|
{
|
|
area: "workflow",
|
|
action: "rm",
|
|
args: ["pipe_del_999"],
|
|
options: { yes: true },
|
|
raw: ["workflow", "rm", "pipe_del_999", "--yes"],
|
|
},
|
|
mockRuntime
|
|
);
|
|
expect(delRes.exitCode).toBe(0);
|
|
expect(delRes.stdout).toContain("pipe_del_999");
|
|
expect(delRes.stdout).toContain("已成功删除");
|
|
expect(deletedUrl as string | null).toBe("api/easo/pipelines/pipe_del_999");
|
|
|
|
// 5. JSON mode via alias "remove"
|
|
const jsonRes = await handleWorkflowCommand(
|
|
{
|
|
area: "workflow",
|
|
action: "remove",
|
|
args: ["pipe_del_999"],
|
|
options: { yes: true },
|
|
raw: ["workflow", "remove", "pipe_del_999", "--yes"],
|
|
},
|
|
{ ...mockRuntime, jsonMode: true }
|
|
);
|
|
expect(jsonRes.exitCode).toBe(0);
|
|
const parsedJson = JSON.parse(jsonRes.stdout);
|
|
expect(parsedJson.success).toBe(true);
|
|
expect(parsedJson.pipelineId).toBe("pipe_del_999");
|
|
});
|
|
|
|
it("handles workflow create: requires confirmation, dry-run, execution, triggers, and json mode", async () => {
|
|
// 1. Missing mutation confirmation
|
|
await expect(
|
|
handleWorkflowCommand(
|
|
{
|
|
area: "workflow",
|
|
action: "create",
|
|
args: ["新风险拦截流程"],
|
|
options: {},
|
|
raw: ["workflow", "create", "新风险拦截流程"],
|
|
},
|
|
mockRuntime
|
|
)
|
|
).rejects.toThrow("请先使用 --dry-run");
|
|
|
|
// 2. Dry-run preview
|
|
const dryRunRes = await handleWorkflowCommand(
|
|
{
|
|
area: "workflow",
|
|
action: "create",
|
|
args: ["新风险拦截流程"],
|
|
options: { trigger: "webhook", "dry-run": true },
|
|
raw: ["workflow", "create", "新风险拦截流程", "--trigger=webhook", "--dry-run"],
|
|
},
|
|
mockRuntime
|
|
);
|
|
expect(dryRunRes.exitCode).toBe(0);
|
|
expect(dryRunRes.stdout).toContain("[DRY-RUN]");
|
|
expect(dryRunRes.stdout).toContain("新风险拦截流程");
|
|
expect(dryRunRes.stdout).toContain("webhook");
|
|
|
|
let createdPayload: any = null;
|
|
const mockClient = {
|
|
post: (url: string, opts: any) => {
|
|
if (url.includes("api/easo/pipelines")) {
|
|
createdPayload = opts.json;
|
|
return {
|
|
json: async () => ({
|
|
code: 200,
|
|
data: {
|
|
id: "pipe_new_777",
|
|
label: opts.json.label,
|
|
platformId: opts.json.platformId || "app_default",
|
|
state: opts.json.state ?? 0,
|
|
version: "26.10.1",
|
|
tasks: opts.json.tasks || [],
|
|
},
|
|
}),
|
|
};
|
|
}
|
|
return { json: async () => ({ code: 200, data: null }) };
|
|
},
|
|
get: () => ({ json: async () => ({ code: 200, data: null }) }),
|
|
};
|
|
|
|
spies.push(
|
|
spyOn(helpers, "createClientsForCorp").mockResolvedValue({
|
|
ekbClient: mockClient as any,
|
|
easoClient: mockClient as any,
|
|
corp: mockCorp,
|
|
} as any)
|
|
);
|
|
spies.push(
|
|
spyOn(helpers, "createPiperClientForCorp").mockResolvedValue(mockClient as any)
|
|
);
|
|
|
|
// 3. Confirmed execution with webhook trigger
|
|
const createRes = await handleWorkflowCommand(
|
|
{
|
|
area: "workflow",
|
|
action: "create",
|
|
args: ["外部发票接入"],
|
|
options: { trigger: "webhook", yes: true },
|
|
raw: ["workflow", "create", "外部发票接入", "--trigger=webhook", "--yes"],
|
|
},
|
|
mockRuntime
|
|
);
|
|
expect(createRes.exitCode).toBe(0);
|
|
expect(createRes.stdout).toContain("工作流创建成功");
|
|
expect(createRes.stdout).toContain("pipe_new_777");
|
|
expect(createRes.stdout).toContain("外部发票接入");
|
|
expect(createRes.stdout).toContain("https://piper.ekuaibao.com/api/webhook/");
|
|
expect(createRes.stdout).toContain("草稿未发布");
|
|
|
|
expect(createdPayload).not.toBeNull();
|
|
expect(createdPayload.label).toBe("外部发票接入");
|
|
expect(createdPayload.state).toBe(0);
|
|
expect(createdPayload.tasks).toHaveLength(1);
|
|
expect(createdPayload.tasks[0].type).toBe("webhook");
|
|
expect(createdPayload.tasks[0].urlPath).toBeDefined();
|
|
|
|
// 4. Create with clock trigger via alias "new"
|
|
const clockRes = await handleWorkflowCommand(
|
|
{
|
|
area: "workflow",
|
|
action: "new",
|
|
args: ["每日定时同步"],
|
|
options: { trigger: "clock", yes: true },
|
|
raw: ["workflow", "new", "每日定时同步", "--trigger=clock", "--yes"],
|
|
},
|
|
mockRuntime
|
|
);
|
|
expect(clockRes.exitCode).toBe(0);
|
|
expect(createdPayload.tasks[0].type).toBe("clock");
|
|
expect(createdPayload.tasks[0].cron).toBe("0 0 * * *");
|
|
|
|
// 5. JSON mode via alias "add"
|
|
const jsonRes = await handleWorkflowCommand(
|
|
{
|
|
area: "workflow",
|
|
action: "add",
|
|
args: ["API创建流程"],
|
|
options: { yes: true },
|
|
raw: ["workflow", "add", "API创建流程", "--yes"],
|
|
},
|
|
{ ...mockRuntime, jsonMode: true }
|
|
);
|
|
expect(jsonRes.exitCode).toBe(0);
|
|
const parsedJson = JSON.parse(jsonRes.stdout);
|
|
expect(parsedJson.id).toBe("pipe_new_777");
|
|
expect(parsedJson.state).toBe(0);
|
|
|
|
// 6. Create from template file
|
|
const tmpFile = `/tmp/test_wf_${Date.now()}.json`;
|
|
await (await import("fs/promises")).writeFile(
|
|
tmpFile,
|
|
JSON.stringify({
|
|
label: "文件模板流程",
|
|
state: 1,
|
|
desc: "来自模板文件",
|
|
tasks: [
|
|
{
|
|
name: "trigger_webhook",
|
|
type: "webhook",
|
|
label: "Webhook触发",
|
|
groupName: "trigger",
|
|
orderIndex: 0,
|
|
levelIndex: [0],
|
|
status: "active",
|
|
},
|
|
],
|
|
})
|
|
);
|
|
|
|
const fileRes = await handleWorkflowCommand(
|
|
{
|
|
area: "workflow",
|
|
action: "create",
|
|
args: [],
|
|
options: { file: tmpFile, yes: true },
|
|
raw: ["workflow", "create", `--file=${tmpFile}`, "--yes"],
|
|
},
|
|
mockRuntime
|
|
);
|
|
expect(fileRes.exitCode).toBe(0);
|
|
expect(createdPayload.label).toBe("文件模板流程");
|
|
expect(createdPayload.state).toBe(0);
|
|
expect(createdPayload.desc).toBe("来自模板文件");
|
|
expect(createdPayload.tasks[0].urlPath).toBeDefined();
|
|
|
|
await (await import("fs/promises")).unlink(tmpFile).catch(() => {});
|
|
});
|
|
|
|
it("handles workflow node list, get, add, edit, and rm commands with dry-run and safety checks", async () => {
|
|
// 1. Missing pipelineId -> usage
|
|
const noArgRes = await handleWorkflowCommand(
|
|
{
|
|
area: "workflow",
|
|
action: "node",
|
|
args: [],
|
|
options: {},
|
|
raw: ["workflow", "node"],
|
|
},
|
|
mockRuntime
|
|
);
|
|
expect(noArgRes.exitCode).toBe(1);
|
|
expect(noArgRes.stderr).toContain("用法: hose-use workflow node");
|
|
|
|
let savedWorkflowPayload: any = null;
|
|
const testTasks = [
|
|
{
|
|
name: "trigger_webhook_1",
|
|
type: "webhook",
|
|
label: "发票数据接入",
|
|
groupName: "trigger",
|
|
orderIndex: 0,
|
|
levelIndex: [0],
|
|
status: "active",
|
|
urlPath: "test-uuid-1",
|
|
params: [],
|
|
},
|
|
{
|
|
name: "action_js_1",
|
|
type: "code-js2",
|
|
label: "数据清洗",
|
|
groupName: "action",
|
|
orderIndex: 1,
|
|
levelIndex: [1],
|
|
status: "active",
|
|
code: "return items.filter(x => x.amount > 0);",
|
|
},
|
|
];
|
|
|
|
const mockDetail = {
|
|
id: "pipe_node_test",
|
|
label: "节点编排测试流程",
|
|
state: 0,
|
|
tasks: testTasks,
|
|
};
|
|
|
|
const mockClient = {
|
|
get: (url: string) => {
|
|
if (url.includes("api/easo/pipelines/pipe_node_test")) {
|
|
return {
|
|
json: async () => ({
|
|
code: 200,
|
|
data: mockDetail,
|
|
}),
|
|
};
|
|
}
|
|
return { json: async () => ({ code: 200, data: null }) };
|
|
},
|
|
put: (url: string, opts: any) => {
|
|
if (url.includes("api/easo/pipelines/pipe_node_test")) {
|
|
savedWorkflowPayload = opts.json;
|
|
return {
|
|
json: async () => ({
|
|
code: 200,
|
|
data: {
|
|
...mockDetail,
|
|
...opts.json,
|
|
},
|
|
}),
|
|
};
|
|
}
|
|
return { json: async () => ({ code: 200, data: null }) };
|
|
},
|
|
};
|
|
|
|
spies.push(
|
|
spyOn(helpers, "createClientsForCorp").mockResolvedValue({
|
|
ekbClient: mockClient as any,
|
|
easoClient: mockClient as any,
|
|
corp: mockCorp,
|
|
} as any)
|
|
);
|
|
spies.push(
|
|
spyOn(helpers, "createPiperClientForCorp").mockResolvedValue(mockClient as any)
|
|
);
|
|
|
|
// 2. node list
|
|
const listRes = await handleWorkflowCommand(
|
|
{
|
|
area: "workflow",
|
|
action: "node",
|
|
args: ["list", "pipe_node_test"],
|
|
options: {},
|
|
raw: ["workflow", "node", "list", "pipe_node_test"],
|
|
},
|
|
mockRuntime
|
|
);
|
|
expect(listRes.exitCode).toBe(0);
|
|
expect(listRes.stdout).toContain("任务节点树 (共 2 个节点)");
|
|
expect(listRes.stdout).toContain("trigger_webhook_1");
|
|
expect(listRes.stdout).toContain("action_js_1");
|
|
|
|
// 2.1 node list in json mode
|
|
const listJsonRes = await handleWorkflowCommand(
|
|
{
|
|
area: "workflow",
|
|
action: "node",
|
|
args: ["ls", "pipe_node_test"],
|
|
options: {},
|
|
raw: ["workflow", "node", "ls", "pipe_node_test"],
|
|
},
|
|
{ ...mockRuntime, jsonMode: true }
|
|
);
|
|
expect(listJsonRes.exitCode).toBe(0);
|
|
const parsedList = JSON.parse(listJsonRes.stdout);
|
|
expect(parsedList.totalNodes).toBe(2);
|
|
|
|
// 3. node get
|
|
const getRes = await handleWorkflowCommand(
|
|
{
|
|
area: "workflow",
|
|
action: "node",
|
|
args: ["get", "pipe_node_test", "action_js_1"],
|
|
options: {},
|
|
raw: ["workflow", "node", "get", "pipe_node_test", "action_js_1"],
|
|
},
|
|
mockRuntime
|
|
);
|
|
expect(getRes.exitCode).toBe(0);
|
|
expect(getRes.stdout).toContain("节点详情 [action_js_1]");
|
|
expect(getRes.stdout).toContain("return items.filter");
|
|
|
|
// 4. node add (requires confirmation)
|
|
await expect(
|
|
handleWorkflowCommand(
|
|
{
|
|
area: "workflow",
|
|
action: "node",
|
|
args: ["add", "pipe_node_test"],
|
|
options: { type: "stop", label: "终止超额" },
|
|
raw: ["workflow", "node", "add", "pipe_node_test", "--type=stop"],
|
|
},
|
|
mockRuntime
|
|
)
|
|
).rejects.toThrow("请先使用 --dry-run");
|
|
|
|
// 4.1 node add dry-run
|
|
const addDryRunRes = await handleWorkflowCommand(
|
|
{
|
|
area: "workflow",
|
|
action: "node",
|
|
args: ["add", "pipe_node_test"],
|
|
options: { type: "stop", label: "终止超额", "dry-run": true },
|
|
raw: ["workflow", "node", "add", "pipe_node_test", "--type=stop", "--label=终止超额", "--dry-run"],
|
|
},
|
|
mockRuntime
|
|
);
|
|
expect(addDryRunRes.exitCode).toBe(0);
|
|
expect(addDryRunRes.stdout).toContain("[DRY-RUN]");
|
|
expect(addDryRunRes.stdout).toContain("终止超额");
|
|
expect(savedWorkflowPayload).toBeNull();
|
|
|
|
// 4.2 node add confirmed execution
|
|
const addRes = await handleWorkflowCommand(
|
|
{
|
|
area: "workflow",
|
|
action: "node",
|
|
args: ["add", "pipe_node_test"],
|
|
options: { type: "stop", label: "终止超额", yes: true },
|
|
raw: ["workflow", "node", "add", "pipe_node_test", "--type=stop", "--label=终止超额", "--yes"],
|
|
},
|
|
mockRuntime
|
|
);
|
|
expect(addRes.exitCode).toBe(0);
|
|
expect(addRes.stdout).toContain("已成功添加至工作流");
|
|
expect(addRes.stdout).toContain("终止超额");
|
|
expect(savedWorkflowPayload).not.toBeNull();
|
|
expect(savedWorkflowPayload.tasks).toHaveLength(3);
|
|
|
|
// 5. node edit
|
|
const editRes = await handleWorkflowCommand(
|
|
{
|
|
area: "workflow",
|
|
action: "node",
|
|
args: ["edit", "pipe_node_test", "action_js_1"],
|
|
options: { label: "数据清洗升级版", code: "return true;", yes: true },
|
|
raw: ["workflow", "node", "edit", "pipe_node_test", "action_js_1", "--label=数据清洗升级版", "--code=return true;", "--yes"],
|
|
},
|
|
mockRuntime
|
|
);
|
|
expect(editRes.exitCode).toBe(0);
|
|
expect(editRes.stdout).toContain("修改已保存至工作流");
|
|
|
|
// 6. node rm
|
|
const rmRes = await handleWorkflowCommand(
|
|
{
|
|
area: "workflow",
|
|
action: "node",
|
|
args: ["rm", "pipe_node_test", "action_js_1"],
|
|
options: { yes: true },
|
|
raw: ["workflow", "node", "rm", "pipe_node_test", "action_js_1", "--yes"],
|
|
},
|
|
mockRuntime
|
|
);
|
|
expect(rmRes.exitCode).toBe(0);
|
|
expect(rmRes.stdout).toContain("已从工作流 [pipe_node_test] 中安全移除");
|
|
|
|
// 6.1 node rm trigger guard
|
|
await expect(
|
|
handleWorkflowCommand(
|
|
{
|
|
area: "workflow",
|
|
action: "node",
|
|
args: ["rm", "pipe_node_test", "trigger_webhook_1"],
|
|
options: { yes: true },
|
|
raw: ["workflow", "node", "rm", "pipe_node_test", "trigger_webhook_1", "--yes"],
|
|
},
|
|
mockRuntime
|
|
)
|
|
).rejects.toThrow("触发源节点");
|
|
});
|
|
|
|
it("handles workflow tail and watch commands for real-time streaming and snapshots", async () => {
|
|
// 1. Missing target -> usage
|
|
const noArgRes = await handleWorkflowCommand(
|
|
{
|
|
area: "workflow",
|
|
action: "tail",
|
|
args: [],
|
|
options: {},
|
|
raw: ["workflow", "tail"],
|
|
},
|
|
mockRuntime
|
|
);
|
|
expect(noArgRes.exitCode).toBe(1);
|
|
expect(noArgRes.stderr).toContain("用法: hose-use workflow tail");
|
|
|
|
const mockJobDetail = {
|
|
id: "job_tail_101",
|
|
pipelineId: "pipe_tail_test",
|
|
label: "实时监控流程",
|
|
status: "COMPLETED",
|
|
runType: "DEBUG",
|
|
durationTime: 850,
|
|
successTaskCount: 2,
|
|
errorTaskCount: 0,
|
|
hasError: false,
|
|
};
|
|
|
|
const mockExecutions = [
|
|
{
|
|
id: "ex_node_1",
|
|
name: "trigger_webhook",
|
|
label: "发票接入",
|
|
type: "webhook",
|
|
status: "COMPLETED",
|
|
executionTime: 15,
|
|
},
|
|
{
|
|
id: "ex_node_2",
|
|
name: "action_clean",
|
|
label: "数据清洗",
|
|
type: "code-js2",
|
|
status: "COMPLETED",
|
|
executionTime: 120,
|
|
},
|
|
];
|
|
|
|
const mockClient = {
|
|
get: (url: string) => {
|
|
if (url.includes("api/easo/pipelines/pipe_tail_test/log")) {
|
|
return {
|
|
json: async () => ({
|
|
code: 200,
|
|
data: {
|
|
jobList: [{ jobId: "job_tail_101", status: "COMPLETED" }],
|
|
},
|
|
}),
|
|
};
|
|
}
|
|
if (url.includes("api/easo/jobs/running")) {
|
|
return { json: async () => ({ code: 200, data: [] }) };
|
|
}
|
|
if (url.includes("api/easo/jobs/job_tail_101/execution/level/failed")) {
|
|
return { json: async () => ({ code: 200, data: { items: [] } }) };
|
|
}
|
|
if (url.includes("api/easo/jobs/job_tail_101/execution")) {
|
|
return { json: async () => ({ code: 200, data: mockExecutions }) };
|
|
}
|
|
if (url.includes("api/easo/jobs/job_tail_101")) {
|
|
return { json: async () => ({ code: 200, data: mockJobDetail }) };
|
|
}
|
|
if (url.includes("api/easo/pipelines/pipe_tail_test")) {
|
|
return { json: async () => ({ code: 200, data: { id: "pipe_tail_test", label: "实时监控流程" } }) };
|
|
}
|
|
return { json: async () => ({ code: 200, data: null }) };
|
|
},
|
|
};
|
|
|
|
spies.push(
|
|
spyOn(helpers, "createClientsForCorp").mockResolvedValue({
|
|
ekbClient: mockClient as any,
|
|
easoClient: mockClient as any,
|
|
corp: mockCorp,
|
|
} as any)
|
|
);
|
|
spies.push(
|
|
spyOn(helpers, "createPiperClientForCorp").mockResolvedValue(mockClient as any)
|
|
);
|
|
|
|
// 2. tail --once snapshot
|
|
const onceRes = await handleWorkflowCommand(
|
|
{
|
|
area: "workflow",
|
|
action: "tail",
|
|
args: ["pipe_tail_test"],
|
|
options: { once: true },
|
|
raw: ["workflow", "tail", "pipe_tail_test", "--once"],
|
|
},
|
|
mockRuntime
|
|
);
|
|
expect(onceRes.exitCode).toBe(0);
|
|
expect(onceRes.stdout).toContain("trigger_webhook");
|
|
expect(onceRes.stdout).toContain("action_clean");
|
|
expect(onceRes.stdout).toContain("Job [job_tail_101] 执行结束");
|
|
|
|
// 3. tail --once --json
|
|
const onceJsonRes = await handleWorkflowCommand(
|
|
{
|
|
area: "workflow",
|
|
action: "tail",
|
|
args: ["pipe_tail_test"],
|
|
options: { once: true },
|
|
raw: ["workflow", "tail", "pipe_tail_test", "--once"],
|
|
},
|
|
{ ...mockRuntime, jsonMode: true }
|
|
);
|
|
expect(onceJsonRes.exitCode).toBe(0);
|
|
const parsedReport = JSON.parse(onceJsonRes.stdout);
|
|
expect(parsedReport.totalJobsWatched).toBe(1);
|
|
expect(parsedReport.jobs[0].jobId).toBe("job_tail_101");
|
|
expect(parsedReport.jobs[0].successCount).toBe(2);
|
|
|
|
// 4. watch alias targeting specific job
|
|
const watchJobRes = await handleWorkflowCommand(
|
|
{
|
|
area: "workflow",
|
|
action: "watch",
|
|
args: ["pipe_tail_test"],
|
|
options: { job: "job_tail_101", interval: 1, once: true },
|
|
raw: ["workflow", "watch", "pipe_tail_test", "--job=job_tail_101", "--once"],
|
|
},
|
|
mockRuntime
|
|
);
|
|
expect(watchJobRes.exitCode).toBe(0);
|
|
expect(watchJobRes.stdout).toContain("Job [job_tail_101]");
|
|
});
|
|
|
|
it("handles workflow lint-script and eval-script commands end-to-end", async () => {
|
|
// 1. Missing args usage
|
|
const missingRes = await handleWorkflowCommand(
|
|
{
|
|
area: "workflow",
|
|
action: "lint-script",
|
|
args: [],
|
|
options: {},
|
|
raw: ["workflow", "lint-script"],
|
|
},
|
|
mockRuntime
|
|
);
|
|
expect(missingRes.exitCode).toBe(1);
|
|
expect(missingRes.stderr).toContain("用法: hose-use workflow lint-script");
|
|
|
|
// 2. Inline JavaScript linting - valid
|
|
const validJsRes = await handleWorkflowCommand(
|
|
{
|
|
area: "workflow",
|
|
action: "lint-script",
|
|
args: [],
|
|
options: { code: "const x = 10; return x * 2;" },
|
|
raw: ["workflow", "lint-script", '--code="const x = 10; return x * 2;"'],
|
|
},
|
|
mockRuntime
|
|
);
|
|
expect(validJsRes.exitCode).toBe(0);
|
|
expect(validJsRes.stdout).toContain("✅ 语法完全合规");
|
|
|
|
// 3. Inline JavaScript linting - syntax error
|
|
const syntaxErrRes = await handleWorkflowCommand(
|
|
{
|
|
area: "workflow",
|
|
action: "lint-script",
|
|
args: [],
|
|
options: { code: "const a = ;" },
|
|
raw: ["workflow", "lint-script", '--code="const a = ;"'],
|
|
},
|
|
mockRuntime
|
|
);
|
|
expect(syntaxErrRes.exitCode).toBe(1);
|
|
expect(syntaxErrRes.stdout).toContain("JavaScript 语法错误");
|
|
|
|
// 4. Inline MVEL linting - unclosed bracket
|
|
const mvelErrRes = await handleWorkflowCommand(
|
|
{
|
|
area: "workflow",
|
|
action: "lint",
|
|
args: [],
|
|
options: { code: "var list = [1, 2; return list;", type: "mvel" },
|
|
raw: ["workflow", "lint", '--code="var list = [1, 2; return list;"', "--type=mvel"],
|
|
},
|
|
mockRuntime
|
|
);
|
|
expect(mvelErrRes.exitCode).toBe(1);
|
|
expect(mvelErrRes.stdout).toContain("未闭合的括号");
|
|
|
|
// 5. Offline sandbox eval - inline code with inputs
|
|
const evalSuccessRes = await handleWorkflowCommand(
|
|
{
|
|
area: "workflow",
|
|
action: "eval-script",
|
|
args: [],
|
|
options: {
|
|
code: 'console.log("计算中:", a, b); return { result: a + b };',
|
|
input: JSON.stringify({ a: 15, b: 25 }),
|
|
},
|
|
raw: ["workflow", "eval-script", '--code="..."', '--input="..."'],
|
|
},
|
|
mockRuntime
|
|
);
|
|
expect(evalSuccessRes.exitCode).toBe(0);
|
|
expect(evalSuccessRes.stdout).toContain("执行成功 ✅");
|
|
expect(evalSuccessRes.stdout).toContain("计算中: 15 25");
|
|
expect(evalSuccessRes.stdout).toContain('"result": 40');
|
|
|
|
// 6. Offline sandbox eval - runtime error
|
|
const evalFailRes = await handleWorkflowCommand(
|
|
{
|
|
area: "workflow",
|
|
action: "eval-script",
|
|
args: [],
|
|
options: {
|
|
code: 'return obj.nonExistent.subField;',
|
|
input: JSON.stringify({ obj: {} }),
|
|
},
|
|
raw: ["workflow", "eval-script", '--code="..."', '--input="..."'],
|
|
},
|
|
mockRuntime
|
|
);
|
|
expect(evalFailRes.exitCode).toBe(1);
|
|
expect(evalFailRes.stdout).toContain("执行失败 ❌");
|
|
expect(evalFailRes.stdout).toContain("TypeError");
|
|
|
|
// 7. Workflow level lint-script with mocked pipeline
|
|
const mockDetail = {
|
|
id: "pipe_script_test",
|
|
label: "脚本测试流水线",
|
|
tasks: [
|
|
{
|
|
name: "trigger_webhook",
|
|
type: "webhook",
|
|
label: "Webhook 触发器",
|
|
},
|
|
{
|
|
name: "action_js_clean",
|
|
type: "code-js2",
|
|
label: "数据清洗 JS",
|
|
code: "console.log(info); return { total: 100 };",
|
|
mapping: [{ key: "info", value: "@{choose(trigger_webhook.data)}" }],
|
|
},
|
|
{
|
|
name: "action_mvel_calc",
|
|
type: "code",
|
|
label: "MVEL 计算",
|
|
code: "var val = trigger_webhook.data;\nreturn val;",
|
|
},
|
|
],
|
|
};
|
|
|
|
const mockClient = {
|
|
get: () => ({
|
|
json: async () => ({
|
|
code: 200,
|
|
data: mockDetail,
|
|
}),
|
|
}),
|
|
};
|
|
spies.push(
|
|
spyOn(helpers, "createClientsForCorp").mockResolvedValue({
|
|
ekbClient: mockClient as any,
|
|
easoClient: mockClient as any,
|
|
corp: mockCorp,
|
|
} as any)
|
|
);
|
|
spies.push(spyOn(helpers, "createPiperClientForCorp").mockResolvedValue(mockClient as any));
|
|
|
|
const wfLintRes = await handleWorkflowCommand(
|
|
{
|
|
area: "workflow",
|
|
action: "lint-script",
|
|
args: ["pipe_script_test"],
|
|
options: {},
|
|
raw: ["workflow", "lint-script", "pipe_script_test"],
|
|
},
|
|
mockRuntime
|
|
);
|
|
expect(wfLintRes.exitCode).toBe(0);
|
|
expect(wfLintRes.stdout).toContain("共检测 2 个代码节点");
|
|
expect(wfLintRes.stdout).toContain("action_js_clean");
|
|
expect(wfLintRes.stdout).toContain("action_mvel_calc");
|
|
expect(wfLintRes.stdout).toContain("总体验证结果: 全部代码节点均通过语法与引用校验 ✅");
|
|
|
|
// 8. Workflow level eval-script targeting node
|
|
const wfEvalRes = await handleWorkflowCommand(
|
|
{
|
|
area: "workflow",
|
|
action: "eval-script",
|
|
args: ["pipe_script_test", "action_js_clean"],
|
|
options: { input: JSON.stringify({ info: "sample_input" }) },
|
|
raw: ["workflow", "eval-script", "pipe_script_test", "action_js_clean"],
|
|
},
|
|
mockRuntime
|
|
);
|
|
expect(wfEvalRes.exitCode).toBe(0);
|
|
expect(wfEvalRes.stdout).toContain("节点 [action_js_clean]");
|
|
expect(wfEvalRes.stdout).toContain("执行成功 ✅");
|
|
expect(wfEvalRes.stdout).toContain('"total": 100');
|
|
});
|
|
});
|
|
|