From 48e4628c4839e5f7174160b547e769458a8f0bee Mon Sep 17 00:00:00 2001 From: carlosjr Date: Thu, 30 Dec 2021 09:49:11 +0100 Subject: [PATCH 1/2] refactor(ticket.summary): change state button is now dropdown --- modules/ticket/front/summary/index.html | 16 ++++++++-------- modules/ticket/front/summary/index.js | 9 +++++---- modules/ticket/front/summary/locale/es.yml | 3 ++- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/modules/ticket/front/summary/index.html b/modules/ticket/front/summary/index.html index 0177ba710..42a77a394 100644 --- a/modules/ticket/front/summary/index.html +++ b/modules/ticket/front/summary/index.html @@ -11,14 +11,14 @@ Ticket #{{$ctrl.summary.id}} - {{$ctrl.summary.client.name}} ({{$ctrl.summary.client.id}}) - {{$ctrl.summary.nickname}} - - + + { diff --git a/modules/ticket/front/summary/locale/es.yml b/modules/ticket/front/summary/locale/es.yml index afa06f206..d1e6dba58 100644 --- a/modules/ticket/front/summary/locale/es.yml +++ b/modules/ticket/front/summary/locale/es.yml @@ -2,4 +2,5 @@ Address phone: Tel. consignatario Address mobile: Móv. consignatario Client phone: Tel. cliente Client mobile: Móv. cliente -Go to the ticket: Ir al ticket \ No newline at end of file +Go to the ticket: Ir al ticket +Change state: Cambiar estado \ No newline at end of file -- 2.40.1 From 7dbf03ed726cf268b496da5283be49e1c1c607a4 Mon Sep 17 00:00:00 2001 From: carlosjr Date: Thu, 30 Dec 2021 10:45:19 +0100 Subject: [PATCH 2/2] front unit test and e2e for change state --- e2e/helpers/selectors.js | 3 ++- e2e/paths/05-ticket/16_summary.spec.js | 20 ++++++++++++++++++-- modules/ticket/front/summary/index.spec.js | 15 +++++++++++++++ 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 155ffdd22..2900a285b 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -458,7 +458,8 @@ export default { firstSaleQuantity: 'vn-ticket-summary [name="sales"] vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(5)', firstSaleDiscount: 'vn-ticket-summary [name="sales"] vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(8)', invoiceOutRef: 'vn-ticket-summary > vn-card > vn-horizontal > vn-one:nth-child(1) > vn-label-value:nth-child(7) > section > span', - setOk: 'vn-ticket-summary vn-button[label="SET OK"] > button', + stateButton: 'vn-ticket-summary vn-button-menu > button ', + stateAutocomplete: 'div.filter.ng-scope > vn-textfield > div.container > div.infix > div.control', descriptorTicketId: 'vn-ticket-descriptor > vn-descriptor-content > div > div.body > div.top > div' }, ticketsIndex: { diff --git a/e2e/paths/05-ticket/16_summary.spec.js b/e2e/paths/05-ticket/16_summary.spec.js index 5095b6f3d..960998c7d 100644 --- a/e2e/paths/05-ticket/16_summary.spec.js +++ b/e2e/paths/05-ticket/16_summary.spec.js @@ -76,8 +76,24 @@ describe('Ticket Summary path', () => { await page.waitForState('ticket.card.summary'); }); - it('should click on the SET OK button', async() => { - await page.waitToClick(selectors.ticketSummary.setOk); + it('should set the ticket state to OK using the top right button', async() => { + const searchValue = 'OK'; + await page.waitToClick(selectors.ticketSummary.stateButton); + await page.write(selectors.ticketSummary.stateAutocomplete, searchValue); + try { + await page.waitForFunction(text => { + const element = document.querySelector('li.active'); + if (element) + return element.innerText.toLowerCase().includes(text.toLowerCase()); + }, {}, searchValue); + } catch (error) { + const state = await page.evaluate(() => { + const stateSelector = 'vn-ticket-summary vn-label-value:nth-child(1) > section > span'; + return document.querySelector(stateSelector).value; + }); + throw new Error(`${stateSelector} innerText is ${state}! ${error}`); + } + await page.keyboard.press('Enter'); const message = await page.waitForSnackbar(); expect(message.text).toContain('Data saved!'); diff --git a/modules/ticket/front/summary/index.spec.js b/modules/ticket/front/summary/index.spec.js index 9f836e204..599da73ae 100644 --- a/modules/ticket/front/summary/index.spec.js +++ b/modules/ticket/front/summary/index.spec.js @@ -42,5 +42,20 @@ describe('Ticket', () => { expect(controller.formattedAddress).toEqual('1007 Mountain Drive - 46060 - Gotham (Gotham)'); }); }); + + describe('changeState()', () => { + it('should change the state', () => { + jest.spyOn(controller.vnApp, 'showSuccess'); + const value = 'myTicketState'; + + let res = {id: 1, nickname: 'myNickname'}; + $httpBackend.when('GET', `Tickets/1/summary`).respond(200, res); + $httpBackend.expectPOST(`TicketTrackings/changeState`).respond(200, 'ok'); + controller.changeState(value); + $httpBackend.flush(); + + expect(controller.vnApp.showSuccess).toHaveBeenCalledWith('Data saved!'); + }); + }); }); }); -- 2.40.1