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