tests: prevent race condition by inserting RUNNING execution directly

This commit is contained in:
Dries Augustyns
2026-05-27 18:14:29 +02:00
parent 58be4abc31
commit 8e3fb9595d
@@ -761,7 +761,9 @@ describe('WorkflowService', () => {
// Insert a RUNNING execution directly to avoid racing with the background // Insert a RUNNING execution directly to avoid racing with the background
// step processor that startExecution kicks off (a trigger-only workflow can // step processor that startExecution kicks off (a trigger-only workflow can
// transition to COMPLETED before the second call observes it as RUNNING). // transition to COMPLETED before the second call observes it as RUNNING).
const triggerStep = workflow.steps.find(step => step.type === WorkflowStepType.TRIGGER); const triggerStep = await prisma.workflowStep.findFirst({
where: {workflowId: workflow.id, type: WorkflowStepType.TRIGGER},
});
await prisma.workflowExecution.create({ await prisma.workflowExecution.create({
data: { data: {
workflowId: workflow.id, workflowId: workflow.id,