@yh-ui/flow 1.0.25 → 1.0.30

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 (143) hide show
  1. package/package.json +13 -11
  2. package/LICENSE +0 -21
  3. package/dist/__tests__/ai-workflow.ssr.test.cjs +0 -352
  4. package/dist/__tests__/ai-workflow.ssr.test.d.ts +0 -1
  5. package/dist/__tests__/ai-workflow.ssr.test.mjs +0 -283
  6. package/dist/__tests__/ai-workflow.test.cjs +0 -109
  7. package/dist/__tests__/ai-workflow.test.d.ts +0 -1
  8. package/dist/__tests__/ai-workflow.test.mjs +0 -112
  9. package/dist/__tests__/bpmn-engine.test.cjs +0 -357
  10. package/dist/__tests__/bpmn-engine.test.d.ts +0 -1
  11. package/dist/__tests__/bpmn-engine.test.mjs +0 -406
  12. package/dist/__tests__/bpmn-utils.test.cjs +0 -268
  13. package/dist/__tests__/bpmn-utils.test.d.ts +0 -1
  14. package/dist/__tests__/bpmn-utils.test.mjs +0 -227
  15. package/dist/__tests__/bpmn-xml.test.cjs +0 -150
  16. package/dist/__tests__/bpmn-xml.test.d.ts +0 -1
  17. package/dist/__tests__/bpmn-xml.test.mjs +0 -112
  18. package/dist/__tests__/bpmn.ssr.test.cjs +0 -278
  19. package/dist/__tests__/bpmn.ssr.test.d.ts +0 -1
  20. package/dist/__tests__/bpmn.ssr.test.mjs +0 -237
  21. package/dist/__tests__/bpmn.test.cjs +0 -103
  22. package/dist/__tests__/bpmn.test.d.ts +0 -1
  23. package/dist/__tests__/bpmn.test.mjs +0 -106
  24. package/dist/__tests__/collaboration.test.cjs +0 -487
  25. package/dist/__tests__/collaboration.test.d.ts +0 -1
  26. package/dist/__tests__/collaboration.test.mjs +0 -424
  27. package/dist/__tests__/custom-types.test.cjs +0 -300
  28. package/dist/__tests__/custom-types.test.d.ts +0 -1
  29. package/dist/__tests__/custom-types.test.mjs +0 -248
  30. package/dist/__tests__/edge-types.test.cjs +0 -275
  31. package/dist/__tests__/edge-types.test.d.ts +0 -1
  32. package/dist/__tests__/edge-types.test.mjs +0 -234
  33. package/dist/__tests__/edge-utils.test.cjs +0 -375
  34. package/dist/__tests__/edge-utils.test.d.ts +0 -1
  35. package/dist/__tests__/edge-utils.test.mjs +0 -376
  36. package/dist/__tests__/edge.test.cjs +0 -56
  37. package/dist/__tests__/edge.test.d.ts +0 -1
  38. package/dist/__tests__/edge.test.mjs +0 -69
  39. package/dist/__tests__/event-bus.test.cjs +0 -80
  40. package/dist/__tests__/event-bus.test.d.ts +0 -1
  41. package/dist/__tests__/event-bus.test.mjs +0 -51
  42. package/dist/__tests__/events-types.test.cjs +0 -184
  43. package/dist/__tests__/events-types.test.d.ts +0 -1
  44. package/dist/__tests__/events-types.test.mjs +0 -184
  45. package/dist/__tests__/export-image-plugin.test.cjs +0 -142
  46. package/dist/__tests__/export-image-plugin.test.d.ts +0 -1
  47. package/dist/__tests__/export-image-plugin.test.mjs +0 -118
  48. package/dist/__tests__/export.test.cjs +0 -237
  49. package/dist/__tests__/export.test.d.ts +0 -1
  50. package/dist/__tests__/export.test.mjs +0 -171
  51. package/dist/__tests__/flow-context.test.cjs +0 -16
  52. package/dist/__tests__/flow-context.test.d.ts +0 -1
  53. package/dist/__tests__/flow-context.test.mjs +0 -16
  54. package/dist/__tests__/flow-props.test.cjs +0 -94
  55. package/dist/__tests__/flow-props.test.d.ts +0 -1
  56. package/dist/__tests__/flow-props.test.mjs +0 -92
  57. package/dist/__tests__/flow.ssr.test.cjs +0 -156
  58. package/dist/__tests__/flow.ssr.test.d.ts +0 -1
  59. package/dist/__tests__/flow.ssr.test.mjs +0 -112
  60. package/dist/__tests__/geometry.test.cjs +0 -191
  61. package/dist/__tests__/geometry.test.d.ts +0 -1
  62. package/dist/__tests__/geometry.test.mjs +0 -105
  63. package/dist/__tests__/graph.test.cjs +0 -115
  64. package/dist/__tests__/graph.test.d.ts +0 -1
  65. package/dist/__tests__/graph.test.mjs +0 -85
  66. package/dist/__tests__/history-plugin.test.cjs +0 -191
  67. package/dist/__tests__/history-plugin.test.d.ts +0 -1
  68. package/dist/__tests__/history-plugin.test.mjs +0 -161
  69. package/dist/__tests__/history.test.cjs +0 -81
  70. package/dist/__tests__/history.test.d.ts +0 -1
  71. package/dist/__tests__/history.test.mjs +0 -43
  72. package/dist/__tests__/layout-plugin.test.cjs +0 -233
  73. package/dist/__tests__/layout-plugin.test.d.ts +0 -1
  74. package/dist/__tests__/layout-plugin.test.mjs +0 -215
  75. package/dist/__tests__/layout.test.cjs +0 -213
  76. package/dist/__tests__/layout.test.d.ts +0 -1
  77. package/dist/__tests__/layout.test.mjs +0 -170
  78. package/dist/__tests__/node-edit-panel.ssr.test.cjs +0 -168
  79. package/dist/__tests__/node-edit-panel.ssr.test.d.ts +0 -1
  80. package/dist/__tests__/node-edit-panel.ssr.test.mjs +0 -118
  81. package/dist/__tests__/node-group-plugin.test.cjs +0 -235
  82. package/dist/__tests__/node-group-plugin.test.d.ts +0 -1
  83. package/dist/__tests__/node-group-plugin.test.mjs +0 -187
  84. package/dist/__tests__/node-handles.test.cjs +0 -340
  85. package/dist/__tests__/node-handles.test.d.ts +0 -1
  86. package/dist/__tests__/node-handles.test.mjs +0 -230
  87. package/dist/__tests__/node-types.test.cjs +0 -368
  88. package/dist/__tests__/node-types.test.d.ts +0 -1
  89. package/dist/__tests__/node-types.test.mjs +0 -292
  90. package/dist/__tests__/performance.test.cjs +0 -313
  91. package/dist/__tests__/performance.test.d.ts +0 -1
  92. package/dist/__tests__/performance.test.mjs +0 -218
  93. package/dist/__tests__/plugin-advanced.test.cjs +0 -301
  94. package/dist/__tests__/plugin-advanced.test.d.ts +0 -1
  95. package/dist/__tests__/plugin-advanced.test.mjs +0 -225
  96. package/dist/__tests__/plugin.test.cjs +0 -151
  97. package/dist/__tests__/plugin.test.d.ts +0 -1
  98. package/dist/__tests__/plugin.test.mjs +0 -116
  99. package/dist/__tests__/plugins.test.cjs +0 -412
  100. package/dist/__tests__/plugins.test.d.ts +0 -1
  101. package/dist/__tests__/plugins.test.mjs +0 -402
  102. package/dist/__tests__/screenshot-capture.test.cjs +0 -183
  103. package/dist/__tests__/screenshot-capture.test.d.ts +0 -1
  104. package/dist/__tests__/screenshot-capture.test.mjs +0 -124
  105. package/dist/__tests__/screenshot.test.cjs +0 -74
  106. package/dist/__tests__/screenshot.test.d.ts +0 -1
  107. package/dist/__tests__/screenshot.test.mjs +0 -69
  108. package/dist/__tests__/theme.test.cjs +0 -185
  109. package/dist/__tests__/theme.test.d.ts +0 -1
  110. package/dist/__tests__/theme.test.mjs +0 -191
  111. package/dist/__tests__/transform.test.cjs +0 -384
  112. package/dist/__tests__/transform.test.d.ts +0 -1
  113. package/dist/__tests__/transform.test.mjs +0 -239
  114. package/dist/__tests__/useAlignment.test.cjs +0 -128
  115. package/dist/__tests__/useAlignment.test.d.ts +0 -1
  116. package/dist/__tests__/useAlignment.test.mjs +0 -72
  117. package/dist/__tests__/useEdges.test.cjs +0 -117
  118. package/dist/__tests__/useEdges.test.d.ts +0 -1
  119. package/dist/__tests__/useEdges.test.mjs +0 -80
  120. package/dist/__tests__/useKeyboard.test.cjs +0 -88
  121. package/dist/__tests__/useKeyboard.test.d.ts +0 -1
  122. package/dist/__tests__/useKeyboard.test.mjs +0 -56
  123. package/dist/__tests__/useNodeDistribution.test.cjs +0 -643
  124. package/dist/__tests__/useNodeDistribution.test.d.ts +0 -1
  125. package/dist/__tests__/useNodeDistribution.test.mjs +0 -297
  126. package/dist/__tests__/useNodes.test.cjs +0 -150
  127. package/dist/__tests__/useNodes.test.d.ts +0 -1
  128. package/dist/__tests__/useNodes.test.mjs +0 -80
  129. package/dist/__tests__/useSelection.test.cjs +0 -112
  130. package/dist/__tests__/useSelection.test.d.ts +0 -1
  131. package/dist/__tests__/useSelection.test.mjs +0 -76
  132. package/dist/__tests__/useViewport.test.cjs +0 -171
  133. package/dist/__tests__/useViewport.test.d.ts +0 -1
  134. package/dist/__tests__/useViewport.test.mjs +0 -82
  135. package/dist/__tests__/utils/ssr.cjs +0 -124
  136. package/dist/__tests__/utils/ssr.d.ts +0 -33
  137. package/dist/__tests__/utils/ssr.mjs +0 -129
  138. package/dist/__tests__/validation.test.cjs +0 -95
  139. package/dist/__tests__/validation.test.d.ts +0 -1
  140. package/dist/__tests__/validation.test.mjs +0 -36
  141. package/dist/__tests__/viewport-types.test.cjs +0 -324
  142. package/dist/__tests__/viewport-types.test.d.ts +0 -1
  143. package/dist/__tests__/viewport-types.test.mjs +0 -207
@@ -1,227 +0,0 @@
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
- });
@@ -1,150 +0,0 @@
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
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,112 +0,0 @@
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
- });