salix/e2e/paths/05-ticket/13_services.spec.js

142 lines
6.1 KiB
JavaScript
Raw Normal View History

2019-01-14 10:19:39 +00:00
import selectors from '../../helpers/selectors.js';
import getBrowser from '../../helpers/puppeteer';
2019-01-14 10:19:39 +00:00
2019-12-13 11:01:15 +00:00
describe('Ticket services path', () => {
let browser;
let page;
const invoicedTicketId = '1';
afterAll(async() => {
await browser.close();
});
2019-05-20 09:16:56 +00:00
describe('as employee', () => {
it('should log in as employee, search for an invoice and get to services', async() => {
browser = await getBrowser();
page = browser.page;
await page.loginAndModule('employee', 'ticket');
await page.accessToSearchResult(invoicedTicketId);
await page.accessToSection('ticket.card.service');
2019-05-20 09:16:56 +00:00
});
it('should find the add descripton button disabled for this user role', async() => {
await page.waitForClassPresent(selectors.ticketService.firstAddServiceTypeButton, 'disabled');
await page.waitToClick(selectors.ticketService.addServiceButton);
await page.wait(selectors.ticketService.firstAddServiceTypeButton);
const result = await page.isDisabled(selectors.ticketService.firstAddServiceTypeButton);
2019-05-20 09:16:56 +00:00
expect(result).toBeTruthy();
});
2019-05-20 09:16:56 +00:00
it('should receive an error if you attempt to save a service without access rights', async() => {
2020-02-03 14:55:11 +00:00
await page.clearInput(selectors.ticketService.firstPrice);
await page.write(selectors.ticketService.firstPrice, '999');
await page.waitToClick(selectors.ticketService.saveServiceButton);
const result = await page.waitForLastSnackbar();
2019-05-20 09:16:56 +00:00
expect(result).toEqual(`The current ticket can't be modified`);
2019-05-20 09:16:56 +00:00
});
2019-01-14 10:19:39 +00:00
});
2019-05-20 09:16:56 +00:00
describe('as administrative', () => {
let editableTicketId = '16';
2019-06-27 06:41:07 +00:00
it('should navigate to the services of a target ticket', async() => {
await page.loginAndModule('administrative', 'ticket');
await page.accessToSearchResult(editableTicketId);
await page.accessToSection('ticket.card.service');
2020-02-04 15:21:10 +00:00
let url = await page.expectURL('/service');
2019-06-27 06:41:07 +00:00
2020-02-04 15:21:10 +00:00
expect(url).toBe(true);
2019-05-20 09:16:56 +00:00
});
it('should click on the add button to prepare the form to create a new service', async() => {
await page.waitToClick(selectors.ticketService.addServiceButton);
const result = await page
2020-02-03 14:55:11 +00:00
.isVisible(selectors.ticketService.firstServiceType);
2019-05-20 09:16:56 +00:00
expect(result).toBeTruthy();
});
it('should receive an error if you attempt to save it with empty fields', async() => {
await page.waitToClick(selectors.ticketService.saveServiceButton);
const result = await page.waitForLastSnackbar();
2019-05-20 09:16:56 +00:00
expect(result).toEqual(`can't be blank`);
});
it('should click on the add new service type to open the dialog', async() => {
await page.waitToClick(selectors.ticketService.firstAddServiceTypeButton);
await page.wait('.vn-dialog.shown');
2020-02-03 14:55:11 +00:00
const result = await page.isVisible(selectors.ticketService.newServiceTypeName);
2019-05-20 09:16:56 +00:00
expect(result).toBeTruthy();
});
it('should receive an error if service type is empty on submit', async() => {
await page.waitToClick(selectors.ticketService.saveServiceTypeButton);
const result = await page.waitForLastSnackbar();
2019-05-20 09:16:56 +00:00
2019-10-14 09:51:26 +00:00
expect(result).toEqual(`Name can't be empty`);
2019-05-20 09:16:56 +00:00
});
it('should create a new service type then add price then create the service', async() => {
2020-02-03 14:55:11 +00:00
await page.write(selectors.ticketService.newServiceTypeName, 'Documentos');
await page.autocompleteSearch(selectors.ticketService.newServiceTypeExpense, 'Retencion');
await page.waitToClick(selectors.ticketService.saveServiceTypeButton);
2020-02-03 14:55:11 +00:00
await page.write(selectors.ticketService.firstPrice, '999');
2020-02-04 15:21:10 +00:00
await page.waitFor(1000); // time needed for the button to be clickable
await page.waitToClick(selectors.ticketService.saveServiceButton);
const result = await page.waitForLastSnackbar();
2019-05-20 09:16:56 +00:00
expect(result).toEqual('Data saved!');
});
it('should confirm the service description was created correctly', async() => {
await page.reloadSection('ticket.card.service');
const result = await page
2020-02-03 14:55:11 +00:00
.waitToGetProperty(selectors.ticketService.firstServiceType, 'value');
2019-05-20 09:16:56 +00:00
expect(result).toEqual('Documentos');
2019-05-20 09:16:56 +00:00
});
it('should confirm the service quantity was created correctly', async() => {
const result = await page
2020-02-03 14:55:11 +00:00
.waitToGetProperty(selectors.ticketService.firstQuantity, 'value');
2019-05-20 09:16:56 +00:00
expect(result).toEqual('1');
});
it('should confirm the service price was created correctly', async() => {
const result = await page
2020-02-03 14:55:11 +00:00
.waitToGetProperty(selectors.ticketService.firstPrice, 'value');
2019-05-20 09:16:56 +00:00
expect(result).toEqual('999');
});
it('should confirm the service VAT was created correctly', async() => {
const result = await page
2020-02-03 14:55:11 +00:00
.waitToGetProperty(selectors.ticketService.firstVatType, 'value');
2019-05-20 09:16:56 +00:00
expect(result).toEqual('General VAT');
});
it('should delete the service', async() => {
await page.waitToClick(selectors.ticketService.fistDeleteServiceButton);
await page.waitForNumberOfElements(selectors.ticketService.serviceLine, 0);
2020-02-04 15:21:10 +00:00
await page.waitFor(1000); // without this wait it fails to click the save button
await page.waitToClick(selectors.ticketService.saveServiceButton);
const result = await page.waitForLastSnackbar();
2019-05-20 09:16:56 +00:00
expect(result).toEqual('Data saved!');
});
2019-11-12 07:51:50 +00:00
it(`should confirm the service was removed`, async() => {
await page.reloadSection('ticket.card.service');
await page.waitForNumberOfElements(selectors.ticketService.serviceLine, 0);
const result = await page.countElement(selectors.ticketService.serviceLine);
2019-05-20 09:16:56 +00:00
expect(result).toEqual(0);
});
2019-01-14 10:19:39 +00:00
});
});