import selectors from '../../helpers/selectors.js'; import config from '../../helpers/config.js'; import createNightmare from '../../helpers/nightmare'; describe('Ticket diary path', () => { const nightmare = createNightmare(); beforeAll(() => { 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 a specific ticket', 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 summary`, async () => { const url = await nightmare .waitForTextInElement(selectors.ticketsIndex.searchResult, 'address 21') .waitToClick(selectors.ticketsIndex.searchResult) .waitForURL('/summary') .url(); expect(url).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) .waitForLogin('employee') .goto(`${config.url}#!/item/1/diary?warehouseFk=1&ticketFk=1`) .parsedUrl(); expect(url.hash).toContain('/diary'); }); it(`should check the seventh line id is marked as counter`, async () => { const result = await nightmare .waitProperty(selectors.itemDiary.thirdTicketId, 'className') .getProperty(selectors.itemDiary.thirdTicketId, 'className'); expect(result).toContain('counter'); }); it(`should check the fifth line balance is marked as counter`, async () => { const result = await nightmare .getProperty(selectors.itemDiary.fifthBalance, 'className'); expect(result).toContain('counter'); }); it(`should change to the warehouse two and check there are sales marked as negative balance`, async () => { const result = await nightmare .waitToClick(selectors.itemDiary.warehouseSelect) .waitToClick(selectors.itemDiary.warehouseSelectFourthOption) .waitProperty(selectors.itemDiary.firstBalance, 'className') .getProperty(selectors.itemDiary.firstBalance, 'className'); expect(result).toContain('balance'); }); });