Merge origin/main and preserve debug safeguards across trigger paths
This commit is contained in:
commit
b605d7c2bb
7 files changed
+569
-61
No files matched your search
@@ -35,6 +35,40 @@ describe("workflow debug mutation and result contract", () => {
|
||||
expect(client).not.toHaveBeenCalled();
|
||||
expect(run).not.toHaveBeenCalled();
|
||||
});
|
||||
for (const [triggerType, options] of [
|
||||
["clock", {}],
|
||||
["webhook", { body: '{"event":"test"}' }],
|
||||
["webhook", { empty: true }],
|
||||
["webhook", { file: "/unused-in-dry-run.json" }],
|
||||
["ekuaibao-datalink-create-trigger", { record: "ID01-record" }],
|
||||
] as Array<[string, Record<string, string | boolean>]>) {
|
||||
it(`previews ${triggerType} without creating clients (${Object.keys(options).join(",")})`, async () => {
|
||||
const { client, run } = setup();
|
||||
const result = await handleWorkflowTest({ ...args(), options: { ...options, "dry-run": true, yes: true } }, runtime);
|
||||
expect(JSON.parse(result.stdout).dryRun).toBe(true);
|
||||
expect(client).not.toHaveBeenCalled();
|
||||
expect(run).not.toHaveBeenCalled();
|
||||
});
|
||||
}
|
||||
it("requires confirmation for a schedule trigger without --flow", async () => {
|
||||
const { detail, run } = setup();
|
||||
detail.mockResolvedValue({ state: 1, tasks: [{ type: "clock" }] } as any);
|
||||
await expect(handleWorkflowTest({ ...args(), options: {} }, runtime)).rejects.toThrow("请先使用 --dry-run");
|
||||
expect(run).not.toHaveBeenCalled();
|
||||
});
|
||||
it("keeps confirmed schedule and webhook trigger routing", async () => {
|
||||
const { detail, run } = setup();
|
||||
detail.mockResolvedValue({ state: 1, tasks: [{ type: "clock" }] } as any);
|
||||
const scheduled = await handleWorkflowTest({ ...args(), options: { yes: true } }, runtime);
|
||||
expect(scheduled.exitCode).toBe(0);
|
||||
expect(run.mock.calls[0]?.[2]?.triggerCategory).toBe("SCHEDULE");
|
||||
expect(run.mock.calls[0]?.[2]?.flowCodeOrId).toBe("");
|
||||
detail.mockResolvedValue({ state: 1, tasks: [{ type: "webhook" }] } as any);
|
||||
const webhook = await handleWorkflowTest({ ...args(), options: { body: '{"event":"test"}', yes: true } }, runtime);
|
||||
expect(webhook.exitCode).toBe(0);
|
||||
expect(run.mock.calls[1]?.[2]?.data).toEqual({ event: "test" });
|
||||
expect(run.mock.calls[1]?.[2]?.triggerCategory).toBe("WEBHOOK");
|
||||
});
|
||||
it("allows confirmed enabled-workflow debug with machine-readable risk information", async () => {
|
||||
const { run } = setup();
|
||||
const result = await handleWorkflowTest(args({ yes: true }), runtime);
|
||||
|
||||
Reference in new issue
Block a user