import selectors from '../../helpers/selectors.js'; import createNightmare from '../../helpers/nightmare'; describe('Ticket descriptor path', () => { const nightmare = createNightmare(); beforeAll(() => { nightmare .loginAndModule('employee', 'ticket'); }); it('should count the amount of tickets in the turns section', async() => { const result = await nightmare .waitToClick(selectors.ticketsIndex.menuWeeklyTickets) .wait(selectors.ticketsIndex.weeklyTicket) .countElement(selectors.ticketsIndex.weeklyTicket); expect(result).toEqual(5); }); 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.searchTicketInput) .parsedUrl(); expect(url.hash).toEqual('#!/ticket/index'); }); it('should search for the ticket 11', async() => { const result = await nightmare .write(selectors.ticketsIndex.searchTicketInput, 11) .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`, async() => { const url = await nightmare .waitToClick(selectors.ticketsIndex.searchResult) .waitForURL('/summary') .parsedUrl(); expect(url.hash).toContain('/summary'); }); it('should add the ticket to thursday turn using the descriptor more menu', async() => { const result = await nightmare .waitToClick(selectors.ticketDescriptor.moreMenu) .waitToClick(selectors.ticketDescriptor.moreMenuAddToTurn) .waitToClick(selectors.ticketDescriptor.thursdayButton) .waitForLastSnackbar(); expect(result).toEqual('Data saved!'); }); it('should again 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 confirm the ticket 11 was added on thursday', async() => { const result = await nightmare .waitToClick(selectors.ticketsIndex.menuWeeklyTickets) .waitToGetProperty(selectors.ticketsIndex.sixthWeeklyTicket, 'value'); expect(result).toEqual('Thursday'); }); it('should click on the Tickets button of the top bar menu once more', 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 now search for the ticket 11', async() => { const result = await nightmare .write(selectors.ticketsIndex.searchTicketInput, 11) .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`, async() => { const url = await nightmare .waitToClick(selectors.ticketsIndex.searchResult) .waitForURL('/summary') .parsedUrl(); expect(url.hash).toContain('/summary'); }); it('should add the ticket to saturday turn using the descriptor more menu', async() => { const result = await nightmare .waitToClick(selectors.ticketDescriptor.moreMenu) .waitToClick(selectors.ticketDescriptor.moreMenuAddToTurn) .waitToClick(selectors.ticketDescriptor.saturdayButton) .waitForLastSnackbar(); expect(result).toEqual('Data saved!'); }); it('should click on the Tickets button of the top bar menu once again', 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 confirm the ticket 11 was added on saturday', async() => { const result = await nightmare .waitToClick(selectors.ticketsIndex.menuWeeklyTickets) .waitToGetProperty(selectors.ticketsIndex.sixthWeeklyTicket, 'value'); expect(result).toEqual('Saturday'); }); it('should now search for the weekly ticket 11', async() => { const result = await nightmare .write(selectors.ticketsIndex.searchWeeklyTicketInput, 11) .waitToClick(selectors.ticketsIndex.searchWeeklyButton) .waitForNumberOfElements(selectors.ticketsIndex.searchWeeklyResult, 1) .countElement(selectors.ticketsIndex.searchWeeklyResult); expect(result).toEqual(1); }); it('should delete the weekly ticket 11', async() => { const result = await nightmare .waitToClick(selectors.ticketsIndex.firstWeeklyTicketDeleteIcon) .waitToClick(selectors.ticketsIndex.acceptDeleteTurn) .waitForLastSnackbar(); expect(result).toEqual('Data saved!'); }); it('should confirm the sixth weekly ticket was deleted', async() => { const result = await nightmare .waitToClick('vn-searchbar vn-icon[icon=clear]') .waitToClick(selectors.ticketsIndex.searchWeeklyButton) .waitForNumberOfElements(selectors.ticketsIndex.searchWeeklyResult, 5) .countElement(selectors.ticketsIndex.searchWeeklyResult); expect(result).toEqual(5); }); });