Merge pull request #14514 from Budibase/fix/automation-context-bug
This commit is contained in:
commit
f191bc390a
|
@ -364,6 +364,32 @@ describe("Automation Scenarios", () => {
|
|||
}
|
||||
)
|
||||
})
|
||||
|
||||
it("should run an automation where a loop is used twice to ensure context correctness further down the tree", async () => {
|
||||
const builder = createAutomationBuilder({
|
||||
name: "Test Trigger with Loop and Create Row",
|
||||
})
|
||||
|
||||
const results = await builder
|
||||
.appAction({ fields: {} })
|
||||
.loop({
|
||||
option: LoopStepType.ARRAY,
|
||||
binding: [1, 2, 3],
|
||||
})
|
||||
.serverLog({ text: "Message {{loop.currentItem}}" })
|
||||
.serverLog({ text: "{{steps.1.iterations}}" })
|
||||
.loop({
|
||||
option: LoopStepType.ARRAY,
|
||||
binding: [1, 2, 3],
|
||||
})
|
||||
.serverLog({ text: "{{loop.currentItem}}" })
|
||||
.serverLog({ text: "{{steps.3.iterations}}" })
|
||||
.run()
|
||||
|
||||
// We want to ensure that bindings are corr
|
||||
expect(results.steps[1].outputs.message).toContain("- 3")
|
||||
expect(results.steps[3].outputs.message).toContain("- 3")
|
||||
})
|
||||
})
|
||||
|
||||
describe("Row Automations", () => {
|
||||
|
|
|
@ -449,7 +449,11 @@ class Orchestrator {
|
|||
outputs: tempOutput,
|
||||
inputs: steps[stepToLoopIndex].inputs,
|
||||
})
|
||||
this.context.steps[currentIndex + 1] = tempOutput
|
||||
this.context.steps[this.context.steps.length] = tempOutput
|
||||
this.context.steps = this.context.steps.filter(
|
||||
item => !item.hasOwnProperty.call(item, "currentItem")
|
||||
)
|
||||
|
||||
this.loopStepOutputs = []
|
||||
}
|
||||
|
||||
|
@ -582,8 +586,8 @@ class Orchestrator {
|
|||
this.loopStepOutputs.push(outputs)
|
||||
} else {
|
||||
this.updateExecutionOutput(step.id, step.stepId, step.inputs, outputs)
|
||||
this.context.steps[this.context.steps.length] = outputs
|
||||
}
|
||||
this.context.steps[this.context.steps.length] = outputs
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue