From d4d3fdceb5075874f19d4a163d0bc54326c6e130 Mon Sep 17 00:00:00 2001 From: carlossa Date: Thu, 7 Mar 2024 11:36:30 +0100 Subject: [PATCH] refs #6755 fix canRestoreTicket --- modules/ticket/back/methods/ticket/restore.js | 2 -- .../back/methods/ticket/specs/filter.spec.js | 2 +- .../back/methods/ticket/specs/restore.spec.js | 18 ++++++++++++------ 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/modules/ticket/back/methods/ticket/restore.js b/modules/ticket/back/methods/ticket/restore.js index 0d2452df9..9dde43ff9 100644 --- a/modules/ticket/back/methods/ticket/restore.js +++ b/modules/ticket/back/methods/ticket/restore.js @@ -47,8 +47,6 @@ module.exports = Self => { }] }, myOptions); - console.log('id', id); - console.log('ticket', ticket); const now = Date.vnNew(); const maxDate = new Date(ticket.creationDate); maxDate.setHours(maxDate.getHours() + 1); diff --git a/modules/ticket/back/methods/ticket/specs/filter.spec.js b/modules/ticket/back/methods/ticket/specs/filter.spec.js index c1d3f1a9c..09c4ebbb7 100644 --- a/modules/ticket/back/methods/ticket/specs/filter.spec.js +++ b/modules/ticket/back/methods/ticket/specs/filter.spec.js @@ -68,7 +68,7 @@ describe('ticket filter()', () => { const filter = {}; const result = await models.Ticket.filter(ctx, filter, options); - expect(result.length).toEqual(6); + expect(result.length).toEqual(5); await tx.rollback(); } catch (e) { diff --git a/modules/ticket/back/methods/ticket/specs/restore.spec.js b/modules/ticket/back/methods/ticket/specs/restore.spec.js index 3b35ae2b4..736e68628 100644 --- a/modules/ticket/back/methods/ticket/specs/restore.spec.js +++ b/modules/ticket/back/methods/ticket/specs/restore.spec.js @@ -2,9 +2,9 @@ const app = require('vn-loopback/server/server'); const LoopBackContext = require('loopback-context'); const models = app.models; -describe('ticket restore()', () => { +fdescribe('ticket restore()', () => { const employeeUser = 1110; - const ticketId = 18; + const ticketId = 9; const activeCtx = { accessToken: {userId: employeeUser}, headers: { @@ -48,25 +48,31 @@ describe('ticket restore()', () => { const tx = await app.models.Ticket.beginTransaction({}); const now = Date.vnNew(); + console.log('now', now); try { const options = {transaction: tx}; - const ticketBeforeUpdate = await models.Ticket.findById(ticketId, null, options); + const ticketBeforeUpdate = await models.TicketLog.findById(ticketId, null, options); await ticketBeforeUpdate.updateAttributes({ - isDeleted: true, - updated: now + creationDate: '2001-01-01T11:00:00.000Z', }, options); - const ticketAfterUpdate = await models.Ticket.findById(ticketId, null, options); + console.log('ticketBeforeUpdate', ticketBeforeUpdate); + const ticketAfterUpdate = await models.TicketLog.findById(ticketId, null, options); + console.log('ticketAfterUpdate: ', ticketAfterUpdate); expect(ticketAfterUpdate.isDeleted).toBeTruthy(); await models.Ticket.restore(ctx, ticketId, options); const ticketAfterRestore = await models.Ticket.findById(ticketId, null, options); + console.log('ticketAfterRestore: ', ticketAfterRestore); const fullYear = now.getFullYear(); + console.log('fullYear: ', fullYear); const shippedFullYear = ticketAfterRestore.shipped.getFullYear(); + console.log('shippedFullYear: ', shippedFullYear); const landedFullYear = ticketAfterRestore.landed.getFullYear(); + console.log('landedFullYear: ', landedFullYear); expect(ticketAfterRestore.isDeleted).toBeFalsy(); expect(shippedFullYear).toEqual(fullYear);