Merge pull request #3007 from Budibase/fix/3005
Fixing issues with filter step in automations breaking test flow
This commit is contained in:
commit
ec82053d88
|
@ -103,7 +103,7 @@
|
|||
<Detail size="S">{block?.name?.toUpperCase() || ""}</Detail>
|
||||
</div>
|
||||
</div>
|
||||
{#if testResult}
|
||||
{#if testResult && testResult[0]}
|
||||
<span on:click={() => resultsModal.show()}>
|
||||
<StatusLight
|
||||
positive={isTrigger || testResult[0].outputs?.success}
|
||||
|
|
|
@ -10,6 +10,7 @@ const env = require("../environment")
|
|||
const usage = require("../utilities/usageQuota")
|
||||
|
||||
const FILTER_STEP_ID = actions.ACTION_DEFINITIONS.FILTER.stepId
|
||||
const STOPPED_STATUS = { success: false, status: "STOPPED" }
|
||||
|
||||
/**
|
||||
* The automation orchestrator is a class responsible for executing automations.
|
||||
|
@ -68,7 +69,13 @@ class Orchestrator {
|
|||
async execute() {
|
||||
let automation = this._automation
|
||||
const app = await this.getApp()
|
||||
let stopped = false
|
||||
for (let step of automation.definition.steps) {
|
||||
// execution stopped, record state for that
|
||||
if (stopped) {
|
||||
this.updateExecutionOutput(step.id, step.stepId, {}, STOPPED_STATUS)
|
||||
continue
|
||||
}
|
||||
let stepFn = await this.getStepFunctionality(step.stepId)
|
||||
step.inputs = await processObject(step.inputs, this._context)
|
||||
step.inputs = automationUtils.cleanInputValues(
|
||||
|
@ -86,10 +93,17 @@ class Orchestrator {
|
|||
context: this._context,
|
||||
})
|
||||
})
|
||||
if (step.stepId === FILTER_STEP_ID && !outputs.success) {
|
||||
break
|
||||
}
|
||||
this._context.steps.push(outputs)
|
||||
// if filter causes us to stop execution don't break the loop, set a var
|
||||
// so that we can finish iterating through the steps and record that it stopped
|
||||
if (step.stepId === FILTER_STEP_ID && !outputs.success) {
|
||||
stopped = true
|
||||
this.updateExecutionOutput(step.id, step.stepId, step.inputs, {
|
||||
...outputs,
|
||||
...STOPPED_STATUS,
|
||||
})
|
||||
continue
|
||||
}
|
||||
this.updateExecutionOutput(step.id, step.stepId, step.inputs, outputs)
|
||||
} catch (err) {
|
||||
console.error(`Automation error - ${step.stepId} - ${err}`)
|
||||
|
@ -99,7 +113,7 @@ class Orchestrator {
|
|||
|
||||
// Increment quota for automation runs
|
||||
if (!env.SELF_HOSTED && !isDevAppID(this._appId)) {
|
||||
usage.update(usage.Properties.AUTOMATION, 1)
|
||||
await usage.update(usage.Properties.AUTOMATION, 1)
|
||||
}
|
||||
return this.executionOutput
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ describe("MongoDB Integration", () => {
|
|||
const body = {
|
||||
name: "Hello"
|
||||
}
|
||||
const response = await config.integration.create({
|
||||
await config.integration.create({
|
||||
index: indexName,
|
||||
json: body,
|
||||
extra: { collection: 'testCollection', actionTypes: 'insertOne'}
|
||||
|
@ -54,7 +54,7 @@ describe("MongoDB Integration", () => {
|
|||
},
|
||||
extra: { collection: 'testCollection', actionTypes: 'deleteOne'}
|
||||
}
|
||||
const response = await config.integration.delete(query)
|
||||
await config.integration.delete(query)
|
||||
expect(config.integration.client.deleteOne).toHaveBeenCalledWith(query.json)
|
||||
})
|
||||
|
||||
|
@ -65,7 +65,7 @@ describe("MongoDB Integration", () => {
|
|||
},
|
||||
extra: { collection: 'testCollection', actionTypes: 'updateOne'}
|
||||
}
|
||||
const response = await config.integration.update(query)
|
||||
await config.integration.update(query)
|
||||
expect(config.integration.client.updateOne).toHaveBeenCalledWith(query.json)
|
||||
})
|
||||
|
||||
|
@ -75,10 +75,14 @@ describe("MongoDB Integration", () => {
|
|||
const query = {
|
||||
extra: { collection: 'testCollection', actionTypes: 'deleteOne'}
|
||||
}
|
||||
// Weird, need to do an IIFE for jest to recognize that it throws
|
||||
expect(() => config.integration.read(query)()).toThrow(expect.any(Object))
|
||||
|
||||
let error = null
|
||||
try {
|
||||
await config.integration.read(query)
|
||||
} catch (err) {
|
||||
error = err
|
||||
}
|
||||
expect(error).toBeDefined()
|
||||
restore()
|
||||
})
|
||||
|
||||
})
|
Loading…
Reference in New Issue