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

128 lines
5.4 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
2020-03-17 10:00:16 +00:00
expect(result).toBe(true);
});
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);
2020-04-08 09:24:40 +00:00
const message = await page.waitForSnackbar();
2019-05-20 09:16:56 +00:00
2020-04-08 09:24:40 +00:00
expect(message.text).toBe(`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');
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);
2020-04-08 09:24:40 +00:00
const message = await page.waitForSnackbar();
2019-05-20 09:16:56 +00:00
2020-04-08 09:24:40 +00:00
expect(message.text).toBe(`can't be blank`);
2019-05-20 09:16:56 +00:00
});
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);
2020-04-08 09:24:40 +00:00
const message = await page.waitForSnackbar();
2019-05-20 09:16:56 +00:00
2020-04-08 09:24:40 +00:00
expect(message.text).toBe(`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.waitToClick(selectors.ticketService.saveServiceTypeButton);
2020-02-03 14:55:11 +00:00
await page.write(selectors.ticketService.firstPrice, '999');
await page.waitToClick(selectors.ticketService.saveServiceButton);
2020-04-08 09:24:40 +00:00
const message = await page.waitForSnackbar();
2019-05-20 09:16:56 +00:00
2020-04-08 09:24:40 +00:00
expect(message.type).toBe('success');
2019-05-20 09:16:56 +00:00
});
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 delete the service', async() => {
await page.waitToClick(selectors.ticketService.fistDeleteServiceButton);
await page.waitForNumberOfElements(selectors.ticketService.serviceLine, 0);
await page.waitToClick(selectors.ticketService.saveServiceButton);
2020-04-08 09:24:40 +00:00
const message = await page.waitForSnackbar();
2019-05-20 09:16:56 +00:00
2020-04-08 09:24:40 +00:00
expect(message.type).toBe('success');
2019-05-20 09:16:56 +00:00
});
2019-11-12 07:51:50 +00:00
it(`should confirm the service was removed`, async() => {
await page.reloadSection('ticket.card.service');
const nResults = await page.countElement(selectors.ticketService.serviceLine);
2019-05-20 09:16:56 +00:00
expect(nResults).toEqual(0);
2019-05-20 09:16:56 +00:00
});
2019-01-14 10:19:39 +00:00
});
});