import selectors from '../../helpers/selectors.js'; import getBrowser from '../../helpers/puppeteer'; describe('Ticket Create new tracking state path', () => { let browser; let page; afterAll(async() => { await browser.close(); }); describe('as production', () => { it('should log into the ticket 1 tracking', async() => { browser = await getBrowser(); page = browser.page; await page.loginAndModule('production', 'ticket'); await page.accessToSearchResult('1'); await page.accessToSection('ticket.card.tracking.index'); }); it('should access to the create state view by clicking the create floating button', async() => { await page.waitToClick(selectors.ticketTracking.createStateButton); await page.waitForSelector(selectors.createStateView.state, {visible: true}); await page.waitForState('ticket.card.tracking.edit'); }); it(`should create a new state`, async() => { await page.autocompleteSearch(selectors.createStateView.state, 'OK'); await page.waitToClick(selectors.createStateView.saveStateButton); const message = await page.waitForSnackbar(); expect(message.text).toContain('Data saved!'); }); }); describe('as salesPerson', () => { it('should now log into the ticket 1 tracking', async() => { await page.loginAndModule('salesPerson', 'ticket'); await page.accessToSearchResult('1'); await page.accessToSection('ticket.card.tracking.index'); }); it('should now access to the create state view by clicking the create floating button', async() => { await page.waitForSelector('.vn-popup', {hidden: true}); await page.waitToClick(selectors.ticketTracking.createStateButton); await page.waitForState('ticket.card.tracking.edit'); }); it(`should attemp to create an state for which salesPerson doesn't have permissions`, async() => { await page.autocompleteSearch(selectors.createStateView.state, 'Encajado'); await page.waitToClick(selectors.createStateView.saveStateButton); const message = await page.waitForSnackbar(); expect(message.text).toContain(`You don't have enough privileges`); }); it(`should make sure the worker gets autocomplete uppon selecting the assigned state`, async() => { await page.autocompleteSearch(selectors.createStateView.state, 'asignado'); const result = await page .waitToGetProperty(selectors.createStateView.worker, 'value'); expect(result).toEqual('salesPersonNick'); }); it(`should succesfully create a valid state`, async() => { await page.waitToClick(selectors.createStateView.saveStateButton); const message = await page.waitForSnackbar(); expect(message.text).toContain('Data saved!'); }); }); });