import selectors from '../../helpers/selectors.js'; import createNightmare from '../../helpers/nightmare'; describe('Ticket Edit basic data path', () => { const nightmare = createNightmare(); beforeAll(() => { return nightmare .waitForLogin('employee'); }); it('should click on the Tickets button of the top bar menu', async () => { let url = await nightmare .waitToClick(selectors.globalItems.applicationsMenuButton) .wait(selectors.globalItems.applicationsMenuVisible) .waitToClick(selectors.globalItems.ticketsButton) .wait(selectors.ticketsIndex.searchTicketInput) .parsedUrl(); expect(url.hash).toEqual('#!/ticket/index'); }); it('should search for the ticket 11', async () => { let result = await nightmare .wait(selectors.ticketsIndex.searchTicketInput) .type(selectors.ticketsIndex.searchTicketInput, 'id:11') .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 Basic Data`, async () => { let url = await nightmare .waitForTextInElement(selectors.ticketsIndex.searchResult, 'address 21') // should be Bruce Wayne .waitToClick(selectors.ticketsIndex.searchResult) .waitToClick(selectors.ticketBasicData.basicDataButton) .waitForURL('data/step-one') .parsedUrl(); expect(url.hash).toContain('data/step-one'); }); it(`should edit the client and address of the ticket then click next`, async () => { let url = await nightmare .waitToClick(selectors.ticketBasicData.clientSelect) .waitToClick(selectors.ticketBasicData.clientSelectThirdOption) .wait(500) .waitToClick(selectors.ticketBasicData.addressSelect) .waitToClick(selectors.ticketBasicData.addressSelectSecondOption) .waitForTextInInput(selectors.ticketBasicData.addressSelect, 'Charles Xavier') .click(selectors.ticketBasicData.nextStepButton) .waitForURL('data/step-two') .parsedUrl(); expect(url.hash).toContain('data/step-two'); }); it(`should have no price diference`, async () => { const result = await nightmare .waitToGetProperty(selectors.ticketBasicData.stepTwoTotalPriceDif, 'innerText'); expect(result).toContain('0'); }); it(`should click next to move on to step three`, async () => { let url = await nightmare .click(selectors.ticketBasicData.nextStepButton) .waitForURL('data/step-three') .parsedUrl(); expect(url.hash).toContain('data/step-three'); }); it(`should select a reason for the changes made then click on finalize`, async () => { let url = await nightmare .waitToClick(selectors.ticketBasicData.chargesReason) .waitToClick(selectors.ticketBasicData.chargesReasonFourthOption) .waitForTextInInput(selectors.ticketBasicData.chargesReason, 'No realizar modificaciones en precios') .click(selectors.ticketBasicData.finalizeButton) .waitForURL('summary') .parsedUrl(); expect(url.hash).toContain('summary'); }); it(`should go back to ticket.basicData section`, async () => { let url = await nightmare .waitToClick(selectors.ticketBasicData.basicDataButton) .waitForURL('data/step-one') .parsedUrl(); expect(url.hash).toContain('data/step-one'); }); it(`should edit the ticket agency then click next`, async () => { let url = await nightmare .waitToClick(selectors.ticketBasicData.agencySelect) .waitToClick(selectors.ticketBasicData.agencySelectOptionSix) .waitForTextInInput(selectors.ticketBasicData.agencySelect, 'Expensive') .click(selectors.ticketBasicData.nextStepButton) .waitForURL('data/step-two') .parsedUrl(); expect(url.hash).toContain('data/step-two'); }); it(`should have a price diference`, async () => { const result = await nightmare .waitToGetProperty(selectors.ticketBasicData.stepTwoTotalPriceDif, 'innerText'); expect(result).toContain('-20.65 €'); }); it(`should then click next to move on to step three`, async () => { let url = await nightmare .click(selectors.ticketBasicData.nextStepButton) .waitForURL('data/step-three') .parsedUrl(); expect(url.hash).toContain('data/step-three'); }); it(`should select a new reason for the changes made then click on finalize`, async () => { let url = await nightmare .waitToClick(selectors.ticketBasicData.chargesReason) .waitToClick(selectors.ticketBasicData.chargesReasonFirstOption) .waitForTextInInput(selectors.ticketBasicData.chargesReason, 'Cambiar los precios en el ticket') .click(selectors.ticketBasicData.finalizeButton) .waitForURL('summary') .parsedUrl(); expect(url.hash).toContain('summary'); }); });