refactor: Implement test run helper to work with services

This commit is contained in:
Faruk AYDIN
2022-10-14 20:18:58 +02:00
parent 56a9aeece7
commit 628f872180
11 changed files with 262 additions and 119 deletions

View File

@@ -1,6 +1,5 @@
import Context from '../../types/express/context';
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import flowQueue from '../../queues/flow';
import testRun from '../../services/test-run';
type Params = {
input: {
@@ -13,25 +12,22 @@ const executeFlow = async (
params: Params,
context: Context
) => {
// const untilStep = await context.currentUser
// .$relatedQuery('steps')
// .withGraphFetched('connection')
// .findOne({
// 'steps.id': params.input.stepId,
// })
// .throwIfNotFound();
// const flow = await untilStep.$relatedQuery('flow');
// const executionStep = await new Processor(flow, {
// untilStep,
// testRun: true,
// }).run();
// await untilStep.$query().patch({
// status: 'completed',
// });
// if (executionStep.errorDetails) {
// throw new Error(JSON.stringify(executionStep.errorDetails));
// }
// return { data: executionStep.dataOut, step: untilStep };
const { stepId } = params.input;
const { executionStep } = await testRun({ stepId });
const untilStep = await context.currentUser
.$relatedQuery('steps')
.findById(stepId);
await untilStep.$query().patch({
status: 'completed',
});
if (executionStep.errorDetails) {
throw new Error(JSON.stringify(executionStep.errorDetails));
}
return { data: executionStep.dataOut, step: untilStep };
};
export default executeFlow;