import selectors from '../../helpers/selectors.js'; import createNightmare from '../../helpers/nightmare'; describe('Ticket List components path', () => { const nightmare = createNightmare(); beforeAll(() => { return nightmare .waitForLogin('employee'); }); 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.searchTicketInput) .parsedUrl(); expect(url.hash).toEqual('#!/ticket/index'); }); it('should search for the ticket 1', async () => { const result = await nightmare .wait(selectors.ticketsIndex.searchTicketInput) .type(selectors.ticketsIndex.searchTicketInput, 'id:1') .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 components`, async () => { const url = await nightmare .waitForTextInElement(selectors.ticketsIndex.searchResult, 'address 21') .waitToClick(selectors.ticketsIndex.searchResult) .waitToClick(selectors.ticketComponents.componentsButton) .waitForURL('components') .parsedUrl(); expect(url.hash).toContain('components'); }); it('should confirm the total base is correct', async () => { const name = 'Base €'; const minLength = name.length; const base = await nightmare .waitPropertyLength(selectors.ticketComponents.base, 'innerText', minLength) .waitToGetProperty(selectors.ticketComponents.base, 'innerText'); expect(base).toContain('Base'); expect(base.length).toBeGreaterThan(minLength); }); it('should confirm the total margin is correct', async () => { const name = 'Margin €'; const minLength = name.length; const margin = await nightmare .waitPropertyLength(selectors.ticketComponents.margin, 'innerText', minLength) .waitToGetProperty(selectors.ticketComponents.margin, 'innerText'); expect(margin).toContain('Margin'); expect(margin.length).toBeGreaterThan(minLength); }); it('should confirm the total total is correct', async () => { const name = 'Total €'; const minLength = name.length; const total = await nightmare .waitPropertyLength(selectors.ticketComponents.total, 'innerText', minLength) .waitToGetProperty(selectors.ticketComponents.total, 'innerText'); expect(total).toContain('Total'); expect(total.length).toBeGreaterThan(minLength); }); });