salix/e2e/paths/09-invoice-out-module/01_descriptor.spec.js

173 lines
7.5 KiB
JavaScript
Raw Normal View History

import selectors from '../../helpers/selectors.js';
import getBrowser from '../../helpers/puppeteer';
2019-10-18 19:54:13 +00:00
describe('InvoiceOut descriptor path', () => {
let browser;
let page;
describe('as Administrative', () => {
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
await page.loginAndModule('administrative', 'ticket');
});
afterAll(async() => {
await browser.close();
});
it('should search for tickets with an specific invoiceOut', async() => {
await page.waitToClick(selectors.ticketsIndex.openAdvancedSearchButton);
await page.write(selectors.ticketsIndex.advancedSearchInvoiceOut, 'T2222222');
await page.waitToClick(selectors.ticketsIndex.advancedSearchButton);
await page.waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1);
const result = await page.countElement(selectors.ticketsIndex.searchResult);
2019-06-19 07:03:45 +00:00
expect(result).toEqual(1);
});
it('should navigate to the invoiceOut index', async() => {
await page.waitToClick(selectors.globalItems.applicationsMenuButton);
await page.wait(selectors.globalItems.applicationsMenuVisible);
await page.waitToClick(selectors.globalItems.invoiceOutButton);
await page.wait(selectors.invoiceOutIndex.searchInvoiceOutInput);
const url = await page.parsedUrl();
expect(url.hash).toEqual('#!/invoice-out/index');
});
it('should search for the target invoiceOut', async() => {
await page.write(selectors.invoiceOutIndex.searchInvoiceOutInput, 'T2222222');
await page.waitToClick(selectors.invoiceOutIndex.searchButton);
await page.waitForNumberOfElements(selectors.invoiceOutIndex.searchResult, 1);
const result = await page.countElement(selectors.invoiceOutIndex.searchResult);
expect(result).toEqual(1);
});
it(`should click on the search result to access to the invoiceOut summary`, async() => {
await page.accessToSearchResult('T2222222');
await page.waitForURL('/summary');
const url = await page.parsedUrl();
expect(url.hash).toContain('/summary');
});
it('should delete the invoiceOut using the descriptor more menu', async() => {
await page.waitToClick(selectors.invoiceOutDescriptor.moreMenu);
await page.waitToClick(selectors.invoiceOutDescriptor.moreMenuDeleteInvoiceOut);
await page.waitToClick(selectors.invoiceOutDescriptor.acceptDeleteButton);
const result = await page.waitForLastSnackbar();
expect(result).toEqual('InvoiceOut deleted');
});
it('should have been relocated to the invoiceOut index', async() => {
const url = await page.parsedUrl();
expect(url.hash).toEqual('#!/invoice-out/index');
});
it(`should search for the deleted invouceOut to find no results`, async() => {
await page.write(selectors.invoiceOutIndex.searchInvoiceOutInput, 'T2222222');
await page.waitToClick(selectors.invoiceOutIndex.searchButton);
await page.waitForNumberOfElements(selectors.invoiceOutIndex.searchResult, 0);
const result = await page.countElement(selectors.invoiceOutIndex.searchResult);
expect(result).toEqual(0);
});
it('should navigate to the ticket index', async() => {
await page.waitToClick(selectors.globalItems.applicationsMenuButton);
await page.wait(selectors.globalItems.applicationsMenuVisible);
await page.waitToClick(selectors.globalItems.ticketsButton);
await page.wait(selectors.ticketsIndex.searchTicketInput);
const url = await page.parsedUrl();
expect(url.hash).toEqual('#!/ticket/index');
});
it('should search for tickets with an specific invoiceOut to find no results', async() => {
await page.waitToClick(selectors.ticketsIndex.openAdvancedSearchButton);
await page.write(selectors.ticketsIndex.advancedSearchInvoiceOut, 'T2222222');
await page.waitToClick(selectors.ticketsIndex.advancedSearchButton);
await page.waitForNumberOfElements(selectors.ticketsIndex.searchResult, 0);
const result = await page.countElement(selectors.ticketsIndex.searchResult);
expect(result).toEqual(0);
});
it('should now navigate to the invoiceOut index', async() => {
await page.waitToClick(selectors.globalItems.applicationsMenuButton);
await page.wait(selectors.globalItems.applicationsMenuVisible);
await page.waitToClick(selectors.globalItems.invoiceOutButton);
await page.wait(selectors.invoiceOutIndex.searchInvoiceOutInput);
const url = await page.parsedUrl();
expect(url.hash).toEqual('#!/invoice-out/index');
});
2019-06-19 07:03:45 +00:00
it(`should search and access to the invoiceOut summary`, async() => {
await page.accessToSearchResult('T1111111');
await page.waitForURL('/summary');
const url = await page.parsedUrl();
expect(url.hash).toContain('/summary');
});
2019-06-27 10:38:30 +00:00
it(`should check the invoiceOut is booked in the summary data`, async() => {
await page.waitForTextInElement(selectors.invoiceOutSummary.bookedLabel, '/');
const result = await page.waitToGetProperty(selectors.invoiceOutSummary.bookedLabel, 'innerText');
2019-06-27 10:38:30 +00:00
expect(result.length).toBeGreaterThan(1);
});
2019-06-27 10:38:30 +00:00
it('should re-book the invoiceOut using the descriptor more menu', async() => {
await page.waitToClick(selectors.invoiceOutDescriptor.moreMenu);
await page.waitToClick(selectors.invoiceOutDescriptor.moreMenuBookInvoiceOut);
await page.waitToClick(selectors.invoiceOutDescriptor.acceptBookingButton);
const result = await page.waitForLastSnackbar();
expect(result).toEqual('InvoiceOut booked');
});
it(`should check the invoiceOut booked in the summary data`, async() => {
2019-10-29 10:28:35 +00:00
let today = new Date();
2019-11-12 07:51:50 +00:00
let day = today.getDate();
if (day < 10) day = `0${day}`;
let month = (today.getMonth() + 1);
if (month < 10) month = `0${month}`;
let expectedDate = `${day}/${month}/${today.getFullYear()}`;
2019-10-29 10:28:35 +00:00
const result = await page
.waitToGetProperty(selectors.invoiceOutSummary.bookedLabel, 'innerText');
2019-10-29 10:28:35 +00:00
expect(result).toEqual(expectedDate);
});
});
describe('as salesPerson', () => {
beforeAll(async() => {
await page.loginAndModule('salesPerson', 'invoiceOut');
await page.accessToSearchResult('A1111111');
});
it(`should check the salesPerson role doens't see the book option in the more menu`, async() => {
await page.waitToClick(selectors.invoiceOutDescriptor.moreMenu);
await page.wait(selectors.invoiceOutDescriptor.moreMenuShowInvoiceOutPdf);
const result = await page.exists(selectors.invoiceOutDescriptor.moreMenuBookInvoiceOut);
expect(result).toBeFalsy();
});
it(`should check the salesPerson role doens't see the delete option in the more menu`, async() => {
const result = await page.exists(selectors.invoiceOutDescriptor.moreMenuDeleteInvoiceOut);
expect(result).toBeFalsy();
});
});
});