2019-01-14 10:19:39 +00:00
|
|
|
import selectors from '../../helpers/selectors.js';
|
|
|
|
import createNightmare from '../../helpers/nightmare';
|
|
|
|
|
2019-12-13 10:59:25 +00:00
|
|
|
fdescribe('Ticket services path', () => {
|
2019-01-14 10:19:39 +00:00
|
|
|
const nightmare = createNightmare();
|
2019-06-27 06:41:07 +00:00
|
|
|
const invoicedTicketId = 1;
|
2019-05-20 09:16:56 +00:00
|
|
|
|
|
|
|
describe('as employee', () => {
|
|
|
|
beforeAll(() => {
|
|
|
|
nightmare
|
|
|
|
.loginAndModule('employee', 'ticket')
|
2019-05-29 11:06:42 +00:00
|
|
|
.accessToSearchResult(invoicedTicketId)
|
2019-05-20 09:16:56 +00:00
|
|
|
.accessToSection('ticket.card.service');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should find the add descripton button disabled for this user role', async() => {
|
|
|
|
const result = await nightmare
|
2019-12-13 10:59:25 +00:00
|
|
|
.waitForClassPresent(selectors.ticketService.firstAddServiceTypeButton, 'disabled')
|
2019-05-20 09:16:56 +00:00
|
|
|
.waitToClick(selectors.ticketService.addServiceButton)
|
2019-12-13 10:59:25 +00:00
|
|
|
.wait(selectors.ticketService.firstAddServiceTypeButton)
|
|
|
|
.isDisabled(selectors.ticketService.firstAddServiceTypeButton);
|
2019-05-20 09:16:56 +00:00
|
|
|
|
|
|
|
expect(result).toBeTruthy();
|
2019-11-11 15:32:03 +00:00
|
|
|
}, 100000);
|
2019-05-20 09:16:56 +00:00
|
|
|
|
|
|
|
it('should receive an error if you attempt to save a service without access rights', async() => {
|
|
|
|
const result = await nightmare
|
|
|
|
.clearInput(selectors.ticketService.firstPriceInput)
|
|
|
|
.write(selectors.ticketService.firstPriceInput, 999)
|
|
|
|
.waitToClick(selectors.ticketService.saveServiceButton)
|
|
|
|
.waitForLastSnackbar();
|
|
|
|
|
2019-05-29 11:06:42 +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', () => {
|
2019-06-27 06:41:07 +00:00
|
|
|
let editableTicketId = 16;
|
|
|
|
it('should navigate to the services of a target ticket', async() => {
|
|
|
|
const url = await nightmare
|
2019-05-20 09:16:56 +00:00
|
|
|
.loginAndModule('administrative', 'ticket')
|
2019-05-29 11:06:42 +00:00
|
|
|
.accessToSearchResult(editableTicketId)
|
2019-06-27 06:41:07 +00:00
|
|
|
.accessToSection('ticket.card.service')
|
|
|
|
.waitForURL('/service')
|
|
|
|
.parsedUrl();
|
|
|
|
|
|
|
|
expect(url.hash).toContain('/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() => {
|
|
|
|
const result = await nightmare
|
|
|
|
.waitToClick(selectors.ticketService.addServiceButton)
|
2019-12-13 10:59:25 +00:00
|
|
|
.isVisible(selectors.ticketService.firstServiceTypeAutocomplete);
|
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() => {
|
|
|
|
const result = await nightmare
|
|
|
|
.waitToClick(selectors.ticketService.saveServiceButton)
|
|
|
|
.waitForLastSnackbar();
|
|
|
|
|
|
|
|
expect(result).toEqual(`can't be blank`);
|
|
|
|
});
|
|
|
|
|
2019-12-13 10:59:25 +00:00
|
|
|
it('should click on the add new service type to open the dialog', async() => {
|
2019-05-20 09:16:56 +00:00
|
|
|
const result = await nightmare
|
2019-12-13 10:59:25 +00:00
|
|
|
.waitToClick(selectors.ticketService.firstAddServiceTypeButton)
|
2019-10-28 16:31:33 +00:00
|
|
|
.wait('.vn-dialog.shown')
|
2019-12-13 10:59:25 +00:00
|
|
|
.isVisible(selectors.ticketService.newServiceTypeNameInput);
|
2019-05-20 09:16:56 +00:00
|
|
|
|
|
|
|
expect(result).toBeTruthy();
|
|
|
|
});
|
|
|
|
|
2019-12-13 10:59:25 +00:00
|
|
|
it('should receive an error if service type is empty on submit', async() => {
|
2019-05-20 09:16:56 +00:00
|
|
|
const result = await nightmare
|
2019-12-13 10:59:25 +00:00
|
|
|
.waitToClick(selectors.ticketService.saveServiceTypeButton)
|
2019-05-20 09:16:56 +00:00
|
|
|
.waitForLastSnackbar();
|
|
|
|
|
2019-10-14 09:51:26 +00:00
|
|
|
expect(result).toEqual(`Name can't be empty`);
|
2019-05-20 09:16:56 +00:00
|
|
|
});
|
|
|
|
|
2019-12-13 10:59:25 +00:00
|
|
|
it('should create a new service type then add price then create the service', async() => {
|
2019-05-20 09:16:56 +00:00
|
|
|
const result = await nightmare
|
2019-12-13 10:59:25 +00:00
|
|
|
.write(selectors.ticketService.newServiceTypeNameInput, 'Documentos')
|
|
|
|
.autocompleteSearch(selectors.ticketService.newServiceTypeExpenseAutocomplete, 'Retencion')
|
|
|
|
.waitToClick(selectors.ticketService.saveServiceTypeButton)
|
2019-05-20 09:16:56 +00:00
|
|
|
.write(selectors.ticketService.firstPriceInput, 999)
|
|
|
|
.waitToClick(selectors.ticketService.saveServiceButton)
|
|
|
|
.waitForLastSnackbar();
|
|
|
|
|
|
|
|
expect(result).toEqual('Data saved!');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should confirm the service description was created correctly', async() => {
|
|
|
|
const result = await nightmare
|
|
|
|
.reloadSection('ticket.card.service')
|
2019-12-13 10:59:25 +00:00
|
|
|
.waitToGetProperty(`${selectors.ticketService.firstServiceTypeAutocomplete} input`, 'value');
|
2019-05-20 09:16:56 +00:00
|
|
|
|
2019-12-13 10:59:25 +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 nightmare
|
|
|
|
.waitToGetProperty(selectors.ticketService.firstQuantityInput, 'value');
|
|
|
|
|
|
|
|
expect(result).toEqual('1');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should confirm the service price was created correctly', async() => {
|
|
|
|
const result = await nightmare
|
|
|
|
.waitToGetProperty(selectors.ticketService.firstPriceInput, 'value');
|
|
|
|
|
|
|
|
expect(result).toEqual('999');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should confirm the service VAT was created correctly', async() => {
|
|
|
|
const result = await nightmare
|
|
|
|
.waitToGetProperty(`${selectors.ticketService.firstVatTypeAutocomplete} input`, 'value');
|
|
|
|
|
|
|
|
expect(result).toEqual('General VAT');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should delete the service', async() => {
|
|
|
|
const result = await nightmare
|
|
|
|
.waitToClick(selectors.ticketService.fistDeleteServiceButton)
|
|
|
|
.waitForNumberOfElements(selectors.ticketService.serviceLine, 0)
|
|
|
|
.waitToClick(selectors.ticketService.saveServiceButton)
|
|
|
|
.waitForLastSnackbar();
|
|
|
|
|
|
|
|
expect(result).toEqual('Data saved!');
|
|
|
|
});
|
|
|
|
|
2019-11-12 07:51:50 +00:00
|
|
|
it(`should confirm the service was removed`, async() => {
|
2019-05-20 09:16:56 +00:00
|
|
|
const result = await nightmare
|
|
|
|
.reloadSection('ticket.card.service')
|
|
|
|
.waitForNumberOfElements(selectors.ticketService.serviceLine, 0)
|
|
|
|
.countElement(selectors.ticketService.serviceLine);
|
|
|
|
|
|
|
|
expect(result).toEqual(0);
|
|
|
|
});
|
2019-01-14 10:19:39 +00:00
|
|
|
});
|
|
|
|
});
|