@marktoflow/gui 2.0.0-alpha.5 → 2.0.1

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 (164) hide show
  1. package/README.md +48 -180
  2. package/client.log +0 -0
  3. package/dist/client/assets/index-DQeR1ew6.css +1 -0
  4. package/dist/client/assets/index-LbIVPHbD.js +833 -0
  5. package/dist/client/assets/index-LbIVPHbD.js.map +1 -0
  6. package/dist/client/index.html +2 -2
  7. package/dist/client/marktoflow-logo.png +0 -0
  8. package/dist/server/index.js +31 -5
  9. package/dist/server/index.js.map +1 -1
  10. package/dist/server/routes/admin.js +95 -0
  11. package/dist/server/routes/admin.js.map +1 -0
  12. package/dist/server/routes/ai.js +2 -2
  13. package/dist/server/routes/ai.js.map +1 -1
  14. package/dist/server/routes/collaboration.js +104 -0
  15. package/dist/server/routes/collaboration.js.map +1 -0
  16. package/dist/server/routes/execute.js +181 -14
  17. package/dist/server/routes/execute.js.map +1 -1
  18. package/dist/server/routes/form.js +160 -0
  19. package/dist/server/routes/form.js.map +1 -0
  20. package/dist/server/routes/settings.js +90 -0
  21. package/dist/server/routes/settings.js.map +1 -0
  22. package/dist/server/routes/templates.js +106 -0
  23. package/dist/server/routes/templates.js.map +1 -0
  24. package/dist/server/routes/versions.js +101 -0
  25. package/dist/server/routes/versions.js.map +1 -0
  26. package/dist/server/services/AIService.js +85 -2
  27. package/dist/server/services/AIService.js.map +1 -1
  28. package/dist/server/services/ExecutionManager.js +571 -0
  29. package/dist/server/services/ExecutionManager.js.map +1 -0
  30. package/dist/server/services/VersionService.js +65 -0
  31. package/dist/server/services/VersionService.js.map +1 -0
  32. package/dist/server/services/WorkflowService.js +8 -2
  33. package/dist/server/services/WorkflowService.js.map +1 -1
  34. package/dist/server/services/agents/copilot-provider.js +32 -0
  35. package/dist/server/services/agents/copilot-provider.js.map +1 -1
  36. package/dist/server/websocket/index.js +42 -0
  37. package/dist/server/websocket/index.js.map +1 -1
  38. package/dist/shared/constants.js +9 -0
  39. package/dist/shared/constants.js.map +1 -1
  40. package/dist/shared/settings.js +51 -0
  41. package/dist/shared/settings.js.map +1 -0
  42. package/package.json +14 -10
  43. package/public/marktoflow-logo.png +0 -0
  44. package/server.log +0 -0
  45. package/tests/integration/fixtures/test-workflow.md +6 -0
  46. package/.turbo/turbo-build.log +0 -42
  47. package/dist/client/assets/index-CM44OayM.js +0 -704
  48. package/dist/client/assets/index-CM44OayM.js.map +0 -1
  49. package/dist/client/assets/index-Dru63gi6.css +0 -1
  50. package/marktoflow-gui-2.0.0-alpha.5.tgz +0 -0
  51. package/playwright.config.ts +0 -27
  52. package/postcss.config.js +0 -6
  53. package/src/client/App.tsx +0 -520
  54. package/src/client/components/Canvas/Canvas.tsx +0 -425
  55. package/src/client/components/Canvas/ExecutionOverlay.tsx +0 -935
  56. package/src/client/components/Canvas/ForEachNode.tsx +0 -152
  57. package/src/client/components/Canvas/IfElseNode.tsx +0 -141
  58. package/src/client/components/Canvas/NodeContextMenu.tsx +0 -192
  59. package/src/client/components/Canvas/OutputNode.tsx +0 -111
  60. package/src/client/components/Canvas/ParallelNode.tsx +0 -157
  61. package/src/client/components/Canvas/StepNode.tsx +0 -106
  62. package/src/client/components/Canvas/SubWorkflowNode.tsx +0 -141
  63. package/src/client/components/Canvas/SwitchNode.tsx +0 -185
  64. package/src/client/components/Canvas/Toolbar.tsx +0 -227
  65. package/src/client/components/Canvas/TransformNode.tsx +0 -194
  66. package/src/client/components/Canvas/TriggerNode.tsx +0 -128
  67. package/src/client/components/Canvas/TryCatchNode.tsx +0 -164
  68. package/src/client/components/Canvas/WhileNode.tsx +0 -161
  69. package/src/client/components/Canvas/index.ts +0 -24
  70. package/src/client/components/Debug/VariableInspector.tsx +0 -148
  71. package/src/client/components/Editor/InputsEditor.tsx +0 -458
  72. package/src/client/components/Editor/NewStepWizard.tsx +0 -344
  73. package/src/client/components/Editor/StepEditor.tsx +0 -532
  74. package/src/client/components/Editor/YamlEditor.tsx +0 -160
  75. package/src/client/components/Panels/PropertiesPanel.tsx +0 -589
  76. package/src/client/components/Prompt/ChangePreview.tsx +0 -281
  77. package/src/client/components/Prompt/PromptHistoryPanel.tsx +0 -209
  78. package/src/client/components/Prompt/PromptInput.tsx +0 -110
  79. package/src/client/components/Settings/ProviderSwitcher.tsx +0 -228
  80. package/src/client/components/Sidebar/ImportDialog.tsx +0 -257
  81. package/src/client/components/Sidebar/Sidebar.tsx +0 -362
  82. package/src/client/components/common/Breadcrumb.tsx +0 -40
  83. package/src/client/components/common/Button.tsx +0 -68
  84. package/src/client/components/common/ContextMenu.tsx +0 -202
  85. package/src/client/components/common/KeyboardShortcuts.tsx +0 -149
  86. package/src/client/components/common/Modal.tsx +0 -93
  87. package/src/client/components/common/Tabs.tsx +0 -57
  88. package/src/client/components/common/ThemeToggle.tsx +0 -63
  89. package/src/client/components/index.ts +0 -32
  90. package/src/client/hooks/index.ts +0 -4
  91. package/src/client/hooks/useAIPrompt.ts +0 -108
  92. package/src/client/hooks/useCanvas.ts +0 -247
  93. package/src/client/hooks/useWebSocket.ts +0 -164
  94. package/src/client/hooks/useWorkflow.ts +0 -138
  95. package/src/client/main.tsx +0 -10
  96. package/src/client/stores/agentStore.ts +0 -109
  97. package/src/client/stores/canvasStore.ts +0 -348
  98. package/src/client/stores/editorStore.ts +0 -133
  99. package/src/client/stores/executionStore.ts +0 -502
  100. package/src/client/stores/index.ts +0 -4
  101. package/src/client/stores/layoutStore.ts +0 -103
  102. package/src/client/stores/navigationStore.ts +0 -49
  103. package/src/client/stores/promptStore.ts +0 -113
  104. package/src/client/stores/themeStore.ts +0 -75
  105. package/src/client/stores/workflowStore.ts +0 -185
  106. package/src/client/styles/globals.css +0 -452
  107. package/src/client/utils/cn.ts +0 -9
  108. package/src/client/utils/index.ts +0 -4
  109. package/src/client/utils/platform.ts +0 -46
  110. package/src/client/utils/serviceIcons.tsx +0 -97
  111. package/src/client/utils/stepValidation.ts +0 -155
  112. package/src/client/utils/workflowToGraph.ts +0 -523
  113. package/src/server/index.ts +0 -137
  114. package/src/server/routes/ai.ts +0 -91
  115. package/src/server/routes/execute.ts +0 -71
  116. package/src/server/routes/executions.ts +0 -136
  117. package/src/server/routes/tools.ts +0 -970
  118. package/src/server/routes/workflows.ts +0 -147
  119. package/src/server/services/AIService.ts +0 -105
  120. package/src/server/services/FileWatcher.ts +0 -69
  121. package/src/server/services/WorkflowService.ts +0 -601
  122. package/src/server/services/agents/claude-code-provider.ts +0 -320
  123. package/src/server/services/agents/claude-provider.ts +0 -248
  124. package/src/server/services/agents/codex-provider.ts +0 -398
  125. package/src/server/services/agents/copilot-provider.ts +0 -311
  126. package/src/server/services/agents/demo-provider.ts +0 -184
  127. package/src/server/services/agents/index.ts +0 -31
  128. package/src/server/services/agents/ollama-provider.ts +0 -267
  129. package/src/server/services/agents/prompts.ts +0 -509
  130. package/src/server/services/agents/registry.ts +0 -310
  131. package/src/server/services/agents/types.ts +0 -146
  132. package/src/server/websocket/index.ts +0 -117
  133. package/src/shared/constants.ts +0 -180
  134. package/src/shared/types.ts +0 -179
  135. package/tailwind.config.ts +0 -73
  136. package/tests/e2e/app.spec.ts +0 -90
  137. package/tests/e2e/canvas.spec.ts +0 -128
  138. package/tests/e2e/workflow.spec.ts +0 -185
  139. package/tests/integration/api.test.ts +0 -452
  140. package/tests/integration/testApp.ts +0 -31
  141. package/tests/setup.ts +0 -72
  142. package/tests/unit/ForEachNode.test.tsx +0 -308
  143. package/tests/unit/IfElseNode.test.tsx +0 -235
  144. package/tests/unit/ParallelNode.test.tsx +0 -344
  145. package/tests/unit/SwitchNode.test.tsx +0 -327
  146. package/tests/unit/TransformNode.test.tsx +0 -386
  147. package/tests/unit/TryCatchNode.test.tsx +0 -243
  148. package/tests/unit/WhileNode.test.tsx +0 -230
  149. package/tests/unit/agentStore.test.ts +0 -218
  150. package/tests/unit/canvasStore.test.ts +0 -502
  151. package/tests/unit/codexProvider.test.ts +0 -399
  152. package/tests/unit/components.test.tsx +0 -151
  153. package/tests/unit/executionStore.test.ts +0 -567
  154. package/tests/unit/layoutStore.test.ts +0 -194
  155. package/tests/unit/navigationStore.test.ts +0 -152
  156. package/tests/unit/platform.test.ts +0 -118
  157. package/tests/unit/serviceIcons.test.ts +0 -197
  158. package/tests/unit/stepValidation.test.ts +0 -226
  159. package/tests/unit/themeStore.test.ts +0 -141
  160. package/tests/unit/workflowToGraph.test.ts +0 -311
  161. package/tsconfig.json +0 -29
  162. package/tsconfig.server.json +0 -28
  163. package/vite.config.ts +0 -31
  164. package/vitest.config.ts +0 -26
