Skip to content

Commit 893f8db

Browse files
committed
run pre flow, then main graph and then run post flow
1 parent 233c654 commit 893f8db

File tree

4 files changed

+13
-10
lines changed

4 files changed

+13
-10
lines changed

src/components/molecules/flow/flowtestai.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ const translateGeneratedNodesToOpenApiNodes = (generatedNodes, openApiNodes) =>
1414
outputNode['requestBody']['body'] = JSON.stringify(node_arguments.requestBody);
1515
}
1616
if (node_arguments.parameters) {
17-
outputNode.variables = {};
17+
outputNode.preReqVars = {};
1818
Object.entries(node_arguments.parameters).forEach(([paramName, paramValue], _) => {
19-
outputNode.variables[paramName] = {
19+
outputNode.preReqVars[paramName] = {
2020
type: typeof paramValue,
2121
value: paramValue,
2222
};

src/components/molecules/flow/graph/Graph.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,6 @@ class Graph {
187187
console.debug('Flow failed at: ', result.node);
188188
}
189189
this.logs.push('End Flowtest');
190-
this.logs.push(`Total time: ${Date.now() - this.startTime} ms`);
191190
return {
192191
status: result.status,
193192
logs: this.logs,

src/components/molecules/flow/index.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ const Flow = ({ collectionId }) => {
259259
}
260260

261261
// ============= pre flow ================
262-
const preFlowData = readFlowTestSync(preFlow);
262+
const preFlowData = await readFlowTestSync(preFlow);
263263
if (preFlowData) {
264264
g = new Graph(
265265
cloneDeep(preFlowData.nodes),
@@ -271,7 +271,7 @@ const Flow = ({ collectionId }) => {
271271
result = await g.run();
272272
}
273273

274-
console.log('pre flow: ', result);
274+
//console.log('pre flow: ', result);
275275

276276
if (result?.status === 'Failed') {
277277
onGraphComplete(result.status, result.logs);
@@ -288,16 +288,16 @@ const Flow = ({ collectionId }) => {
288288
);
289289
result = await g.run();
290290

291-
console.log('flow: ', result);
292-
console.log('after flow vars: ', result.envVars);
291+
//console.log('flow: ', result);
292+
//console.log('after flow vars: ', result.envVars);
293293

294294
if (result.status === 'Failed') {
295295
onGraphComplete(result.status, result.logs);
296296
return;
297297
}
298298

299299
// ============= post flow ================
300-
const postFlowData = readFlowTestSync(postFlow);
300+
const postFlowData = await readFlowTestSync(postFlow);
301301
if (postFlowData) {
302302
g = new Graph(
303303
cloneDeep(postFlowData.nodes),
@@ -309,8 +309,9 @@ const Flow = ({ collectionId }) => {
309309
result = await g.run();
310310
}
311311

312-
console.log('post flow: ', result);
312+
//console.log('post flow: ', result);
313313

314+
result.logs.push(`Total time: ${Date.now() - startTime} ms`);
314315
onGraphComplete(result.status, result.logs);
315316
} catch (error) {
316317
toast.error(`Error running graph: ${error}`);

src/service/collection.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,10 +298,13 @@ export const readFlowTestSync = (pathname) => {
298298
if (pathname.trim() != '') {
299299
const { ipcRenderer } = window;
300300

301-
return ipcRenderer.invoke('renderer:read-flowtest-sync', pathname);
301+
return new Promise((resolve, reject) => {
302+
return ipcRenderer.invoke('renderer:read-flowtest-sync', pathname).then(resolve).catch(reject);
303+
});
302304
}
303305
} catch (error) {
304306
console.log(`Error reading flowtest: ${error}`);
307+
return Promise.reject(new Error('Error reading flowtest'));
305308
}
306309
};
307310

0 commit comments

Comments
 (0)