salix/e2e/paths/09-invoice-out/04_globalInvoice.spec.js

64 lines
2.7 KiB
JavaScript
Raw Normal View History

2021-08-11 11:34:32 +00:00
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"]');
2021-08-11 11:37:24 +00:00
await page.waitForTimeout(1000); // index search needs time to return results
2021-08-11 11:34:32 +00:00
});
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);
2022-10-19 13:10:43 +00:00
await page.waitToClick(selectors.invoiceOutIndex.globalInvoiceClientsRange);
2021-08-11 11:34:32 +00:00
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"]');
2021-08-11 11:37:24 +00:00
await page.waitForTimeout(1000); // index search needs time to return results
2021-08-11 11:34:32 +00:00
const currentInvoices = await page.countElement(selectors.invoiceOutIndex.searchResult);
expect(currentInvoices).toBeGreaterThan(invoicesBefore);
});
2022-10-19 13:10:43 +00:00
it('should create a global invoice for all clients today', async() => {
await page.waitToClick(selectors.invoiceOutIndex.createInvoice);
await page.waitToClick(selectors.invoiceOutIndex.createGlobalInvoice);
await page.waitForSelector(selectors.invoiceOutIndex.globalInvoiceForm);
await page.pickDate(selectors.invoiceOutIndex.globalInvoiceDate);
await page.waitToClick(selectors.invoiceOutIndex.saveInvoice);
const message = await page.waitForSnackbar();
expect(message.text).toContain('Data saved!');
});
2021-08-11 11:34:32 +00:00
});