diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index c0b454857..050358749 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -336,10 +336,11 @@ export default { firstSaleDiscount: 'vn-ticket-sale:nth-child(1) vn-td:nth-child(8)', firstSaleDiscountInput: 'vn-ticket-sale:nth-child(1) vn-ticket-sale-edit-discount > div > vn-textfield > div > div > div.infix > input.ng-not-empty', firstSaleImport: 'vn-ticket-sale:nth-child(1) vn-td:nth-child(9)', - firstSaleReservedIcon: 'vn-ticket-sale vn-tr:nth-child(1) > vn-td:nth-child(2) > vn-icon:nth-child(2)', + firstSaleReservedIcon: 'vn-ticket-sale vn-tr:nth-child(1) > vn-td:nth-child(2) > vn-icon:nth-child(3)', firstSaleColour: `vn-ticket-sale vn-tr:nth-child(1) vn-td:nth-child(5) section:nth-child(5)`, firstSaleLength: `vn-ticket-sale vn-tr:nth-child(1) vn-td:nth-child(5) section:nth-child(3)`, firstSaleCheckbox: `vn-ticket-sale vn-tr:nth-child(1) vn-check[field="sale.checked"] label`, + secondSaleClaimId: 'vn-ticket-sale > vn-vertical > vn-card > div > vn-vertical > vn-table > div > vn-tbody > vn-tr:nth-child(2) > vn-td:nth-child(2) > a > vn-icon', secondSaleColour: `vn-ticket-sale vn-tr:nth-child(2) vn-td:nth-child(5) section:nth-child(5)`, secondSalePrice: `vn-ticket-sale vn-tr:nth-child(2) vn-td:nth-child(7)`, secondSaleDiscount: `vn-ticket-sale vn-tr:nth-child(2) vn-td:nth-child(8)`, diff --git a/e2e/paths/ticket-module/07_edit_sale.spec.js b/e2e/paths/ticket-module/07_edit_sale.spec.js index d51a454a5..20a355f45 100644 --- a/e2e/paths/ticket-module/07_edit_sale.spec.js +++ b/e2e/paths/ticket-module/07_edit_sale.spec.js @@ -5,131 +5,152 @@ describe('Ticket Edit sale path', () => { const nightmare = createNightmare(); beforeAll(() => { - return nightmare + nightmare .waitForLogin('salesPerson'); }); - it('should click on the Tickets button of the top bar menu', (done) => { - return nightmare + it('should click on the Tickets button of the top bar menu', async () => { + const url = await nightmare .waitToClick(selectors.globalItems.applicationsMenuButton) .wait(selectors.globalItems.applicationsMenuVisible) .waitToClick(selectors.globalItems.ticketsButton) .wait(selectors.ticketsIndex.searchResult) - .parsedUrl() - .then((url) => { - expect(url.hash).toEqual('#!/ticket/index'); - done(); - }).catch(done.fail); + .parsedUrl(); + + expect(url.hash).toEqual('#!/ticket/index'); }); - it('should search for a specific ticket', (done) => { - return nightmare + it('should search for a specific ticket', async () => { + const result = await nightmare .wait(selectors.ticketsIndex.searchResult) .type(selectors.ticketsIndex.searchTicketInput, 'id:16') .click(selectors.ticketsIndex.searchButton) .waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1) - .countElement(selectors.ticketsIndex.searchResult) - .then((result) => { - expect(result).toEqual(1); - done(); - }).catch(done.fail); + .countElement(selectors.ticketsIndex.searchResult); + + expect(result).toEqual(1); }); - it(`should click on the search result to access to the ticket Sale`, (done) => { - return nightmare + it(`should click on the search result to access to the ticket Sale`, async () => { + const url = await nightmare .waitForTextInElement(selectors.ticketsIndex.searchResult, 'address 21') .waitToClick(selectors.ticketsIndex.searchResult) .waitToClick(selectors.ticketSales.saleButton) .waitForURL('/sale') - .url() - .then((url) => { - expect(url).toContain('/sale'); - done(); - }).catch(done.fail); + .url(); + + expect(url).toContain('/sale'); }); - it(`should check the zoomed image isnt present`, (done) => { - return nightmare - .countElement(selectors.ticketSales.firstSaleZoomedImage) - .then((result) => { - expect(result).toEqual(0); - done(); - }).catch(done.fail); + it(`should click on the first claim id to navigate over there`, async () => { + const url = await nightmare + .waitToClick(selectors.ticketSales.secondSaleClaimId) + .wait(selectors.claimBasicData.claimStateSelect) + .parsedUrl(); + + expect(url.hash).toEqual('#!/claim/2/basic-data'); }); - it(`should click on the thumbnail image of the 1st sale and see the zoomed image`, (done) => { - return nightmare + + it('should now click on the Tickets button of the top bar menu', async () => { + const url = await nightmare + .waitToClick(selectors.globalItems.applicationsMenuButton) + .wait(selectors.globalItems.applicationsMenuVisible) + .waitToClick(selectors.globalItems.ticketsButton) + .wait(selectors.ticketsIndex.searchResult) + .parsedUrl(); + + expect(url.hash).toEqual('#!/ticket/index'); + }); + + it('should again search for a specific ticket', async () => { + const result = await nightmare + .wait(selectors.ticketsIndex.searchResult) + .type(selectors.ticketsIndex.searchTicketInput, 'id:16') + .click(selectors.ticketsIndex.searchButton) + .waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1) + .countElement(selectors.ticketsIndex.searchResult); + + expect(result).toEqual(1); + }); + + it(`should click on the search result to access to the ticket Sale`, async () => { + const url = await nightmare + .waitForTextInElement(selectors.ticketsIndex.searchResult, 'address 21') + .waitToClick(selectors.ticketsIndex.searchResult) + .waitToClick(selectors.ticketSales.saleButton) + .waitForURL('/sale') + .url(); + + expect(url).toContain('/sale'); + }); + + it(`should check the zoomed image isnt present`, async () => { + const result = await nightmare + .countElement(selectors.ticketSales.firstSaleZoomedImage); + + expect(result).toEqual(0); + }); + + it(`should click on the thumbnail image of the 1st sale and see the zoomed image`, async () => { + const result = await nightmare .waitToClick(selectors.ticketSales.firstSaleThumbnailImage) - .countElement(selectors.ticketSales.firstSaleZoomedImage) - .then((result) => { - expect(result).toEqual(1); - done(); - }).catch(done.fail); + .countElement(selectors.ticketSales.firstSaleZoomedImage); + + expect(result).toEqual(1); }); - it(`should click on the zoomed image to close it`, (done) => { - return nightmare + it(`should click on the zoomed image to close it`, async () => { + const result = await nightmare .waitToClick(selectors.ticketSales.firstSaleZoomedImage) - .countElement(selectors.ticketSales.firstSaleZoomedImage) - .then((result) => { - expect(result).toEqual(0); - done(); - }).catch(done.fail); + .countElement(selectors.ticketSales.firstSaleZoomedImage); + + expect(result).toEqual(0); }); - it(`should confirm the item descriptor insnt visible yet`, (done) => { - return nightmare - .isVisible(selectors.ticketSales.saleDescriptorPopover) - .then((visible) => { - expect(visible).toBeFalsy(); - done(); - }).catch(done.fail); + it(`should confirm the item descriptor insnt visible yet`, async () => { + const visible = await nightmare + .isVisible(selectors.ticketSales.saleDescriptorPopover); + + expect(visible).toBeFalsy(); }); - it(`should click on the first sale ID making the item descriptor visible`, (done) => { - return nightmare + it(`should click on the first sale ID making the item descriptor visible`, async () => { + const visible = await nightmare .waitToClick(selectors.ticketSales.firstSaleID) .wait(1000) - .isVisible(selectors.ticketSales.saleDescriptorPopover) - .then((visible) => { - expect(visible).toBeTruthy(); - done(); - }).catch(done.fail); + .isVisible(selectors.ticketSales.saleDescriptorPopover); + + expect(visible).toBeTruthy(); }); - it(`should click on the descriptor image of the 1st sale and see the zoomed image`, (done) => { - return nightmare + it(`should click on the descriptor image of the 1st sale and see the zoomed image`, async () => { + const result = await nightmare .waitToClick('vn-item-descriptor img') - .countElement(selectors.ticketSales.firstSaleZoomedImage) - .then((result) => { - expect(result).toEqual(1); - done(); - }).catch(done.fail); + .countElement(selectors.ticketSales.firstSaleZoomedImage); + + expect(result).toEqual(1); }); - it(`should click on the zoomed image to close it`, (done) => { - return nightmare + it(`should click on the zoomed image to close it`, async () => { + const result = await nightmare .waitToClick(selectors.ticketSales.firstSaleZoomedImage) - .countElement(selectors.ticketSales.firstSaleZoomedImage) - .then((result) => { - expect(result).toEqual(0); - done(); - }).catch(done.fail); + .countElement(selectors.ticketSales.firstSaleZoomedImage); + + expect(result).toEqual(0); }); - it(`should click on the summary icon of the item-descriptor to access to the item summary`, (done) => { - return nightmare + it(`should click on the summary icon of the item-descriptor to access to the item summary`, async () => { + const url = await nightmare .waitToClick(selectors.ticketSales.saleDescriptorPopoverSummaryButton) .waitForURL('/summary') - .url() - .then((url) => { - expect(url).toContain('/summary'); - done(); - }).catch(done.fail); + .url(); + + expect(url).toContain('/summary'); }); - it('should return to ticket sales section', (done) => { - return nightmare + it('should return to ticket sales section', async () => { + const url = await nightmare .waitToClick(selectors.globalItems.applicationsMenuButton) .wait(selectors.globalItems.applicationsMenuVisible) .waitToClick(selectors.globalItems.ticketsButton) @@ -141,241 +162,197 @@ describe('Ticket Edit sale path', () => { .waitToClick(selectors.ticketsIndex.searchResult) .waitToClick(selectors.ticketSales.saleButton) .waitForURL('/sale') - .url() - .then((url) => { - expect(url).toContain('/sale'); - done(); - }).catch(done.fail); + .url(); + + expect(url).toContain('/sale'); }); - it('should try to add a higher quantity value and then receive an error', (done) => { - return nightmare + it('should try to add a higher quantity value and then receive an error', async () => { + const result = await nightmare .waitToClick(selectors.ticketSales.firstSaleQuantityClearInput) .type(selectors.ticketSales.firstSaleQuantity, '9\u000d') - .waitForLastSnackbar() - .then((result) => { - expect(result).toEqual('The new quantity should be smaller than the old one'); - done(); - }).catch(done.fail); + .waitForLastSnackbar(); + + expect(result).toEqual('The new quantity should be smaller than the old one'); }); - it('should remove 1 from quantity', (done) => { - return nightmare + it('should remove 1 from quantity', async () => { + const result = await nightmare .waitToClick(selectors.ticketSales.firstSaleQuantityClearInput) .type(selectors.ticketSales.firstSaleQuantity, '4\u000d') - .waitForLastSnackbar() - .then((result) => { - expect(result).toEqual('Data saved!'); - done(); - }).catch(done.fail); + .waitForLastSnackbar(); + + expect(result).toEqual('Data saved!'); }); - it('should update the price', (done) => { - return nightmare + it('should update the price', async () => { + const result = await nightmare .waitToClick(selectors.ticketSales.firstSalePrice) .wait(selectors.ticketSales.firstSalePriceInput) .type(selectors.ticketSales.firstSalePriceInput, 5) .type('body', '\u000d') // simulates enter - .waitForLastSnackbar() - .then((result) => { - expect(result).toEqual('Data saved!'); - done(); - }).catch(done.fail); + .waitForLastSnackbar(); + + expect(result).toEqual('Data saved!'); }); - it('should confirm the price have been updated', (done) => { - return nightmare - .getInnerText(selectors.ticketSales.firstSalePrice) - .then((result) => { - expect(result).toContain('5.00'); - done(); - }).catch(done.fail); + it('should confirm the price have been updated', async () => { + const result = await nightmare + .getInnerText(selectors.ticketSales.firstSalePrice); + + expect(result).toContain('5.00'); }); - it('should confirm the total price for that item have been updated', (done) => { - return nightmare - .getInnerText(selectors.ticketSales.firstSaleImport) - .then((result) => { - expect(result).toContain('20.00'); - done(); - }).catch(done.fail); + it('should confirm the total price for that item have been updated', async () => { + const result = await nightmare + .getInnerText(selectors.ticketSales.firstSaleImport); + + expect(result).toContain('20.00'); }); - it('should update the discount', (done) => { - return nightmare + it('should update the discount', async () => { + const result = await nightmare .waitToClick(selectors.ticketSales.firstSaleDiscount) .wait('vn-textfield[label="Discount"] > div[class="container selected"]') // a function selects the text after it's loaded .type(selectors.ticketSales.firstSaleDiscountInput, 50) .type('body', '\u000d') // simulates enter - .waitForLastSnackbar() - .then((result) => { - expect(result).toEqual('Data saved!'); - done(); - }).catch(done.fail); + .waitForLastSnackbar(); + + expect(result).toEqual('Data saved!'); }); - it('should confirm the discount have been updated', (done) => { - return nightmare + it('should confirm the discount have been updated', async () => { + const result = await nightmare .waitForTextInElement(selectors.ticketSales.firstSaleDiscount, '50 %') - .getInnerText(selectors.ticketSales.firstSaleDiscount) - .then((result) => { - expect(result).toContain('50 %'); - done(); - }).catch(done.fail); + .getInnerText(selectors.ticketSales.firstSaleDiscount); + + expect(result).toContain('50 %'); }); - it('should confirm the total import for that item have been updated', (done) => { - return nightmare + it('should confirm the total import for that item have been updated', async () => { + const result = await nightmare .waitForTextInElement(selectors.ticketSales.firstSaleImport, '10.00') - .getInnerText(selectors.ticketSales.firstSaleImport) - .then((result) => { - expect(result).toContain('10.00'); - done(); - }).catch(done.fail); + .getInnerText(selectors.ticketSales.firstSaleImport); + + expect(result).toContain('10.00'); }); - it('should select the third sale and create a claim of it', (done) => { - return nightmare + it('should select the third sale and create a claim of it', async () => { + const url = await nightmare .waitToClick(selectors.ticketSales.thirdSaleCheckbox) .waitToClick(selectors.ticketSales.moreMenuButton) .waitToClick(selectors.ticketSales.moreMenuCreateClaim) - .waitForLogin('salesPerson') - .waitToClick(selectors.globalItems.applicationsMenuButton) - .wait(selectors.globalItems.applicationsMenuVisible) - .waitToClick(selectors.globalItems.claimsButton) - .wait(selectors.claimsIndex.searchResult) - .parsedUrl() - .then((url) => { - expect(url.hash).toEqual('#!/claim/index'); - done(); - }).catch(done.fail); + .wait(selectors.claimBasicData.claimStateSelect) + .parsedUrl(); + + expect(url.hash).toEqual('#!/claim/4/basic-data'); }); - it('should click on the Claims button of the top bar menu', (done) => { - return nightmare + it('should click on the Claims button of the top bar menu', async () => { + const url = await nightmare .waitToClick(selectors.globalItems.applicationsMenuButton) .wait(selectors.globalItems.applicationsMenuVisible) .waitToClick(selectors.globalItems.claimsButton) .wait(selectors.claimsIndex.searchClaimInput) - .parsedUrl() - .then((url) => { - expect(url.hash).toEqual('#!/claim/index'); - done(); - }).catch(done.fail); + .parsedUrl(); + + expect(url.hash).toEqual('#!/claim/index'); }); - it('should search for the claim with id 4', (done) => { - return nightmare + it('should search for the claim with id 4', async () => { + const result = await nightmare .wait(selectors.claimsIndex.searchResult) .type(selectors.claimsIndex.searchClaimInput, 4) .click(selectors.claimsIndex.searchButton) .waitForNumberOfElements(selectors.claimsIndex.searchResult, 1) - .countElement(selectors.claimsIndex.searchResult) - .then((result) => { - expect(result).toEqual(1); - done(); - }).catch(done.fail); + .countElement(selectors.claimsIndex.searchResult); + + expect(result).toEqual(1); }); - it('should click the Tickets button of the top bar menu', (done) => { - return nightmare + it('should click the Tickets button of the top bar menu', async () => { + const url = await nightmare .waitToClick(selectors.globalItems.applicationsMenuButton) .wait(selectors.globalItems.applicationsMenuVisible) .waitToClick(selectors.globalItems.ticketsButton) .wait(selectors.ticketsIndex.searchResult) - .parsedUrl() - .then((url) => { - expect(url.hash).toEqual('#!/ticket/index'); - done(); - }).catch(done.fail); + .parsedUrl(); + + expect(url.hash).toEqual('#!/ticket/index'); }); - it('should search the ticket', (done) => { - return nightmare + it('should search the ticket', async () => { + const result = await nightmare .wait(selectors.ticketsIndex.searchResult) .type(selectors.ticketsIndex.searchTicketInput, 'id:16') .click(selectors.ticketsIndex.searchButton) .waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1) - .countElement(selectors.ticketsIndex.searchResult) - .then((result) => { - expect(result).toEqual(1); - done(); - }).catch(done.fail); + .countElement(selectors.ticketsIndex.searchResult); + + expect(result).toEqual(1); }); - it(`should click on the result to access to the ticket Sale`, (done) => { - return nightmare + it(`should click on the result to access to the ticket Sale`, async () => { + const url = await nightmare .waitForTextInElement(selectors.ticketsIndex.searchResult, 'address 21') .waitToClick(selectors.ticketsIndex.searchResult) .waitToClick(selectors.ticketSales.saleButton) .waitForURL('/sale') - .url() - .then((url) => { - expect(url).toContain('/sale'); - done(); - }).catch(done.fail); + .url(); + + expect(url).toContain('/sale'); }); - it('should select the third sale and delete it', (done) => { - return nightmare + it('should select the third sale and delete it', async () => { + const result = await nightmare .waitToClick(selectors.ticketSales.thirdSaleCheckbox) .waitToClick(selectors.ticketSales.deleteSaleButton) .waitToClick(selectors.ticketSales.acceptDeleteLineButton) - .waitForLastSnackbar() - .then((result) => { - expect(result).toEqual('Data saved!'); - done(); - }).catch(done.fail); + .waitForLastSnackbar(); + + expect(result).toEqual('Data saved!'); }); - it(`should confirm the third sale was deleted`, (done) => { - return nightmare - .countElement(selectors.ticketSales.saleLine) - .then((result) => { - expect(result).toEqual(3); - done(); - }).catch(done.fail); + it(`should confirm the third sale was deleted`, async () => { + const result = await nightmare + .countElement(selectors.ticketSales.saleLine); + + expect(result).toEqual(3); }); - it('should select the third sale and attempt to send it to a frozen client ticket', (done) => { - return nightmare + it('should select the third sale and attempt to send it to a frozen client ticket', async () => { + const result = await nightmare .waitToClick(selectors.ticketSales.thirdSaleCheckbox) .waitToClick(selectors.ticketSales.transferSaleButton) .wait(selectors.ticketSales.moveToTicketInput) .type(selectors.ticketSales.moveToTicketInput, 2) .waitToClick(selectors.ticketSales.moveToTicketButton) - .waitForLastSnackbar() - .then((result) => { - expect(result).toEqual(`The sales of this ticket can't be modified`); - done(); - }).catch(done.fail); + .waitForLastSnackbar(); + + expect(result).toEqual(`The sales of this ticket can't be modified`); }); - it('should transfer the sale to a valid ticket', (done) => { - return nightmare + it('should transfer the sale to a valid ticket', async () => { + const result = await nightmare .waitToClick(selectors.ticketSales.moveToTicketInputClearButton) .type(selectors.ticketSales.moveToTicketInput, 12) .waitToClick(selectors.ticketSales.moveToTicketButton) .waitForURL('ticket/12/sale') - .url() - .then((result) => { - expect(result).toContain(`ticket/12/sale`); - done(); - }).catch(done.fail); + .url(); + + expect(result).toContain(`ticket/12/sale`); }); - it('should confirm the transfered line is the correct one', (done) => { - return nightmare + it('should confirm the transfered line is the correct one', async () => { + const result = await nightmare .wait(selectors.ticketSales.firstSaleText) - .getInnerText(selectors.ticketSales.firstSaleText) - .then((result) => { - expect(result).toContain(`Mark I`); - done(); - }).catch(done.fail); + .getInnerText(selectors.ticketSales.firstSaleText); + + expect(result).toContain(`Mark I`); }); - it('should go back to the original ticket sales section', (done) => { - return nightmare + it('should go back to the original ticket sales section', async () => { + const url = await nightmare .waitToClick(selectors.itemsIndex.goBackToModuleIndexButton) .wait(selectors.ticketsIndex.searchResult) .type(selectors.ticketsIndex.searchTicketInput, 'id:16') @@ -385,25 +362,21 @@ describe('Ticket Edit sale path', () => { .waitToClick(selectors.ticketsIndex.searchResult) .waitToClick(selectors.ticketSales.saleButton) .waitForURL('/sale') - .url() - .then((url) => { - expect(url).toContain('/sale'); - done(); - }).catch(done.fail); + .url(); + + expect(url).toContain('/sale'); }); - it(`should confirm the original ticket has only two lines now`, (done) => { - return nightmare + it(`should confirm the original ticket has only two lines now`, async () => { + const result = await nightmare .wait(selectors.ticketSales.saleLine) - .countElement(selectors.ticketSales.saleLine) - .then((result) => { - expect(result).toEqual(2); - done(); - }).catch(done.fail); + .countElement(selectors.ticketSales.saleLine); + + expect(result).toEqual(2); }); - it('should go back to the receiver ticket sales section', (done) => { - return nightmare + it('should go back to the receiver ticket sales section', async () => { + const url = await nightmare .waitToClick(selectors.itemsIndex.goBackToModuleIndexButton) .wait(selectors.ticketsIndex.searchResult) .type(selectors.ticketsIndex.searchTicketInput, 'id:12') @@ -413,40 +386,34 @@ describe('Ticket Edit sale path', () => { .waitToClick(selectors.ticketsIndex.searchResult) .waitToClick(selectors.ticketSales.saleButton) .waitForURL('/sale') - .url() - .then((url) => { - expect(url).toContain('/sale'); - done(); - }).catch(done.fail); + .url(); + + expect(url).toContain('/sale'); }); - it('should transfer the sale back to the original ticket', (done) => { - return nightmare + it('should transfer the sale back to the original ticket', async () => { + const result = await nightmare .waitToClick(selectors.ticketSales.firstSaleCheckbox) .waitToClick(selectors.ticketSales.transferSaleButton) .wait(selectors.ticketSales.moveToTicketInput) .type(selectors.ticketSales.moveToTicketInput, 16) .waitToClick(selectors.ticketSales.moveToTicketButton) .waitForURL('ticket/16/sale') - .url() - .then((result) => { - expect(result).toContain(`ticket/16/sale`); - done(); - }).catch(done.fail); + .url(); + + expect(result).toContain(`ticket/16/sale`); }); - it('should confirm the original ticket received the line', (done) => { - return nightmare + it('should confirm the original ticket received the line', async () => { + const result = await nightmare .wait(selectors.ticketSales.saleLine) - .countElement(selectors.ticketSales.saleLine) - .then((result) => { - expect(result).toEqual(3); - done(); - }).catch(done.fail); + .countElement(selectors.ticketSales.saleLine); + + expect(result).toEqual(3); }); - it('should select the second and third sale and tranfer them to a new ticket then get to the ticket index', (done) => { - return nightmare + it('should select the second and third sale and tranfer them to a new ticket then get to the ticket index', async () => { + const url = await nightmare .waitToClick(selectors.ticketSales.secondSaleCheckbox) .waitToClick(selectors.ticketSales.thirdSaleCheckbox) .waitToClick(selectors.ticketSales.transferSaleButton) @@ -456,154 +423,129 @@ describe('Ticket Edit sale path', () => { .wait(selectors.globalItems.applicationsMenuVisible) .waitToClick(selectors.globalItems.ticketsButton) .wait(selectors.ticketsIndex.searchResult) - .parsedUrl() - .then((url) => { - expect(url.hash).toEqual('#!/ticket/index'); - done(); - }).catch(done.fail); + .parsedUrl(); + + expect(url.hash).toEqual('#!/ticket/index'); }); - it('should search for a specific created ticket', (done) => { - return nightmare + it('should search for a specific created ticket', async () => { + const result = await nightmare .wait(selectors.ticketsIndex.searchResult) .type(selectors.ticketsIndex.searchTicketInput, 'id:22') .click(selectors.ticketsIndex.searchButton) .waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1) - .countElement(selectors.ticketsIndex.searchResult) - .then((result) => { - expect(result).toEqual(1); - done(); - }).catch(done.fail); + .countElement(selectors.ticketsIndex.searchResult); + + expect(result).toEqual(1); }); - it(`should click on the search result to access to the ticket Sale`, (done) => { - return nightmare + it(`should click on the search result to access to the ticket Sale`, async () => { + const url = await nightmare .waitForTextInElement(selectors.ticketsIndex.searchResult, 'address 21') .waitToClick(selectors.ticketsIndex.searchResult) .waitToClick(selectors.ticketSales.saleButton) .waitForURL('/sale') - .url() - .then((url) => { - expect(url).toContain('/sale'); - done(); - }).catch(done.fail); + .url(); + + expect(url).toContain('/sale'); }); - it('should confirm the new ticket received both lines', (done) => { - return nightmare - .countElement(selectors.ticketSales.saleLine) - .then((result) => { - expect(result).toEqual(2); - done(); - }).catch(done.fail); + it('should confirm the new ticket received both lines', async () => { + const result = await nightmare + .countElement(selectors.ticketSales.saleLine); + + expect(result).toEqual(2); }); - it('should check the first sale reserved icon isnt visible', (done) => { - return nightmare - .isVisible(selectors.ticketSales.firstSaleReservedIcon) - .then((result) => { - expect(result).toBeFalsy(); - done(); - }).catch(done.fail); + it('should check the first sale reserved icon isnt visible', async () => { + const result = await nightmare + .isVisible(selectors.ticketSales.firstSaleReservedIcon); + + expect(result).toBeFalsy(); }); - it('should mark the first sale as reserved', (done) => { - return nightmare + it('should mark the first sale as reserved', async () => { + const result = await nightmare .waitToClick(selectors.ticketSales.firstSaleCheckbox) .waitToClick(selectors.ticketSales.moreMenuButton) .waitToClick(selectors.ticketSales.moreMenuReseveOption) .waitForClassNotPresent(selectors.ticketSales.firstSaleReservedIcon, 'ng-hide') - .isVisible(selectors.ticketSales.firstSaleReservedIcon) - .then((result) => { - expect(result).toBeTruthy(); - done(); - }).catch(done.fail); + .isVisible(selectors.ticketSales.firstSaleReservedIcon); + + expect(result).toBeTruthy(); }); - it('should unmark the first sale as reserved', (done) => { - return nightmare + it('should unmark the first sale as reserved', async () => { + const result = await nightmare .waitToClick(selectors.ticketSales.firstSaleCheckbox) .waitToClick(selectors.ticketSales.moreMenuButton) .waitToClick(selectors.ticketSales.moreMenuUnmarkResevedOption) .waitForClassPresent(selectors.ticketSales.firstSaleReservedIcon, 'ng-hide') - .isVisible(selectors.ticketSales.firstSaleReservedIcon) - .then((result) => { - expect(result).toBeFalsy(); - done(); - }).catch(done.fail); + .isVisible(selectors.ticketSales.firstSaleReservedIcon); + + expect(result).toBeFalsy(); }); - // #744 fix edit sale bug, boton MAS descuento - // it('should update all sales discount', done => { - // return nightmare - // .waitToClick(selectors.ticketSales.selectAllSalesCheckbox) - // .waitToClick(selectors.ticketSales.moreMenuButton) - // .waitToClick(selectors.ticketSales.moreMenuUpdateDiscount) - // .wait(selectors.ticketSales.moreMenuUpdateDiscountInput) - // .type(selectors.ticketSales.moreMenuUpdateDiscountInput, 100) - // .type('body', '\u000d') // simulates enter - // .waitForTextInElement(selectors.ticketSales.totalImport, '0.00') - // .getInnerText(selectors.ticketSales.totalImport) - // .then(result => { - // expect(result).toContain('0.00'); - // done(); - // }).catch(done.fail); - // }); + it('should update all sales discount', async () => { + const result = await nightmare + .waitToClick(selectors.ticketSales.selectAllSalesCheckbox) + .waitToClick(selectors.ticketSales.moreMenuButton) + .waitToClick(selectors.ticketSales.moreMenuUpdateDiscount) + .wait(selectors.ticketSales.moreMenuUpdateDiscountInput) + .type(selectors.ticketSales.moreMenuUpdateDiscountInput, 100) + .type('body', '\u000d') // simulates enter + .waitForTextInElement(selectors.ticketSales.totalImport, '0.00') + .getInnerText(selectors.ticketSales.totalImport); - it('should log in as Production role and go to the ticket index', (done) => { - return nightmare + expect(result).toContain('0.00'); + }); + + it('should log in as Production role and go to the ticket index', async () => { + const url = await nightmare .waitToClick(selectors.globalItems.logOutButton) .waitForLogin('production') .waitToClick(selectors.globalItems.applicationsMenuButton) .wait(selectors.globalItems.applicationsMenuVisible) .waitToClick(selectors.globalItems.ticketsButton) .wait(selectors.ticketsIndex.searchResult) - .parsedUrl() - .then((url) => { - expect(url.hash).toEqual('#!/ticket/index'); - done(); - }).catch(done.fail); + .parsedUrl(); + + expect(url.hash).toEqual('#!/ticket/index'); }); - it('should now search for a specific ticket', (done) => { - return nightmare + it('should now search for a specific ticket', async () => { + const result = await nightmare .wait(selectors.ticketsIndex.searchResult) .type(selectors.ticketsIndex.searchTicketInput, 'id:16') .click(selectors.ticketsIndex.searchButton) .waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1) - .countElement(selectors.ticketsIndex.searchResult) - .then((result) => { - expect(result).toEqual(1); - done(); - }).catch(done.fail); + .countElement(selectors.ticketsIndex.searchResult); + + expect(result).toEqual(1); }); - it(`should now click on the search result to access to the ticket Tracking`, (done) => { - return nightmare + it(`should now click on the search result to access to the ticket Tracking`, async () => { + const url = await nightmare .waitForTextInElement(selectors.ticketsIndex.searchResult, 'address 21') .waitToClick(selectors.ticketsIndex.searchResult) .waitToClick(selectors.ticketTracking.trackingButton) .waitForURL('/tracking/index') - .url() - .then((url) => { - expect(url).toContain('/tracking/index'); - done(); - }).catch(done.fail); + .url(); + + expect(url).toContain('/tracking/index'); }); - it(`should click on the edit ticket tracking state button`, (done) => { - return nightmare + it(`should click on the edit ticket tracking state button`, async () => { + const url = await nightmare .waitToClick(selectors.ticketTracking.createStateButton) .waitForURL('/tracking/edit') - .url() - .then((url) => { - expect(url).toContain('/tracking/edit'); - done(); - }).catch(done.fail); + .url(); + + expect(url).toContain('/tracking/edit'); }); - it(`should set the state of the ticket to preparation`, (done) => { - return nightmare + it(`should set the state of the ticket to preparation`, async () => { + const url = await nightmare .waitToClick(selectors.ticketTracking.stateSelect) .wait(selectors.ticketTracking.stateSelectInput) .type(selectors.ticketTracking.stateSelectInput, 'PreparaciĆ³n') @@ -611,130 +553,108 @@ describe('Ticket Edit sale path', () => { .waitForTextInInput(selectors.ticketTracking.stateSelectInput, 'PreparaciĆ³n') .click(selectors.ticketTracking.saveButton) .waitForURL('/tracking/index') - .url() - .then((url) => { - expect(url).toContain('/tracking/index'); - done(); - }).catch(done.fail); + .url(); + + expect(url).toContain('/tracking/index'); }); - it(`should click on the ticket Sale menu button`, (done) => { - return nightmare + it(`should click on the ticket Sale menu button`, async () => { + const url = await nightmare .waitToClick(selectors.ticketSales.saleButton) .waitForURL('/sale') - .url() - .then((url) => { - expect(url).toContain('/sale'); - done(); - }).catch(done.fail); + .url(); + + expect(url).toContain('/sale'); }); describe('when state is preparation and loged as Production', () => { - it(`should not be able to edit the sale price`, (done) => { - return nightmare + it(`should not be able to edit the sale price`, async () => { + const result = await nightmare .waitToClick(selectors.ticketSales.firstSalePrice) - .exists(selectors.ticketSales.firstSalePriceInput) - .then((result) => { - expect(result).toBeFalsy(); - done(); - }).catch(done.fail); + .exists(selectors.ticketSales.firstSalePriceInput); + + expect(result).toBeFalsy(); }); - it(`should not be able to edit the sale discount`, (done) => { - return nightmare + it(`should not be able to edit the sale discount`, async () => { + const result = await nightmare .waitToClick(selectors.ticketSales.firstSaleDiscount) - .exists(selectors.ticketSales.firstSaleDiscountInput) - .then((result) => { - expect(result).toBeFalsy(); - done(); - }).catch(done.fail); + .exists(selectors.ticketSales.firstSaleDiscountInput); + + expect(result).toBeFalsy(); }); - it(`should not be able to edit the sale state`, (done) => { - return nightmare + it(`should not be able to edit the sale state`, async () => { + const result = await nightmare .waitToClick(selectors.ticketSales.stateMenuButton) - .exists(selectors.ticketSales.stateMenuOptions) - .then((result) => { - expect(result).toBeFalsy(); - done(); - }).catch(done.fail); + .exists(selectors.ticketSales.stateMenuOptions); + + expect(result).toBeFalsy(); }); - it('should log in as salesPerson role and go to the ticket index', (done) => { - return nightmare + it('should log in as salesPerson role and go to the ticket index', async () => { + const url = await nightmare .waitToClick(selectors.globalItems.logOutButton) .waitForLogin('salesPerson') .waitToClick(selectors.globalItems.applicationsMenuButton) .wait(selectors.globalItems.applicationsMenuVisible) .waitToClick(selectors.globalItems.ticketsButton) .wait(selectors.ticketsIndex.searchResult) - .parsedUrl() - .then((url) => { - expect(url.hash).toEqual('#!/ticket/index'); - done(); - }).catch(done.fail); + .parsedUrl(); + + expect(url.hash).toEqual('#!/ticket/index'); }); - it('should again search for a specific ticket', (done) => { - return nightmare + it('should again search for a specific ticket', async () => { + const result = await nightmare .wait(selectors.ticketsIndex.searchResult) .type(selectors.ticketsIndex.searchTicketInput, 'id:16') .click(selectors.ticketsIndex.searchButton) .waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1) - .countElement(selectors.ticketsIndex.searchResult) - .then((result) => { - expect(result).toEqual(1); - done(); - }).catch(done.fail); + .countElement(selectors.ticketsIndex.searchResult); + + expect(result).toEqual(1); }); - it(`should again click on the search result to access to the ticket Sales`, (done) => { - return nightmare + it(`should again click on the search result to access to the ticket Sales`, async () => { + const url = await nightmare .waitForTextInElement(selectors.ticketsIndex.searchResult, 'address 21') .waitToClick(selectors.ticketsIndex.searchResult) .waitToClick(selectors.ticketSales.saleButton) .waitForURL('/sale') - .url() - .then((url) => { - expect(url).toContain('/sale'); - done(); - }).catch(done.fail); + .url(); + + expect(url).toContain('/sale'); }); }); describe('when state is preparation and loged as salesPerson', () => { - it(`shouldnt be able to edit the sale price`, (done) => { - return nightmare + it(`shouldnt be able to edit the sale price`, async () => { + const result = await nightmare .waitToClick(selectors.ticketSales.firstSalePrice) - .exists(selectors.ticketSales.firstSalePriceInput) - .then((result) => { - expect(result).toBeFalsy(); - done(); - }).catch(done.fail); + .exists(selectors.ticketSales.firstSalePriceInput); + + expect(result).toBeFalsy(); }); - it(`shouldnt be able to edit the sale discount`, (done) => { - return nightmare + it(`shouldnt be able to edit the sale discount`, async () => { + const result = await nightmare .waitToClick(selectors.ticketSales.firstSaleDiscount) - .exists(selectors.ticketSales.firstSaleDiscountInput) - .then((result) => { - expect(result).toBeFalsy(); - done(); - }).catch(done.fail); + .exists(selectors.ticketSales.firstSaleDiscountInput); + + expect(result).toBeFalsy(); }); - it(`shouldnt be able to edit the sale state`, (done) => { - return nightmare + it(`shouldnt be able to edit the sale state`, async () => { + const result = await nightmare .waitToClick(selectors.ticketSales.stateMenuButton) - .exists(selectors.ticketSales.stateMenuOptions) - .then((result) => { - expect(result).toBeFalsy(); - done(); - }).catch(done.fail); + .exists(selectors.ticketSales.stateMenuOptions); + + expect(result).toBeFalsy(); }); - it('should go to another ticket sales section', (done) => { - return nightmare + it('should go to another ticket sales section', async () => { + const url = await nightmare .waitToClick(selectors.itemsIndex.goBackToModuleIndexButton) .wait(selectors.ticketsIndex.searchResult) .type(selectors.ticketsIndex.searchTicketInput, 'id:17') @@ -744,47 +664,39 @@ describe('Ticket Edit sale path', () => { .waitToClick(selectors.ticketsIndex.searchResult) .waitToClick(selectors.ticketSales.saleButton) .waitForURL('/sale') - .url() - .then((url) => { - expect(url).toContain('/sale'); - done(); - }).catch(done.fail); + .url(); + + expect(url).toContain('/sale'); }); - it(`should be able to delete the ticket`, (done) => { - return nightmare + it(`should be able to delete the ticket`, async () => { + const url = await nightmare .waitToClick(selectors.ticketSales.moreMenuButton) .waitToClick(selectors.ticketSales.moreMenuDeleteOption) .waitToClick(selectors.ticketSales.acceptDeleteTicketButton) .waitForURL('/ticket/index') - .url() - .then((url) => { - expect(url).toContain('/ticket/index'); - done(); - }).catch(done.fail); + .url(); + + expect(url).toContain('/ticket/index'); }); - it(`should search for the deleted ticket`, (done) => { - return nightmare + it(`should search for the deleted ticket`, async () => { + const result = await nightmare .wait(selectors.ticketsIndex.searchResult) .type(selectors.ticketsIndex.searchTicketInput, 'id:17') .click(selectors.ticketsIndex.searchButton) .waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1) - .countElement(selectors.ticketsIndex.searchResult) - .then((result) => { - expect(result).toEqual(1); - done(); - }).catch(done.fail); + .countElement(selectors.ticketsIndex.searchResult); + + expect(result).toEqual(1); }); - it(`should search for the deleted ticket`, (done) => { - return nightmare + it(`should search for the deleted ticket`, async () => { + const result = await nightmare .wait(selectors.ticketsIndex.searchResultDate) - .getInnerText(selectors.ticketsIndex.searchResultDate) - .then((result) => { - expect(result).toContain(2000); - done(); - }).catch(done.fail); + .getInnerText(selectors.ticketsIndex.searchResultDate); + + expect(result).toContain(2000); }); }); });