fix issue with multiple loops breaking automation context
This commit is contained in:
parent
d54f87af03
commit
3a8a8b1195
|
@ -362,6 +362,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", () => {
|
describe("Row Automations", () => {
|
||||||
|
|
|
@ -449,7 +449,11 @@ class Orchestrator {
|
||||||
outputs: tempOutput,
|
outputs: tempOutput,
|
||||||
inputs: steps[stepToLoopIndex].inputs,
|
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("currentItem")
|
||||||
|
)
|
||||||
|
|
||||||
this.loopStepOutputs = []
|
this.loopStepOutputs = []
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -569,8 +573,8 @@ class Orchestrator {
|
||||||
this.loopStepOutputs.push(outputs)
|
this.loopStepOutputs.push(outputs)
|
||||||
} else {
|
} else {
|
||||||
this.updateExecutionOutput(step.id, step.stepId, step.inputs, outputs)
|
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