import selectors from '../../helpers/selectors.js'; import createNightmare from '../../helpers/nightmare'; describe('Ticket diary path', () => { const nightmare = createNightmare(); beforeAll(() => { nightmare .loginAndModule('employee', 'ticket'); }); it('should search for a specific ticket', async() => { const result = await nightmare .write(selectors.ticketsIndex.searchTicketInput, 1) .waitToClick(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 summary`, async() => { const url = await nightmare .waitForTextInElement(selectors.ticketsIndex.searchResult, 'Bat cave') .waitToClick(selectors.ticketsIndex.searchResult) .waitForURL('/summary') .parsedUrl(); expect(url.hash).toContain('/summary'); }); it(`should navigate to the item diary from the 1st sale item id descriptor popover`, async() => { const url = await nightmare .waitToClick(selectors.ticketSummary.firstSaleItemId) .waitToClick(selectors.ticketSummary.popoverDiaryButton) .parsedUrl(); expect(url.hash).toContain('/diary'); }); it(`should check the second line id is marked as message`, async() => { const result = await nightmare .waitToGetProperty(selectors.itemDiary.secondTicketId, 'className'); expect(result).toContain('message'); }); it(`should check the third line balance is marked as message`, async() => { const result = await nightmare .waitToGetProperty(`${selectors.itemDiary.fourthBalance} > span`, 'className'); expect(result).toContain('message'); }); it(`should change to the warehouse two and check there are sales marked as negative balance`, async() => { const result = await nightmare .autocompleteSearch(selectors.itemDiary.warehouseAutocomplete, 'Warehouse Two') .waitToGetProperty(selectors.itemDiary.firstBalance, 'className'); expect(result).toContain('balance'); }); });