@yh-ui/flow 1.0.1 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/dist/__tests__/bpmn-engine.test.cjs +357 -0
  2. package/dist/__tests__/bpmn-engine.test.d.ts +1 -0
  3. package/dist/__tests__/bpmn-engine.test.mjs +406 -0
  4. package/dist/__tests__/bpmn-utils.test.cjs +268 -0
  5. package/dist/__tests__/bpmn-utils.test.d.ts +1 -0
  6. package/dist/__tests__/bpmn-utils.test.mjs +227 -0
  7. package/dist/__tests__/bpmn-xml.test.cjs +150 -0
  8. package/dist/__tests__/bpmn-xml.test.d.ts +1 -0
  9. package/dist/__tests__/bpmn-xml.test.mjs +112 -0
  10. package/dist/__tests__/collaboration.test.cjs +487 -0
  11. package/dist/__tests__/collaboration.test.d.ts +1 -0
  12. package/dist/__tests__/collaboration.test.mjs +424 -0
  13. package/dist/__tests__/edge-types.test.cjs +275 -0
  14. package/dist/__tests__/edge-types.test.d.ts +1 -0
  15. package/dist/__tests__/edge-types.test.mjs +234 -0
  16. package/dist/__tests__/edge-utils.test.cjs +375 -0
  17. package/dist/__tests__/edge-utils.test.d.ts +1 -0
  18. package/dist/__tests__/edge-utils.test.mjs +376 -0
  19. package/dist/__tests__/events-types.test.cjs +184 -0
  20. package/dist/__tests__/events-types.test.d.ts +1 -0
  21. package/dist/__tests__/events-types.test.mjs +184 -0
  22. package/dist/__tests__/export-image-plugin.test.cjs +142 -0
  23. package/dist/__tests__/export-image-plugin.test.d.ts +1 -0
  24. package/dist/__tests__/export-image-plugin.test.mjs +118 -0
  25. package/dist/__tests__/export.test.cjs +237 -0
  26. package/dist/__tests__/export.test.d.ts +1 -0
  27. package/dist/__tests__/export.test.mjs +171 -0
  28. package/dist/__tests__/flow-context.test.cjs +16 -0
  29. package/dist/__tests__/flow-context.test.d.ts +1 -0
  30. package/dist/__tests__/flow-context.test.mjs +16 -0
  31. package/dist/__tests__/flow-props.test.cjs +94 -0
  32. package/dist/__tests__/flow-props.test.d.ts +1 -0
  33. package/dist/__tests__/flow-props.test.mjs +92 -0
  34. package/dist/__tests__/layout-plugin.test.cjs +233 -0
  35. package/dist/__tests__/layout-plugin.test.d.ts +1 -0
  36. package/dist/__tests__/layout-plugin.test.mjs +215 -0
  37. package/dist/__tests__/node-types.test.cjs +368 -0
  38. package/dist/__tests__/node-types.test.d.ts +1 -0
  39. package/dist/__tests__/node-types.test.mjs +292 -0
  40. package/dist/__tests__/performance.test.cjs +313 -0
  41. package/dist/__tests__/performance.test.d.ts +1 -0
  42. package/dist/__tests__/performance.test.mjs +218 -0
  43. package/dist/__tests__/plugin-advanced.test.cjs +301 -0
  44. package/dist/__tests__/plugin-advanced.test.d.ts +1 -0
  45. package/dist/__tests__/plugin-advanced.test.mjs +225 -0
  46. package/dist/__tests__/plugins.test.cjs +412 -0
  47. package/dist/__tests__/plugins.test.d.ts +1 -0
  48. package/dist/__tests__/plugins.test.mjs +402 -0
  49. package/dist/__tests__/screenshot-capture.test.cjs +183 -0
  50. package/dist/__tests__/screenshot-capture.test.d.ts +1 -0
  51. package/dist/__tests__/screenshot-capture.test.mjs +124 -0
  52. package/dist/__tests__/screenshot.test.cjs +74 -0
  53. package/dist/__tests__/screenshot.test.d.ts +1 -0
  54. package/dist/__tests__/screenshot.test.mjs +69 -0
  55. package/dist/__tests__/theme.test.cjs +185 -0
  56. package/dist/__tests__/theme.test.d.ts +1 -0
  57. package/dist/__tests__/theme.test.mjs +191 -0
  58. package/dist/__tests__/transform.test.cjs +376 -50
  59. package/dist/__tests__/transform.test.mjs +229 -28
  60. package/dist/__tests__/useAlignment.test.cjs +37 -0
  61. package/dist/__tests__/useAlignment.test.mjs +20 -0
  62. package/dist/__tests__/useNodeDistribution.test.cjs +643 -0
  63. package/dist/__tests__/useNodeDistribution.test.d.ts +1 -0
  64. package/dist/__tests__/useNodeDistribution.test.mjs +297 -0
  65. package/dist/__tests__/viewport-types.test.cjs +324 -0
  66. package/dist/__tests__/viewport-types.test.d.ts +1 -0
  67. package/dist/__tests__/viewport-types.test.mjs +207 -0
  68. package/dist/utils/bpmn.cjs +27 -16
  69. package/dist/utils/bpmn.mjs +27 -19
  70. package/package.json +3 -3
