From 9acc323450234ae63fccec56c4ba7a46196178d8 Mon Sep 17 00:00:00 2001 From: roggervalf Date: Fri, 20 Oct 2023 20:31:03 -0700 Subject: [PATCH] test(fpof): make sure parent is moved to failed immediately --- tests/test_flow.ts | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/tests/test_flow.ts b/tests/test_flow.ts index b677fc0909..c5adaf0729 100644 --- a/tests/test_flow.ts +++ b/tests/test_flow.ts @@ -1558,15 +1558,15 @@ describe('flows', () => { let grandChildrenProcessor, processedGrandChildren = 0; const processingChildren = new Promise(resolve => { - grandChildrenProcessor = async () => { + grandChildrenProcessor = async job => { processedGrandChildren++; + await delay(job.data.delay); + if (processedGrandChildren === 2) { return resolve(); } - await delay(200); - throw new Error('failed'); }; }); @@ -1598,13 +1598,13 @@ describe('flows', () => { children: [ { name, - data: { foo: 'bar' }, + data: { foo: 'bar', delay: 200 }, queueName: grandChildrenQueueName, opts: { failParentOnFailure: true }, }, { name, - data: { foo: 'baz' }, + data: { foo: 'baz', delay: 2500 }, queueName: grandChildrenQueueName, }, ], @@ -1615,9 +1615,15 @@ describe('flows', () => { const failed = new Promise(resolve => { queueEvents.on('failed', async ({ jobId, failedReason, prev }) => { if (jobId === tree.job.id) { + await delay(200); + const grandChildState = await grandChildrenQueue.getJobState( + tree.children![1].children![1].job.id!, + ); + expect(grandChildState).to.be.equal('active'); + expect(prev).to.be.equal('waiting-children'); expect(failedReason).to.be.equal( - `child bull:${queueName}:${tree.children[1].job.id} failed`, + `child bull:${queueName}:${tree.children![1].job.id} failed`, ); resolve(); }