fix(workflow): protect the sole trigger when deleting task nodes
This commit is contained in:
1 parent
fac81b08e8
commit
e86c05d51a
4 files changed
+18
-2
No files matched your search
@@ -128,3 +128,5 @@ hose-use workflow eval-script --code="return a + b;" --input='{"a":1,"b":2}'
|
||||
- 借助 Kimi 网桥(`kimi-webbridge`)建立真实微前端会话,自动探测并解析不同应用类型下的非费用类表单元数据;
|
||||
- 提取出动态列、关联实体 ID 与系统字段字典,在 CLI 层面提供对非费用类业务对象的只读探针与结构化校验能力。
|
||||
|
||||
|
||||
节点删除命令始终保护工作流首个触发器,包括仅包含触发器的新建草稿;移除普通动作节点不受影响。触发器结构变更仍通过完整草稿保存或设计器进行。
|
||||
@@ -284,7 +284,6 @@ export function removeWorkflowTask(
|
||||
if (
|
||||
target.parentTasks === cloned.tasks &&
|
||||
target.arrayIndex === 0 &&
|
||||
cloned.tasks.length > 1 &&
|
||||
(target.task.groupName === "trigger" || target.task.type.includes("trigger") || target.task.type === "webhook" || target.task.type === "clock")
|
||||
) {
|
||||
throw new ValidationError(
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
import { expect, test } from "bun:test";
|
||||
import { removeWorkflowTask } from "./mutations.js";
|
||||
for (const type of ["webhook", "clock", "ekuaibao-datalink-create-trigger"]) {
|
||||
test(`protects the only ${type} trigger from removal`, () => {
|
||||
const workflow = { tasks: [{ name: "trigger", type }] } as any;
|
||||
expect(() => removeWorkflowTask(workflow, "trigger")).toThrow("触发源节点");
|
||||
expect(workflow.tasks).toHaveLength(1);
|
||||
});
|
||||
}
|
||||
test("ordinary action removal remains supported while the last trigger stays protected", () => {
|
||||
const workflow = { tasks: [{ name: "trigger", type: "webhook" }, { name: "action", type: "http" }] } as any;
|
||||
const result = removeWorkflowTask(workflow, "action");
|
||||
expect(result.workflow.tasks.map(t => t.name)).toEqual(["trigger"]);
|
||||
expect(() => removeWorkflowTask(result.workflow, "trigger")).toThrow("触发源节点");
|
||||
});
|
||||
Reference in new issue
Block a user