feat(workflow): add end-to-end workflow debug test command and condition branch explanation
This commit is contained in:
1 parent
26a6b7318c
commit
fe6183dd44
13 files changed
+1026
-3
No files matched your search
@@ -491,4 +491,178 @@ describe("CLI - workflow job 执行详情与异常精准透视", () => {
|
||||
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("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,
|
||||
},
|
||||
],
|
||||
}),
|
||||
};
|
||||
}
|
||||
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" },
|
||||
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");
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user