From 6865f606a4da4fc1b1ea16a41bc3699702e5396c Mon Sep 17 00:00:00 2001 From: Carlos Jimenez <=> Date: Mon, 14 Jan 2019 11:19:39 +0100 Subject: [PATCH] #892 e2e ticket.services --- e2e/helpers/selectors.js | 10 +++ e2e/paths/ticket-module/07_edit_sale.spec.js | 2 +- .../12_delete_ticket_from_descriptor.spec.js | 10 +-- .../13_create_ticket_services.spec.js | 71 +++++++++++++++++++ 4 files changed, 87 insertions(+), 6 deletions(-) create mode 100644 e2e/paths/ticket-module/13_create_ticket_services.spec.js diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 20627b4db..83b6f446f 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -412,6 +412,16 @@ export default { actionTaken: 'vn-ticket-log > vn-log > vn-vertical > vn-card > div > vn-vertical > vn-table > div > vn-tbody > vn-tr > vn-td:nth-child(1) > div > div:nth-child(3) > span.value.ng-scope.ng-binding', id: 'vn-ticket-log > vn-log > vn-vertical > vn-card > div > vn-vertical > vn-table > div > vn-tbody > vn-tr > vn-td.before > vn-one:nth-child(1) > div > span.value.ng-scope.ng-binding' }, + ticketService: { + serviceButton: 'vn-left-menu a[ui-sref="ticket.card.service"]', + addServiceButton: 'vn-ticket-service > form > vn-card > div > vn-one:nth-child(3) > vn-icon-button > button > vn-icon', + descriptionInput: 'vn-ticket-service vn-textfield[label="Description"] input', + quantityInput: 'vn-ticket-service vn-textfield[label="Quantity"] input', + priceInput: 'vn-ticket-service vn-textfield[label="Price"] input', + vatTypeAutocomplete: 'vn-ticket-service vn-autocomplete[label="Tax class"]', + fistDeleteServiceButton: 'vn-ticket-service > form > vn-card > div > vn-one:nth-child(2) > vn-horizontal > vn-auto > vn-icon', + saveServiceButton: `${components.vnSubmit}` + }, createStateView: { stateAutocomplete: `vn-autocomplete[field="$ctrl.ticket.stateFk"]`, clearStateInputButton: `vn-autocomplete[field="$ctrl.ticket.stateFk"] > div > div > div > vn-icon > i`, diff --git a/e2e/paths/ticket-module/07_edit_sale.spec.js b/e2e/paths/ticket-module/07_edit_sale.spec.js index 6499a6c83..562dcfb3d 100644 --- a/e2e/paths/ticket-module/07_edit_sale.spec.js +++ b/e2e/paths/ticket-module/07_edit_sale.spec.js @@ -381,7 +381,7 @@ describe('Ticket Edit sale path', () => { expect(result).toEqual(3); }); - it('should go back to the original ticket sales section', async() => { + it('should now go back to the original ticket sales section', async() => { const url = await nightmare .waitToClick(selectors.itemsIndex.goBackToModuleIndexButton) .wait(selectors.ticketsIndex.searchTicketInput) diff --git a/e2e/paths/ticket-module/12_delete_ticket_from_descriptor.spec.js b/e2e/paths/ticket-module/12_delete_ticket_from_descriptor.spec.js index 2a7c6df15..47951b608 100644 --- a/e2e/paths/ticket-module/12_delete_ticket_from_descriptor.spec.js +++ b/e2e/paths/ticket-module/12_delete_ticket_from_descriptor.spec.js @@ -9,7 +9,7 @@ describe('Ticket descriptor path', () => { .loginAndModule('employee', 'ticket'); }); - it('should search for a specific ticket', async () => { + it('should search for a specific ticket', async() => { const result = await nightmare .wait(selectors.ticketsIndex.searchTicketInput) .type(selectors.ticketsIndex.searchTicketInput, 'id:17') @@ -20,7 +20,7 @@ describe('Ticket descriptor path', () => { expect(result).toEqual(1); }); - it(`should click on the search result to access to the ticket Sale`, async () => { + it(`should click on the search result to access to the ticket Sale`, async() => { const url = await nightmare .waitForTextInElement(selectors.ticketsIndex.searchResult, 'address 26') .waitToClick(selectors.ticketsIndex.searchResult) @@ -30,7 +30,7 @@ describe('Ticket descriptor path', () => { expect(url.hash).toContain('/summary'); }); - it('should delete the ticket using the descriptor more menu', async () => { + it('should delete the ticket using the descriptor more menu', async() => { const result = await nightmare .waitToClick(selectors.ticketDescriptor.moreMenu) .waitToClick(selectors.ticketDescriptor.moreMenuDeleteTicket) @@ -40,14 +40,14 @@ describe('Ticket descriptor path', () => { expect(result).toEqual('Ticket deleted'); }); - it('should have been relocated to the ticket index', async () => { + it('should have been relocated to the ticket index', async() => { const url = await nightmare .parsedUrl(); expect(url.hash).toEqual('#!/ticket/index'); }); - it(`should search for the deleted ticket and check it's date`, async () => { + it(`should search for the deleted ticket and check it's date`, async() => { const result = await nightmare .wait(selectors.ticketsIndex.searchTicketInput) .type(selectors.ticketsIndex.searchTicketInput, 'id:17') diff --git a/e2e/paths/ticket-module/13_create_ticket_services.spec.js b/e2e/paths/ticket-module/13_create_ticket_services.spec.js new file mode 100644 index 000000000..a2c6d11d9 --- /dev/null +++ b/e2e/paths/ticket-module/13_create_ticket_services.spec.js @@ -0,0 +1,71 @@ +import selectors from '../../helpers/selectors.js'; +import createNightmare from '../../helpers/nightmare'; + +// Bug #961 ticket.service fallo en borrado +xdescribe('Ticket services path', () => { + const nightmare = createNightmare(); + + beforeAll(() => { + nightmare + .loginAndModule('employee', 'ticket') + .accessToSearchResult('id:1') + .accessToSection('ticket.card.service'); + }); + + it('should create a new service', async() => { + const result = await nightmare + .waitToClick(selectors.ticketService.addServiceButton) + .write(selectors.ticketService.descriptionInput, 'my service') + .clearInput(selectors.ticketService.quantityInput) + .write(selectors.ticketService.quantityInput, 99) + .write(selectors.ticketService.priceInput, 999) + .autocompleteSearch(selectors.ticketService.vatTypeAutocomplete, 'Reduced VAT') + .waitToClick(selectors.ticketService.saveServiceButton) + .waitForLastSnackbar(); + + expect(result).toEqual('Data saved!'); + }); + + it('should confirm the service description was created correctly', async() => { + const result = await nightmare + .waitToClick(selectors.ticketBasicData.basicDataButton) + .wait(selectors.ticketBasicData.clientAutocomplete) + .click(selectors.ticketService.serviceButton) + .waitToGetProperty(selectors.ticketService.descriptionInput, 'value'); + + expect(result).toEqual('my service'); + }); + + it('should confirm the service quantity was created correctly', async() => { + const result = await nightmare + .waitToGetProperty(selectors.ticketService.quantityInput, 'value'); + + expect(result).toEqual('99'); + }); + + it('should confirm the service price was created correctly', async() => { + const result = await nightmare + .waitToGetProperty(selectors.ticketService.priceInput, 'value'); + + expect(result).toEqual('999'); + }); + + it('should confirm the service VAT was created correctly', async() => { + const result = await nightmare + .waitToGetProperty(`${selectors.ticketService.vatTypeAutocomplete} input`, 'value'); + + expect(result).toEqual('Reduced VAT'); + }); + + it('should delete the service and check there are none now', async() => { + const result = await nightmare + .waitToClick(selectors.ticketService.fistDeleteServiceButton) + .waitToClick(selectors.ticketBasicData.basicDataButton) + .wait(selectors.ticketBasicData.clientAutocomplete) + .click(selectors.ticketService.serviceButton) + .waitForNumberOfElements(selectors.ticketService.descriptionInput, 0) + .countElement(selectors.ticketService.descriptionInput); + + expect(result).toEqual(0); + }); +});