1
0
Fork 0
mirror of synced 2024-09-19 18:59:06 +12:00

Merge pull request #14514 from Budibase/fix/automation-context-bug

This commit is contained in:
Peter Clement 2024-09-04 18:03:41 +01:00 committed by GitHub
commit f191bc390a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 32 additions and 2 deletions

View file

@ -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", () => {

View file

@ -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
}
}