diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 5cd24cda5..98236c8d5 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -10,7 +10,7 @@ export default { ticketsButton: '.modules-menu [ui-sref="ticket.index"]', invoiceOutButton: '.modules-menu [ui-sref="invoiceOut.index"]', claimsButton: '.modules-menu [ui-sref="claim.index"]', - returnToModuleIndexButton: 'a[ui-sref="order.index"]', + returnToModuleIndexButton: 'a[name="goToModuleIndex"]', homeButton: 'vn-topbar > div.side.start > a', userLocalWarehouse: '.user-popover vn-autocomplete[ng-model="$ctrl.localWarehouseFk"]', userLocalBank: '.user-popover vn-autocomplete[ng-model="$ctrl.localBankFk"]', @@ -365,7 +365,8 @@ export default { 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 > 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' + setOk: 'vn-ticket-summary vn-button[label="SET OK"] > button', + returnToIndexButton: '' }, ticketsIndex: { openAdvancedSearchButton: 'vn-searchbar .append vn-icon[icon="arrow_drop_down"]', diff --git a/e2e/paths/05-ticket/14_create_ticket.spec.js b/e2e/paths/05-ticket/14_create_ticket.spec.js index 4ce2e5156..f377e9e39 100644 --- a/e2e/paths/05-ticket/14_create_ticket.spec.js +++ b/e2e/paths/05-ticket/14_create_ticket.spec.js @@ -4,6 +4,9 @@ import getBrowser from '../../helpers/puppeteer'; describe('Ticket create path', () => { let browser; let page; + let nextMonth = new Date(); + nextMonth.setMonth(nextMonth.getMonth() + 1); + let stowawayTicketId; beforeAll(async() => { browser = await getBrowser(); @@ -21,13 +24,9 @@ describe('Ticket create path', () => { }); it('should succeed to create a ticket', async() => { - const nextMonth = new Date(); - nextMonth.setMonth(nextMonth.getMonth() + 1); - - await page.autocompleteSearch(selectors.createTicketView.client, 'Tony Stark'); - await page.autocompleteSearch(selectors.createTicketView.address, 'Tony Stark'); + await page.autocompleteSearch(selectors.createTicketView.client, 'Clark Kent'); await page.pickDate(selectors.createTicketView.deliveryDate, nextMonth); - await page.autocompleteSearch(selectors.createTicketView.warehouse, 'Warehouse One'); + await page.autocompleteSearch(selectors.createTicketView.warehouse, 'Warehouse Two'); await page.autocompleteSearch(selectors.createTicketView.agency, 'Silla247'); await page.waitToClick(selectors.createTicketView.createButton); const message = await page.waitForSnackbar(); @@ -37,5 +36,53 @@ describe('Ticket create path', () => { it('should check the url is now the summary of the ticket', async() => { await page.waitForState('ticket.card.summary'); + stowawayTicketId = await page.waitToGetProperty('vn-ticket-descriptor > vn-descriptor-content > div > div.body > div.top > div', 'innerText'); + stowawayTicketId = stowawayTicketId.substring(1); + }); + + it('should again open the new ticket form', async() => { + await page.waitToClick(selectors.globalItems.returnToModuleIndexButton); + await page.waitToClick(selectors.ticketsIndex.newTicketButton); + await page.waitForState('ticket.create'); + }); + + it('should succeed to create another ticket for the same client', async() => { + await page.autocompleteSearch(selectors.createTicketView.client, 'Clark Kent'); + await page.pickDate(selectors.createTicketView.deliveryDate, nextMonth); + await page.autocompleteSearch(selectors.createTicketView.warehouse, 'Warehouse One'); + await page.autocompleteSearch(selectors.createTicketView.agency, 'Silla247'); + await page.waitToClick(selectors.createTicketView.createButton); + const message = await page.waitForSnackbar(); + + expect(message.type).toBe('success'); + }); + + it('should check the url is now the summary of the created ticket', async() => { + await page.waitForState('ticket.card.summary'); + }); + + it('should make the previously created ticket the stowaway of the current ticket', async() => { + await page.waitToClick(selectors.ticketDescriptor.moreMenu); + await page.waitToClick(selectors.ticketDescriptor.moreMenuAddStowaway); + await page.waitToClick(selectors.ticketDescriptor.addStowawayDialogFirstTicket); + const message = await page.waitForSnackbar(); + + expect(message.type).toBe('success'); + }); + + it('should delete the current ticket', async() => { + await page.waitToClick(selectors.ticketDescriptor.moreMenu); + await page.waitToClick(selectors.ticketDescriptor.moreMenuDeleteTicket); + await page.waitToClick(selectors.ticketDescriptor.acceptDeleteButton); + const message = await page.waitForSnackbar(); + + expect(message.type).toBe('success'); + }); + + it('should search for the stowaway ticket of the previously deleted ticket', async() => { + await page.accessToSearchResult(stowawayTicketId); + const result = await page.countElement(selectors.ticketDescriptor.shipButton); + + expect(result).toBe(0); }); });