import selectors from '../../helpers/selectors.js'; import getBrowser from '../../helpers/puppeteer'; const $ = { newPayment: '.vn-dialog.shown', anyBalanceLine: 'vn-client-balance-index vn-tbody > vn-tr', firstLineReference: 'vn-client-balance-index vn-tbody > vn-tr:nth-child(1) > vn-td-editable' }; describe('Ticket index payout path', () => { let browser; let page; beforeAll(async() => { browser = await getBrowser(); page = browser.page; await page.loginAndModule('administrative', 'ticket'); await page.waitForState('ticket.index'); }); afterAll(async() => { await browser.close(); }); 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.thirdTicketCheckbox); await page.waitToClick(selectors.ticketsIndex.fifthTicketCheckbox); 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, '1101'); await page.keyboard.press('Enter'); await page.waitForNumberOfElements(selectors.ticketsIndex.anySearchResult, 9); 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 and check a new balance line was entered', async() => { await page.fillForm($.newPayment, { company: 'VNL', bank: 'cash', amountPaid: 100, description: 'Payment', viewReceipt: false }); await page.respondToDialog('accept'); const message = await page.waitForSnackbar(); await page.waitToClick(selectors.globalItems.homeButton); await page.selectModule('client'); await page.accessToSearchResult('1101'); await page.accessToSection('client.card.balance.index'); await page.waitForSelector($.anyBalanceLine); const count = await page.countElement($.anyBalanceLine); const reference = await page.innerText($.firstLineReference); expect(message.isSuccess).toBeTrue(); expect(count).toEqual(4); expect(reference).toContain('Payment'); }); });