From 8e3fb9595d3965c1cb483373c23cc4bda6a7e5a9 Mon Sep 17 00:00:00 2001 From: Dries Augustyns Date: Wed, 27 May 2026 18:14:29 +0200 Subject: [PATCH] tests: prevent race condition by inserting RUNNING execution directly --- apps/api/src/services/__tests__/WorkflowService.test.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/api/src/services/__tests__/WorkflowService.test.ts b/apps/api/src/services/__tests__/WorkflowService.test.ts index a45a26a..1128798 100644 --- a/apps/api/src/services/__tests__/WorkflowService.test.ts +++ b/apps/api/src/services/__tests__/WorkflowService.test.ts @@ -761,7 +761,9 @@ describe('WorkflowService', () => { // Insert a RUNNING execution directly to avoid racing with the background // step processor that startExecution kicks off (a trigger-only workflow can // 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({ data: { workflowId: workflow.id,