@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.
- package/package.json +13 -11
- package/LICENSE +0 -21
- 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,184 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _vitest = require("vitest");
|
|
4
|
-
(0, _vitest.describe)("flow/types/events", () => {
|
|
5
|
-
(0, _vitest.describe)("FlowEventCallback", () => {
|
|
6
|
-
(0, _vitest.it)("should define callback type", () => {
|
|
7
|
-
const callback = event => {
|
|
8
|
-
(0, _vitest.expect)(event).toBeDefined();
|
|
9
|
-
};
|
|
10
|
-
(0, _vitest.expect)(typeof callback).toBe("function");
|
|
11
|
-
});
|
|
12
|
-
(0, _vitest.it)("should accept void event type", () => {
|
|
13
|
-
const callback = () => {};
|
|
14
|
-
(0, _vitest.expect)(typeof callback).toBe("function");
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
(0, _vitest.describe)("FlowEventKey", () => {
|
|
18
|
-
(0, _vitest.it)("should define all event keys", () => {
|
|
19
|
-
const keys = ["node:click", "node:dblclick", "node:dragstart", "node:drag", "node:dragend", "node:selected", "node:unselected", "node:contextmenu", "edge:click", "edge:dblclick", "edge:selected", "edge:unselected", "edge:contextmenu", "edge:connect", "edge:update", "viewport:change", "selection:change", "selection:dragstart", "selection:drag", "selection:dragend", "pane:click", "pane:dblclick", "pane:contextmenu", "connect:start", "connect:end", "connect:cancel"];
|
|
20
|
-
(0, _vitest.expect)(keys.length).toBeGreaterThan(20);
|
|
21
|
-
});
|
|
22
|
-
});
|
|
23
|
-
(0, _vitest.describe)("FlowEvents", () => {
|
|
24
|
-
(0, _vitest.it)("should define node click event", () => {
|
|
25
|
-
const event = {
|
|
26
|
-
node: {
|
|
27
|
-
id: "n1",
|
|
28
|
-
type: "default",
|
|
29
|
-
position: {
|
|
30
|
-
x: 0,
|
|
31
|
-
y: 0
|
|
32
|
-
},
|
|
33
|
-
data: {}
|
|
34
|
-
},
|
|
35
|
-
nativeEvent: new MouseEvent("click")
|
|
36
|
-
};
|
|
37
|
-
(0, _vitest.expect)(event.node.id).toBe("n1");
|
|
38
|
-
});
|
|
39
|
-
(0, _vitest.it)("should define node drag event", () => {
|
|
40
|
-
const event = {
|
|
41
|
-
node: {
|
|
42
|
-
id: "n1",
|
|
43
|
-
type: "default",
|
|
44
|
-
position: {
|
|
45
|
-
x: 0,
|
|
46
|
-
y: 0
|
|
47
|
-
},
|
|
48
|
-
data: {}
|
|
49
|
-
},
|
|
50
|
-
nativeEvent: new MouseEvent("mousedown"),
|
|
51
|
-
position: {
|
|
52
|
-
x: 100,
|
|
53
|
-
y: 200
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
(0, _vitest.expect)(event.position.x).toBe(100);
|
|
57
|
-
});
|
|
58
|
-
(0, _vitest.it)("should define edge connect event", () => {
|
|
59
|
-
const event = {
|
|
60
|
-
connection: {
|
|
61
|
-
source: "n1",
|
|
62
|
-
target: "n2",
|
|
63
|
-
sourceHandle: "right",
|
|
64
|
-
targetHandle: "left"
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
(0, _vitest.expect)(event.connection.source).toBe("n1");
|
|
68
|
-
(0, _vitest.expect)(event.connection.target).toBe("n2");
|
|
69
|
-
});
|
|
70
|
-
(0, _vitest.it)("should define viewport change event", () => {
|
|
71
|
-
const event = {
|
|
72
|
-
transform: {
|
|
73
|
-
x: 100,
|
|
74
|
-
y: 50,
|
|
75
|
-
zoom: 1.5
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
(0, _vitest.expect)(event.transform.zoom).toBe(1.5);
|
|
79
|
-
});
|
|
80
|
-
(0, _vitest.it)("should define selection change event", () => {
|
|
81
|
-
const event = {
|
|
82
|
-
selectedNodes: [{
|
|
83
|
-
id: "n1",
|
|
84
|
-
type: "default",
|
|
85
|
-
position: {
|
|
86
|
-
x: 0,
|
|
87
|
-
y: 0
|
|
88
|
-
},
|
|
89
|
-
data: {}
|
|
90
|
-
}],
|
|
91
|
-
selectedEdges: []
|
|
92
|
-
};
|
|
93
|
-
(0, _vitest.expect)(event.selectedNodes.length).toBe(1);
|
|
94
|
-
});
|
|
95
|
-
(0, _vitest.it)("should define pane click event", () => {
|
|
96
|
-
const event = {
|
|
97
|
-
nativeEvent: new MouseEvent("click")
|
|
98
|
-
};
|
|
99
|
-
(0, _vitest.expect)(event.nativeEvent).toBeDefined();
|
|
100
|
-
});
|
|
101
|
-
(0, _vitest.it)("should define connect start event", () => {
|
|
102
|
-
const event = {
|
|
103
|
-
connection: {
|
|
104
|
-
source: "n1",
|
|
105
|
-
target: "n2"
|
|
106
|
-
},
|
|
107
|
-
nativeEvent: new MouseEvent("mousedown")
|
|
108
|
-
};
|
|
109
|
-
(0, _vitest.expect)(event.connection).toBeDefined();
|
|
110
|
-
});
|
|
111
|
-
(0, _vitest.it)("should define connect cancel event", () => {
|
|
112
|
-
const event = void 0;
|
|
113
|
-
(0, _vitest.expect)(event).toBeUndefined();
|
|
114
|
-
});
|
|
115
|
-
});
|
|
116
|
-
(0, _vitest.describe)("FlowEventHandler", () => {
|
|
117
|
-
(0, _vitest.it)("should define handler for node click", () => {
|
|
118
|
-
const handler = event => {
|
|
119
|
-
(0, _vitest.expect)(event.node.id).toBeDefined();
|
|
120
|
-
};
|
|
121
|
-
(0, _vitest.expect)(typeof handler).toBe("function");
|
|
122
|
-
});
|
|
123
|
-
(0, _vitest.it)("should define handler for void event", () => {
|
|
124
|
-
const handler = () => {};
|
|
125
|
-
(0, _vitest.expect)(typeof handler).toBe("function");
|
|
126
|
-
});
|
|
127
|
-
(0, _vitest.it)("should define handler for viewport change", () => {
|
|
128
|
-
const handler = event => {
|
|
129
|
-
(0, _vitest.expect)(event.transform).toBeDefined();
|
|
130
|
-
};
|
|
131
|
-
(0, _vitest.expect)(typeof handler).toBe("function");
|
|
132
|
-
});
|
|
133
|
-
});
|
|
134
|
-
(0, _vitest.describe)("EventBus", () => {
|
|
135
|
-
(0, _vitest.it)("should define EventBus interface", () => {
|
|
136
|
-
const bus = {
|
|
137
|
-
on: () => {},
|
|
138
|
-
off: () => {},
|
|
139
|
-
emit: () => {},
|
|
140
|
-
once: () => {},
|
|
141
|
-
clear: () => {}
|
|
142
|
-
};
|
|
143
|
-
(0, _vitest.expect)(typeof bus.on).toBe("function");
|
|
144
|
-
(0, _vitest.expect)(typeof bus.off).toBe("function");
|
|
145
|
-
(0, _vitest.expect)(typeof bus.emit).toBe("function");
|
|
146
|
-
(0, _vitest.expect)(typeof bus.once).toBe("function");
|
|
147
|
-
(0, _vitest.expect)(typeof bus.clear).toBe("function");
|
|
148
|
-
});
|
|
149
|
-
});
|
|
150
|
-
(0, _vitest.describe)("SelectionRect", () => {
|
|
151
|
-
(0, _vitest.it)("should define selection rectangle", () => {
|
|
152
|
-
const rect = {
|
|
153
|
-
x: 100,
|
|
154
|
-
y: 200,
|
|
155
|
-
width: 300,
|
|
156
|
-
height: 150
|
|
157
|
-
};
|
|
158
|
-
(0, _vitest.expect)(rect.x).toBe(100);
|
|
159
|
-
(0, _vitest.expect)(rect.y).toBe(200);
|
|
160
|
-
(0, _vitest.expect)(rect.width).toBe(300);
|
|
161
|
-
(0, _vitest.expect)(rect.height).toBe(150);
|
|
162
|
-
});
|
|
163
|
-
(0, _vitest.it)("should allow negative coordinates", () => {
|
|
164
|
-
const rect = {
|
|
165
|
-
x: -50,
|
|
166
|
-
y: -100,
|
|
167
|
-
width: 200,
|
|
168
|
-
height: 100
|
|
169
|
-
};
|
|
170
|
-
(0, _vitest.expect)(rect.x).toBe(-50);
|
|
171
|
-
(0, _vitest.expect)(rect.y).toBe(-100);
|
|
172
|
-
});
|
|
173
|
-
(0, _vitest.it)("should allow zero dimensions", () => {
|
|
174
|
-
const rect = {
|
|
175
|
-
x: 0,
|
|
176
|
-
y: 0,
|
|
177
|
-
width: 0,
|
|
178
|
-
height: 0
|
|
179
|
-
};
|
|
180
|
-
(0, _vitest.expect)(rect.width).toBe(0);
|
|
181
|
-
(0, _vitest.expect)(rect.height).toBe(0);
|
|
182
|
-
});
|
|
183
|
-
});
|
|
184
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from "vitest";
|
|
2
|
-
describe("flow/types/events", () => {
|
|
3
|
-
describe("FlowEventCallback", () => {
|
|
4
|
-
it("should define callback type", () => {
|
|
5
|
-
const callback = (event) => {
|
|
6
|
-
expect(event).toBeDefined();
|
|
7
|
-
};
|
|
8
|
-
expect(typeof callback).toBe("function");
|
|
9
|
-
});
|
|
10
|
-
it("should accept void event type", () => {
|
|
11
|
-
const callback = () => {
|
|
12
|
-
};
|
|
13
|
-
expect(typeof callback).toBe("function");
|
|
14
|
-
});
|
|
15
|
-
});
|
|
16
|
-
describe("FlowEventKey", () => {
|
|
17
|
-
it("should define all event keys", () => {
|
|
18
|
-
const keys = [
|
|
19
|
-
"node:click",
|
|
20
|
-
"node:dblclick",
|
|
21
|
-
"node:dragstart",
|
|
22
|
-
"node:drag",
|
|
23
|
-
"node:dragend",
|
|
24
|
-
"node:selected",
|
|
25
|
-
"node:unselected",
|
|
26
|
-
"node:contextmenu",
|
|
27
|
-
"edge:click",
|
|
28
|
-
"edge:dblclick",
|
|
29
|
-
"edge:selected",
|
|
30
|
-
"edge:unselected",
|
|
31
|
-
"edge:contextmenu",
|
|
32
|
-
"edge:connect",
|
|
33
|
-
"edge:update",
|
|
34
|
-
"viewport:change",
|
|
35
|
-
"selection:change",
|
|
36
|
-
"selection:dragstart",
|
|
37
|
-
"selection:drag",
|
|
38
|
-
"selection:dragend",
|
|
39
|
-
"pane:click",
|
|
40
|
-
"pane:dblclick",
|
|
41
|
-
"pane:contextmenu",
|
|
42
|
-
"connect:start",
|
|
43
|
-
"connect:end",
|
|
44
|
-
"connect:cancel"
|
|
45
|
-
];
|
|
46
|
-
expect(keys.length).toBeGreaterThan(20);
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
describe("FlowEvents", () => {
|
|
50
|
-
it("should define node click event", () => {
|
|
51
|
-
const event = {
|
|
52
|
-
node: { id: "n1", type: "default", position: { x: 0, y: 0 }, data: {} },
|
|
53
|
-
nativeEvent: new MouseEvent("click")
|
|
54
|
-
};
|
|
55
|
-
expect(event.node.id).toBe("n1");
|
|
56
|
-
});
|
|
57
|
-
it("should define node drag event", () => {
|
|
58
|
-
const event = {
|
|
59
|
-
node: { id: "n1", type: "default", position: { x: 0, y: 0 }, data: {} },
|
|
60
|
-
nativeEvent: new MouseEvent("mousedown"),
|
|
61
|
-
position: { x: 100, y: 200 }
|
|
62
|
-
};
|
|
63
|
-
expect(event.position.x).toBe(100);
|
|
64
|
-
});
|
|
65
|
-
it("should define edge connect event", () => {
|
|
66
|
-
const event = {
|
|
67
|
-
connection: {
|
|
68
|
-
source: "n1",
|
|
69
|
-
target: "n2",
|
|
70
|
-
sourceHandle: "right",
|
|
71
|
-
targetHandle: "left"
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
expect(event.connection.source).toBe("n1");
|
|
75
|
-
expect(event.connection.target).toBe("n2");
|
|
76
|
-
});
|
|
77
|
-
it("should define viewport change event", () => {
|
|
78
|
-
const event = {
|
|
79
|
-
transform: { x: 100, y: 50, zoom: 1.5 }
|
|
80
|
-
};
|
|
81
|
-
expect(event.transform.zoom).toBe(1.5);
|
|
82
|
-
});
|
|
83
|
-
it("should define selection change event", () => {
|
|
84
|
-
const event = {
|
|
85
|
-
selectedNodes: [
|
|
86
|
-
{ id: "n1", type: "default", position: { x: 0, y: 0 }, data: {} }
|
|
87
|
-
],
|
|
88
|
-
selectedEdges: []
|
|
89
|
-
};
|
|
90
|
-
expect(event.selectedNodes.length).toBe(1);
|
|
91
|
-
});
|
|
92
|
-
it("should define pane click event", () => {
|
|
93
|
-
const event = {
|
|
94
|
-
nativeEvent: new MouseEvent("click")
|
|
95
|
-
};
|
|
96
|
-
expect(event.nativeEvent).toBeDefined();
|
|
97
|
-
});
|
|
98
|
-
it("should define connect start event", () => {
|
|
99
|
-
const event = {
|
|
100
|
-
connection: { source: "n1", target: "n2" },
|
|
101
|
-
nativeEvent: new MouseEvent("mousedown")
|
|
102
|
-
};
|
|
103
|
-
expect(event.connection).toBeDefined();
|
|
104
|
-
});
|
|
105
|
-
it("should define connect cancel event", () => {
|
|
106
|
-
const event = void 0;
|
|
107
|
-
expect(event).toBeUndefined();
|
|
108
|
-
});
|
|
109
|
-
});
|
|
110
|
-
describe("FlowEventHandler", () => {
|
|
111
|
-
it("should define handler for node click", () => {
|
|
112
|
-
const handler = (event) => {
|
|
113
|
-
expect(event.node.id).toBeDefined();
|
|
114
|
-
};
|
|
115
|
-
expect(typeof handler).toBe("function");
|
|
116
|
-
});
|
|
117
|
-
it("should define handler for void event", () => {
|
|
118
|
-
const handler = () => {
|
|
119
|
-
};
|
|
120
|
-
expect(typeof handler).toBe("function");
|
|
121
|
-
});
|
|
122
|
-
it("should define handler for viewport change", () => {
|
|
123
|
-
const handler = (event) => {
|
|
124
|
-
expect(event.transform).toBeDefined();
|
|
125
|
-
};
|
|
126
|
-
expect(typeof handler).toBe("function");
|
|
127
|
-
});
|
|
128
|
-
});
|
|
129
|
-
describe("EventBus", () => {
|
|
130
|
-
it("should define EventBus interface", () => {
|
|
131
|
-
const bus = {
|
|
132
|
-
on: () => {
|
|
133
|
-
},
|
|
134
|
-
off: () => {
|
|
135
|
-
},
|
|
136
|
-
emit: () => {
|
|
137
|
-
},
|
|
138
|
-
once: () => {
|
|
139
|
-
},
|
|
140
|
-
clear: () => {
|
|
141
|
-
}
|
|
142
|
-
};
|
|
143
|
-
expect(typeof bus.on).toBe("function");
|
|
144
|
-
expect(typeof bus.off).toBe("function");
|
|
145
|
-
expect(typeof bus.emit).toBe("function");
|
|
146
|
-
expect(typeof bus.once).toBe("function");
|
|
147
|
-
expect(typeof bus.clear).toBe("function");
|
|
148
|
-
});
|
|
149
|
-
});
|
|
150
|
-
describe("SelectionRect", () => {
|
|
151
|
-
it("should define selection rectangle", () => {
|
|
152
|
-
const rect = {
|
|
153
|
-
x: 100,
|
|
154
|
-
y: 200,
|
|
155
|
-
width: 300,
|
|
156
|
-
height: 150
|
|
157
|
-
};
|
|
158
|
-
expect(rect.x).toBe(100);
|
|
159
|
-
expect(rect.y).toBe(200);
|
|
160
|
-
expect(rect.width).toBe(300);
|
|
161
|
-
expect(rect.height).toBe(150);
|
|
162
|
-
});
|
|
163
|
-
it("should allow negative coordinates", () => {
|
|
164
|
-
const rect = {
|
|
165
|
-
x: -50,
|
|
166
|
-
y: -100,
|
|
167
|
-
width: 200,
|
|
168
|
-
height: 100
|
|
169
|
-
};
|
|
170
|
-
expect(rect.x).toBe(-50);
|
|
171
|
-
expect(rect.y).toBe(-100);
|
|
172
|
-
});
|
|
173
|
-
it("should allow zero dimensions", () => {
|
|
174
|
-
const rect = {
|
|
175
|
-
x: 0,
|
|
176
|
-
y: 0,
|
|
177
|
-
width: 0,
|
|
178
|
-
height: 0
|
|
179
|
-
};
|
|
180
|
-
expect(rect.width).toBe(0);
|
|
181
|
-
expect(rect.height).toBe(0);
|
|
182
|
-
});
|
|
183
|
-
});
|
|
184
|
-
});
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _vitest = require("vitest");
|
|
4
|
-
var _vue = require("vue");
|
|
5
|
-
var _export = require("../plugins/plugins/export.cjs");
|
|
6
|
-
var screenshot = _interopRequireWildcard(require("../utils/screenshot.cjs"));
|
|
7
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
8
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
9
|
-
_vitest.vi.mock("../utils/screenshot", () => ({
|
|
10
|
-
captureElement: _vitest.vi.fn().mockResolvedValue({
|
|
11
|
-
dataUrl: "data:image/png;base64,xx",
|
|
12
|
-
blob: new Blob(),
|
|
13
|
-
extension: "png"
|
|
14
|
-
}),
|
|
15
|
-
triggerDownload: _vitest.vi.fn(),
|
|
16
|
-
copyBlobToClipboard: _vitest.vi.fn().mockResolvedValue(void 0)
|
|
17
|
-
}));
|
|
18
|
-
function createMockFlow(overrides = {}) {
|
|
19
|
-
const nodes = (0, _vue.ref)([]);
|
|
20
|
-
const edges = (0, _vue.ref)([]);
|
|
21
|
-
const viewport = (0, _vue.ref)({
|
|
22
|
-
x: 0,
|
|
23
|
-
y: 0,
|
|
24
|
-
zoom: 1
|
|
25
|
-
});
|
|
26
|
-
const el = document.createElement("div");
|
|
27
|
-
return {
|
|
28
|
-
nodes,
|
|
29
|
-
edges,
|
|
30
|
-
viewport,
|
|
31
|
-
draggingNodeId: (0, _vue.ref)(null),
|
|
32
|
-
addNode: _vitest.vi.fn(),
|
|
33
|
-
removeNode: _vitest.vi.fn(),
|
|
34
|
-
updateNode: _vitest.vi.fn(),
|
|
35
|
-
getNode: _vitest.vi.fn(),
|
|
36
|
-
addEdge: _vitest.vi.fn(),
|
|
37
|
-
removeEdge: _vitest.vi.fn(),
|
|
38
|
-
updateEdge: _vitest.vi.fn(),
|
|
39
|
-
getEdge: _vitest.vi.fn(),
|
|
40
|
-
setViewport: _vitest.vi.fn(),
|
|
41
|
-
fitView: _vitest.vi.fn(),
|
|
42
|
-
zoomIn: _vitest.vi.fn(),
|
|
43
|
-
zoomOut: _vitest.vi.fn(),
|
|
44
|
-
centerView: _vitest.vi.fn(),
|
|
45
|
-
selectNode: _vitest.vi.fn(),
|
|
46
|
-
selectEdge: _vitest.vi.fn(),
|
|
47
|
-
clearSelection: _vitest.vi.fn(),
|
|
48
|
-
getNodes: _vitest.vi.fn(() => nodes.value),
|
|
49
|
-
getEdges: _vitest.vi.fn(() => edges.value),
|
|
50
|
-
getViewport: _vitest.vi.fn(() => viewport.value),
|
|
51
|
-
screenToCanvas: _vitest.vi.fn(),
|
|
52
|
-
canvasToScreen: _vitest.vi.fn(),
|
|
53
|
-
on: _vitest.vi.fn(),
|
|
54
|
-
off: _vitest.vi.fn(),
|
|
55
|
-
emit: _vitest.vi.fn(),
|
|
56
|
-
isValidConnection: _vitest.vi.fn(() => true),
|
|
57
|
-
$el: el,
|
|
58
|
-
usePlugin: _vitest.vi.fn(),
|
|
59
|
-
removePlugin: _vitest.vi.fn(),
|
|
60
|
-
...overrides
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
(0, _vitest.describe)("flow export plugin exportImage", () => {
|
|
64
|
-
(0, _vitest.beforeEach)(() => {
|
|
65
|
-
_vitest.vi.mocked(screenshot.captureElement).mockClear();
|
|
66
|
-
_vitest.vi.mocked(screenshot.triggerDownload).mockClear();
|
|
67
|
-
_vitest.vi.mocked(screenshot.copyBlobToClipboard).mockClear();
|
|
68
|
-
});
|
|
69
|
-
(0, _vitest.afterEach)(() => {
|
|
70
|
-
_vitest.vi.clearAllMocks();
|
|
71
|
-
});
|
|
72
|
-
(0, _vitest.it)("captures viewport and triggers download by default", async () => {
|
|
73
|
-
const flow = createMockFlow();
|
|
74
|
-
const plugin = (0, _export.createExportPlugin)({
|
|
75
|
-
fileName: "chart"
|
|
76
|
-
});
|
|
77
|
-
plugin.install(flow);
|
|
78
|
-
await flow.exportImage();
|
|
79
|
-
(0, _vitest.expect)(screenshot.captureElement).toHaveBeenCalled();
|
|
80
|
-
(0, _vitest.expect)(screenshot.triggerDownload).toHaveBeenCalled();
|
|
81
|
-
});
|
|
82
|
-
(0, _vitest.it)("throws when no container is available", async () => {
|
|
83
|
-
const flow = createMockFlow({
|
|
84
|
-
$el: void 0
|
|
85
|
-
});
|
|
86
|
-
const plugin = (0, _export.createExportPlugin)();
|
|
87
|
-
plugin.install(flow);
|
|
88
|
-
await (0, _vitest.expect)(flow.exportImage()).rejects.toThrow(/No element found/);
|
|
89
|
-
});
|
|
90
|
-
(0, _vitest.it)("uses explicit HTMLElement as capture target", async () => {
|
|
91
|
-
const flow = createMockFlow({
|
|
92
|
-
$el: void 0
|
|
93
|
-
});
|
|
94
|
-
const plugin = (0, _export.createExportPlugin)();
|
|
95
|
-
plugin.install(flow);
|
|
96
|
-
const box = document.createElement("div");
|
|
97
|
-
await flow.exportImage(box);
|
|
98
|
-
(0, _vitest.expect)(screenshot.captureElement).toHaveBeenCalledWith(box, _vitest.expect.objectContaining({
|
|
99
|
-
imageType: "png",
|
|
100
|
-
pixelRatio: 2
|
|
101
|
-
}));
|
|
102
|
-
});
|
|
103
|
-
(0, _vitest.it)("skips download when download: false", async () => {
|
|
104
|
-
const flow = createMockFlow();
|
|
105
|
-
const plugin = (0, _export.createExportPlugin)();
|
|
106
|
-
plugin.install(flow);
|
|
107
|
-
await flow.exportImage({
|
|
108
|
-
download: false
|
|
109
|
-
});
|
|
110
|
-
(0, _vitest.expect)(screenshot.triggerDownload).not.toHaveBeenCalled();
|
|
111
|
-
});
|
|
112
|
-
(0, _vitest.it)("copies to clipboard when copyToClipboard is true", async () => {
|
|
113
|
-
const flow = createMockFlow();
|
|
114
|
-
const plugin = (0, _export.createExportPlugin)();
|
|
115
|
-
plugin.install(flow);
|
|
116
|
-
await flow.exportImage({
|
|
117
|
-
copyToClipboard: true
|
|
118
|
-
});
|
|
119
|
-
(0, _vitest.expect)(screenshot.copyBlobToClipboard).toHaveBeenCalled();
|
|
120
|
-
});
|
|
121
|
-
(0, _vitest.it)("uses full mode with fitView and restores viewport", async () => {
|
|
122
|
-
const vp = {
|
|
123
|
-
x: 1,
|
|
124
|
-
y: 2,
|
|
125
|
-
zoom: 1.5
|
|
126
|
-
};
|
|
127
|
-
const flow = createMockFlow({
|
|
128
|
-
getViewport: _vitest.vi.fn(() => vp),
|
|
129
|
-
fitView: _vitest.vi.fn()
|
|
130
|
-
});
|
|
131
|
-
const plugin = (0, _export.createExportPlugin)();
|
|
132
|
-
plugin.install(flow);
|
|
133
|
-
await flow.exportImage({
|
|
134
|
-
mode: "full",
|
|
135
|
-
fullModePadding: 12
|
|
136
|
-
});
|
|
137
|
-
(0, _vitest.expect)(flow.fitView).toHaveBeenCalledWith({
|
|
138
|
-
padding: 12
|
|
139
|
-
});
|
|
140
|
-
(0, _vitest.expect)(flow.setViewport).toHaveBeenCalledWith(vp);
|
|
141
|
-
});
|
|
142
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
|
|
2
|
-
import { ref } from "vue";
|
|
3
|
-
import { createExportPlugin } from "../plugins/plugins/export.mjs";
|
|
4
|
-
import * as screenshot from "../utils/screenshot.mjs";
|
|
5
|
-
vi.mock("../utils/screenshot", () => ({
|
|
6
|
-
captureElement: vi.fn().mockResolvedValue({
|
|
7
|
-
dataUrl: "data:image/png;base64,xx",
|
|
8
|
-
blob: new Blob(),
|
|
9
|
-
extension: "png"
|
|
10
|
-
}),
|
|
11
|
-
triggerDownload: vi.fn(),
|
|
12
|
-
copyBlobToClipboard: vi.fn().mockResolvedValue(void 0)
|
|
13
|
-
}));
|
|
14
|
-
function createMockFlow(overrides = {}) {
|
|
15
|
-
const nodes = ref([]);
|
|
16
|
-
const edges = ref([]);
|
|
17
|
-
const viewport = ref({ x: 0, y: 0, zoom: 1 });
|
|
18
|
-
const el = document.createElement("div");
|
|
19
|
-
return {
|
|
20
|
-
nodes,
|
|
21
|
-
edges,
|
|
22
|
-
viewport,
|
|
23
|
-
draggingNodeId: ref(null),
|
|
24
|
-
addNode: vi.fn(),
|
|
25
|
-
removeNode: vi.fn(),
|
|
26
|
-
updateNode: vi.fn(),
|
|
27
|
-
getNode: vi.fn(),
|
|
28
|
-
addEdge: vi.fn(),
|
|
29
|
-
removeEdge: vi.fn(),
|
|
30
|
-
updateEdge: vi.fn(),
|
|
31
|
-
getEdge: vi.fn(),
|
|
32
|
-
setViewport: vi.fn(),
|
|
33
|
-
fitView: vi.fn(),
|
|
34
|
-
zoomIn: vi.fn(),
|
|
35
|
-
zoomOut: vi.fn(),
|
|
36
|
-
centerView: vi.fn(),
|
|
37
|
-
selectNode: vi.fn(),
|
|
38
|
-
selectEdge: vi.fn(),
|
|
39
|
-
clearSelection: vi.fn(),
|
|
40
|
-
getNodes: vi.fn(() => nodes.value),
|
|
41
|
-
getEdges: vi.fn(() => edges.value),
|
|
42
|
-
getViewport: vi.fn(() => viewport.value),
|
|
43
|
-
screenToCanvas: vi.fn(),
|
|
44
|
-
canvasToScreen: vi.fn(),
|
|
45
|
-
on: vi.fn(),
|
|
46
|
-
off: vi.fn(),
|
|
47
|
-
emit: vi.fn(),
|
|
48
|
-
isValidConnection: vi.fn(() => true),
|
|
49
|
-
$el: el,
|
|
50
|
-
usePlugin: vi.fn(),
|
|
51
|
-
removePlugin: vi.fn(),
|
|
52
|
-
...overrides
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
describe("flow export plugin exportImage", () => {
|
|
56
|
-
beforeEach(() => {
|
|
57
|
-
vi.mocked(screenshot.captureElement).mockClear();
|
|
58
|
-
vi.mocked(screenshot.triggerDownload).mockClear();
|
|
59
|
-
vi.mocked(screenshot.copyBlobToClipboard).mockClear();
|
|
60
|
-
});
|
|
61
|
-
afterEach(() => {
|
|
62
|
-
vi.clearAllMocks();
|
|
63
|
-
});
|
|
64
|
-
it("captures viewport and triggers download by default", async () => {
|
|
65
|
-
const flow = createMockFlow();
|
|
66
|
-
const plugin = createExportPlugin({ fileName: "chart" });
|
|
67
|
-
plugin.install(flow);
|
|
68
|
-
await flow.exportImage();
|
|
69
|
-
expect(screenshot.captureElement).toHaveBeenCalled();
|
|
70
|
-
expect(screenshot.triggerDownload).toHaveBeenCalled();
|
|
71
|
-
});
|
|
72
|
-
it("throws when no container is available", async () => {
|
|
73
|
-
const flow = createMockFlow({ $el: void 0 });
|
|
74
|
-
const plugin = createExportPlugin();
|
|
75
|
-
plugin.install(flow);
|
|
76
|
-
await expect(flow.exportImage()).rejects.toThrow(/No element found/);
|
|
77
|
-
});
|
|
78
|
-
it("uses explicit HTMLElement as capture target", async () => {
|
|
79
|
-
const flow = createMockFlow({ $el: void 0 });
|
|
80
|
-
const plugin = createExportPlugin();
|
|
81
|
-
plugin.install(flow);
|
|
82
|
-
const box = document.createElement("div");
|
|
83
|
-
await flow.exportImage(box);
|
|
84
|
-
expect(screenshot.captureElement).toHaveBeenCalledWith(
|
|
85
|
-
box,
|
|
86
|
-
expect.objectContaining({
|
|
87
|
-
imageType: "png",
|
|
88
|
-
pixelRatio: 2
|
|
89
|
-
})
|
|
90
|
-
);
|
|
91
|
-
});
|
|
92
|
-
it("skips download when download: false", async () => {
|
|
93
|
-
const flow = createMockFlow();
|
|
94
|
-
const plugin = createExportPlugin();
|
|
95
|
-
plugin.install(flow);
|
|
96
|
-
await flow.exportImage({ download: false });
|
|
97
|
-
expect(screenshot.triggerDownload).not.toHaveBeenCalled();
|
|
98
|
-
});
|
|
99
|
-
it("copies to clipboard when copyToClipboard is true", async () => {
|
|
100
|
-
const flow = createMockFlow();
|
|
101
|
-
const plugin = createExportPlugin();
|
|
102
|
-
plugin.install(flow);
|
|
103
|
-
await flow.exportImage({ copyToClipboard: true });
|
|
104
|
-
expect(screenshot.copyBlobToClipboard).toHaveBeenCalled();
|
|
105
|
-
});
|
|
106
|
-
it("uses full mode with fitView and restores viewport", async () => {
|
|
107
|
-
const vp = { x: 1, y: 2, zoom: 1.5 };
|
|
108
|
-
const flow = createMockFlow({
|
|
109
|
-
getViewport: vi.fn(() => vp),
|
|
110
|
-
fitView: vi.fn()
|
|
111
|
-
});
|
|
112
|
-
const plugin = createExportPlugin();
|
|
113
|
-
plugin.install(flow);
|
|
114
|
-
await flow.exportImage({ mode: "full", fullModePadding: 12 });
|
|
115
|
-
expect(flow.fitView).toHaveBeenCalledWith({ padding: 12 });
|
|
116
|
-
expect(flow.setViewport).toHaveBeenCalledWith(vp);
|
|
117
|
-
});
|
|
118
|
-
});
|