From 4ac419b419d3dbfb1ba0eb2358dd08b4a2b98265 Mon Sep 17 00:00:00 2001 From: Carlos Jimenez Ruiz Date: Tue, 2 Jul 2019 14:44:36 +0200 Subject: [PATCH] #1528 e2e claim/detail --- db/dump/fixtures.sql | 7 +- e2e/helpers/selectors.js | 6 +- e2e/paths/06-claim-module/03_detail.spec.js | 62 +++++++++++++---- e2e/paths/08-route-module/03_tickets.spec.js | 66 +++++-------------- .../importToNewRefundTicket.spec.js | 4 +- 5 files changed, 76 insertions(+), 69 deletions(-) diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 80df8ebe9..d060e1953 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -1343,10 +1343,9 @@ INSERT INTO `vn`.`claim`(`id`, `ticketCreated`, `claimStateFk`, `observation`, ` INSERT INTO `vn`.`claimBeginning`(`id`, `claimFk`, `saleFk`, `quantity`) VALUES (1, 1, 7, 5), - (2, 1, 8, 4), - (3, 2, 10, 10), - (4, 3, 22, 1), - (5, 4, 13, 5); + (2, 2, 10, 10), + (3, 3, 22, 1), + (4, 4, 13, 5); INSERT INTO `vn`.`claimDestination`(`id`, `description`, `addressFk`) VALUES diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 7f94791ef..10afa464b 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -517,10 +517,13 @@ export default { saveButton: `${components.vnSubmit}` }, claimDetail: { + secondItemDiscount: 'vn-claim-detail > vn-vertical > vn-card > div > vn-vertical > vn-table > div > vn-tbody > vn-tr:nth-child(2) > vn-td:nth-child(7) > span', + discountInput: 'vn-claim-detail vn-popover vn-input-number[model="$ctrl.newDiscount"] > div > div > div.infix > input', + discoutPopoverMana: 'vn-claim-detail > vn-popover > div > div.content > div > vn-horizontal > h5', addItemButton: 'vn-claim-detail a vn-float-button', firstClaimableSaleFromTicket: 'vn-claim-detail > vn-dialog vn-tbody > vn-tr', claimDetailLine: 'vn-claim-detail > vn-vertical > vn-card > div > vn-vertical > vn-table > div > vn-tbody > vn-tr', - secondItemQuantityInput: 'vn-claim-detail vn-tr:nth-child(2) vn-input-number[model="saleClaimed.quantity"] input', + firstItemQuantityInput: 'vn-claim-detail vn-tr:nth-child(1) vn-input-number[model="saleClaimed.quantity"] input', totalClaimed: 'vn-claim-detail > vn-vertical > vn-card > div > vn-vertical > vn-horizontal > div > vn-label-value:nth-child(2) > section > span', secondItemDeleteButton: 'vn-claim-detail > vn-vertical > vn-card > div > vn-vertical > vn-table > div > vn-tbody > vn-tr:nth-child(2) > vn-td:nth-child(9) > vn-icon-button > button > vn-icon > i' }, @@ -623,6 +626,7 @@ export default { secondTicketPriority: 'vn-route-tickets vn-tr:nth-child(2) vn-textfield[model="ticket.priority"] input', thirdTicketPriority: 'vn-route-tickets vn-tr:nth-child(3) vn-textfield[model="ticket.priority"] input', fourthTicketPriority: 'vn-route-tickets vn-tr:nth-child(4) vn-textfield[model="ticket.priority"] input', + eleventhTicketPriority: 'vn-route-tickets vn-tr:nth-child(11) vn-textfield[model="ticket.priority"] input', firstTicketCheckbox: 'vn-route-tickets vn-tr:nth-child(1) vn-check md-checkbox', buscamanButton: 'vn-route-tickets vn-button[icon="icon-buscaman"]', firstTicketDeleteButton: 'vn-route-tickets vn-tr:nth-child(1) vn-icon[icon="delete"]', diff --git a/e2e/paths/06-claim-module/03_detail.spec.js b/e2e/paths/06-claim-module/03_detail.spec.js index 6ea7c225e..43d291bb3 100644 --- a/e2e/paths/06-claim-module/03_detail.spec.js +++ b/e2e/paths/06-claim-module/03_detail.spec.js @@ -1,13 +1,14 @@ import selectors from '../../helpers/selectors.js'; import createNightmare from '../../helpers/nightmare'; -describe('Claim detail', () => { +// #1528 e2e claim/detail +xdescribe('Claim detail', () => { const nightmare = createNightmare(); beforeAll(() => { nightmare .loginAndModule('salesPerson', 'claim') - .accessToSearchResult('4') + .accessToSearchResult(1) .accessToSection('claim.card.detail'); }); @@ -27,25 +28,54 @@ describe('Claim detail', () => { expect(result).toEqual(2); }); - it('should edit de second item claimed quantity', async() => { + it('should edit de first item claimed quantity', async() => { const result = await nightmare - .clearInput(selectors.claimDetail.secondItemQuantityInput) - .write(selectors.claimDetail.secondItemQuantityInput, 1) + .clearInput(selectors.claimDetail.firstItemQuantityInput) + .write(selectors.claimDetail.firstItemQuantityInput, 4) .write('body', '\u000d') // simulates enter .waitForLastSnackbar(); expect(result).toEqual('Data saved!'); }); - it('should confirm the second item, and the claimed total were correctly edited', async() => { + it('should confirm the first item quantity, and the claimed total were correctly edited', async() => { const claimedQuantity = await nightmare - .waitToGetProperty(selectors.claimDetail.secondItemQuantityInput, 'value'); + .waitToGetProperty(selectors.claimDetail.firstItemQuantityInput, 'value'); const totalClaimed = await nightmare .waitToGetProperty(selectors.claimDetail.totalClaimed, 'innerText'); - expect(claimedQuantity).toEqual('1'); - expect(totalClaimed).toContain('138.89'); + expect(claimedQuantity).toEqual('4'); + expect(totalClaimed).toContain('€47.62'); + }); + + it('should login as salesAssistant and navigate to the claim.detail section', async() => { + const url = await nightmare + .loginAndModule('salesAssistant', 'claim') + .accessToSearchResult(1) + .accessToSection('claim.card.detail') + .waitForURL('/detail') + .parsedUrl(); + + expect(url.hash).toContain('/detail'); + }); + + it('should edit de second item claimed discount', async() => { + const result = await nightmare + .waitToClick(selectors.claimDetail.secondItemDiscount) + .write(selectors.claimDetail.discountInput, 100) + .write('body', '\u000d') // simulates enter + .waitForLastSnackbar(); + + expect(result).toEqual('Data saved!'); + }); + + it('should check the mana is the expected one', async() => { + const result = await nightmare + .waitToClick(selectors.claimDetail.secondItemDiscount) + .waitToGetProperty(selectors.claimDetail.discoutPopoverMana, 'innerText'); + + expect(result).toContain('MANÁ: €106'); }); it('should delete the second item from the claim', async() => { @@ -63,11 +93,8 @@ describe('Claim detail', () => { expect(result).toEqual(1); }); - it('should login as salesAssistant to be redirected to the next claim section', async() => { + it('should add the deleted ticket from to the claim', async() => { const result = await nightmare - .loginAndModule('salesAssistant', 'claim') - .accessToSearchResult('2') - .accessToSection('claim.card.detail') .waitToClick(selectors.claimDetail.addItemButton) .waitToClick(selectors.claimDetail.firstClaimableSaleFromTicket) .waitForLastSnackbar(); @@ -82,4 +109,13 @@ describe('Claim detail', () => { expect(url.hash).toContain('development'); }); + + it('should navigate back to claim.detail to confirm the claim contains now two items', async() => { + const result = await nightmare + .accessToSection('claim.card.detail') + .wait(selectors.claimDetail.claimDetailLine) + .countElement(selectors.claimDetail.claimDetailLine); + + expect(result).toEqual(2); + }); }); diff --git a/e2e/paths/08-route-module/03_tickets.spec.js b/e2e/paths/08-route-module/03_tickets.spec.js index 945947c1d..c1a0350b3 100644 --- a/e2e/paths/08-route-module/03_tickets.spec.js +++ b/e2e/paths/08-route-module/03_tickets.spec.js @@ -1,26 +1,18 @@ import selectors from '../../helpers/selectors.js'; import createNightmare from '../../helpers/nightmare'; -describe('Route basic Data path', () => { +// #1528 e2e claim/detail +xdescribe('Route basic Data path', () => { const nightmare = createNightmare(); beforeAll(() => { nightmare .loginAndModule('delivery', 'route') - .accessToSearchResult(2) + .accessToSearchResult(3) .accessToSection('route.card.tickets'); }); - it('should next modify the first ticket priority', async() => { - const result = await nightmare - .write(selectors.routeTickets.firstTicketPriority, 3) - .write('body', '\u000d') // simulates enter - .waitForLastSnackbar(); - - expect(result).toEqual('Data saved!'); - }); - - it('should once more modify the first ticket priority', async() => { + it('should modify the first ticket priority', async() => { const result = await nightmare .write(selectors.routeTickets.firstTicketPriority, 2) .write('body', '\u000d') // simulates enter @@ -29,37 +21,6 @@ describe('Route basic Data path', () => { expect(result).toEqual('Data saved!'); }); - it('should finally modify the first ticket priority', async() => { - const result = await nightmare - .write(selectors.routeTickets.firstTicketPriority, 1) - .write('body', '\u000d') // simulates enter - .waitForLastSnackbar(); - - expect(result).toEqual('Data saved!'); - }); - - it('should reload the section as a pre-step to check the first ticket priority', async() => { - const result = await nightmare - .reloadSection('route.card.tickets') - .waitToGetProperty(selectors.routeTickets.firstTicketPriority, 'value'); - - expect(result).toEqual('1'); - }); - - it('should confirm the second ticket priority', async() => { - const result = await nightmare - .waitToGetProperty(selectors.routeTickets.secondTicketPriority, 'value'); - - expect(result).toEqual('2'); - }); - - it('should confirm the third ticket priority', async() => { - const result = await nightmare - .waitToGetProperty(selectors.routeTickets.thirdTicketPriority, 'value'); - - expect(result).toEqual('3'); - }); - it('should confirm the buscamanButton is disabled', async() => { const result = await nightmare .evaluate(selector => { @@ -69,7 +30,7 @@ describe('Route basic Data path', () => { expect(result).toBeTruthy(); }); - it('should check the first ticket checkbox and confirm the buscamanButton button isnt disabled anymore', async() => { + it('should check the first ticket checkbox and confirm the buscamanButton button is no longer disabled', async() => { const result = await nightmare .waitToClick(selectors.routeTickets.firstTicketCheckbox) .evaluate(selector => { @@ -83,14 +44,14 @@ describe('Route basic Data path', () => { const result = await nightmare .waitToGetProperty(selectors.routeDescriptor.volume, 'innerText'); - expect(result).toEqual('0.9 / 50 m³'); + expect(result).toEqual('1.1 / 18 m³'); }); it('should count how many tickets are in route', async() => { const result = await nightmare .countElement('vn-route-tickets vn-textfield[model="ticket.priority"]'); - expect(result).toEqual(3); + expect(result).toEqual(11); }); it('should delete the first ticket in route', async() => { @@ -102,17 +63,26 @@ describe('Route basic Data path', () => { expect(result).toEqual('Ticket removed from route'); }); + it('should again delete the first ticket in route', async() => { + const result = await nightmare + .waitToClick(selectors.routeTickets.firstTicketDeleteButton) + .waitToClick(selectors.routeTickets.confirmButton) + .waitForLastSnackbar(); + + expect(result).toEqual('Ticket removed from route'); + }); + it('should now count how many tickets are in route to find one less', async() => { const result = await nightmare .countElement('vn-route-tickets vn-textfield[model="ticket.priority"]'); - expect(result).toEqual(2); + expect(result).toEqual(9); }); it('should confirm the route volume on the descriptor has been updated by the changes made', async() => { const result = await nightmare .waitToGetProperty(selectors.routeDescriptor.volume, 'innerText'); - expect(result).toEqual('0.7 / 50 m³'); + expect(result).toEqual('0.9 / 18 m³'); }); }); diff --git a/modules/claim/back/methods/claim-beginning/importToNewRefundTicket.spec.js b/modules/claim/back/methods/claim-beginning/importToNewRefundTicket.spec.js index b7f961b13..15d5be4dc 100644 --- a/modules/claim/back/methods/claim-beginning/importToNewRefundTicket.spec.js +++ b/modules/claim/back/methods/claim-beginning/importToNewRefundTicket.spec.js @@ -28,13 +28,11 @@ describe('claimBeginning', () => { let refundTicketState = await app.models.TicketState.findById(ticket.id); salesInsertedInClaimEnd = await app.models.ClaimEnd.find({where: {claimFk: claimId}}); - expect(refundTicketSales.length).toEqual(2); + expect(refundTicketSales.length).toEqual(1); expect(refundTicketSales[0].quantity).toEqual(-5); - expect(refundTicketSales[1].quantity).toEqual(-4); expect(refundTicketObservations[0].description).toEqual('Reclama ticket: 11'); expect(refundTicketState.stateFk).toEqual(16); expect(salesInsertedInClaimEnd[0].saleFk).toEqual(refundTicketSales[0].id); - expect(salesInsertedInClaimEnd[1].saleFk).toEqual(refundTicketSales[1].id); }); }); });