From e4a6585b6af91fff3192cf1819a6b4b27d9c3fb0 Mon Sep 17 00:00:00 2001 From: alexandre Date: Wed, 16 Nov 2022 13:46:16 +0100 Subject: [PATCH] fix test back --- .../10503-november/00-sale_missingTrash.sql | 4 ++++ db/changes/10503-november/delete.keep | 0 .../methods/sale/specs/missingTrash.spec.js | 21 +++++++++---------- 3 files changed, 14 insertions(+), 11 deletions(-) delete mode 100644 db/changes/10503-november/delete.keep diff --git a/db/changes/10503-november/00-sale_missingTrash.sql b/db/changes/10503-november/00-sale_missingTrash.sql index f0de6d5cd..8c1bcaed3 100644 --- a/db/changes/10503-november/00-sale_missingTrash.sql +++ b/db/changes/10503-november/00-sale_missingTrash.sql @@ -21,3 +21,7 @@ BEGIN CALL vn.collection_missingTrash(vSaleFk ,vQuantity ,vIsTrash ,vWarehouseFk ,vNewQuantity); END$$ DELIMITER ; + +INSERT INTO `salix`.`ACL` +(model, property, accessType, permission, principalType, principalId) +VALUES('Sale', 'missingTrash', 'WRITE', 'ALLOW', 'ROLE', 'employee'); diff --git a/db/changes/10503-november/delete.keep b/db/changes/10503-november/delete.keep deleted file mode 100644 index e69de29bb..000000000 diff --git a/modules/ticket/back/methods/sale/specs/missingTrash.spec.js b/modules/ticket/back/methods/sale/specs/missingTrash.spec.js index 4dbe2588c..490ad7e0e 100644 --- a/modules/ticket/back/methods/sale/specs/missingTrash.spec.js +++ b/modules/ticket/back/methods/sale/specs/missingTrash.spec.js @@ -7,23 +7,22 @@ describe('sale missingTrash()', () => { try { const options = { transaction: tx }; - const saleFk = 1; - const quantity = 3; + const quantity = 1; const isTrash = true; - const warehouseFk = 1; - const newQuantity = 2; const ctx = { req: { accessToken: { userId: 9 } } }; - let sale = await models.Sale.findById(saleFk, null, options); - expect(sale.quantity).toEqual(5); - expect(sale.originalQuantity).toBe(null); + const sale = await models.Sale.findOne({fields: ['id','quantity', 'originalQuantity', 'ticketFk']}, options); + console.log(sale); + const ticket = await models.Ticket.findById(sale.ticketFk, {fields: ['warehouseFk']}, options); + console.log(ticket); + const newQuantity = sale.quantity-quantity; - await models.Sale.missingTrash(ctx, saleFk, quantity, isTrash, warehouseFk, newQuantity, options); + await models.Sale.missingTrash(ctx, sale.id, quantity, isTrash, ticket.warehouseFk, newQuantity, options); - sale = await models.Sale.findById(saleFk, null, options); - expect(sale.quantity).toEqual(2); - expect(sale.originalQuantity).toBe(5); + const saleAfter = await models.Sale.findById(sale.id, {fields: ['quantity', 'originalQuantity']}, options); + expect(saleAfter.quantity).toEqual(newQuantity); + expect(saleAfter.originalQuantity).toBe(sale.quantity); await tx.rollback();