import selectors from '../../helpers/selectors.js'; import getBrowser from '../../helpers/puppeteer'; describe('InvoiceOut manual invoice path', () => { let browser; let page; beforeAll(async() => { browser = await getBrowser(); page = browser.page; await page.loginAndModule('administrative', 'invoiceOut'); }); afterAll(async() => { await browser.close(); }); it('should open the manual invoice form', async() => { await page.waitToClick(selectors.invoiceOutIndex.createInvoice); await page.waitToClick(selectors.invoiceOutIndex.createManualInvoice); await page.waitForSelector(selectors.invoiceOutIndex.manualInvoiceForm); }); it('should create an invoice from a ticket', async() => { await page.autocompleteSearch(selectors.invoiceOutIndex.manualInvoiceTicket, '15'); await page.autocompleteSearch(selectors.invoiceOutIndex.manualInvoiceSerial, 'Global nacional'); await page.autocompleteSearch(selectors.invoiceOutIndex.manualInvoiceTaxArea, 'national'); await page.waitToClick(selectors.invoiceOutIndex.saveInvoice); const message = await page.waitForSnackbar(); expect(message.text).toContain('Data saved!'); }); it(`should have been redirected to the created invoice summary`, async() => { await page.waitForState('invoiceOut.card.summary'); }); it(`should navigate back to the invoiceOut index`, async() => { await page.waitToClick(selectors.globalItems.applicationsMenuButton); await page.waitForSelector(selectors.globalItems.applicationsMenuVisible); await page.waitToClick(selectors.globalItems.invoiceOutButton); await page.waitForSelector(selectors.invoiceOutIndex.topbarSearch); await page.waitForState('invoiceOut.index'); }); it('should now open the manual invoice form', async() => { await page.waitToClick(selectors.invoiceOutIndex.createInvoice); await page.waitToClick(selectors.invoiceOutIndex.createManualInvoice); await page.waitForSelector(selectors.invoiceOutIndex.manualInvoiceForm); }); it('should create an invoice from a client', async() => { await page.autocompleteSearch(selectors.invoiceOutIndex.manualInvoiceClient, 'Max Eisenhardt'); await page.autocompleteSearch(selectors.invoiceOutIndex.manualInvoiceSerial, 'Global nacional'); await page.autocompleteSearch(selectors.invoiceOutIndex.manualInvoiceTaxArea, 'national'); await page.waitToClick(selectors.invoiceOutIndex.saveInvoice); const message = await page.waitForSnackbar(); expect(message.text).toContain('Data saved!'); }); it(`should have been redirected to the created invoice summary`, async() => { await page.waitForState('invoiceOut.card.summary'); }); });