@marktoflow/gui 2.0.0-alpha.12 → 2.0.0-alpha.13

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 (121) hide show
  1. package/package.json +1 -3
  2. package/.marktoflow/state/workflow-state.db +0 -0
  3. package/.marktoflow/state/workflow-state.db-shm +0 -0
  4. package/.marktoflow/state/workflow-state.db-wal +0 -0
  5. package/.turbo/turbo-build.log +0 -42
  6. package/.turbo/turbo-test.log +0 -38
  7. package/marktoflow-gui-2.0.0-alpha.12.tgz +0 -0
  8. package/playwright.config.ts +0 -27
  9. package/postcss.config.js +0 -6
  10. package/src/client/App.tsx +0 -520
  11. package/src/client/components/Canvas/Canvas.tsx +0 -425
  12. package/src/client/components/Canvas/ExecutionOverlay.tsx +0 -935
  13. package/src/client/components/Canvas/ForEachNode.tsx +0 -152
  14. package/src/client/components/Canvas/IfElseNode.tsx +0 -141
  15. package/src/client/components/Canvas/NodeContextMenu.tsx +0 -192
  16. package/src/client/components/Canvas/OutputNode.tsx +0 -111
  17. package/src/client/components/Canvas/ParallelNode.tsx +0 -157
  18. package/src/client/components/Canvas/StepNode.tsx +0 -106
  19. package/src/client/components/Canvas/SubWorkflowNode.tsx +0 -141
  20. package/src/client/components/Canvas/SwitchNode.tsx +0 -185
  21. package/src/client/components/Canvas/Toolbar.tsx +0 -227
  22. package/src/client/components/Canvas/TransformNode.tsx +0 -194
  23. package/src/client/components/Canvas/TriggerNode.tsx +0 -128
  24. package/src/client/components/Canvas/TryCatchNode.tsx +0 -164
  25. package/src/client/components/Canvas/WhileNode.tsx +0 -161
  26. package/src/client/components/Canvas/index.ts +0 -24
  27. package/src/client/components/Debug/VariableInspector.tsx +0 -148
  28. package/src/client/components/Editor/InputsEditor.tsx +0 -458
  29. package/src/client/components/Editor/NewStepWizard.tsx +0 -344
  30. package/src/client/components/Editor/StepEditor.tsx +0 -532
  31. package/src/client/components/Editor/YamlEditor.tsx +0 -160
  32. package/src/client/components/Panels/PropertiesPanel.tsx +0 -589
  33. package/src/client/components/Prompt/ChangePreview.tsx +0 -281
  34. package/src/client/components/Prompt/PromptHistoryPanel.tsx +0 -209
  35. package/src/client/components/Prompt/PromptInput.tsx +0 -110
  36. package/src/client/components/Settings/ProviderSwitcher.tsx +0 -228
  37. package/src/client/components/Sidebar/ImportDialog.tsx +0 -257
  38. package/src/client/components/Sidebar/Sidebar.tsx +0 -362
  39. package/src/client/components/common/Breadcrumb.tsx +0 -40
  40. package/src/client/components/common/Button.tsx +0 -68
  41. package/src/client/components/common/ContextMenu.tsx +0 -202
  42. package/src/client/components/common/KeyboardShortcuts.tsx +0 -149
  43. package/src/client/components/common/Modal.tsx +0 -93
  44. package/src/client/components/common/Tabs.tsx +0 -57
  45. package/src/client/components/common/ThemeToggle.tsx +0 -63
  46. package/src/client/components/index.ts +0 -32
  47. package/src/client/hooks/index.ts +0 -4
  48. package/src/client/hooks/useAIPrompt.ts +0 -108
  49. package/src/client/hooks/useCanvas.ts +0 -247
  50. package/src/client/hooks/useWebSocket.ts +0 -164
  51. package/src/client/hooks/useWorkflow.ts +0 -138
  52. package/src/client/main.tsx +0 -10
  53. package/src/client/stores/agentStore.ts +0 -109
  54. package/src/client/stores/canvasStore.ts +0 -348
  55. package/src/client/stores/editorStore.ts +0 -133
  56. package/src/client/stores/executionStore.ts +0 -502
  57. package/src/client/stores/index.ts +0 -4
  58. package/src/client/stores/layoutStore.ts +0 -103
  59. package/src/client/stores/navigationStore.ts +0 -49
  60. package/src/client/stores/promptStore.ts +0 -113
  61. package/src/client/stores/themeStore.ts +0 -75
  62. package/src/client/stores/workflowStore.ts +0 -185
  63. package/src/client/styles/globals.css +0 -452
  64. package/src/client/utils/cn.ts +0 -9
  65. package/src/client/utils/index.ts +0 -4
  66. package/src/client/utils/platform.ts +0 -46
  67. package/src/client/utils/serviceIcons.tsx +0 -97
  68. package/src/client/utils/stepValidation.ts +0 -155
  69. package/src/client/utils/workflowToGraph.ts +0 -523
  70. package/src/server/index.ts +0 -137
  71. package/src/server/routes/ai.ts +0 -91
  72. package/src/server/routes/execute.ts +0 -71
  73. package/src/server/routes/executions.ts +0 -136
  74. package/src/server/routes/tools.ts +0 -970
  75. package/src/server/routes/workflows.ts +0 -147
  76. package/src/server/services/AIService.ts +0 -105
  77. package/src/server/services/FileWatcher.ts +0 -69
  78. package/src/server/services/WorkflowService.ts +0 -601
  79. package/src/server/services/agents/claude-code-provider.ts +0 -320
  80. package/src/server/services/agents/claude-provider.ts +0 -248
  81. package/src/server/services/agents/codex-provider.ts +0 -398
  82. package/src/server/services/agents/copilot-provider.ts +0 -311
  83. package/src/server/services/agents/demo-provider.ts +0 -184
  84. package/src/server/services/agents/index.ts +0 -31
  85. package/src/server/services/agents/ollama-provider.ts +0 -267
  86. package/src/server/services/agents/prompts.ts +0 -509
  87. package/src/server/services/agents/registry.ts +0 -310
  88. package/src/server/services/agents/types.ts +0 -146
  89. package/src/server/websocket/index.ts +0 -117
  90. package/src/shared/constants.ts +0 -180
  91. package/src/shared/types.ts +0 -179
  92. package/tailwind.config.ts +0 -73
  93. package/tests/e2e/app.spec.ts +0 -90
  94. package/tests/e2e/canvas.spec.ts +0 -128
  95. package/tests/e2e/workflow.spec.ts +0 -185
  96. package/tests/integration/api.test.ts +0 -452
  97. package/tests/integration/testApp.ts +0 -31
  98. package/tests/setup.ts +0 -72
  99. package/tests/unit/ForEachNode.test.tsx +0 -308
  100. package/tests/unit/IfElseNode.test.tsx +0 -235
  101. package/tests/unit/ParallelNode.test.tsx +0 -344
  102. package/tests/unit/SwitchNode.test.tsx +0 -327
  103. package/tests/unit/TransformNode.test.tsx +0 -386
  104. package/tests/unit/TryCatchNode.test.tsx +0 -243
  105. package/tests/unit/WhileNode.test.tsx +0 -230
  106. package/tests/unit/agentStore.test.ts +0 -218
  107. package/tests/unit/canvasStore.test.ts +0 -502
  108. package/tests/unit/codexProvider.test.ts +0 -399
  109. package/tests/unit/components.test.tsx +0 -151
  110. package/tests/unit/executionStore.test.ts +0 -567
  111. package/tests/unit/layoutStore.test.ts +0 -194
  112. package/tests/unit/navigationStore.test.ts +0 -152
  113. package/tests/unit/platform.test.ts +0 -118
  114. package/tests/unit/serviceIcons.test.ts +0 -197
  115. package/tests/unit/stepValidation.test.ts +0 -226
  116. package/tests/unit/themeStore.test.ts +0 -141
  117. package/tests/unit/workflowToGraph.test.ts +0 -311
  118. package/tsconfig.json +0 -29
  119. package/tsconfig.server.json +0 -28
  120. package/vite.config.ts +0 -31
  121. package/vitest.config.ts +0 -26
