|
2 | 2 |
|
3 | 3 | import { cloneDeep } from 'lodash'; |
4 | 4 | import { readFlowTestSync } from 'service/collection'; |
5 | | -import useCanvasStore from 'stores/CanvasStore'; |
6 | 5 | import authNode from './compute/authnode'; |
7 | 6 | import nestedFlowNode from './compute/nestedflownode'; |
8 | 7 | import assertNode from './compute/assertnode'; |
9 | 8 | import requestNode from './compute/requestnode'; |
10 | 9 | import setVarNode from './compute/setvarnode'; |
11 | 10 | import { LogLevel } from './GraphLogger'; |
| 11 | +import { useTabStore } from 'stores/TabStore'; |
12 | 12 |
|
13 | 13 | class Graph { |
14 | | - constructor(nodes, edges, startTime, initialEnvVars, logger, caller, collectionPath) { |
| 14 | + constructor(nodes, edges, startTime, initialEnvVars, logger, collectionPath, timeout, tab) { |
15 | 15 | this.nodes = nodes; |
16 | 16 | this.edges = edges; |
17 | 17 | this.logger = logger; |
18 | | - this.timeout = useCanvasStore.getState().timeout; |
| 18 | + this.timeout = timeout; |
19 | 19 | this.startTime = startTime; |
20 | 20 | this.graphRunNodeOutput = {}; |
21 | 21 | this.auth = undefined; |
22 | 22 | this.envVariables = initialEnvVars; |
23 | | - this.caller = caller; |
| 23 | + //this.caller = caller; |
24 | 24 | this.collectionPath = collectionPath; |
| 25 | + this.tab = tab; |
25 | 26 | } |
26 | 27 |
|
27 | 28 | #checkTimeout() { |
@@ -71,8 +72,21 @@ class Graph { |
71 | 72 |
|
72 | 73 | if (node.type === 'outputNode') { |
73 | 74 | this.logger.add(LogLevel.INFO, '', { type: 'outputNode', data: { output: prevNodeOutputData } }); |
74 | | - if (this.caller === 'main') { |
75 | | - useCanvasStore.getState().setOutputNode(node.id, prevNodeOutputData); |
| 75 | + if (this.tab) { |
| 76 | + const updatedNodes = this.nodes.map((nd) => { |
| 77 | + if (nd.id === node.id) { |
| 78 | + return { |
| 79 | + ...nd, |
| 80 | + data: { |
| 81 | + ...nd.data, |
| 82 | + output: prevNodeOutputData, |
| 83 | + }, |
| 84 | + }; |
| 85 | + } |
| 86 | + |
| 87 | + return nd; |
| 88 | + }); |
| 89 | + useTabStore.getState().updateFlowTestNodes(this.tab.id, updatedNodes); |
76 | 90 | } |
77 | 91 | result = { |
78 | 92 | status: 'Success', |
@@ -153,8 +167,9 @@ class Graph { |
153 | 167 | this.startTime, |
154 | 168 | this.envVariables, |
155 | 169 | this.logger, |
156 | | - node.type, |
| 170 | + //node.type, |
157 | 171 | this.collectionPath, |
| 172 | + this.timeout, |
158 | 173 | ); |
159 | 174 | result = await cNode.evaluate(); |
160 | 175 | this.envVariables = result.envVars; |
@@ -228,14 +243,20 @@ class Graph { |
228 | 243 | } |
229 | 244 |
|
230 | 245 | async run() { |
231 | | - // reset every output node for a fresh run |
232 | | - if (this.caller === 'main') { |
233 | | - this.nodes.forEach((node) => { |
| 246 | + if (this.tab) { |
| 247 | + const updatedNodes = this.nodes.map((node) => { |
234 | 248 | if (node.type === 'outputNode') { |
235 | | - useCanvasStore.getState().unSetOutputNode(node.id); |
| 249 | + if (node.data.output) { |
| 250 | + const { ['output']: _, ...data } = node.data; |
| 251 | + node.data = data; |
| 252 | + } |
236 | 253 | } |
| 254 | + |
| 255 | + return node; |
237 | 256 | }); |
| 257 | + useTabStore.getState().updateFlowTestNodes(this.tab.id, updatedNodes); |
238 | 258 | } |
| 259 | + |
239 | 260 | this.graphRunNodeOutput = {}; |
240 | 261 |
|
241 | 262 | this.logger.add(LogLevel.INFO, 'Start Flowtest'); |
|
0 commit comments