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

140 lines
5.7 KiB
JavaScript
Raw Normal View History

2019-01-14 10:19:39 +00:00
import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare';
2019-02-07 13:33:52 +00:00
describe('Ticket services path', () => {
2019-01-14 10:19:39 +00:00
const nightmare = createNightmare();
const invoicedTicketId = 10;
2019-05-20 09:16:56 +00:00
describe('as employee', () => {
beforeAll(() => {
nightmare
.loginAndModule('employee', 'ticket')
.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
.waitToClick(selectors.ticketService.addServiceButton)
.wait(selectors.ticketService.firstAddDescriptionButton)
.evaluate(selector => {
return document.querySelector(selector).disabled;
}, selectors.ticketService.firstAddDescriptionButton);
expect(result).toBeTruthy();
});
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();
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 = 13;
2019-05-20 09:16:56 +00:00
beforeAll(() => {
nightmare
.loginAndModule('administrative', 'ticket')
.accessToSearchResult(editableTicketId)
2019-05-20 09:16:56 +00:00
.accessToSection('ticket.card.service');
});
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)
.isVisible(selectors.ticketService.firstDescriptionAutocomplete);
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`);
});
it('should click on the add new description to open the dialog', async() => {
const result = await nightmare
.waitToClick(selectors.ticketService.firstAddDescriptionButton)
.waitForClassPresent('vn-ticket-service > vn-dialog', 'shown')
.isVisible(selectors.ticketService.newDescriptionInput);
expect(result).toBeTruthy();
});
it('should receive an error if description is empty on submit', async() => {
const result = await nightmare
.waitToClick(selectors.ticketService.saveDescriptionButton)
.waitForLastSnackbar();
expect(result).toEqual(`Name can't be empty`);
});
it('should create a new description then add price then create the service', async() => {
const result = await nightmare
.write(selectors.ticketService.newDescriptionInput, 'accurate description')
.waitToClick(selectors.ticketService.saveDescriptionButton)
.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')
.waitToGetProperty(`${selectors.ticketService.firstDescriptionAutocomplete} input`, 'value');
expect(result).toEqual('accurate description');
});
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!');
});
it(`should confirm the service wasn't sucessfully 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
});
});