Merge pull request #30 from yunyingk/chore/platform-null-test

test: cover nullable app metadata
This commit is contained in:
yunyingk authored and GitHub committed 2026-09-05 20:36:14 +08:00
commit 7d9f656567
1 file changed
+7
+7
View File
@@ -1,7 +1,14 @@
import { describe, expect, it } from "bun:test";
import { analyzeWorkflow } from "./analysis.js";
import { PlatformSchema } from "./types.js";
describe("Workflow static analysis", () => {
it("accepts nullable app center metadata", () => {
const platform = PlatformSchema.parse({ id: "app-1", name: "测试应用", corporationId: "corp-1", adminIds: null, importMethod: null });
expect(platform.adminIds).toEqual([]);
expect(platform.importMethod).toEqual([]);
});
it("builds a recursive AST and extracts code references", () => {
const result = analyzeWorkflow({ id: "wf-1", label: "审批", state: 1, version: "3", tasks: [{ name: "条件", type: "condition", label: "条件", groupName: "", orderIndex: 0, levelIndex: [0], status: "", tasks: [{ name: "脚本", type: "code-js2", label: "脚本", groupName: "", orderIndex: 1, levelIndex: [0, 0], status: "", code: "return {{bill.amount}} + ctx.user.id;" }] }] } as any);
expect(result.ast[0]?.children[0]?.path).toBe("0.0"); expect(result.dependencies[0]?.references).toEqual(["bill.amount", "user.id"]); expect(result.diagnostics).toHaveLength(0);