@@ -0,0 +1,227 @@
1
+ import { describe, it, expect } from "vitest";
2
+ import { flowToBpmnXml, validateBpmnXml, generateSampleBpmnXml } from "../utils/bpmn.mjs";
3
+ function createMockNode(id, type, position = { x: 100, y: 100 }) {
4
+ return {
5
+ id,
6
+ type,
7
+ position,
8
+ width: 100,
9
+ height: 80,
10
+ data: {},
11
+ selected: false,
12
+ dragging: false
13
+ };
14
+ }
15
+ function createMockEdge(id, source, target) {
16
+ return {
17
+ id,
18
+ source,
19
+ target,
20
+ type: "smoothstep",
21
+ selected: false,
22
+ animated: false
23
+ };
24
+ }
25
+ describe("flow/utils/bpmn", () => {
26
+ describe("flowToBpmnXml", () => {
27
+ it("should generate BPMN XML with start event", () => {
28
+ const nodes = [createMockNode("start", "bpmn-start", { x: 50, y: 50 })];
29
+ const edges = [];
30
+ const result = flowToBpmnXml(nodes, edges, { processId: "test", processName: "Test" });
31
+ expect(result.xml).toContain("startEvent");
32
+ expect(result.xml).toContain('id="start"');
33
+ expect(result.processId).toBe("test");
34
+ });
35
+ it("should generate BPMN XML with end event", () => {
36
+ const nodes = [createMockNode("end", "bpmn-end", { x: 300, y: 100 })];
37
+ const edges = [];
38
+ const result = flowToBpmnXml(nodes, edges);
39
+ expect(result.xml).toContain("endEvent");
40
+ });
41
+ it("should generate BPMN XML with task", () => {
42
+ const nodes = [createMockNode("task1", "bpmn-task", { x: 150, y: 100 })];
43
+ const edges = [];
44
+ const result = flowToBpmnXml(nodes, edges);
45
+ expect(result.xml).toContain("<bpmn:task");
46
+ });
47
+ it("should generate BPMN XML with service task", () => {
48
+ const nodes = [
49
+ {
50
+ ...createMockNode("service", "bpmn-service-task"),
51
+ data: { implementation: "${myService}" }
52
+ }
53
+ ];
54
+ const edges = [];
55
+ const result = flowToBpmnXml(nodes, edges);
56
+ expect(result.xml).toContain("serviceTask");
57
+ expect(result.xml).toContain('implementation="delegateExpression"');
58
+ });
59
+ it("should generate BPMN XML with user task and assignee", () => {
60
+ const nodes = [
61
+ {
62
+ ...createMockNode("user", "bpmn-user-task"),
63
+ data: { assignee: "admin", candidateUsers: "user1,user2" }
64
+ }
65
+ ];
66
+ const edges = [];
67
+ const result = flowToBpmnXml(nodes, edges);
68
+ expect(result.xml).toContain("userTask");
69
+ expect(result.xml).toContain('assignee="admin"');
70
+ expect(result.xml).toContain('candidateUsers="user1,user2"');
71
+ });
72
+ it("should generate BPMN XML with exclusive gateway", () => {
73
+ const nodes = [createMockNode("gw", "bpmn-exclusive-gateway", { x: 250, y: 100 })];
74
+ const edges = [];
75
+ const result = flowToBpmnXml(nodes, edges);
76
+ expect(result.xml).toContain("exclusiveGateway");
77
+ expect(result.xml).toContain('gatewayDirection="diverging"');
78
+ });
79
+ it("should generate BPMN XML with parallel gateway", () => {
80
+ const nodes = [createMockNode("pgw", "bpmn-parallel-gateway", { x: 250, y: 100 })];
81
+ const edges = [];
82
+ const result = flowToBpmnXml(nodes, edges);
83
+ expect(result.xml).toContain("parallelGateway");
84
+ });
85
+ it("should generate BPMN XML with inclusive gateway", () => {
86
+ const nodes = [createMockNode("igw", "bpmn-inclusive-gateway", { x: 250, y: 100 })];
87
+ const edges = [];
88
+ const result = flowToBpmnXml(nodes, edges);
89
+ expect(result.xml).toContain("inclusiveGateway");
90
+ });
91
+ it("should include node name in XML", () => {
92
+ const nodes = [
93
+ {
94
+ ...createMockNode("task1", "bpmn-task"),
95
+ data: { name: "My Task", label: "My Task" }
96
+ }
97
+ ];
98
+ const edges = [];
99
+ const result = flowToBpmnXml(nodes, edges);
100
+ expect(result.xml).toContain('name="My Task"');
101
+ });
102
+ it("should generate sequence flow with condition expression", () => {
103
+ const nodes = [createMockNode("start", "bpmn-start"), createMockNode("end", "bpmn-end")];
104
+ const edges = [
105
+ {
106
+ ...createMockEdge("flow1", "start", "end"),
107
+ data: { conditionExpression: "${approved == true}" }
108
+ }
109
+ ];
110
+ const result = flowToBpmnXml(nodes, edges);
111
+ expect(result.xml).toContain("sequenceFlow");
112
+ expect(result.xml).toContain("conditionExpression");
113
+ expect(result.xml).toContain("${approved == true}");
114
+ });
115
+ it("should include DI information when includeDi is true", () => {
116
+ const nodes = [createMockNode("n1", "bpmn-start", { x: 10, y: 20 })];
117
+ const edges = [];
118
+ const result = flowToBpmnXml(nodes, edges, { includeDi: true });
119
+ expect(result.xml).toContain("BPMNDiagram");
120
+ expect(result.xml).toContain("BPMNShape");
121
+ });
122
+ it("should not include DI information when includeDi is false", () => {
123
+ const nodes = [createMockNode("n1", "bpmn-start")];
124
+ const edges = [];
125
+ const result = flowToBpmnXml(nodes, edges, { includeDi: false });
126
+ expect(result.xml).not.toContain("BPMNDiagram");
127
+ });
128
+ it("should use default dimensions when node has no width/height", () => {
129
+ const nodes = [
130
+ {
131
+ id: "n1",
132
+ type: "bpmn-start",
133
+ position: { x: 0, y: 0 },
134
+ selected: false,
135
+ dragging: false
136
+ }
137
+ ];
138
+ const edges = [];
139
+ const result = flowToBpmnXml(nodes, edges, { includeDi: true });
140
+ expect(result.xml).toContain('width="100"');
141
+ expect(result.xml).toContain('height="80"');
142
+ });
143
+ it("should skip unknown node types", () => {
144
+ const nodes = [
145
+ {
146
+ id: "n1",
147
+ type: "unknown-type",
148
+ position: { x: 0, y: 0 },
149
+ selected: false,
150
+ dragging: false
151
+ }
152
+ ];
153
+ const edges = [];
154
+ const result = flowToBpmnXml(nodes, edges);
155
+ expect(result.xml).not.toContain("unknown-type");
156
+ });
157
+ it("should generate XML with proper namespaces", () => {
158
+ const nodes = [createMockNode("n1", "bpmn-start")];
159
+ const edges = [];
160
+ const result = flowToBpmnXml(nodes, edges);
161
+ expect(result.xml).toContain('xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL"');
162
+ });
163
+ it("should include edges in XML", () => {
164
+ const nodes = [createMockNode("n1", "bpmn-start"), createMockNode("n2", "bpmn-end")];
165
+ const edges = [createMockEdge("e1", "n1", "n2")];
166
+ const result = flowToBpmnXml(nodes, edges);
167
+ expect(result.xml).toContain("sequenceFlow");
168
+ expect(result.xml).toContain('sourceRef="n1"');
169
+ expect(result.xml).toContain('targetRef="n2"');
170
+ });
171
+ it("should generate valid processId", () => {
172
+ const nodes = [createMockNode("n1", "bpmn-start")];
173
+ const edges = [];
174
+ const result = flowToBpmnXml(nodes, edges, { processId: "MyProcess" });
175
+ expect(result.processId).toBe("MyProcess");
176
+ });
177
+ it("should generate default processId with timestamp", () => {
178
+ const nodes = [createMockNode("n1", "bpmn-start")];
179
+ const edges = [];
180
+ const result = flowToBpmnXml(nodes, edges);
181
+ expect(result.processId).toMatch(/^Process_\d+$/);
182
+ });
183
+ });
184
+ describe("validateBpmnXml", () => {
185
+ it("should return invalid for missing definitions", () => {
186
+ const xml = `<notbpmn></notbpmn>`;
187
+ const result = validateBpmnXml(xml);
188
+ expect(result.valid).toBe(false);
189
+ expect(result.error).toBeDefined();
190
+ });
191
+ it("should return invalid for missing process", () => {
192
+ const xml = `<?xml version="1.0"?>
193
+ <bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" id="def1">
194
+ </bpmn:definitions>`;
195
+ const result = validateBpmnXml(xml);
196
+ expect(result.valid).toBe(false);
197
+ expect(result.error).toBeDefined();
198
+ });
199
+ it("should return invalid for malformed XML", () => {
200
+ const xml = `<?xml version="1.0"?><invalid`;
201
+ const result = validateBpmnXml(xml);
202
+ expect(result.valid).toBe(false);
203
+ });
204
+ });
205
+ describe("generateSampleBpmnXml", () => {
206
+ it("should generate a sample BPMN XML string", () => {
207
+ const xml = generateSampleBpmnXml();
208
+ expect(xml).toContain("<?xml");
209
+ expect(xml).toContain("bpmn:definitions");
210
+ expect(xml).toContain("SampleProcess");
211
+ });
212
+ it("should contain start and end events", () => {
213
+ const xml = generateSampleBpmnXml();
214
+ expect(xml).toContain("startEvent");
215
+ expect(xml).toContain("endEvent");
216
+ });
217
+ it("should contain user task and service task", () => {
218
+ const xml = generateSampleBpmnXml();
219
+ expect(xml).toContain("userTask");
220
+ expect(xml).toContain("serviceTask");
221
+ });
222
+ it("should contain gateway", () => {
223
+ const xml = generateSampleBpmnXml();
224
+ expect(xml).toContain("exclusiveGateway");
225
+ });
226
+ });
227
+ });
@@ -0,0 +1,150 @@
1
+ "use strict";
2
+
3
+ var _vitest = require("vitest");
4
+ var _bpmn = require("../utils/bpmn.cjs");
5
+ function minimalFlow() {
6
+ const nodes = [{
7
+ id: "n_start",
8
+ type: "bpmn-start",
9
+ position: {
10
+ x: 100,
11
+ y: 100
12
+ },
13
+ data: {
14
+ label: "Start",
15
+ name: "Start"
16
+ },
17
+ width: 40,
18
+ height: 40,
19
+ selected: false,
20
+ dragging: false
21
+ }, {
22
+ id: "n_task",
23
+ type: "bpmn-user-task",
24
+ position: {
25
+ x: 300,
26
+ y: 90
27
+ },
28
+ data: {
29
+ label: "Task",
30
+ name: "Task",
31
+ assignee: "u1",
32
+ candidateUsers: "a,b"
33
+ },
34
+ width: 120,
35
+ height: 80,
36
+ selected: false,
37
+ dragging: false
38
+ }, {
39
+ id: "n_gw",
40
+ type: "bpmn-exclusive-gateway",
41
+ position: {
42
+ x: 500,
43
+ y: 100
44
+ },
45
+ data: {
46
+ label: "GW"
47
+ },
48
+ width: 50,
49
+ height: 50,
50
+ selected: false,
51
+ dragging: false
52
+ }, {
53
+ id: "n_end",
54
+ type: "bpmn-end",
55
+ position: {
56
+ x: 700,
57
+ y: 100
58
+ },
59
+ data: {
60
+ label: "End"
61
+ },
62
+ width: 40,
63
+ height: 40,
64
+ selected: false,
65
+ dragging: false
66
+ }];
67
+ const edges = [{
68
+ id: "e1",
69
+ source: "n_start",
70
+ target: "n_task"
71
+ }, {
72
+ id: "e2",
73
+ source: "n_task",
74
+ target: "n_gw",
75
+ type: "smoothstep",
76
+ data: {
77
+ conditionExpression: "${approved}"
78
+ }
79
+ }, {
80
+ id: "e3",
81
+ source: "n_gw",
82
+ target: "n_end"
83
+ }];
84
+ return {
85
+ nodes,
86
+ edges
87
+ };
88
+ }
89
+ (0, _vitest.describe)("flow/utils/bpmn XML", () => {
90
+ (0, _vitest.it)("flowToBpmnXml produces definitions and round-trips via bpmnXmlToFlow", () => {
91
+ const {
92
+ nodes,
93
+ edges
94
+ } = minimalFlow();
95
+ const {
96
+ xml,
97
+ processId
98
+ } = (0, _bpmn.flowToBpmnXml)(nodes, edges, {
99
+ processId: "Proc_test",
100
+ processName: "Test proc",
101
+ includeDi: true
102
+ });
103
+ (0, _vitest.expect)(xml).toContain("bpmn:definitions");
104
+ (0, _vitest.expect)(xml).toContain(`id="${processId}"`);
105
+ (0, _vitest.expect)(xml).toContain("bpmn:userTask");
106
+ (0, _vitest.expect)(xml).toContain('assignee="u1"');
107
+ (0, _vitest.expect)(xml).toContain("conditionExpression");
108
+ const parsed = (0, _bpmn.bpmnXmlToFlow)(xml);
109
+ (0, _vitest.expect)(parsed.processId).toBe("Proc_test");
110
+ (0, _vitest.expect)(parsed.nodes.length).toBeGreaterThanOrEqual(4);
111
+ (0, _vitest.expect)(parsed.edges.length).toBeGreaterThanOrEqual(3);
112
+ const types = new Set(parsed.nodes.map(n => n.type));
113
+ (0, _vitest.expect)(types.has("bpmn-start")).toBe(true);
114
+ (0, _vitest.expect)(types.has("bpmn-user-task")).toBe(true);
115
+ (0, _vitest.expect)(types.has("bpmn-exclusive-gateway")).toBe(true);
116
+ (0, _vitest.expect)(types.has("bpmn-end")).toBe(true);
117
+ });
118
+ (0, _vitest.it)("flowToBpmnXml can omit DI", () => {
119
+ const {
120
+ nodes,
121
+ edges
122
+ } = minimalFlow();
123
+ const {
124
+ xml
125
+ } = (0, _bpmn.flowToBpmnXml)(nodes, edges, {
126
+ includeDi: false
127
+ });
128
+ (0, _vitest.expect)(xml).toContain("<bpmn:process");
129
+ (0, _vitest.expect)(xml).not.toContain("BPMNDiagram");
130
+ });
131
+ (0, _vitest.it)("validateBpmnXml validates exported sample", () => {
132
+ const sample = (0, _bpmn.generateSampleBpmnXml)();
133
+ (0, _vitest.expect)((0, _bpmn.validateBpmnXml)(sample).valid).toBe(true);
134
+ });
135
+ (0, _vitest.it)("validateBpmnXml rejects malformed XML", () => {
136
+ const r = (0, _bpmn.validateBpmnXml)("<<<");
137
+ (0, _vitest.expect)(r.valid).toBe(false);
138
+ (0, _vitest.expect)(r.error).toBeDefined();
139
+ });
140
+ (0, _vitest.it)("validateBpmnXml rejects missing definitions", () => {
141
+ const r = (0, _bpmn.validateBpmnXml)('<?xml version="1.0"?><root/>');
142
+ (0, _vitest.expect)(r.valid).toBe(false);
143
+ });
144
+ (0, _vitest.it)("generateSampleBpmnXml includes multiple node kinds", () => {
145
+ const xml = (0, _bpmn.generateSampleBpmnXml)();
146
+ (0, _vitest.expect)(xml).toContain("bpmn:startEvent");
147
+ (0, _vitest.expect)(xml).toContain("bpmn:userTask");
148
+ (0, _vitest.expect)((0, _bpmn.validateBpmnXml)(xml).valid).toBe(true);
149
+ });
150
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,112 @@
1
+ import { describe, it, expect } from "vitest";
2
+ import {
3
+ flowToBpmnXml,
4
+ bpmnXmlToFlow,
5
+ validateBpmnXml,
6
+ generateSampleBpmnXml
7
+ } from "../utils/bpmn.mjs";
8
+ function minimalFlow() {
9
+ const nodes = [
10
+ {
11
+ id: "n_start",
12
+ type: "bpmn-start",
13
+ position: { x: 100, y: 100 },
14
+ data: { label: "Start", name: "Start" },
15
+ width: 40,
16
+ height: 40,
17
+ selected: false,
18
+ dragging: false
19
+ },
20
+ {
21
+ id: "n_task",
22
+ type: "bpmn-user-task",
23
+ position: { x: 300, y: 90 },
24
+ data: { label: "Task", name: "Task", assignee: "u1", candidateUsers: "a,b" },
25
+ width: 120,
26
+ height: 80,
27
+ selected: false,
28
+ dragging: false
29
+ },
30
+ {
31
+ id: "n_gw",
32
+ type: "bpmn-exclusive-gateway",
33
+ position: { x: 500, y: 100 },
34
+ data: { label: "GW" },
35
+ width: 50,
36
+ height: 50,
37
+ selected: false,
38
+ dragging: false
39
+ },
40
+ {
41
+ id: "n_end",
42
+ type: "bpmn-end",
43
+ position: { x: 700, y: 100 },
44
+ data: { label: "End" },
45
+ width: 40,
46
+ height: 40,
47
+ selected: false,
48
+ dragging: false
49
+ }
50
+ ];
51
+ const edges = [
52
+ { id: "e1", source: "n_start", target: "n_task" },
53
+ {
54
+ id: "e2",
55
+ source: "n_task",
56
+ target: "n_gw",
57
+ type: "smoothstep",
58
+ data: { conditionExpression: "${approved}" }
59
+ },
60
+ { id: "e3", source: "n_gw", target: "n_end" }
61
+ ];
62
+ return { nodes, edges };
63
+ }
64
+ describe("flow/utils/bpmn XML", () => {
65
+ it("flowToBpmnXml produces definitions and round-trips via bpmnXmlToFlow", () => {
66
+ const { nodes, edges } = minimalFlow();
67
+ const { xml, processId } = flowToBpmnXml(nodes, edges, {
68
+ processId: "Proc_test",
69
+ processName: "Test proc",
70
+ includeDi: true
71
+ });
72
+ expect(xml).toContain("bpmn:definitions");
73
+ expect(xml).toContain(`id="${processId}"`);
74
+ expect(xml).toContain("bpmn:userTask");
75
+ expect(xml).toContain('assignee="u1"');
76
+ expect(xml).toContain("conditionExpression");
77
+ const parsed = bpmnXmlToFlow(xml);
78
+ expect(parsed.processId).toBe("Proc_test");
79
+ expect(parsed.nodes.length).toBeGreaterThanOrEqual(4);
80
+ expect(parsed.edges.length).toBeGreaterThanOrEqual(3);
81
+ const types = new Set(parsed.nodes.map((n) => n.type));
82
+ expect(types.has("bpmn-start")).toBe(true);
83
+ expect(types.has("bpmn-user-task")).toBe(true);
84
+ expect(types.has("bpmn-exclusive-gateway")).toBe(true);
85
+ expect(types.has("bpmn-end")).toBe(true);
86
+ });
87
+ it("flowToBpmnXml can omit DI", () => {
88
+ const { nodes, edges } = minimalFlow();
89
+ const { xml } = flowToBpmnXml(nodes, edges, { includeDi: false });
90
+ expect(xml).toContain("<bpmn:process");
91
+ expect(xml).not.toContain("BPMNDiagram");
92
+ });
93
+ it("validateBpmnXml validates exported sample", () => {
94
+ const sample = generateSampleBpmnXml();
95
+ expect(validateBpmnXml(sample).valid).toBe(true);
96
+ });
97
+ it("validateBpmnXml rejects malformed XML", () => {
98
+ const r = validateBpmnXml("<<<");
99
+ expect(r.valid).toBe(false);
100
+ expect(r.error).toBeDefined();
101
+ });
102
+ it("validateBpmnXml rejects missing definitions", () => {
103
+ const r = validateBpmnXml('<?xml version="1.0"?><root/>');
104
+ expect(r.valid).toBe(false);
105
+ });
106
+ it("generateSampleBpmnXml includes multiple node kinds", () => {
107
+ const xml = generateSampleBpmnXml();
108
+ expect(xml).toContain("bpmn:startEvent");
109
+ expect(xml).toContain("bpmn:userTask");
110
+ expect(validateBpmnXml(xml).valid).toBe(true);
111
+ });
112
+ });