fix(workflow): propagate rejected node grants to CLI failure status

This commit is contained in:
gitea committed 2026-10-20 18:04:48 +08:00
1 parent fac81b08e8
commit 3141cc3b29
4 files changed
+24 -2

No files matched your search

@@ -0,0 +1,16 @@
import { expect, spyOn, test } from "bun:test";
import { handleWorkflowCommand } from "./workflow/index.js";
import { parseArgs } from "../parser.js";
import * as services from "../../domains/platform/services.js";
test("failed grants retain gateway details and never report success", async () => {
const grant = spyOn(services, "grantWorkflowNodes").mockResolvedValue({ success: false, saved: [], skipped: [], rawMessage: "permission denied" });
try {
for (const jsonMode of [false, true]) {
const result = await handleWorkflowCommand(parseArgs(["workflow", "nodes", "grant", "code-js2", "--yes"]), { selectedCorp: { id: "corp", name: "test" }, jsonMode } as any);
expect(result.exitCode).toBe(1);
expect(result.stdout).not.toContain("节点权限已生效");
if (jsonMode) expect(JSON.parse(result.stdout)).toMatchObject({ success: false, rawMessage: "permission denied" });
else expect(result.stderr).toContain("permission denied");
}
} finally { grant.mockRestore(); }
});