@@ -1,567 +0,0 @@
1
- import { describe, it, expect, beforeEach } from 'vitest';
2
- import { useExecutionStore, formatDuration, formatRelativeTime } from '../../src/client/stores/executionStore';
3
-
4
- describe('executionStore', () => {
5
- beforeEach(() => {
6
- // Reset store state before each test
7
- useExecutionStore.setState({
8
- runs: [],
9
- currentRunId: null,
10
- isExecuting: false,
11
- isPaused: false,
12
- debug: {
13
- enabled: false,
14
- breakpoints: new Set(),
15
- currentStepId: null,
16
- pausedAtBreakpoint: false,
17
- stepOverPending: false,
18
- watchExpressions: [],
19
- callStack: [],
20
- },
21
- });
22
- });
23
-
24
- describe('startExecution', () => {
25
- it('should create a new execution run', () => {
26
- const { startExecution } = useExecutionStore.getState();
27
-
28
- const runId = startExecution('workflow-1', 'Test Workflow');
29
-
30
- const state = useExecutionStore.getState();
31
- expect(runId).toBeDefined();
32
- expect(state.currentRunId).toBe(runId);
33
- expect(state.isExecuting).toBe(true);
34
- expect(state.isPaused).toBe(false);
35
- expect(state.runs).toHaveLength(1);
36
- expect(state.runs[0].workflowId).toBe('workflow-1');
37
- expect(state.runs[0].workflowName).toBe('Test Workflow');
38
- expect(state.runs[0].status).toBe('running');
39
- });
40
-
41
- it('should include inputs in the run', () => {
42
- const { startExecution } = useExecutionStore.getState();
43
-
44
- const inputs = { repo: 'owner/repo', pr: 123 };
45
- const runId = startExecution('workflow-1', 'Test', inputs);
46
-
47
- const state = useExecutionStore.getState();
48
- expect(state.runs[0].inputs).toEqual(inputs);
49
- });
50
-
51
- it('should limit runs to 50', () => {
52
- const { startExecution } = useExecutionStore.getState();
53
-
54
- // Create 55 runs
55
- for (let i = 0; i < 55; i++) {
56
- startExecution('wf-' + i, 'Workflow ' + i);
57
- // Manually complete each run so we can start another
58
- useExecutionStore.setState({ isExecuting: false, currentRunId: null });
59
- }
60
-
61
- const state = useExecutionStore.getState();
62
- expect(state.runs).toHaveLength(50);
63
- });
64
- });
65
-
66
- describe('updateStepStatus', () => {
67
- it('should add a new step when it does not exist', () => {
68
- const { startExecution, updateStepStatus } = useExecutionStore.getState();
69
-
70
- const runId = startExecution('wf-1', 'Test');
71
- updateStepStatus(runId, 'step-1', 'running');
72
-
73
- const state = useExecutionStore.getState();
74
- const run = state.runs.find(r => r.id === runId);
75
- expect(run?.steps).toHaveLength(1);
76
- expect(run?.steps[0].stepId).toBe('step-1');
77
- expect(run?.steps[0].status).toBe('running');
78
- });
79
-
80
- it('should update an existing step', () => {
81
- const { startExecution, updateStepStatus } = useExecutionStore.getState();
82
-
83
- const runId = startExecution('wf-1', 'Test');
84
- updateStepStatus(runId, 'step-1', 'running');
85
- updateStepStatus(runId, 'step-1', 'completed');
86
-
87
- const state = useExecutionStore.getState();
88
- const run = state.runs.find(r => r.id === runId);
89
- expect(run?.steps).toHaveLength(1);
90
- expect(run?.steps[0].status).toBe('completed');
91
- });
92
-
93
- it('should record error on failed step', () => {
94
- const { startExecution, updateStepStatus } = useExecutionStore.getState();
95
-
96
- const runId = startExecution('wf-1', 'Test');
97
- updateStepStatus(runId, 'step-1', 'running');
98
- updateStepStatus(runId, 'step-1', 'failed', undefined, 'Something went wrong');
99
-
100
- const state = useExecutionStore.getState();
101
- const run = state.runs.find(r => r.id === runId);
102
- expect(run?.steps[0].error).toBe('Something went wrong');
103
- });
104
-
105
- it('should record step inputs', () => {
106
- const { startExecution, updateStepStatus } = useExecutionStore.getState();
107
-
108
- const runId = startExecution('wf-1', 'Test');
109
- const inputs = { channel: '#general', message: 'Hello' };
110
- updateStepStatus(runId, 'step-1', 'running', undefined, undefined, undefined, inputs);
111
-
112
- const state = useExecutionStore.getState();
113
- const run = state.runs.find(r => r.id === runId);
114
- expect(run?.steps[0].inputs).toEqual(inputs);
115
- });
116
-
117
- it('should record step output and output variable', () => {
118
- const { startExecution, updateStepStatus } = useExecutionStore.getState();
119
-
120
- const runId = startExecution('wf-1', 'Test');
121
- const output = { ts: '1234567890.123456', ok: true };
122
- updateStepStatus(runId, 'step-1', 'running');
123
- updateStepStatus(runId, 'step-1', 'completed', output, undefined, 'result');
124
-
125
- const state = useExecutionStore.getState();
126
- const run = state.runs.find(r => r.id === runId);
127
- expect(run?.steps[0].output).toEqual(output);
128
- expect(run?.steps[0].outputVariable).toBe('result');
129
- });
130
-
131
- it('should preserve inputs when updating step status', () => {
132
- const { startExecution, updateStepStatus } = useExecutionStore.getState();
133
-
134
- const runId = startExecution('wf-1', 'Test');
135
- const inputs = { foo: 'bar' };
136
- updateStepStatus(runId, 'step-1', 'running', undefined, undefined, undefined, inputs);
137
- updateStepStatus(runId, 'step-1', 'completed', { result: 'success' });
138
-
139
- const state = useExecutionStore.getState();
140
- const run = state.runs.find(r => r.id === runId);
141
- expect(run?.steps[0].inputs).toEqual(inputs);
142
- expect(run?.steps[0].output).toEqual({ result: 'success' });
143
- });
144
- });
145
-
146
- describe('completeExecution', () => {
147
- it('should mark execution as completed', () => {
148
- const { startExecution, completeExecution } = useExecutionStore.getState();
149
-
150
- const runId = startExecution('wf-1', 'Test');
151
- completeExecution(runId, 'completed', { result: 'success' });
152
-
153
- const state = useExecutionStore.getState();
154
- expect(state.isExecuting).toBe(false);
155
- expect(state.currentRunId).toBeNull();
156
-
157
- const run = state.runs.find(r => r.id === runId);
158
- expect(run?.status).toBe('completed');
159
- expect(run?.outputs).toEqual({ result: 'success' });
160
- expect(run?.endTime).toBeDefined();
161
- expect(run?.duration).toBeDefined();
162
- });
163
-
164
- it('should mark execution as failed', () => {
165
- const { startExecution, completeExecution } = useExecutionStore.getState();
166
-
167
- const runId = startExecution('wf-1', 'Test');
168
- completeExecution(runId, 'failed');
169
-
170
- const state = useExecutionStore.getState();
171
- const run = state.runs.find(r => r.id === runId);
172
- expect(run?.status).toBe('failed');
173
- });
174
- });
175
-
176
- describe('addLog', () => {
177
- it('should add a log message to the run', () => {
178
- const { startExecution, addLog } = useExecutionStore.getState();
179
-
180
- const runId = startExecution('wf-1', 'Test');
181
- addLog(runId, 'Test message');
182
-
183
- const state = useExecutionStore.getState();
184
- const run = state.runs.find(r => r.id === runId);
185
- const hasMessage = run?.logs.some(log => log.includes('Test message'));
186
- expect(hasMessage).toBe(true);
187
- });
188
- });
189
-
190
- describe('pauseExecution / resumeExecution', () => {
191
- it('should pause execution', () => {
192
- const { startExecution, pauseExecution } = useExecutionStore.getState();
193
-
194
- startExecution('wf-1', 'Test');
195
- pauseExecution();
196
-
197
- const state = useExecutionStore.getState();
198
- expect(state.isPaused).toBe(true);
199
- });
200
-
201
- it('should resume execution', () => {
202
- const { startExecution, pauseExecution, resumeExecution } = useExecutionStore.getState();
203
-
204
- startExecution('wf-1', 'Test');
205
- pauseExecution();
206
- resumeExecution();
207
-
208
- const state = useExecutionStore.getState();
209
- expect(state.isPaused).toBe(false);
210
- });
211
- });
212
-
213
- describe('cancelExecution', () => {
214
- it('should cancel and complete execution', () => {
215
- const { startExecution, cancelExecution } = useExecutionStore.getState();
216
-
217
- const runId = startExecution('wf-1', 'Test');
218
- cancelExecution(runId);
219
-
220
- const state = useExecutionStore.getState();
221
- expect(state.isExecuting).toBe(false);
222
-
223
- const run = state.runs.find(r => r.id === runId);
224
- expect(run?.status).toBe('cancelled');
225
- });
226
- });
227
-
228
- describe('clearHistory', () => {
229
- it('should clear all runs', () => {
230
- const { startExecution, clearHistory, completeExecution } = useExecutionStore.getState();
231
-
232
- const runId = startExecution('wf-1', 'Test');
233
- completeExecution(runId, 'completed');
234
-
235
- clearHistory();
236
-
237
- const state = useExecutionStore.getState();
238
- expect(state.runs).toHaveLength(0);
239
- });
240
- });
241
-
242
- describe('getRun', () => {
243
- it('should return a run by ID', () => {
244
- const { startExecution, getRun } = useExecutionStore.getState();
245
-
246
- const runId = startExecution('wf-1', 'Test');
247
- const run = getRun(runId);
248
-
249
- expect(run).toBeDefined();
250
- expect(run?.id).toBe(runId);
251
- });
252
-
253
- it('should return undefined for non-existent run', () => {
254
- const { getRun } = useExecutionStore.getState();
255
-
256
- const run = getRun('non-existent');
257
- expect(run).toBeUndefined();
258
- });
259
- });
260
-
261
- // Debug mode tests
262
- describe('debug mode', () => {
263
- describe('enableDebugMode / disableDebugMode', () => {
264
- it('should enable debug mode', () => {
265
- const { enableDebugMode } = useExecutionStore.getState();
266
-
267
- enableDebugMode();
268
-
269
- const state = useExecutionStore.getState();
270
- expect(state.debug.enabled).toBe(true);
271
- });
272
-
273
- it('should disable debug mode but preserve breakpoints', () => {
274
- const { enableDebugMode, disableDebugMode, toggleBreakpoint } = useExecutionStore.getState();
275
-
276
- enableDebugMode();
277
- toggleBreakpoint('step-1');
278
- toggleBreakpoint('step-2');
279
- disableDebugMode();
280
-
281
- const state = useExecutionStore.getState();
282
- expect(state.debug.enabled).toBe(false);
283
- expect(state.debug.breakpoints.has('step-1')).toBe(true);
284
- expect(state.debug.breakpoints.has('step-2')).toBe(true);
285
- });
286
-
287
- it('should reset other debug state when disabling', () => {
288
- const { enableDebugMode, disableDebugMode, setCurrentDebugStep, addWatchExpression } = useExecutionStore.getState();
289
-
290
- enableDebugMode();
291
- setCurrentDebugStep('step-1');
292
- addWatchExpression('variable.foo');
293
-
294
- disableDebugMode();
295
-
296
- const state = useExecutionStore.getState();
297
- expect(state.debug.currentStepId).toBeNull();
298
- expect(state.debug.pausedAtBreakpoint).toBe(false);
299
- expect(state.debug.stepOverPending).toBe(false);
300
- expect(state.debug.callStack).toHaveLength(0);
301
- });
302
- });
303
-
304
- describe('toggleBreakpoint / hasBreakpoint / clearAllBreakpoints', () => {
305
- it('should add a breakpoint', () => {
306
- const { toggleBreakpoint, hasBreakpoint } = useExecutionStore.getState();
307
-
308
- toggleBreakpoint('step-1');
309
-
310
- expect(hasBreakpoint('step-1')).toBe(true);
311
- expect(hasBreakpoint('step-2')).toBe(false);
312
- });
313
-
314
- it('should remove a breakpoint when toggled twice', () => {
315
- const { toggleBreakpoint, hasBreakpoint } = useExecutionStore.getState();
316
-
317
- toggleBreakpoint('step-1');
318
- toggleBreakpoint('step-1');
319
-
320
- expect(hasBreakpoint('step-1')).toBe(false);
321
- });
322
-
323
- it('should clear all breakpoints', () => {
324
- const { toggleBreakpoint, clearAllBreakpoints, hasBreakpoint } = useExecutionStore.getState();
325
-
326
- toggleBreakpoint('step-1');
327
- toggleBreakpoint('step-2');
328
- toggleBreakpoint('step-3');
329
-
330
- clearAllBreakpoints();
331
-
332
- const state = useExecutionStore.getState();
333
- expect(state.debug.breakpoints.size).toBe(0);
334
- expect(hasBreakpoint('step-1')).toBe(false);
335
- });
336
- });
337
-
338
- describe('stepOver / stepInto / stepOut', () => {
339
- it('should set stepOverPending when stepping over', () => {
340
- const { enableDebugMode, startExecution, pauseExecution, stepOver } = useExecutionStore.getState();
341
-
342
- enableDebugMode();
343
- startExecution('wf-1', 'Test');
344
- pauseExecution();
345
-
346
- stepOver();
347
-
348
- const state = useExecutionStore.getState();
349
- expect(state.isPaused).toBe(false);
350
- expect(state.debug.stepOverPending).toBe(true);
351
- });
352
-
353
- it('should not step over when not paused', () => {
354
- const { enableDebugMode, startExecution, stepOver } = useExecutionStore.getState();
355
-
356
- enableDebugMode();
357
- startExecution('wf-1', 'Test');
358
-
359
- stepOver();
360
-
361
- const state = useExecutionStore.getState();
362
- expect(state.debug.stepOverPending).toBe(false);
363
- });
364
-
365
- it('should not step over when debug mode is disabled', () => {
366
- const { startExecution, pauseExecution, stepOver } = useExecutionStore.getState();
367
-
368
- startExecution('wf-1', 'Test');
369
- pauseExecution();
370
-
371
- stepOver();
372
-
373
- const state = useExecutionStore.getState();
374
- expect(state.isPaused).toBe(true); // Should still be paused
375
- });
376
-
377
- it('stepInto should work like stepOver', () => {
378
- const { enableDebugMode, startExecution, pauseExecution, stepInto } = useExecutionStore.getState();
379
-
380
- enableDebugMode();
381
- startExecution('wf-1', 'Test');
382
- pauseExecution();
383
-
384
- stepInto();
385
-
386
- const state = useExecutionStore.getState();
387
- expect(state.isPaused).toBe(false);
388
- expect(state.debug.stepOverPending).toBe(true);
389
- });
390
-
391
- it('stepOut should resume without stepOverPending', () => {
392
- const { enableDebugMode, startExecution, pauseExecution, stepOut } = useExecutionStore.getState();
393
-
394
- enableDebugMode();
395
- startExecution('wf-1', 'Test');
396
- pauseExecution();
397
-
398
- stepOut();
399
-
400
- const state = useExecutionStore.getState();
401
- expect(state.isPaused).toBe(false);
402
- expect(state.debug.stepOverPending).toBe(false);
403
- });
404
- });
405
-
406
- describe('setCurrentDebugStep', () => {
407
- it('should set the current debug step', () => {
408
- const { setCurrentDebugStep } = useExecutionStore.getState();
409
-
410
- setCurrentDebugStep('step-5');
411
-
412
- const state = useExecutionStore.getState();
413
- expect(state.debug.currentStepId).toBe('step-5');
414
- });
415
-
416
- it('should clear the current debug step when set to null', () => {
417
- const { setCurrentDebugStep } = useExecutionStore.getState();
418
-
419
- setCurrentDebugStep('step-5');
420
- setCurrentDebugStep(null);
421
-
422
- const state = useExecutionStore.getState();
423
- expect(state.debug.currentStepId).toBeNull();
424
- });
425
- });
426
-
427
- describe('watch expressions', () => {
428
- it('should add a watch expression', () => {
429
- const { addWatchExpression } = useExecutionStore.getState();
430
-
431
- addWatchExpression('variable.foo');
432
-
433
- const state = useExecutionStore.getState();
434
- expect(state.debug.watchExpressions).toContain('variable.foo');
435
- });
436
-
437
- it('should not add duplicate watch expressions', () => {
438
- const { addWatchExpression } = useExecutionStore.getState();
439
-
440
- addWatchExpression('variable.foo');
441
- addWatchExpression('variable.foo');
442
-
443
- const state = useExecutionStore.getState();
444
- expect(state.debug.watchExpressions.filter(e => e === 'variable.foo')).toHaveLength(1);
445
- });
446
-
447
- it('should remove a watch expression', () => {
448
- const { addWatchExpression, removeWatchExpression } = useExecutionStore.getState();
449
-
450
- addWatchExpression('variable.foo');
451
- addWatchExpression('variable.bar');
452
- removeWatchExpression('variable.foo');
453
-
454
- const state = useExecutionStore.getState();
455
- expect(state.debug.watchExpressions).not.toContain('variable.foo');
456
- expect(state.debug.watchExpressions).toContain('variable.bar');
457
- });
458
- });
459
-
460
- describe('updateCallStack', () => {
461
- it('should update the call stack', () => {
462
- const { updateCallStack } = useExecutionStore.getState();
463
-
464
- const stack = ['main', 'sub-workflow-1', 'step-3'];
465
- updateCallStack(stack);
466
-
467
- const state = useExecutionStore.getState();
468
- expect(state.debug.callStack).toEqual(stack);
469
- });
470
-
471
- it('should clear the call stack with empty array', () => {
472
- const { updateCallStack } = useExecutionStore.getState();
473
-
474
- updateCallStack(['main', 'sub-workflow-1']);
475
- updateCallStack([]);
476
-
477
- const state = useExecutionStore.getState();
478
- expect(state.debug.callStack).toHaveLength(0);
479
- });
480
- });
481
-
482
- describe('breakpoint pause behavior', () => {
483
- it('should pause at breakpoint when debug mode is enabled', () => {
484
- const { enableDebugMode, toggleBreakpoint, startExecution, updateStepStatus } = useExecutionStore.getState();
485
-
486
- enableDebugMode();
487
- toggleBreakpoint('step-2');
488
-
489
- const runId = startExecution('wf-1', 'Test');
490
- updateStepStatus(runId, 'step-2', 'running');
491
-
492
- const state = useExecutionStore.getState();
493
- expect(state.isPaused).toBe(true);
494
- expect(state.debug.pausedAtBreakpoint).toBe(true);
495
- expect(state.debug.currentStepId).toBe('step-2');
496
- });
497
-
498
- it('should not pause at breakpoint when debug mode is disabled', () => {
499
- const { toggleBreakpoint, startExecution, updateStepStatus } = useExecutionStore.getState();
500
-
501
- toggleBreakpoint('step-2');
502
-
503
- const runId = startExecution('wf-1', 'Test');
504
- updateStepStatus(runId, 'step-2', 'running');
505
-
506
- const state = useExecutionStore.getState();
507
- expect(state.isPaused).toBe(false);
508
- expect(state.debug.pausedAtBreakpoint).toBe(false);
509
- });
510
-
511
- it('should not pause at step without breakpoint', () => {
512
- const { enableDebugMode, toggleBreakpoint, startExecution, updateStepStatus } = useExecutionStore.getState();
513
-
514
- enableDebugMode();
515
- toggleBreakpoint('step-1'); // Breakpoint on step-1, not step-2
516
-
517
- const runId = startExecution('wf-1', 'Test');
518
- updateStepStatus(runId, 'step-2', 'running');
519
-
520
- const state = useExecutionStore.getState();
521
- expect(state.isPaused).toBe(false);
522
- expect(state.debug.pausedAtBreakpoint).toBe(false);
523
- });
524
- });
525
- });
526
- });
527
-
528
- describe('formatDuration', () => {
529
- it('should format milliseconds', () => {
530
- expect(formatDuration(500)).toBe('500ms');
531
- expect(formatDuration(999)).toBe('999ms');
532
- });
533
-
534
- it('should format seconds', () => {
535
- expect(formatDuration(1000)).toBe('1.0s');
536
- expect(formatDuration(2500)).toBe('2.5s');
537
- expect(formatDuration(59999)).toBe('60.0s');
538
- });
539
-
540
- it('should format minutes and seconds', () => {
541
- expect(formatDuration(60000)).toBe('1m 0s');
542
- expect(formatDuration(90000)).toBe('1m 30s');
543
- expect(formatDuration(125000)).toBe('2m 5s');
544
- });
545
- });
546
-
547
- describe('formatRelativeTime', () => {
548
- it('should format just now', () => {
549
- const now = new Date().toISOString();
550
- expect(formatRelativeTime(now)).toBe('just now');
551
- });
552
-
553
- it('should format minutes ago', () => {
554
- const fiveMinAgo = new Date(Date.now() - 5 * 60 * 1000).toISOString();
555
- expect(formatRelativeTime(fiveMinAgo)).toBe('5 min ago');
556
- });
557
-
558
- it('should format hours ago', () => {
559
- const twoHoursAgo = new Date(Date.now() - 2 * 60 * 60 * 1000).toISOString();
560
- expect(formatRelativeTime(twoHoursAgo)).toBe('2 hours ago');
561
- });
562
-
563
- it('should format days ago', () => {
564
- const threeDaysAgo = new Date(Date.now() - 3 * 24 * 60 * 60 * 1000).toISOString();
565
- expect(formatRelativeTime(threeDaysAgo)).toBe('3 days ago');
566
- });
567
- });