From 9ddf11c6bc1305ad3289431a56f9c9f66556d72a Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 18 Jan 2022 12:49:16 +0100 Subject: [PATCH] test(ticket): update to advanceable --- .../05-ticket/06_basic_data_steps.spec.js | 8 +-- .../ticket/specs/componentUpdate.spec.js | 56 +++++++++++++++++++ .../ticket/specs/priceDifference.spec.js | 2 +- 3 files changed, 61 insertions(+), 5 deletions(-) diff --git a/e2e/paths/05-ticket/06_basic_data_steps.spec.js b/e2e/paths/05-ticket/06_basic_data_steps.spec.js index 6ae7029797..93c6bba657 100644 --- a/e2e/paths/05-ticket/06_basic_data_steps.spec.js +++ b/e2e/paths/05-ticket/06_basic_data_steps.spec.js @@ -8,7 +8,7 @@ describe('Ticket Edit basic data path', () => { beforeAll(async() => { browser = await getBrowser(); page = browser.page; - await page.loginAndModule('employee', 'ticket'); + await page.loginAndModule('employee', 'ticket'); await page.accessToSearchResult('11'); await page.accessToSection('ticket.card.basicData.stepOne'); }); @@ -85,7 +85,7 @@ describe('Ticket Edit basic data path', () => { }); it(`should not find ticket`, async() => { - await page.doSearch('28'); + await page.doSearch('29'); const count = await page.countElement(selectors.ticketsIndex.searchResult); expect(count).toEqual(0); @@ -128,8 +128,8 @@ describe('Ticket Edit basic data path', () => { const expectedMonth = tomorrow.getMonth() + 1; const expectedYear = tomorrow.getFullYear(); - await page.loginAndModule('employee', 'ticket'); - await page.accessToSearchResult('28'); + await page.loginAndModule('employee', 'ticket'); + await page.accessToSearchResult('29'); await page.accessToSection('ticket.card.sale'); const item = await page.waitToGetProperty(selectors.ticketSales.firstSaleId, 'innerText'); diff --git a/modules/ticket/back/methods/ticket/specs/componentUpdate.spec.js b/modules/ticket/back/methods/ticket/specs/componentUpdate.spec.js index 38e6ce6a7d..2aa2a07c4c 100644 --- a/modules/ticket/back/methods/ticket/specs/componentUpdate.spec.js +++ b/modules/ticket/back/methods/ticket/specs/componentUpdate.spec.js @@ -136,4 +136,60 @@ describe('ticket componentUpdate()', () => { throw e; } }); + + it('should change warehouse and without negatives', async() => { + const tx = await models.SaleComponent.beginTransaction({}); + + try { + const options = {transaction: tx}; + + const saleToTransfer = 27; + const originDate = today; + const newDate = tomorrow; + const ticketID = 14; + newDate.setHours(0, 0, 0, 0, 0); + originDate.setHours(0, 0, 0, 0, 0); + + const args = { + id: ticketID, + clientFk: 1104, + agencyModeFk: 2, + addressFk: 4, + zoneFk: 9, + warehouseFk: 1, + companyFk: 442, + shipped: newDate, + landed: tomorrow, + isDeleted: false, + option: 1, + isWithoutNegatives: true + }; + + const ctx = { + args: args, + req: { + accessToken: {userId: 9}, + headers: {origin: 'http://localhost'}, + __: value => { + return value; + } + } + }; + await models.Ticket.componentUpdate(ctx, options); + + const [newTicketID] = await models.Ticket.rawSql('SELECT MAX(id) as id FROM ticket', null, options); + const oldTicket = await models.Ticket.findById(ticketID, null, options); + const newTicket = await models.Ticket.findById(newTicketID.id, null, options); + const newTicketSale = await models.Sale.findOne({where: {ticketFk: args.id}}, options); + + expect(oldTicket.shipped).toEqual(originDate); + expect(newTicket.shipped).toEqual(newDate); + expect(newTicketSale.id).toEqual(saleToTransfer); + + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + }); }); diff --git a/modules/ticket/back/methods/ticket/specs/priceDifference.spec.js b/modules/ticket/back/methods/ticket/specs/priceDifference.spec.js index bc37e33cbc..362c3e923e 100644 --- a/modules/ticket/back/methods/ticket/specs/priceDifference.spec.js +++ b/modules/ticket/back/methods/ticket/specs/priceDifference.spec.js @@ -60,7 +60,7 @@ describe('sale priceDifference()', () => { expect(error).toEqual(new UserError(`The sales of this ticket can't be modified`)); }); - it('should return ticket available', async() => { + it('should return ticket advanceable', async() => { const tx = await models.Ticket.beginTransaction({}); try {