import selectors from '../../helpers/selectors.js'; import getBrowser from '../../helpers/puppeteer'; describe('Ticket create path', () => { let browser; let page; beforeAll(async() => { browser = await getBrowser(); page = browser.page; await page.loginAndModule('employee', 'ticket'); }); afterAll(async() => { await browser.close(); }); it('should open the new ticket form', async() => { await page.waitToClick(selectors.ticketsIndex.newTicketButton); await page.waitForState('ticket.create'); }); it('should succeed to create a ticket', async() => { const nextMonth = new Date(); nextMonth.setMonth(nextMonth.getMonth() + 1); await page.autocompleteSearch(selectors.createTicketView.client, 'Tony Stark'); await page.autocompleteSearch(selectors.createTicketView.address, 'Tony Stark'); await page.pickDate(selectors.createTicketView.deliveryDate, nextMonth); await page.autocompleteSearch(selectors.createTicketView.warehouse, 'Warehouse One'); await page.autocompleteSearch(selectors.createTicketView.agency, 'Silla247'); await page.waitToClick(selectors.createTicketView.createButton); const message = await page.waitForSnackbar(); expect(message.type).toBe('success'); }); it('should check the url is now the summary of the ticket', async() => { await page.waitForState('ticket.card.summary'); }); });