refactor: 整理工作流触发器并校验节点写入版本
集中触发器分类及 Webhook 规则,节点写入前检查远端版本并保留部分保存语义。
This commit is contained in:
1 parent
c813498da2
commit
7af7e7db35
13 files changed
+191
-112
No files matched your search
@@ -0,0 +1,17 @@
|
||||
import { afterEach, expect, mock, spyOn, test } from "bun:test";
|
||||
import * as services from "../../../domains/platform/workflow/services.js";
|
||||
import * as shared from "./shared.js";
|
||||
import { handleWorkflowCommand } from "./index.js";
|
||||
import { parseArgs } from "../../parser.js";
|
||||
|
||||
afterEach(() => { mock.restore(); });
|
||||
|
||||
test("节点修改在远端版本变化时不提交完整快照", async () => {
|
||||
const detail = { id: "wf", version: "v1", tasksVersion: 1, tasks: [{ name: "code", type: "code-js2", code: "return 1", groupName: "action", orderIndex: 0, levelIndex: [0], status: "active" }] } as any;
|
||||
spyOn(shared, "createWorkflowDetailClient").mockResolvedValue({ client: {} } as any);
|
||||
spyOn(services, "getWorkflowDetail").mockResolvedValueOnce(detail).mockResolvedValueOnce({ ...detail, tasksVersion: 2 });
|
||||
const save = spyOn(services, "updateWorkflow").mockResolvedValue(detail);
|
||||
const runtime = { selectedCorp: { id: "corp" }, jsonMode: true } as any;
|
||||
await expect(handleWorkflowCommand(parseArgs(["workflow", "node", "edit", "wf", "code", "--code=return 2", "--yes"]), runtime)).rejects.toThrow("版本已变化");
|
||||
expect(save).not.toHaveBeenCalled();
|
||||
});
|
||||
Reference in new issue
Block a user