@@ -1,502 +0,0 @@
1
- import { describe, it, expect, beforeEach } from 'vitest';
2
- import { useCanvasStore } from '../../src/client/stores/canvasStore';
3
- import type { Node, Edge } from '@xyflow/react';
4
-
5
- describe('canvasStore', () => {
6
- beforeEach(() => {
7
- // Reset store state before each test
8
- useCanvasStore.setState({
9
- nodes: [],
10
- edges: [],
11
- past: [],
12
- future: [],
13
- clipboard: null,
14
- });
15
- });
16
-
17
- describe('setNodes', () => {
18
- it('should set nodes', () => {
19
- const { setNodes } = useCanvasStore.getState();
20
-
21
- const nodes: Node[] = [
22
- { id: 'node-1', position: { x: 0, y: 0 }, data: { label: 'Node 1' } },
23
- { id: 'node-2', position: { x: 100, y: 100 }, data: { label: 'Node 2' } },
24
- ];
25
-
26
- setNodes(nodes);
27
-
28
- const state = useCanvasStore.getState();
29
- expect(state.nodes).toHaveLength(2);
30
- expect(state.nodes[0].id).toBe('node-1');
31
- expect(state.nodes[1].id).toBe('node-2');
32
- });
33
-
34
- it('should replace existing nodes', () => {
35
- const { setNodes } = useCanvasStore.getState();
36
-
37
- setNodes([{ id: 'old-node', position: { x: 0, y: 0 }, data: {} }]);
38
- setNodes([{ id: 'new-node', position: { x: 0, y: 0 }, data: {} }]);
39
-
40
- const state = useCanvasStore.getState();
41
- expect(state.nodes).toHaveLength(1);
42
- expect(state.nodes[0].id).toBe('new-node');
43
- });
44
- });
45
-
46
- describe('setEdges', () => {
47
- it('should set edges', () => {
48
- const { setEdges } = useCanvasStore.getState();
49
-
50
- const edges: Edge[] = [
51
- { id: 'e-1-2', source: 'node-1', target: 'node-2' },
52
- { id: 'e-2-3', source: 'node-2', target: 'node-3' },
53
- ];
54
-
55
- setEdges(edges);
56
-
57
- const state = useCanvasStore.getState();
58
- expect(state.edges).toHaveLength(2);
59
- expect(state.edges[0].source).toBe('node-1');
60
- expect(state.edges[1].target).toBe('node-3');
61
- });
62
- });
63
-
64
- describe('updateNodeData', () => {
65
- it('should update data for a specific node', () => {
66
- const { setNodes, updateNodeData } = useCanvasStore.getState();
67
-
68
- setNodes([
69
- { id: 'node-1', position: { x: 0, y: 0 }, data: { status: 'pending', name: 'Test' } },
70
- { id: 'node-2', position: { x: 100, y: 100 }, data: { status: 'pending' } },
71
- ]);
72
-
73
- updateNodeData('node-1', { status: 'completed' });
74
-
75
- const state = useCanvasStore.getState();
76
- expect(state.nodes[0].data.status).toBe('completed');
77
- expect(state.nodes[0].data.name).toBe('Test'); // Should preserve other data
78
- expect(state.nodes[1].data.status).toBe('pending'); // Other nodes unchanged
79
- });
80
-
81
- it('should not affect non-existent nodes', () => {
82
- const { setNodes, updateNodeData } = useCanvasStore.getState();
83
-
84
- setNodes([{ id: 'node-1', position: { x: 0, y: 0 }, data: { value: 1 } }]);
85
-
86
- updateNodeData('non-existent', { value: 2 });
87
-
88
- const state = useCanvasStore.getState();
89
- expect(state.nodes).toHaveLength(1);
90
- expect(state.nodes[0].data.value).toBe(1);
91
- });
92
- });
93
-
94
- describe('clearCanvas', () => {
95
- it('should clear all nodes and edges', () => {
96
- const { setNodes, setEdges, clearCanvas } = useCanvasStore.getState();
97
-
98
- setNodes([
99
- { id: 'node-1', position: { x: 0, y: 0 }, data: {} },
100
- { id: 'node-2', position: { x: 100, y: 100 }, data: {} },
101
- ]);
102
- setEdges([{ id: 'e-1-2', source: 'node-1', target: 'node-2' }]);
103
-
104
- clearCanvas();
105
-
106
- const state = useCanvasStore.getState();
107
- expect(state.nodes).toHaveLength(0);
108
- expect(state.edges).toHaveLength(0);
109
- });
110
- });
111
-
112
- describe('onNodesChange', () => {
113
- it('should apply position changes to nodes', () => {
114
- const { setNodes, onNodesChange } = useCanvasStore.getState();
115
-
116
- setNodes([{ id: 'node-1', position: { x: 0, y: 0 }, data: {} }]);
117
-
118
- onNodesChange([
119
- {
120
- type: 'position',
121
- id: 'node-1',
122
- position: { x: 50, y: 75 },
123
- dragging: false,
124
- },
125
- ]);
126
-
127
- const state = useCanvasStore.getState();
128
- expect(state.nodes[0].position).toEqual({ x: 50, y: 75 });
129
- });
130
-
131
- it('should handle node selection changes', () => {
132
- const { setNodes, onNodesChange } = useCanvasStore.getState();
133
-
134
- setNodes([
135
- { id: 'node-1', position: { x: 0, y: 0 }, data: {}, selected: false },
136
- ]);
137
-
138
- onNodesChange([
139
- {
140
- type: 'select',
141
- id: 'node-1',
142
- selected: true,
143
- },
144
- ]);
145
-
146
- const state = useCanvasStore.getState();
147
- expect(state.nodes[0].selected).toBe(true);
148
- });
149
-
150
- it('should handle node removal', () => {
151
- const { setNodes, onNodesChange } = useCanvasStore.getState();
152
-
153
- setNodes([
154
- { id: 'node-1', position: { x: 0, y: 0 }, data: {} },
155
- { id: 'node-2', position: { x: 100, y: 100 }, data: {} },
156
- ]);
157
-
158
- onNodesChange([
159
- {
160
- type: 'remove',
161
- id: 'node-1',
162
- },
163
- ]);
164
-
165
- const state = useCanvasStore.getState();
166
- expect(state.nodes).toHaveLength(1);
167
- expect(state.nodes[0].id).toBe('node-2');
168
- });
169
- });
170
-
171
- describe('onEdgesChange', () => {
172
- it('should handle edge removal', () => {
173
- const { setEdges, onEdgesChange } = useCanvasStore.getState();
174
-
175
- setEdges([
176
- { id: 'e-1', source: 'a', target: 'b' },
177
- { id: 'e-2', source: 'b', target: 'c' },
178
- ]);
179
-
180
- onEdgesChange([
181
- {
182
- type: 'remove',
183
- id: 'e-1',
184
- },
185
- ]);
186
-
187
- const state = useCanvasStore.getState();
188
- expect(state.edges).toHaveLength(1);
189
- expect(state.edges[0].id).toBe('e-2');
190
- });
191
- });
192
-
193
- describe('onConnect', () => {
194
- it('should add a new edge when connecting nodes', () => {
195
- const { setNodes, onConnect } = useCanvasStore.getState();
196
-
197
- setNodes([
198
- { id: 'node-1', position: { x: 0, y: 0 }, data: {} },
199
- { id: 'node-2', position: { x: 100, y: 100 }, data: {} },
200
- ]);
201
-
202
- onConnect({
203
- source: 'node-1',
204
- target: 'node-2',
205
- sourceHandle: null,
206
- targetHandle: null,
207
- });
208
-
209
- const state = useCanvasStore.getState();
210
- expect(state.edges).toHaveLength(1);
211
- expect(state.edges[0].source).toBe('node-1');
212
- expect(state.edges[0].target).toBe('node-2');
213
- expect(state.edges[0].animated).toBe(true);
214
- });
215
- });
216
-
217
- describe('undo/redo', () => {
218
- it('should undo node changes', () => {
219
- const { setNodes, undo, canUndo } = useCanvasStore.getState();
220
-
221
- // Set initial nodes
222
- setNodes([{ id: 'node-1', position: { x: 0, y: 0 }, data: {} }]);
223
-
224
- // Make a change
225
- useCanvasStore.getState().setNodes([
226
- { id: 'node-1', position: { x: 0, y: 0 }, data: {} },
227
- { id: 'node-2', position: { x: 100, y: 100 }, data: {} },
228
- ]);
229
-
230
- expect(useCanvasStore.getState().nodes).toHaveLength(2);
231
- expect(useCanvasStore.getState().canUndo()).toBe(true);
232
-
233
- // Undo
234
- useCanvasStore.getState().undo();
235
-
236
- const state = useCanvasStore.getState();
237
- expect(state.nodes).toHaveLength(1);
238
- expect(state.nodes[0].id).toBe('node-1');
239
- });
240
-
241
- it('should redo undone changes', () => {
242
- const { setNodes } = useCanvasStore.getState();
243
-
244
- // Set initial nodes
245
- setNodes([{ id: 'node-1', position: { x: 0, y: 0 }, data: {} }]);
246
-
247
- // Make a change
248
- useCanvasStore.getState().setNodes([
249
- { id: 'node-1', position: { x: 0, y: 0 }, data: {} },
250
- { id: 'node-2', position: { x: 100, y: 100 }, data: {} },
251
- ]);
252
-
253
- // Undo
254
- useCanvasStore.getState().undo();
255
- expect(useCanvasStore.getState().nodes).toHaveLength(1);
256
- expect(useCanvasStore.getState().canRedo()).toBe(true);
257
-
258
- // Redo
259
- useCanvasStore.getState().redo();
260
-
261
- const state = useCanvasStore.getState();
262
- expect(state.nodes).toHaveLength(2);
263
- expect(state.nodes[1].id).toBe('node-2');
264
- });
265
-
266
- it('should clear future on new changes', () => {
267
- const { setNodes } = useCanvasStore.getState();
268
-
269
- // Set initial nodes
270
- setNodes([{ id: 'node-1', position: { x: 0, y: 0 }, data: {} }]);
271
-
272
- // Make a change
273
- useCanvasStore.getState().setNodes([
274
- { id: 'node-1', position: { x: 0, y: 0 }, data: {} },
275
- { id: 'node-2', position: { x: 100, y: 100 }, data: {} },
276
- ]);
277
-
278
- // Undo
279
- useCanvasStore.getState().undo();
280
- expect(useCanvasStore.getState().canRedo()).toBe(true);
281
-
282
- // Make a new change - should clear future
283
- useCanvasStore.getState().setNodes([
284
- { id: 'node-1', position: { x: 0, y: 0 }, data: {} },
285
- { id: 'node-3', position: { x: 200, y: 200 }, data: {} },
286
- ]);
287
-
288
- expect(useCanvasStore.getState().canRedo()).toBe(false);
289
- });
290
-
291
- it('should handle multiple undo/redo steps', () => {
292
- const { setNodes } = useCanvasStore.getState();
293
-
294
- // Set initial nodes
295
- setNodes([{ id: 'node-1', position: { x: 0, y: 0 }, data: {} }]);
296
-
297
- // Make change 2
298
- useCanvasStore.getState().setNodes([
299
- { id: 'node-1', position: { x: 0, y: 0 }, data: {} },
300
- { id: 'node-2', position: { x: 100, y: 100 }, data: {} },
301
- ]);
302
-
303
- // Make change 3
304
- useCanvasStore.getState().setNodes([
305
- { id: 'node-1', position: { x: 0, y: 0 }, data: {} },
306
- { id: 'node-2', position: { x: 100, y: 100 }, data: {} },
307
- { id: 'node-3', position: { x: 200, y: 200 }, data: {} },
308
- ]);
309
-
310
- expect(useCanvasStore.getState().nodes).toHaveLength(3);
311
-
312
- // Undo twice
313
- useCanvasStore.getState().undo();
314
- expect(useCanvasStore.getState().nodes).toHaveLength(2);
315
-
316
- useCanvasStore.getState().undo();
317
- expect(useCanvasStore.getState().nodes).toHaveLength(1);
318
-
319
- // Redo twice
320
- useCanvasStore.getState().redo();
321
- expect(useCanvasStore.getState().nodes).toHaveLength(2);
322
-
323
- useCanvasStore.getState().redo();
324
- expect(useCanvasStore.getState().nodes).toHaveLength(3);
325
- });
326
-
327
- it('should not undo when history is empty', () => {
328
- const { setNodes } = useCanvasStore.getState();
329
-
330
- setNodes([{ id: 'node-1', position: { x: 0, y: 0 }, data: {} }]);
331
-
332
- // Clear past to simulate empty history
333
- useCanvasStore.setState({ past: [] });
334
-
335
- expect(useCanvasStore.getState().canUndo()).toBe(false);
336
-
337
- // Undo should do nothing
338
- useCanvasStore.getState().undo();
339
- expect(useCanvasStore.getState().nodes).toHaveLength(1);
340
- });
341
-
342
- it('should not redo when future is empty', () => {
343
- const { setNodes } = useCanvasStore.getState();
344
-
345
- setNodes([{ id: 'node-1', position: { x: 0, y: 0 }, data: {} }]);
346
-
347
- expect(useCanvasStore.getState().canRedo()).toBe(false);
348
-
349
- // Redo should do nothing
350
- useCanvasStore.getState().redo();
351
- expect(useCanvasStore.getState().nodes).toHaveLength(1);
352
- });
353
- });
354
-
355
- describe('copy/paste', () => {
356
- it('should copy selected nodes to clipboard', () => {
357
- useCanvasStore.setState({
358
- nodes: [
359
- { id: 'node-1', position: { x: 0, y: 0 }, data: {}, selected: true },
360
- { id: 'node-2', position: { x: 100, y: 100 }, data: {}, selected: false },
361
- ],
362
- edges: [],
363
- past: [],
364
- future: [],
365
- clipboard: null,
366
- });
367
-
368
- useCanvasStore.getState().copySelected();
369
-
370
- const { clipboard } = useCanvasStore.getState();
371
- expect(clipboard).not.toBeNull();
372
- expect(clipboard?.nodes).toHaveLength(1);
373
- expect(clipboard?.nodes[0].id).toBe('node-1');
374
- });
375
-
376
- it('should copy edges between selected nodes', () => {
377
- useCanvasStore.setState({
378
- nodes: [
379
- { id: 'node-1', position: { x: 0, y: 0 }, data: {}, selected: true },
380
- { id: 'node-2', position: { x: 100, y: 100 }, data: {}, selected: true },
381
- { id: 'node-3', position: { x: 200, y: 200 }, data: {}, selected: false },
382
- ],
383
- edges: [
384
- { id: 'e-1-2', source: 'node-1', target: 'node-2' },
385
- { id: 'e-2-3', source: 'node-2', target: 'node-3' },
386
- ],
387
- past: [],
388
- future: [],
389
- clipboard: null,
390
- });
391
-
392
- useCanvasStore.getState().copySelected();
393
-
394
- const { clipboard } = useCanvasStore.getState();
395
- expect(clipboard?.edges).toHaveLength(1);
396
- expect(clipboard?.edges[0].id).toBe('e-1-2');
397
- });
398
-
399
- it('should paste nodes with offset', () => {
400
- useCanvasStore.setState({
401
- nodes: [{ id: 'node-1', position: { x: 0, y: 0 }, data: { name: 'Test' }, selected: true }],
402
- edges: [],
403
- past: [],
404
- future: [],
405
- clipboard: null,
406
- });
407
-
408
- // Copy
409
- useCanvasStore.getState().copySelected();
410
-
411
- // Paste
412
- useCanvasStore.getState().paste({ x: 50, y: 50 });
413
-
414
- const { nodes } = useCanvasStore.getState();
415
- expect(nodes).toHaveLength(2);
416
-
417
- // Original node should be deselected
418
- expect(nodes[0].selected).toBe(false);
419
-
420
- // Pasted node should be selected and offset
421
- expect(nodes[1].selected).toBe(true);
422
- expect(nodes[1].position.x).toBe(50);
423
- expect(nodes[1].position.y).toBe(50);
424
- expect(nodes[1].id).not.toBe('node-1'); // New unique ID
425
- });
426
-
427
- it('should paste edges with updated references', () => {
428
- useCanvasStore.setState({
429
- nodes: [
430
- { id: 'node-1', position: { x: 0, y: 0 }, data: {}, selected: true },
431
- { id: 'node-2', position: { x: 100, y: 100 }, data: {}, selected: true },
432
- ],
433
- edges: [{ id: 'e-1-2', source: 'node-1', target: 'node-2' }],
434
- past: [],
435
- future: [],
436
- clipboard: null,
437
- });
438
-
439
- // Copy
440
- useCanvasStore.getState().copySelected();
441
-
442
- // Paste
443
- useCanvasStore.getState().paste();
444
-
445
- const { nodes, edges } = useCanvasStore.getState();
446
- expect(nodes).toHaveLength(4);
447
- expect(edges).toHaveLength(2);
448
-
449
- // Find the pasted edge
450
- const pastedEdge = edges.find((e) => e.id.includes('-copy-'));
451
- expect(pastedEdge).toBeDefined();
452
-
453
- // Pasted edge should reference pasted nodes
454
- expect(pastedEdge?.source).not.toBe('node-1');
455
- expect(pastedEdge?.target).not.toBe('node-2');
456
- });
457
-
458
- it('should return true for canPaste when clipboard has nodes', () => {
459
- useCanvasStore.setState({
460
- nodes: [{ id: 'node-1', position: { x: 0, y: 0 }, data: {}, selected: true }],
461
- edges: [],
462
- past: [],
463
- future: [],
464
- clipboard: null,
465
- });
466
-
467
- expect(useCanvasStore.getState().canPaste()).toBe(false);
468
-
469
- useCanvasStore.getState().copySelected();
470
-
471
- expect(useCanvasStore.getState().canPaste()).toBe(true);
472
- });
473
-
474
- it('should do nothing when copying with no selection', () => {
475
- useCanvasStore.setState({
476
- nodes: [{ id: 'node-1', position: { x: 0, y: 0 }, data: {}, selected: false }],
477
- edges: [],
478
- past: [],
479
- future: [],
480
- clipboard: null,
481
- });
482
-
483
- useCanvasStore.getState().copySelected();
484
-
485
- expect(useCanvasStore.getState().clipboard).toBeNull();
486
- });
487
-
488
- it('should do nothing when pasting with empty clipboard', () => {
489
- useCanvasStore.setState({
490
- nodes: [{ id: 'node-1', position: { x: 0, y: 0 }, data: {} }],
491
- edges: [],
492
- past: [],
493
- future: [],
494
- clipboard: null,
495
- });
496
-
497
- useCanvasStore.getState().paste();
498
-
499
- expect(useCanvasStore.getState().nodes).toHaveLength(1);
500
- });
501
- });
502
- });