From dc46ede5132879d4081551675087cff2c70645df Mon Sep 17 00:00:00 2001 From: Carlos Jimenez Ruiz Date: Tue, 22 Jan 2019 15:55:58 +0100 Subject: [PATCH] #1020 modificar e2e ticket.tracking --- e2e/helpers/nightmare.js | 2 +- e2e/helpers/selectors.js | 3 +- .../05_create_new_tracking_state.spec.js | 111 +++++++++++++----- loopback/locale/en.json | 4 +- 4 files changed, 85 insertions(+), 35 deletions(-) diff --git a/e2e/helpers/nightmare.js b/e2e/helpers/nightmare.js index f88396fbf..e3b65e16b 100644 --- a/e2e/helpers/nightmare.js +++ b/e2e/helpers/nightmare.js @@ -12,7 +12,7 @@ export default function createNightmare(width = 1280, height = 720) { nightmare.on('console', (type, message, ...args) => { if (type === 'error') - fail(message); + throw new Error(message); else console[type](message, ...args); }); diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index bbe0f219a..12b39939c 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -192,7 +192,7 @@ export default { moreMenu: `vn-item-descriptor vn-icon-menu > div > vn-icon`, moreMenuRegularizeButton: `vn-item-descriptor vn-icon-menu > div > vn-drop-down > vn-popover ul > li:nth-child(1)`, regularizeQuantityInput: `vn-item-descriptor > vn-dialog > div > form > div.body > tpl-body > div > vn-textfield > div > div > div.infix > input`, - regularizeWarehouseAutocomplete: `#warehouse`, + regularizeWarehouseAutocomplete: 'vn-item-descriptor > vn-dialog vn-autocomplete[field="$ctrl.warehouseFk"]', regularizeSaveButton: `vn-item-descriptor > vn-dialog > div > form > div.buttons > tpl-buttons > button` }, itemBasicData: { @@ -439,6 +439,7 @@ export default { }, createStateView: { stateAutocomplete: `vn-autocomplete[field="$ctrl.stateFk"]`, + workerAutocomplete: `vn-autocomplete[field="$ctrl.workerFk"]`, clearStateInputButton: `vn-autocomplete[field="$ctrl.stateFk"] > div > div > div > vn-icon > i`, saveStateButton: `${components.vnSubmit}` }, diff --git a/e2e/paths/ticket-module/05_create_new_tracking_state.spec.js b/e2e/paths/ticket-module/05_create_new_tracking_state.spec.js index 8446d84fc..8ed39f2a0 100644 --- a/e2e/paths/ticket-module/05_create_new_tracking_state.spec.js +++ b/e2e/paths/ticket-module/05_create_new_tracking_state.spec.js @@ -4,47 +4,94 @@ import createNightmare from '../../helpers/nightmare'; describe('Ticket Create new tracking state path', () => { const nightmare = createNightmare(); - beforeAll(() => { - return nightmare - .loginAndModule('production', 'ticket') - .accessToSearchResult('id:1') - .accessToSection('ticket.card.tracking.index'); + describe('as production', () => { + beforeAll(() => { + return nightmare + .loginAndModule('production', 'ticket') + .accessToSearchResult('id:1') + .accessToSection('ticket.card.tracking.index'); + }); + + it('should access to the create state view by clicking the create floating button', async() => { + let url = await nightmare + .waitToClick(selectors.ticketTracking.createStateButton) + .wait(selectors.createStateView.stateAutocomplete) + .parsedUrl(); + + expect(url.hash).toContain('tracking/edit'); + }); + + it(`should attempt create a new state but receive an error if state is empty`, async() => { + let result = await nightmare + .click(selectors.createStateView.saveStateButton) + .waitForLastSnackbar(); + + expect(result).toEqual('State cannot be blank'); + }); + + it(`should attempt create a new state then clear and save it`, async() => { + let result = await nightmare + .autocompleteSearch(selectors.createStateView.stateAutocomplete, '¿Fecha?') + .waitToClick(selectors.createStateView.clearStateInputButton) + .waitToClick(selectors.createStateView.saveStateButton) + .waitForLastSnackbar(); + + expect(result).toEqual('State cannot be blank'); + }); + + + it(`should create a new state`, async() => { + let result = await nightmare + .autocompleteSearch(selectors.createStateView.stateAutocomplete, '¿Fecha?') + .click(selectors.createStateView.saveStateButton) + .waitForLastSnackbar(); + + expect(result).toEqual('Data saved!'); + }); }); - it('should access to the create state view by clicking the create floating button', async() => { - let url = await nightmare - .waitToClick(selectors.ticketTracking.createStateButton) - .wait(selectors.createStateView.stateAutocomplete) - .parsedUrl(); + describe('as salesPerson', () => { + beforeAll(() => { + return nightmare + .loginAndModule('salesPerson', 'ticket') + .accessToSearchResult('id:1') + .accessToSection('ticket.card.tracking.index'); + }); - expect(url.hash).toContain('tracking/edit'); - }); + it('should now access to the create state view by clicking the create floating button', async() => { + let url = await nightmare + .waitToClick(selectors.ticketTracking.createStateButton) + .wait(selectors.createStateView.stateAutocomplete) + .parsedUrl(); - it(`should attempt create a new state but receive an error if state is empty`, async() => { - let result = await nightmare - .click(selectors.createStateView.saveStateButton) - .waitForLastSnackbar(); + expect(url.hash).toContain('tracking/edit'); + }); - expect(result).toEqual('State cannot be blank'); - }); + it(`should attemp to create an state for which salesPerson doesn't have permissions`, async() => { + let result = await nightmare + .autocompleteSearch(selectors.createStateView.stateAutocomplete, '¿Fecha?') + .click(selectors.createStateView.saveStateButton) + .waitForLastSnackbar(); - it(`should attempt create a new state then clear and save it`, async() => { - let result = await nightmare - .autocompleteSearch(selectors.createStateView.stateAutocomplete, '¿Fecha?') - .waitToClick(selectors.createStateView.clearStateInputButton) - .waitToClick(selectors.createStateView.saveStateButton) - .waitForLastSnackbar(); + expect(result).toEqual(`You don't have enough privileges to change the state of this ticket`); + }); - expect(result).toEqual('State cannot be blank'); - }); + it(`should attempt to create an state for the type salesPerson has rights but fail as worker is blank`, async() => { + let result = await nightmare + .autocompleteSearch(selectors.createStateView.stateAutocomplete, 'asignado') + .click(selectors.createStateView.saveStateButton) + .waitForLastSnackbar(); + expect(result).toEqual(`Worker cannot be blank`); + }); - it(`should create a new state`, async() => { - let result = await nightmare - .autocompleteSearch(selectors.createStateView.stateAutocomplete, '¿Fecha?') - .click(selectors.createStateView.saveStateButton) - .waitForLastSnackbar(); + it(`should create a new state with all it's data`, async() => { + let result = await nightmare + .autocompleteSearch(selectors.createStateView.workerAutocomplete, 'accessory') + .click(selectors.createStateView.saveStateButton) + .waitForLastSnackbar(); - expect(result).toEqual('Data saved!'); + expect(result).toEqual('Data saved!'); + }); }); }); diff --git a/loopback/locale/en.json b/loopback/locale/en.json index 9e24f2b04..bc7db2e30 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -27,5 +27,7 @@ "Agency cannot be blank": "Agency cannot be blank", "The IBAN does not have the correct format": "The IBAN does not have the correct format", "You can't make changes on the basic data of an confirmed order or with rows": "You can't make changes on the basic data of an confirmed order or with rows", - "You can't create a ticket for a inactive client": "You can't create a ticket for a inactive client" + "You can't create a ticket for a inactive client": "You can't create a ticket for a inactive client", + "Worker cannot be blank": "Worker cannot be blank", + "You don't have enough privileges to change the state of this ticket": "You don't have enough privileges to change the state of this ticket" } \ No newline at end of file