@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,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
- });