import selectors from '../../helpers/selectors.js'; import getBrowser from '../../helpers/puppeteer'; describe('Ticket index payout path', () => { let browser; let page; beforeAll(async() => { browser = await getBrowser(); page = browser.page; }); afterAll(async() => { await browser.close(); }); it('should navigate to the ticket index', async() => { await page.loginAndModule('administrative', 'ticket'); await page.waitForState('ticket.index'); }); it('should check the second ticket from a client and 1 of another', async() => { await page.waitToClick(selectors.globalItems.searchButton); await page.waitToClick(selectors.ticketsIndex.secondTicketCheckbox); await page.waitToClick(selectors.ticketsIndex.thirdTicketCheckbox); await page.waitToClick(selectors.ticketsIndex.payoutButton); const message = await page.waitForSnackbar(); expect(message.text).toContain('You cannot make a payment on account from multiple clients'); }); it('should search for tickets of the same client then open the payout form', async() => { await page.waitToClick(selectors.ticketsIndex.openAdvancedSearchButton); await page.write(selectors.ticketsIndex.advancedSearchClient, '101'); await page.keyboard.press('Enter'); await page.waitForNumberOfElements(selectors.ticketsIndex.anySearchResult, 6); await page.waitToClick(selectors.ticketsIndex.firstTicketCheckbox); await page.waitToClick(selectors.ticketsIndex.secondTicketCheckbox); await page.waitToClick(selectors.ticketsIndex.payoutButton); await page.waitForSelector(selectors.ticketsIndex.payoutCompany); }); it('should fill the company and bank to perform a payout', async() => { await page.autocompleteSearch(selectors.ticketsIndex.payoutCompany, 'VNL'); await page.autocompleteSearch(selectors.ticketsIndex.payoutBank, 'cash'); await page.write(selectors.clientBalance.newPaymentAmount, '100'); await page.write(selectors.ticketsIndex.payoutDescription, 'Payment'); await page.waitToClick(selectors.ticketsIndex.submitPayout); const message = await page.waitForSnackbar(); expect(message.text).toContain('Data saved!'); }); it('should navigate to the client balance section and check a new balance line was entered', async() => { await page.waitToClick(selectors.globalItems.homeButton); await page.selectModule('client'); await page.accessToSearchResult('101'); await page.accessToSection('client.card.balance.index'); await page.waitForSelector('vn-client-balance-index vn-tbody > vn-tr'); let result = await page.countElement('vn-client-balance-index vn-tbody > vn-tr'); expect(result).toEqual(4); }); });