Merge pull request #2055 from automatisch/rest-test-step
feat: Implement rest api endpoint to test step
This commit is contained in:
@@ -9,6 +9,7 @@ import Telemetry from '../helpers/telemetry/index.js';
|
||||
import appConfig from '../config/app.js';
|
||||
import globalVariable from '../helpers/global-variable.js';
|
||||
import computeParameters from '../helpers/compute-parameters.js';
|
||||
import testRun from '../services/test-run.js';
|
||||
|
||||
class Step extends Base {
|
||||
static tableName = 'steps';
|
||||
@@ -59,6 +60,17 @@ class Step extends Base {
|
||||
to: 'connections.id',
|
||||
},
|
||||
},
|
||||
lastExecutionStep: {
|
||||
relation: Base.HasOneRelation,
|
||||
modelClass: ExecutionStep,
|
||||
join: {
|
||||
from: 'steps.id',
|
||||
to: 'execution_steps.step_id',
|
||||
},
|
||||
filter(builder) {
|
||||
builder.orderBy('created_at', 'desc').limit(1).first();
|
||||
},
|
||||
},
|
||||
executionSteps: {
|
||||
relation: Base.HasManyRelation,
|
||||
modelClass: ExecutionStep,
|
||||
@@ -145,6 +157,16 @@ class Step extends Base {
|
||||
return await App.findOneByKey(this.appKey);
|
||||
}
|
||||
|
||||
async test() {
|
||||
await testRun({ stepId: this.id });
|
||||
|
||||
const updatedStep = await this.$query()
|
||||
.withGraphFetched('lastExecutionStep')
|
||||
.patchAndFetch({ status: 'completed' });
|
||||
|
||||
return updatedStep;
|
||||
}
|
||||
|
||||
async getLastExecutionStep() {
|
||||
const lastExecutionStep = await this.$relatedQuery('executionSteps')
|
||||
.orderBy('created_at', 'desc')
|
||||
|
Reference in New Issue
Block a user