From 1ad22d0e6e2d680be8a3501b92a09a61841963a9 Mon Sep 17 00:00:00 2001 From: cristianpb Date: Thu, 24 Oct 2024 23:50:55 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=B7=20Update=20test=20for=20priority?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/server.spec.ts | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/backend/src/server.spec.ts b/backend/src/server.spec.ts index d888289d..13048f9c 100644 --- a/backend/src/server.spec.ts +++ b/backend/src/server.spec.ts @@ -846,17 +846,7 @@ describe('server.ts - Express application', () => { .field('chunkSize', 20) .attach('csv', buf, 'file.csv') const { body : { id: jobId1 } }: { body: { id: string} } = res - buf = await csv2Buffer('/deces-backend/tests/clients_test.csv', 3000) - res = await server - .post(apiPath('search/csv')) - .set('Authorization', `Bearer ${token.body.access_token as string}`) - .field('sep', ';') - .field('firstName', 'Prenom') - .field('lastName', 'Nom') - .field('birthDate', 'Date') - .field('chunkSize', 20) - .attach('csv', buf, 'file.csv') - const { body : { id: jobId2 } }: { body: { id: string} } = res + let statusJob1; buf = await csv2Buffer('/deces-backend/tests/clients_test.csv', 500) res = await server .post(apiPath('search/csv')) @@ -867,19 +857,23 @@ describe('server.ts - Express application', () => { .field('birthDate', 'Date') .field('chunkSize', 20) .attach('csv', buf, 'file.csv') - const { body : { id: jobId3 } }: { body: { id: string} } = res + const { body : { id: jobId2 } }: { body: { id: string} } = res + let statusJob2; while (['created', 'wait', 'started', 'active'].includes(res.body.status) || res.body.msg === 'started') { - res = await server - .get(apiPath(`search/csv/${jobId2}`)) - .set('Authorization', `Bearer ${token.body.access_token as string}`) res = await server .get(apiPath(`search/csv/${jobId1}`)) .set('Authorization', `Bearer ${token.body.access_token as string}`) + statusJob1 = res.body.status res = await server - .get(apiPath(`search/csv/${jobId3}`)) + .get(apiPath(`search/csv/${jobId2}`)) .set('Authorization', `Bearer ${token.body.access_token as string}`) + statusJob2 = res.body.status } + // smaller job finish faster + expect(statusJob1).toBe('active'); + expect(statusJob2).not.toBe('active'); + res = await server .get(apiPath('queue/jobs?jobsType=wait')) .set('Authorization', `Bearer ${token.body.access_token as string}`)