From 2cab007f57388b861c29a03f5fb58344d615ca47 Mon Sep 17 00:00:00 2001 From: guillermo Date: Tue, 6 Feb 2024 12:12:45 +0100 Subject: [PATCH] fix: refs #6184 Requested changes --- back/tests.js | 1 + .../back/methods/route/specs/downloadCmrsZip.spec.js | 6 +----- .../ticket/back/methods/ticket/specs/saveCmr.spec.js | 12 ++++-------- print/core/cluster.js | 3 ++- 4 files changed, 8 insertions(+), 14 deletions(-) diff --git a/back/tests.js b/back/tests.js index 0fb4c76ea..c48c64b77 100644 --- a/back/tests.js +++ b/back/tests.js @@ -96,6 +96,7 @@ async function test() { // runner.loadConfigFile('back/jasmine.json'); runner.loadConfig(config); + process.env.SPEC_IS_RUNNING = true; await runner.execute(); } diff --git a/modules/route/back/methods/route/specs/downloadCmrsZip.spec.js b/modules/route/back/methods/route/specs/downloadCmrsZip.spec.js index 2930fe703..7312a5d44 100644 --- a/modules/route/back/methods/route/specs/downloadCmrsZip.spec.js +++ b/modules/route/back/methods/route/specs/downloadCmrsZip.spec.js @@ -1,10 +1,6 @@ const models = require('vn-loopback/server/server').models; describe('route downloadCmrsZip()', () => { - beforeEach(() => { - spyOn(models.Route, 'downloadCmrsZip').and.returnValue(true); - }); - it('should create a zip file with the given cmr ids', async() => { const tx = await models.Route.beginTransaction({}); const ctx = { @@ -19,7 +15,7 @@ describe('route downloadCmrsZip()', () => { try { const stream = await models.Route.downloadCmrsZip(ctx, cmrs); - expect(stream).toBeTrue(); + expect(stream[0]).toBeDefined(); await tx.rollback(); } catch (e) { await tx.rollback(); diff --git a/modules/ticket/back/methods/ticket/specs/saveCmr.spec.js b/modules/ticket/back/methods/ticket/specs/saveCmr.spec.js index b8e1b5083..441aae68b 100644 --- a/modules/ticket/back/methods/ticket/specs/saveCmr.spec.js +++ b/modules/ticket/back/methods/ticket/specs/saveCmr.spec.js @@ -1,10 +1,6 @@ const models = require('vn-loopback/server/server').models; describe('ticket saveCmr()', () => { - beforeEach(() => { - spyOn(models.Ticket, 'saveCmr').and.returnValue(true); - }); - it(`should throw error if the cmr can't save`, async() => { const tx = await models.Ticket.beginTransaction({}); const ctx = { @@ -18,11 +14,11 @@ describe('ticket saveCmr()', () => { }; try { const options = {transaction: tx}; - const ticket = [1]; - await models.Ticket.saveCmr(ctx, ticket); + const ticket = [2]; + await models.Ticket.saveCmr(ctx, ticket, options); const hasDmsCmr = await models.TicketDms.findOne({ - where: {ticketFk: ticket[1]}, + where: {ticketFk: ticket[0]}, include: [{ relation: 'dms', fields: ['id'], @@ -35,7 +31,7 @@ describe('ticket saveCmr()', () => { }] }, options); - expect(hasDmsCmr?.dms()?.dmsType()).toEqual(1); + expect(hasDmsCmr?.dms()?.id).toBeGreaterThanOrEqual(1); await tx.rollback(); } catch (e) { await tx.rollback(); diff --git a/print/core/cluster.js b/print/core/cluster.js index a75c4cf24..f2b2c3f21 100644 --- a/print/core/cluster.js +++ b/print/core/cluster.js @@ -35,7 +35,8 @@ module.exports = { logger.error(`[Print] => ${err.message}`); }); - cluster.on('queue', () => logger.info('Printing task initialized by pool')); + cluster.on('queue', () => + process.env.SPEC_IS_RUNNING === 'false' && logger.info('Printing task initialized by pool')); }); } };