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.wait(selectors.createTicketView.clientAutocomplete); const url = await page.parsedUrl(); expect(url.hash).toEqual('#!/ticket/create'); }); it('should succeed to create a ticket', async() => { await page.autocompleteSearch(selectors.createTicketView.clientAutocomplete, 'Tony Stark'); await page.autocompleteSearch(selectors.createTicketView.addressAutocomplete, 'Tony Stark'); await page.datePicker(selectors.createTicketView.deliveryDateInput, 1, null); await page.autocompleteSearch(selectors.createTicketView.warehouseAutocomplete, 'Warehouse One'); await page.autocompleteSearch(selectors.createTicketView.agencyAutocomplete, 'Silla247'); await page.waitToClick(selectors.createTicketView.createButton); const result = await page.waitForLastSnackbar(); expect(result).toEqual('Data saved!'); }); it('should check the url is now the summary of the ticket', async() => { await page.waitForURL('/summary'); const url = await page.parsedUrl(); expect(url.hash).toContain('/summary'); }); });