From bd76840cb3832671626e4419b7c716748f17bd03 Mon Sep 17 00:00:00 2001 From: Carlos Jimenez Ruiz Date: Thu, 27 Jun 2019 15:33:15 +0200 Subject: [PATCH] #1446 e2e ticket.summary --- e2e/helpers/extensions.js | 9 +- e2e/helpers/selectors.js | 7 +- .../06_basic_data_steps.spec.js | 1 - e2e/paths/05-ticket-module/16_summary.spec.js | 89 +++++++++++++++++++ modules/ticket/front/locale/es.yml | 1 + modules/ticket/front/summary/index.html | 2 +- 6 files changed, 105 insertions(+), 4 deletions(-) create mode 100644 e2e/paths/05-ticket-module/16_summary.spec.js diff --git a/e2e/helpers/extensions.js b/e2e/helpers/extensions.js index 6e232a9bf..9ddac8589 100644 --- a/e2e/helpers/extensions.js +++ b/e2e/helpers/extensions.js @@ -488,7 +488,14 @@ let actions = { }) .then(done) .catch(done); - } + }, + + waitForSpinnerLoad: function(done) { + let spinnerSelector = 'vn-spinner > div'; + this.waitForClassNotPresent(spinnerSelector, 'is-active') + .then(done) + .catch(done); + }, }; Object.keys(actions).forEach(function(name) { diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index d88688b89..a1e54abb5 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -300,12 +300,17 @@ export default { fifthLineCreatedProperty: 'vn-item-log > vn-log vn-tbody > vn-tr:nth-child(5) > vn-td > vn-one:nth-child(3) > div span:nth-child(3)', }, ticketSummary: { + header: 'vn-ticket-summary > vn-card > div > h5', + state: 'vn-ticket-summary vn-label-value[label="State"] > section > span', + route: 'vn-ticket-summary vn-label-value[label="Route"] > section > span', + total: 'vn-ticket-summary vn-one.taxes > p:nth-child(3) > strong', sale: 'vn-ticket-summary [name="sales"] vn-table > div > vn-tbody > vn-tr', firstSaleItemId: 'vn-ticket-summary [name="sales"] vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(2) > span', popoverDiaryButton: 'vn-ticket-summary vn-item-descriptor-popover vn-item-descriptor vn-icon[icon="icon-transaction"]', firstSaleQuantity: 'vn-ticket-summary [name="sales"] vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(3)', firstSaleDiscount: 'vn-ticket-summary [name="sales"] vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(6)', - invoiceOutRef: 'vn-ticket-summary > vn-card > div > vn-horizontal > vn-one:nth-child(1) > vn-label-value:nth-child(6) > section > span' + invoiceOutRef: 'vn-ticket-summary > vn-card > div > vn-horizontal > vn-one:nth-child(1) > vn-label-value:nth-child(6) > section > span', + setOk: 'vn-ticket-summary vn-button[label="SET OK"] > button' }, ticketsIndex: { openAdvancedSearchButton: 'vn-ticket-index vn-searchbar t-right-icons > vn-icon[icon="keyboard_arrow_down"]', diff --git a/e2e/paths/05-ticket-module/06_basic_data_steps.spec.js b/e2e/paths/05-ticket-module/06_basic_data_steps.spec.js index 8096935ad..4e0fe9945 100644 --- a/e2e/paths/05-ticket-module/06_basic_data_steps.spec.js +++ b/e2e/paths/05-ticket-module/06_basic_data_steps.spec.js @@ -23,7 +23,6 @@ describe('Ticket Edit basic data path', () => { it(`should have a price diference`, async() => { const result = await nightmare - .wait(1900) .waitToGetProperty(selectors.ticketBasicData.stepTwoTotalPriceDif, 'innerText'); expect(result).toContain('-€184.25'); diff --git a/e2e/paths/05-ticket-module/16_summary.spec.js b/e2e/paths/05-ticket-module/16_summary.spec.js new file mode 100644 index 000000000..c66b636ef --- /dev/null +++ b/e2e/paths/05-ticket-module/16_summary.spec.js @@ -0,0 +1,89 @@ +import selectors from '../../helpers/selectors.js'; +import createNightmare from '../../helpers/nightmare'; + +describe('Ticket Summary path', () => { + const nightmare = createNightmare(); + const ticketId = 20; + + it('should navigate to the target ticket summary section', async() => { + let url = await nightmare + .loginAndModule('employee', 'ticket') + .accessToSearchResult(ticketId) + .waitForURL('/summary') + .parsedUrl(); + + expect(url.hash).toContain('/summary'); + }); + + it(`should display details from the ticket and it's client on the top of the header`, async() => { + let result = await nightmare + .waitForSpinnerLoad() + .waitToGetProperty(selectors.ticketSummary.header, 'innerText'); + + expect(result).toContain(`Ticket #${ticketId}`); + expect(result).toContain('Bruce Banner (109)'); + expect(result).toContain('Somewhere in Thailand'); + }); + + it('should display ticket details', async() => { + let result = await nightmare + .waitToGetProperty(selectors.ticketSummary.state, 'innerText'); + + expect(result).toContain('Arreglar'); + }); + + it('should display delivery details', async() => { + let result = await nightmare + .waitToGetProperty(selectors.ticketSummary.route, 'innerText'); + + expect(result).toContain('3'); + }); + + it('should display the ticket total', async() => { + let result = await nightmare + .waitToGetProperty(selectors.ticketSummary.total, 'innerText'); + + expect(result).toContain('€155.54'); + }); + + it('should display the ticket line(s)', async() => { + let result = await nightmare + .waitToGetProperty(selectors.ticketSummary.firstSaleItemId, 'innerText'); + + expect(result).toContain('000002'); + }); + + it('should click on the SET OK button and throw a privileges error', async() => { + let result = await nightmare + .waitToClick(selectors.ticketSummary.setOk) + .waitForLastSnackbar(); + + expect(result).toEqual(`You don't have enough privileges`); + }); + + it('should log in as production then navigate to the summary of the same ticket', async() => { + let url = await nightmare + .loginAndModule('production', 'ticket') + .accessToSearchResult(ticketId) + .waitForURL('/summary') + .parsedUrl(); + + expect(url.hash).toContain('/summary'); + }); + + it('should click on the SET OK button', async() => { + let result = await nightmare + .waitToClick(selectors.ticketSummary.setOk) + .waitForLastSnackbar(); + + expect(result).toEqual('Data saved!'); + }); + + it('should confirm the ticket state was updated', async() => { + let result = await nightmare + .waitForSpinnerLoad() + .waitToGetProperty(selectors.ticketSummary.state, 'innerText'); + + expect(result).toContain('OK'); + }); +}); diff --git a/modules/ticket/front/locale/es.yml b/modules/ticket/front/locale/es.yml index d57ca3fdf..a1abc81fc 100644 --- a/modules/ticket/front/locale/es.yml +++ b/modules/ticket/front/locale/es.yml @@ -44,6 +44,7 @@ Price gap: Diferencia de precio Quantity: Cantidad Remove lines: Borrar lineas Route: Ruta +SET OK: PONER OK Shipment: Salida Shipped: F. envío Some fields are invalid: Algunos campos no son válidos diff --git a/modules/ticket/front/summary/index.html b/modules/ticket/front/summary/index.html index 0e6052d3d..c718e38f0 100644 --- a/modules/ticket/front/summary/index.html +++ b/modules/ticket/front/summary/index.html @@ -2,7 +2,7 @@
Ticket #{{$ctrl.summary.id}} - {{$ctrl.summary.client.name}} ({{$ctrl.summary.client.id}}) - {{$ctrl.summary.nickname}}