import selectors from '../../helpers/selectors.js'; import getBrowser from '../../helpers/puppeteer'; describe('Ticket descriptor path', () => { let browser; let page; beforeAll(async() => { browser = await getBrowser(); page = browser.page; await page.loginAndModule('buyer', 'ticket'); await page.accessToSection('ticket.weekly.index'); }); afterAll(async() => { await browser.close(); }); it('should count the amount of tickets in the turns section', async() => { await page.waitForNumberOfElements(selectors.ticketsIndex.weeklyTicket, 5); const result = await page.countElement(selectors.ticketsIndex.weeklyTicket); expect(result).toEqual(5); }); it('should go back to the ticket index then search and access a ticket summary', async() => { await page.accessToSection('ticket.index'); await page.accessToSearchResult('11'); }); it('should add the ticket to thursday turn using the descriptor more menu', async() => { await page.waitToClick(selectors.ticketDescriptor.moreMenu); await page.waitToClick(selectors.ticketDescriptor.moreMenuAddToTurn); await page.waitToClick(selectors.ticketDescriptor.thursdayButton); const result = await page.waitForLastSnackbar(); expect(result).toEqual('Data saved!'); }); it('should again click on the Tickets button of the top bar menu', async() => { await page.waitToClick(selectors.globalItems.applicationsMenuButton); await page.wait(selectors.globalItems.applicationsMenuVisible); await page.waitToClick(selectors.globalItems.ticketsButton); let url = await page.expectURL('#!/ticket/index'); expect(url).toBe(true); }); it('should confirm the ticket 11 was added to thursday', async() => { await page.accessToSection('ticket.weekly.index'); const result = await page.waitToGetProperty(selectors.ticketsIndex.sixthWeeklyTicket, 'value'); expect(result).toEqual('Thursday'); }); it('should click on the Tickets button of the top bar menu once more', async() => { await page.waitToClick(selectors.globalItems.applicationsMenuButton); await page.wait(selectors.globalItems.applicationsMenuVisible); await page.waitToClick(selectors.globalItems.ticketsButton); let url = await page.expectURL('#!/ticket/index'); expect(url).toBe(true); }); it('should now search for the ticket 11', async() => { await page.write(selectors.ticketsIndex.topbarSearch, '11'); await page.waitToClick(selectors.ticketsIndex.searchButton); await page.waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1); const result = await page.countElement(selectors.ticketsIndex.searchResult); expect(result).toEqual(1); }); it(`should click on the search result to access to the ticket`, async() => { await page.waitToClick(selectors.ticketsIndex.searchResult); let url = await page.expectURL('/summary'); expect(url).toBe(true); }); it('should add the ticket to saturday turn using the descriptor more menu', async() => { await page.waitToClick(selectors.ticketDescriptor.moreMenu); await page.waitToClick(selectors.ticketDescriptor.moreMenuAddToTurn); await page.waitToClick(selectors.ticketDescriptor.saturdayButton); const result = await page.waitForLastSnackbar(); expect(result).toEqual('Data saved!'); }); it('should click on the Tickets button of the top bar menu once again', async() => { await page.waitToClick(selectors.globalItems.applicationsMenuButton); await page.wait(selectors.globalItems.applicationsMenuVisible); await page.waitToClick(selectors.globalItems.ticketsButton); let url = await page.expectURL('#!/ticket/index'); expect(url).toBe(true); }); it('should confirm the ticket 11 was added on saturday', async() => { await page.accessToSection('ticket.weekly.index'); const result = await page.waitToGetProperty(selectors.ticketsIndex.sixthWeeklyTicket, 'value'); expect(result).toEqual('Saturday'); }); it('should now search for the weekly ticket 11', async() => { await page.write(selectors.ticketsIndex.topbarSearch, '11'); await page.waitToClick(selectors.ticketsIndex.searchButton); await page.waitForNumberOfElements(selectors.ticketsIndex.searchWeeklyResult, 1); const result = await page.countElement(selectors.ticketsIndex.searchWeeklyResult); expect(result).toEqual(1); }); it('should delete the weekly ticket 11', async() => { await page.waitToClick(selectors.ticketsIndex.firstWeeklyTicketDeleteIcon); await page.waitToClick(selectors.ticketsIndex.acceptDeleteTurn); const result = await page.waitForLastSnackbar(); expect(result).toEqual('Data saved!'); }); it('should confirm the sixth weekly ticket was deleted', async() => { await page.waitForContentLoaded(); await page.clearInput('vn-searchbar'); await page.waitToClick(selectors.ticketsIndex.searchWeeklyButton); await page.waitForNumberOfElements(selectors.ticketsIndex.searchWeeklyResult, 5); const result = await page.countElement(selectors.ticketsIndex.searchWeeklyResult); expect(result).toEqual(5); }); });