@yh-ui/flow 1.0.26 → 1.0.36
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.
- package/package.json +6 -6
- package/dist/__tests__/ai-workflow.ssr.test.cjs +0 -352
- package/dist/__tests__/ai-workflow.ssr.test.d.ts +0 -1
- package/dist/__tests__/ai-workflow.ssr.test.mjs +0 -283
- package/dist/__tests__/ai-workflow.test.cjs +0 -109
- package/dist/__tests__/ai-workflow.test.d.ts +0 -1
- package/dist/__tests__/ai-workflow.test.mjs +0 -112
- package/dist/__tests__/bpmn-engine.test.cjs +0 -357
- package/dist/__tests__/bpmn-engine.test.d.ts +0 -1
- package/dist/__tests__/bpmn-engine.test.mjs +0 -406
- package/dist/__tests__/bpmn-utils.test.cjs +0 -268
- package/dist/__tests__/bpmn-utils.test.d.ts +0 -1
- package/dist/__tests__/bpmn-utils.test.mjs +0 -227
- package/dist/__tests__/bpmn-xml.test.cjs +0 -150
- package/dist/__tests__/bpmn-xml.test.d.ts +0 -1
- package/dist/__tests__/bpmn-xml.test.mjs +0 -112
- package/dist/__tests__/bpmn.ssr.test.cjs +0 -278
- package/dist/__tests__/bpmn.ssr.test.d.ts +0 -1
- package/dist/__tests__/bpmn.ssr.test.mjs +0 -237
- package/dist/__tests__/bpmn.test.cjs +0 -103
- package/dist/__tests__/bpmn.test.d.ts +0 -1
- package/dist/__tests__/bpmn.test.mjs +0 -106
- package/dist/__tests__/collaboration.test.cjs +0 -487
- package/dist/__tests__/collaboration.test.d.ts +0 -1
- package/dist/__tests__/collaboration.test.mjs +0 -424
- package/dist/__tests__/custom-types.test.cjs +0 -300
- package/dist/__tests__/custom-types.test.d.ts +0 -1
- package/dist/__tests__/custom-types.test.mjs +0 -248
- package/dist/__tests__/edge-types.test.cjs +0 -275
- package/dist/__tests__/edge-types.test.d.ts +0 -1
- package/dist/__tests__/edge-types.test.mjs +0 -234
- package/dist/__tests__/edge-utils.test.cjs +0 -375
- package/dist/__tests__/edge-utils.test.d.ts +0 -1
- package/dist/__tests__/edge-utils.test.mjs +0 -376
- package/dist/__tests__/edge.test.cjs +0 -56
- package/dist/__tests__/edge.test.d.ts +0 -1
- package/dist/__tests__/edge.test.mjs +0 -69
- package/dist/__tests__/event-bus.test.cjs +0 -80
- package/dist/__tests__/event-bus.test.d.ts +0 -1
- package/dist/__tests__/event-bus.test.mjs +0 -51
- package/dist/__tests__/events-types.test.cjs +0 -184
- package/dist/__tests__/events-types.test.d.ts +0 -1
- package/dist/__tests__/events-types.test.mjs +0 -184
- package/dist/__tests__/export-image-plugin.test.cjs +0 -142
- package/dist/__tests__/export-image-plugin.test.d.ts +0 -1
- package/dist/__tests__/export-image-plugin.test.mjs +0 -118
- package/dist/__tests__/export.test.cjs +0 -237
- package/dist/__tests__/export.test.d.ts +0 -1
- package/dist/__tests__/export.test.mjs +0 -171
- package/dist/__tests__/flow-context.test.cjs +0 -16
- package/dist/__tests__/flow-context.test.d.ts +0 -1
- package/dist/__tests__/flow-context.test.mjs +0 -16
- package/dist/__tests__/flow-props.test.cjs +0 -94
- package/dist/__tests__/flow-props.test.d.ts +0 -1
- package/dist/__tests__/flow-props.test.mjs +0 -92
- package/dist/__tests__/flow.ssr.test.cjs +0 -156
- package/dist/__tests__/flow.ssr.test.d.ts +0 -1
- package/dist/__tests__/flow.ssr.test.mjs +0 -112
- package/dist/__tests__/geometry.test.cjs +0 -191
- package/dist/__tests__/geometry.test.d.ts +0 -1
- package/dist/__tests__/geometry.test.mjs +0 -105
- package/dist/__tests__/graph.test.cjs +0 -115
- package/dist/__tests__/graph.test.d.ts +0 -1
- package/dist/__tests__/graph.test.mjs +0 -85
- package/dist/__tests__/history-plugin.test.cjs +0 -191
- package/dist/__tests__/history-plugin.test.d.ts +0 -1
- package/dist/__tests__/history-plugin.test.mjs +0 -161
- package/dist/__tests__/history.test.cjs +0 -81
- package/dist/__tests__/history.test.d.ts +0 -1
- package/dist/__tests__/history.test.mjs +0 -43
- package/dist/__tests__/layout-plugin.test.cjs +0 -233
- package/dist/__tests__/layout-plugin.test.d.ts +0 -1
- package/dist/__tests__/layout-plugin.test.mjs +0 -215
- package/dist/__tests__/layout.test.cjs +0 -213
- package/dist/__tests__/layout.test.d.ts +0 -1
- package/dist/__tests__/layout.test.mjs +0 -170
- package/dist/__tests__/node-edit-panel.ssr.test.cjs +0 -168
- package/dist/__tests__/node-edit-panel.ssr.test.d.ts +0 -1
- package/dist/__tests__/node-edit-panel.ssr.test.mjs +0 -118
- package/dist/__tests__/node-group-plugin.test.cjs +0 -235
- package/dist/__tests__/node-group-plugin.test.d.ts +0 -1
- package/dist/__tests__/node-group-plugin.test.mjs +0 -187
- package/dist/__tests__/node-handles.test.cjs +0 -340
- package/dist/__tests__/node-handles.test.d.ts +0 -1
- package/dist/__tests__/node-handles.test.mjs +0 -230
- package/dist/__tests__/node-types.test.cjs +0 -368
- package/dist/__tests__/node-types.test.d.ts +0 -1
- package/dist/__tests__/node-types.test.mjs +0 -292
- package/dist/__tests__/performance.test.cjs +0 -313
- package/dist/__tests__/performance.test.d.ts +0 -1
- package/dist/__tests__/performance.test.mjs +0 -218
- package/dist/__tests__/plugin-advanced.test.cjs +0 -301
- package/dist/__tests__/plugin-advanced.test.d.ts +0 -1
- package/dist/__tests__/plugin-advanced.test.mjs +0 -225
- package/dist/__tests__/plugin.test.cjs +0 -151
- package/dist/__tests__/plugin.test.d.ts +0 -1
- package/dist/__tests__/plugin.test.mjs +0 -116
- package/dist/__tests__/plugins.test.cjs +0 -412
- package/dist/__tests__/plugins.test.d.ts +0 -1
- package/dist/__tests__/plugins.test.mjs +0 -402
- package/dist/__tests__/screenshot-capture.test.cjs +0 -183
- package/dist/__tests__/screenshot-capture.test.d.ts +0 -1
- package/dist/__tests__/screenshot-capture.test.mjs +0 -124
- package/dist/__tests__/screenshot.test.cjs +0 -74
- package/dist/__tests__/screenshot.test.d.ts +0 -1
- package/dist/__tests__/screenshot.test.mjs +0 -69
- package/dist/__tests__/theme.test.cjs +0 -185
- package/dist/__tests__/theme.test.d.ts +0 -1
- package/dist/__tests__/theme.test.mjs +0 -191
- package/dist/__tests__/transform.test.cjs +0 -384
- package/dist/__tests__/transform.test.d.ts +0 -1
- package/dist/__tests__/transform.test.mjs +0 -239
- package/dist/__tests__/useAlignment.test.cjs +0 -128
- package/dist/__tests__/useAlignment.test.d.ts +0 -1
- package/dist/__tests__/useAlignment.test.mjs +0 -72
- package/dist/__tests__/useEdges.test.cjs +0 -117
- package/dist/__tests__/useEdges.test.d.ts +0 -1
- package/dist/__tests__/useEdges.test.mjs +0 -80
- package/dist/__tests__/useKeyboard.test.cjs +0 -88
- package/dist/__tests__/useKeyboard.test.d.ts +0 -1
- package/dist/__tests__/useKeyboard.test.mjs +0 -56
- package/dist/__tests__/useNodeDistribution.test.cjs +0 -643
- package/dist/__tests__/useNodeDistribution.test.d.ts +0 -1
- package/dist/__tests__/useNodeDistribution.test.mjs +0 -297
- package/dist/__tests__/useNodes.test.cjs +0 -150
- package/dist/__tests__/useNodes.test.d.ts +0 -1
- package/dist/__tests__/useNodes.test.mjs +0 -80
- package/dist/__tests__/useSelection.test.cjs +0 -112
- package/dist/__tests__/useSelection.test.d.ts +0 -1
- package/dist/__tests__/useSelection.test.mjs +0 -76
- package/dist/__tests__/useViewport.test.cjs +0 -171
- package/dist/__tests__/useViewport.test.d.ts +0 -1
- package/dist/__tests__/useViewport.test.mjs +0 -82
- package/dist/__tests__/utils/ssr.cjs +0 -124
- package/dist/__tests__/utils/ssr.d.ts +0 -33
- package/dist/__tests__/utils/ssr.mjs +0 -129
- package/dist/__tests__/validation.test.cjs +0 -95
- package/dist/__tests__/validation.test.d.ts +0 -1
- package/dist/__tests__/validation.test.mjs +0 -36
- package/dist/__tests__/viewport-types.test.cjs +0 -324
- package/dist/__tests__/viewport-types.test.d.ts +0 -1
- package/dist/__tests__/viewport-types.test.mjs +0 -207
|
@@ -1,230 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from "vitest";
|
|
2
|
-
const getHandles = (node, type) => {
|
|
3
|
-
if (node.handleBounds) {
|
|
4
|
-
const handles = [];
|
|
5
|
-
if (node.handleBounds.top) handles.push(...node.handleBounds.top);
|
|
6
|
-
if (node.handleBounds.right) handles.push(...node.handleBounds.right);
|
|
7
|
-
if (node.handleBounds.bottom) handles.push(...node.handleBounds.bottom);
|
|
8
|
-
if (node.handleBounds.left) handles.push(...node.handleBounds.left);
|
|
9
|
-
return handles.filter((h) => h.type === type);
|
|
10
|
-
}
|
|
11
|
-
if (node.type === "group") {
|
|
12
|
-
return [];
|
|
13
|
-
}
|
|
14
|
-
if (node.type === "input") {
|
|
15
|
-
return type === "source" ? [{ type: "source", position: "right" }] : [];
|
|
16
|
-
}
|
|
17
|
-
if (node.type === "output") {
|
|
18
|
-
return type === "target" ? [{ type: "target", position: "left" }] : [];
|
|
19
|
-
}
|
|
20
|
-
if (node.type === "bpmn-start") {
|
|
21
|
-
return type === "source" ? [{ type: "source", position: "right" }] : [];
|
|
22
|
-
}
|
|
23
|
-
if (node.type === "bpmn-end") {
|
|
24
|
-
return type === "target" ? [{ type: "target", position: "left" }] : [];
|
|
25
|
-
}
|
|
26
|
-
if (node.type === "bpmn-task" || node.type === "bpmn-service-task" || node.type === "bpmn-user-task") {
|
|
27
|
-
return [
|
|
28
|
-
{ type: "target", position: "left" },
|
|
29
|
-
{ type: "source", position: "right" }
|
|
30
|
-
].filter((h) => h.type === type);
|
|
31
|
-
}
|
|
32
|
-
if (node.type === "bpmn-exclusive-gateway" || node.type === "bpmn-parallel-gateway" || node.type === "bpmn-inclusive-gateway") {
|
|
33
|
-
return [
|
|
34
|
-
{ type: "target", position: "left" },
|
|
35
|
-
{ type: "source", position: "right" },
|
|
36
|
-
{ type: "target", position: "top" },
|
|
37
|
-
{ type: "source", position: "bottom" }
|
|
38
|
-
].filter((h) => h.type === type);
|
|
39
|
-
}
|
|
40
|
-
if (node.type === "ai-start") {
|
|
41
|
-
return type === "source" ? [{ type: "source", position: "right" }] : [];
|
|
42
|
-
}
|
|
43
|
-
if (node.type === "ai-end") {
|
|
44
|
-
return type === "target" ? [{ type: "target", position: "left" }] : [];
|
|
45
|
-
}
|
|
46
|
-
if (node.type === "ai-condition") {
|
|
47
|
-
return [
|
|
48
|
-
{ type: "target", position: "left" },
|
|
49
|
-
{ type: "source", position: "right" },
|
|
50
|
-
// true
|
|
51
|
-
{ type: "source", position: "bottom" }
|
|
52
|
-
// false
|
|
53
|
-
].filter((h) => h.type === type);
|
|
54
|
-
}
|
|
55
|
-
if (node.type === "ai-llm" || node.type === "ai-prompt" || node.type === "ai-agent" || node.type === "ai-tool" || node.type === "ai-memory") {
|
|
56
|
-
return [
|
|
57
|
-
{ type: "target", position: "left" },
|
|
58
|
-
{ type: "source", position: "right" }
|
|
59
|
-
].filter((h) => h.type === type);
|
|
60
|
-
}
|
|
61
|
-
return [
|
|
62
|
-
{ type: "target", position: "left" },
|
|
63
|
-
{ type: "source", position: "right" }
|
|
64
|
-
].filter((h) => h.type === type);
|
|
65
|
-
};
|
|
66
|
-
describe("flow/utils/node-handles", () => {
|
|
67
|
-
describe("Default node handles", () => {
|
|
68
|
-
it("should return handles for default node type", () => {
|
|
69
|
-
const node = {
|
|
70
|
-
id: "1",
|
|
71
|
-
type: "default",
|
|
72
|
-
position: { x: 0, y: 0 },
|
|
73
|
-
data: { label: "Test" }
|
|
74
|
-
};
|
|
75
|
-
const handles = getHandles(node, "source");
|
|
76
|
-
expect(handles).toBeDefined();
|
|
77
|
-
expect(handles.length).toBeGreaterThan(0);
|
|
78
|
-
});
|
|
79
|
-
it("should return source and target handles for default node", () => {
|
|
80
|
-
const node = {
|
|
81
|
-
id: "1",
|
|
82
|
-
type: "default",
|
|
83
|
-
position: { x: 0, y: 0 },
|
|
84
|
-
data: { label: "Test" }
|
|
85
|
-
};
|
|
86
|
-
const sourceHandles = getHandles(node, "source");
|
|
87
|
-
const targetHandles = getHandles(node, "target");
|
|
88
|
-
expect(sourceHandles.length).toBe(1);
|
|
89
|
-
expect(sourceHandles[0]?.position).toBe("right");
|
|
90
|
-
expect(targetHandles.length).toBe(1);
|
|
91
|
-
expect(targetHandles[0]?.position).toBe("left");
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
|
-
describe("BPMN node handles", () => {
|
|
95
|
-
it("should return source handle for bpmn-start", () => {
|
|
96
|
-
const node = {
|
|
97
|
-
id: "start1",
|
|
98
|
-
type: "bpmn-start",
|
|
99
|
-
position: { x: 0, y: 0 },
|
|
100
|
-
data: { label: "Start" }
|
|
101
|
-
};
|
|
102
|
-
const handles = getHandles(node, "source");
|
|
103
|
-
expect(handles.length).toBe(1);
|
|
104
|
-
expect(handles[0]?.position).toBe("right");
|
|
105
|
-
});
|
|
106
|
-
it("should return target handle for bpmn-end", () => {
|
|
107
|
-
const node = {
|
|
108
|
-
id: "end1",
|
|
109
|
-
type: "bpmn-end",
|
|
110
|
-
position: { x: 0, y: 0 },
|
|
111
|
-
data: { label: "End" }
|
|
112
|
-
};
|
|
113
|
-
const handles = getHandles(node, "target");
|
|
114
|
-
expect(handles.length).toBe(1);
|
|
115
|
-
expect(handles[0]?.position).toBe("left");
|
|
116
|
-
});
|
|
117
|
-
it("should return both handles for bpmn-task", () => {
|
|
118
|
-
const node = {
|
|
119
|
-
id: "task1",
|
|
120
|
-
type: "bpmn-task",
|
|
121
|
-
position: { x: 0, y: 0 },
|
|
122
|
-
data: { label: "Task" }
|
|
123
|
-
};
|
|
124
|
-
const sourceHandles = getHandles(node, "source");
|
|
125
|
-
const targetHandles = getHandles(node, "target");
|
|
126
|
-
expect(sourceHandles.length).toBe(1);
|
|
127
|
-
expect(targetHandles.length).toBe(1);
|
|
128
|
-
});
|
|
129
|
-
it("should return 4 handles for bpmn-exclusive-gateway", () => {
|
|
130
|
-
const node = {
|
|
131
|
-
id: "gw1",
|
|
132
|
-
type: "bpmn-exclusive-gateway",
|
|
133
|
-
position: { x: 0, y: 0 },
|
|
134
|
-
data: { label: "Gateway" }
|
|
135
|
-
};
|
|
136
|
-
const sourceHandles = getHandles(node, "source");
|
|
137
|
-
const targetHandles = getHandles(node, "target");
|
|
138
|
-
expect(sourceHandles.length).toBe(2);
|
|
139
|
-
expect(targetHandles.length).toBe(2);
|
|
140
|
-
});
|
|
141
|
-
});
|
|
142
|
-
describe("AI Workflow node handles", () => {
|
|
143
|
-
it("should return handles for ai-llm", () => {
|
|
144
|
-
const node = {
|
|
145
|
-
id: "llm1",
|
|
146
|
-
type: "ai-llm",
|
|
147
|
-
position: { x: 0, y: 0 },
|
|
148
|
-
data: { label: "LLM", model: "gpt-4" }
|
|
149
|
-
};
|
|
150
|
-
const sourceHandles = getHandles(node, "source");
|
|
151
|
-
const targetHandles = getHandles(node, "target");
|
|
152
|
-
expect(sourceHandles.length).toBe(1);
|
|
153
|
-
expect(targetHandles.length).toBe(1);
|
|
154
|
-
});
|
|
155
|
-
it("should return source handle for ai-start", () => {
|
|
156
|
-
const node = {
|
|
157
|
-
id: "start1",
|
|
158
|
-
type: "ai-start",
|
|
159
|
-
position: { x: 0, y: 0 },
|
|
160
|
-
data: { label: "Start" }
|
|
161
|
-
};
|
|
162
|
-
const handles = getHandles(node, "source");
|
|
163
|
-
expect(handles.length).toBe(1);
|
|
164
|
-
expect(handles[0]?.position).toBe("right");
|
|
165
|
-
});
|
|
166
|
-
it("should return target handle for ai-end", () => {
|
|
167
|
-
const node = {
|
|
168
|
-
id: "end1",
|
|
169
|
-
type: "ai-end",
|
|
170
|
-
position: { x: 0, y: 0 },
|
|
171
|
-
data: { label: "End" }
|
|
172
|
-
};
|
|
173
|
-
const handles = getHandles(node, "target");
|
|
174
|
-
expect(handles.length).toBe(1);
|
|
175
|
-
expect(handles[0]?.position).toBe("left");
|
|
176
|
-
});
|
|
177
|
-
it("should return 3 handles for ai-condition (left target, right source, bottom source)", () => {
|
|
178
|
-
const node = {
|
|
179
|
-
id: "cond1",
|
|
180
|
-
type: "ai-condition",
|
|
181
|
-
position: { x: 0, y: 0 },
|
|
182
|
-
data: { label: "Condition", condition: "if" }
|
|
183
|
-
};
|
|
184
|
-
const sourceHandles = getHandles(node, "source");
|
|
185
|
-
const targetHandles = getHandles(node, "target");
|
|
186
|
-
expect(sourceHandles.length).toBe(2);
|
|
187
|
-
expect(targetHandles.length).toBe(1);
|
|
188
|
-
});
|
|
189
|
-
});
|
|
190
|
-
describe("Input/Output node handles", () => {
|
|
191
|
-
it("should return only source handle for input node", () => {
|
|
192
|
-
const node = {
|
|
193
|
-
id: "input1",
|
|
194
|
-
type: "input",
|
|
195
|
-
position: { x: 0, y: 0 },
|
|
196
|
-
data: { label: "Input" }
|
|
197
|
-
};
|
|
198
|
-
const sourceHandles = getHandles(node, "source");
|
|
199
|
-
const targetHandles = getHandles(node, "target");
|
|
200
|
-
expect(sourceHandles.length).toBe(1);
|
|
201
|
-
expect(targetHandles.length).toBe(0);
|
|
202
|
-
});
|
|
203
|
-
it("should return only target handle for output node", () => {
|
|
204
|
-
const node = {
|
|
205
|
-
id: "output1",
|
|
206
|
-
type: "output",
|
|
207
|
-
position: { x: 0, y: 0 },
|
|
208
|
-
data: { label: "Output" }
|
|
209
|
-
};
|
|
210
|
-
const sourceHandles = getHandles(node, "source");
|
|
211
|
-
const targetHandles = getHandles(node, "target");
|
|
212
|
-
expect(sourceHandles.length).toBe(0);
|
|
213
|
-
expect(targetHandles.length).toBe(1);
|
|
214
|
-
});
|
|
215
|
-
});
|
|
216
|
-
describe("Group node handles", () => {
|
|
217
|
-
it("should return empty array for group node", () => {
|
|
218
|
-
const node = {
|
|
219
|
-
id: "group1",
|
|
220
|
-
type: "group",
|
|
221
|
-
position: { x: 0, y: 0 },
|
|
222
|
-
data: { label: "Group" }
|
|
223
|
-
};
|
|
224
|
-
const sourceHandles = getHandles(node, "source");
|
|
225
|
-
const targetHandles = getHandles(node, "target");
|
|
226
|
-
expect(sourceHandles.length).toBe(0);
|
|
227
|
-
expect(targetHandles.length).toBe(0);
|
|
228
|
-
});
|
|
229
|
-
});
|
|
230
|
-
});
|
|
@@ -1,368 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _vitest = require("vitest");
|
|
4
|
-
var _node = require("../types/node.cjs");
|
|
5
|
-
(0, _vitest.describe)("flow/types/node", () => {
|
|
6
|
-
(0, _vitest.describe)("NodeHandle", () => {
|
|
7
|
-
(0, _vitest.it)("should define handle with type and position", () => {
|
|
8
|
-
const handle = {
|
|
9
|
-
type: "source",
|
|
10
|
-
position: "right"
|
|
11
|
-
};
|
|
12
|
-
(0, _vitest.expect)(handle.type).toBe("source");
|
|
13
|
-
(0, _vitest.expect)(handle.position).toBe("right");
|
|
14
|
-
});
|
|
15
|
-
(0, _vitest.it)("should support optional properties", () => {
|
|
16
|
-
const handle = {
|
|
17
|
-
type: "target",
|
|
18
|
-
position: "left",
|
|
19
|
-
id: "handle-1",
|
|
20
|
-
style: {
|
|
21
|
-
background: "#fff"
|
|
22
|
-
},
|
|
23
|
-
class: "custom-handle",
|
|
24
|
-
isConnectable: true
|
|
25
|
-
};
|
|
26
|
-
(0, _vitest.expect)(handle.id).toBe("handle-1");
|
|
27
|
-
(0, _vitest.expect)(handle.class).toBe("custom-handle");
|
|
28
|
-
(0, _vitest.expect)(handle.isConnectable).toBe(true);
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
(0, _vitest.describe)("NodeStyle", () => {
|
|
32
|
-
(0, _vitest.it)("should allow CSS-like properties", () => {
|
|
33
|
-
const style = {
|
|
34
|
-
background: "#f0f0f0",
|
|
35
|
-
border: "1px solid #ccc",
|
|
36
|
-
width: 200
|
|
37
|
-
};
|
|
38
|
-
(0, _vitest.expect)(style.background).toBe("#f0f0f0");
|
|
39
|
-
(0, _vitest.expect)(style.width).toBe(200);
|
|
40
|
-
});
|
|
41
|
-
(0, _vitest.it)("should support undefined values", () => {
|
|
42
|
-
const style = {
|
|
43
|
-
background: "#fff",
|
|
44
|
-
border: void 0
|
|
45
|
-
};
|
|
46
|
-
(0, _vitest.expect)(style.border).toBeUndefined();
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
(0, _vitest.describe)("NodeData", () => {
|
|
50
|
-
(0, _vitest.it)("should define basic node data", () => {
|
|
51
|
-
const data = {
|
|
52
|
-
label: "Test Node"
|
|
53
|
-
};
|
|
54
|
-
(0, _vitest.expect)(data.label).toBe("Test Node");
|
|
55
|
-
});
|
|
56
|
-
(0, _vitest.it)("should support extended data fields", () => {
|
|
57
|
-
const data = {
|
|
58
|
-
label: "AI Node",
|
|
59
|
-
style: {
|
|
60
|
-
background: "#e0f7fa"
|
|
61
|
-
},
|
|
62
|
-
class: "ai-node",
|
|
63
|
-
icon: "robot",
|
|
64
|
-
description: "An AI processing node"
|
|
65
|
-
};
|
|
66
|
-
(0, _vitest.expect)(data.icon).toBe("robot");
|
|
67
|
-
(0, _vitest.expect)(data.description).toBe("An AI processing node");
|
|
68
|
-
});
|
|
69
|
-
(0, _vitest.it)("should support AI workflow specific fields", () => {
|
|
70
|
-
const data = {
|
|
71
|
-
label: "LLM Node",
|
|
72
|
-
model: "gpt-4",
|
|
73
|
-
prompt: "You are a helpful assistant",
|
|
74
|
-
temperature: 0.7,
|
|
75
|
-
maxTokens: 2e3,
|
|
76
|
-
tools: ["search", "calculator"],
|
|
77
|
-
toolName: "web_search",
|
|
78
|
-
condition: 'status == "success"',
|
|
79
|
-
memoryType: "vector",
|
|
80
|
-
status: "running",
|
|
81
|
-
streamOutput: "partial"
|
|
82
|
-
};
|
|
83
|
-
(0, _vitest.expect)(data.model).toBe("gpt-4");
|
|
84
|
-
(0, _vitest.expect)(data.temperature).toBe(0.7);
|
|
85
|
-
(0, _vitest.expect)(data.status).toBe("running");
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
|
-
(0, _vitest.describe)("NodePosition", () => {
|
|
89
|
-
(0, _vitest.it)("should define position with x and y", () => {
|
|
90
|
-
const pos = {
|
|
91
|
-
x: 100,
|
|
92
|
-
y: 200
|
|
93
|
-
};
|
|
94
|
-
(0, _vitest.expect)(pos.x).toBe(100);
|
|
95
|
-
(0, _vitest.expect)(pos.y).toBe(200);
|
|
96
|
-
});
|
|
97
|
-
(0, _vitest.it)("should support negative coordinates", () => {
|
|
98
|
-
const pos = {
|
|
99
|
-
x: -50,
|
|
100
|
-
y: -100
|
|
101
|
-
};
|
|
102
|
-
(0, _vitest.expect)(pos.x).toBe(-50);
|
|
103
|
-
(0, _vitest.expect)(pos.y).toBe(-100);
|
|
104
|
-
});
|
|
105
|
-
});
|
|
106
|
-
(0, _vitest.describe)("NodeDimension", () => {
|
|
107
|
-
(0, _vitest.it)("should define width and height", () => {
|
|
108
|
-
const dim = {
|
|
109
|
-
width: 150,
|
|
110
|
-
height: 80
|
|
111
|
-
};
|
|
112
|
-
(0, _vitest.expect)(dim.width).toBe(150);
|
|
113
|
-
(0, _vitest.expect)(dim.height).toBe(80);
|
|
114
|
-
});
|
|
115
|
-
});
|
|
116
|
-
(0, _vitest.describe)("NodeHandleBounds", () => {
|
|
117
|
-
(0, _vitest.it)("should define handle bounds", () => {
|
|
118
|
-
const bounds = {
|
|
119
|
-
top: [{
|
|
120
|
-
type: "source",
|
|
121
|
-
position: "top"
|
|
122
|
-
}],
|
|
123
|
-
right: [{
|
|
124
|
-
type: "target",
|
|
125
|
-
position: "right"
|
|
126
|
-
}]
|
|
127
|
-
};
|
|
128
|
-
(0, _vitest.expect)(bounds.top).toHaveLength(1);
|
|
129
|
-
(0, _vitest.expect)(bounds.right).toHaveLength(1);
|
|
130
|
-
});
|
|
131
|
-
});
|
|
132
|
-
(0, _vitest.describe)("Node", () => {
|
|
133
|
-
(0, _vitest.it)("should create basic node", () => {
|
|
134
|
-
const node = {
|
|
135
|
-
id: "node-1",
|
|
136
|
-
type: "default",
|
|
137
|
-
position: {
|
|
138
|
-
x: 0,
|
|
139
|
-
y: 0
|
|
140
|
-
},
|
|
141
|
-
data: {
|
|
142
|
-
label: "Basic Node"
|
|
143
|
-
}
|
|
144
|
-
};
|
|
145
|
-
(0, _vitest.expect)(node.id).toBe("node-1");
|
|
146
|
-
(0, _vitest.expect)(node.type).toBe("default");
|
|
147
|
-
});
|
|
148
|
-
(0, _vitest.it)("should support all optional properties", () => {
|
|
149
|
-
const node = {
|
|
150
|
-
id: "node-1",
|
|
151
|
-
type: "custom",
|
|
152
|
-
position: {
|
|
153
|
-
x: 100,
|
|
154
|
-
y: 200
|
|
155
|
-
},
|
|
156
|
-
data: {
|
|
157
|
-
label: "Test"
|
|
158
|
-
},
|
|
159
|
-
style: {
|
|
160
|
-
background: "#fff"
|
|
161
|
-
},
|
|
162
|
-
class: "custom-node",
|
|
163
|
-
draggable: true,
|
|
164
|
-
selectable: true,
|
|
165
|
-
connectable: true,
|
|
166
|
-
resizable: true,
|
|
167
|
-
deletable: true,
|
|
168
|
-
hidden: false,
|
|
169
|
-
selected: false,
|
|
170
|
-
dragging: false,
|
|
171
|
-
width: 200,
|
|
172
|
-
height: 100,
|
|
173
|
-
parentId: "parent-1",
|
|
174
|
-
zIndex: 1,
|
|
175
|
-
extent: "parent",
|
|
176
|
-
expandParent: true,
|
|
177
|
-
positionAbsolute: {
|
|
178
|
-
x: 150,
|
|
179
|
-
y: 250
|
|
180
|
-
},
|
|
181
|
-
handleBounds: {
|
|
182
|
-
top: [{
|
|
183
|
-
type: "source",
|
|
184
|
-
position: "top"
|
|
185
|
-
}],
|
|
186
|
-
right: [{
|
|
187
|
-
type: "target",
|
|
188
|
-
position: "right"
|
|
189
|
-
}]
|
|
190
|
-
}
|
|
191
|
-
};
|
|
192
|
-
(0, _vitest.expect)(node.draggable).toBe(true);
|
|
193
|
-
(0, _vitest.expect)(node.width).toBe(200);
|
|
194
|
-
(0, _vitest.expect)(node.parentId).toBe("parent-1");
|
|
195
|
-
});
|
|
196
|
-
(0, _vitest.it)("should support nested children", () => {
|
|
197
|
-
const node = {
|
|
198
|
-
id: "parent",
|
|
199
|
-
type: "group",
|
|
200
|
-
position: {
|
|
201
|
-
x: 0,
|
|
202
|
-
y: 0
|
|
203
|
-
},
|
|
204
|
-
data: {
|
|
205
|
-
label: "Parent"
|
|
206
|
-
},
|
|
207
|
-
children: ["child-1", "child-2"],
|
|
208
|
-
computed: true
|
|
209
|
-
};
|
|
210
|
-
(0, _vitest.expect)(node.children).toEqual(["child-1", "child-2"]);
|
|
211
|
-
(0, _vitest.expect)(node.computed).toBe(true);
|
|
212
|
-
});
|
|
213
|
-
});
|
|
214
|
-
(0, _vitest.describe)("NodeChangeType", () => {
|
|
215
|
-
(0, _vitest.it)("should define all change types", () => {
|
|
216
|
-
const types = ["select", "position", "remove", "dimensions", "style", "data", "selectMulti", "unselect"];
|
|
217
|
-
(0, _vitest.expect)(types).toContain("select");
|
|
218
|
-
(0, _vitest.expect)(types).toContain("position");
|
|
219
|
-
(0, _vitest.expect)(types).toContain("remove");
|
|
220
|
-
});
|
|
221
|
-
});
|
|
222
|
-
(0, _vitest.describe)("NodeChange", () => {
|
|
223
|
-
(0, _vitest.it)("should create select change", () => {
|
|
224
|
-
const node = {
|
|
225
|
-
id: "node-1",
|
|
226
|
-
type: "default",
|
|
227
|
-
position: {
|
|
228
|
-
x: 0,
|
|
229
|
-
y: 0
|
|
230
|
-
},
|
|
231
|
-
data: {}
|
|
232
|
-
};
|
|
233
|
-
const change = {
|
|
234
|
-
type: "select",
|
|
235
|
-
id: "node-1",
|
|
236
|
-
item: node,
|
|
237
|
-
selected: true
|
|
238
|
-
};
|
|
239
|
-
(0, _vitest.expect)(change.type).toBe("select");
|
|
240
|
-
(0, _vitest.expect)(change.selected).toBe(true);
|
|
241
|
-
});
|
|
242
|
-
(0, _vitest.it)("should create position change", () => {
|
|
243
|
-
const node = {
|
|
244
|
-
id: "node-1",
|
|
245
|
-
type: "default",
|
|
246
|
-
position: {
|
|
247
|
-
x: 0,
|
|
248
|
-
y: 0
|
|
249
|
-
},
|
|
250
|
-
data: {}
|
|
251
|
-
};
|
|
252
|
-
const change = {
|
|
253
|
-
type: "position",
|
|
254
|
-
id: "node-1",
|
|
255
|
-
item: node,
|
|
256
|
-
position: {
|
|
257
|
-
x: 100,
|
|
258
|
-
y: 200
|
|
259
|
-
}
|
|
260
|
-
};
|
|
261
|
-
(0, _vitest.expect)(change.position?.x).toBe(100);
|
|
262
|
-
(0, _vitest.expect)(change.position?.y).toBe(200);
|
|
263
|
-
});
|
|
264
|
-
(0, _vitest.it)("should create dimensions change", () => {
|
|
265
|
-
const node = {
|
|
266
|
-
id: "node-1",
|
|
267
|
-
type: "default",
|
|
268
|
-
position: {
|
|
269
|
-
x: 0,
|
|
270
|
-
y: 0
|
|
271
|
-
},
|
|
272
|
-
data: {}
|
|
273
|
-
};
|
|
274
|
-
const change = {
|
|
275
|
-
type: "dimensions",
|
|
276
|
-
id: "node-1",
|
|
277
|
-
item: node,
|
|
278
|
-
dimensions: {
|
|
279
|
-
width: 200,
|
|
280
|
-
height: 100
|
|
281
|
-
}
|
|
282
|
-
};
|
|
283
|
-
(0, _vitest.expect)(change.dimensions?.width).toBe(200);
|
|
284
|
-
});
|
|
285
|
-
(0, _vitest.it)("should create drag change", () => {
|
|
286
|
-
const node = {
|
|
287
|
-
id: "node-1",
|
|
288
|
-
type: "default",
|
|
289
|
-
position: {
|
|
290
|
-
x: 0,
|
|
291
|
-
y: 0
|
|
292
|
-
},
|
|
293
|
-
data: {}
|
|
294
|
-
};
|
|
295
|
-
const change = {
|
|
296
|
-
type: "position",
|
|
297
|
-
id: "node-1",
|
|
298
|
-
item: node,
|
|
299
|
-
drag: true
|
|
300
|
-
};
|
|
301
|
-
(0, _vitest.expect)(change.drag).toBe(true);
|
|
302
|
-
});
|
|
303
|
-
});
|
|
304
|
-
(0, _vitest.describe)("isNode", () => {
|
|
305
|
-
(0, _vitest.it)("should return true for valid node objects", () => {
|
|
306
|
-
const node = {
|
|
307
|
-
id: "node-1",
|
|
308
|
-
type: "default",
|
|
309
|
-
position: {
|
|
310
|
-
x: 0,
|
|
311
|
-
y: 0
|
|
312
|
-
},
|
|
313
|
-
data: {}
|
|
314
|
-
};
|
|
315
|
-
(0, _vitest.expect)((0, _node.isNode)(node)).toBe(true);
|
|
316
|
-
});
|
|
317
|
-
(0, _vitest.it)("should return true for node with extended properties", () => {
|
|
318
|
-
const node = {
|
|
319
|
-
id: "node-1",
|
|
320
|
-
type: "custom",
|
|
321
|
-
position: {
|
|
322
|
-
x: 100,
|
|
323
|
-
y: 200
|
|
324
|
-
},
|
|
325
|
-
data: {
|
|
326
|
-
label: "Test"
|
|
327
|
-
},
|
|
328
|
-
width: 200,
|
|
329
|
-
height: 100
|
|
330
|
-
};
|
|
331
|
-
(0, _vitest.expect)((0, _node.isNode)(node)).toBe(true);
|
|
332
|
-
});
|
|
333
|
-
(0, _vitest.it)("should return false for null", () => {
|
|
334
|
-
(0, _vitest.expect)((0, _node.isNode)(null)).toBe(false);
|
|
335
|
-
});
|
|
336
|
-
(0, _vitest.it)("should return false for undefined", () => {
|
|
337
|
-
(0, _vitest.expect)((0, _node.isNode)(void 0)).toBe(false);
|
|
338
|
-
});
|
|
339
|
-
(0, _vitest.it)("should return false for object missing id", () => {
|
|
340
|
-
(0, _vitest.expect)((0, _node.isNode)({
|
|
341
|
-
type: "default",
|
|
342
|
-
position: {
|
|
343
|
-
x: 0,
|
|
344
|
-
y: 0
|
|
345
|
-
},
|
|
346
|
-
data: {}
|
|
347
|
-
})).toBe(false);
|
|
348
|
-
});
|
|
349
|
-
(0, _vitest.it)("should return false for object missing type", () => {
|
|
350
|
-
(0, _vitest.expect)((0, _node.isNode)({
|
|
351
|
-
id: "node-1",
|
|
352
|
-
position: {
|
|
353
|
-
x: 0,
|
|
354
|
-
y: 0
|
|
355
|
-
},
|
|
356
|
-
data: {}
|
|
357
|
-
})).toBe(false);
|
|
358
|
-
});
|
|
359
|
-
(0, _vitest.it)("should return false for primitive values", () => {
|
|
360
|
-
(0, _vitest.expect)((0, _node.isNode)("node")).toBe(false);
|
|
361
|
-
(0, _vitest.expect)((0, _node.isNode)(123)).toBe(false);
|
|
362
|
-
(0, _vitest.expect)((0, _node.isNode)(true)).toBe(false);
|
|
363
|
-
});
|
|
364
|
-
(0, _vitest.it)("should return false for arrays", () => {
|
|
365
|
-
(0, _vitest.expect)((0, _node.isNode)([])).toBe(false);
|
|
366
|
-
});
|
|
367
|
-
});
|
|
368
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|