import selectors from '../../helpers/selectors.js'; import getBrowser from '../../helpers/puppeteer'; describe('InvoiceOut global invoice path', () => { let browser; let page; beforeAll(async() => { browser = await getBrowser(); page = browser.page; await page.loginAndModule('administrative', 'invoiceOut'); await page.waitToClick('[icon="search"]'); await page.waitForTimeout(1000); // index search needs time to return results }); afterAll(async() => { await browser.close(); }); let invoicesBefore; it('should count the amount of invoices listed before globla invoces are made', async() => { invoicesBefore = await page.countElement(selectors.invoiceOutIndex.searchResult); expect(invoicesBefore).toBeGreaterThanOrEqual(4); }); it('should open the global invoice form', async() => { await page.waitToClick(selectors.invoiceOutIndex.createInvoice); await page.waitToClick(selectors.invoiceOutIndex.createGlobalInvoice); await page.waitForSelector(selectors.invoiceOutIndex.globalInvoiceForm); }); it('should create a global invoice for charles xavier today', async() => { await page.pickDate(selectors.invoiceOutIndex.globalInvoiceDate); await page.autocompleteSearch(selectors.invoiceOutIndex.globalInvoiceFromClient, 'Petter Parker'); await page.autocompleteSearch(selectors.invoiceOutIndex.globalInvoiceToClient, 'Petter Parker'); await page.waitToClick(selectors.invoiceOutIndex.saveInvoice); const message = await page.waitForSnackbar(); expect(message.text).toContain('Data saved!'); }); it('should count the amount of invoices listed after globla invocing', async() => { await page.waitToClick('[icon="search"]'); await page.waitForTimeout(1000); // index search needs time to return results const currentInvoices = await page.countElement(selectors.invoiceOutIndex.searchResult); expect(currentInvoices).toBeGreaterThan(invoicesBefore); }); });