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

143 lines
5.8 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();
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')
.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-11-12 07:51:50 +00:00
.waitForClassPresent(selectors.ticketService.firstAddDescriptionButton, 'disabled')
2019-05-20 09:16:56 +00:00
.waitToClick(selectors.ticketService.addServiceButton)
.wait(selectors.ticketService.firstAddDescriptionButton)
2019-10-18 19:36:30 +00:00
.isDisabled(selectors.ticketService.firstAddDescriptionButton);
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();
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')
.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)
.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)
.wait('.vn-dialog.shown')
2019-05-20 09:16:56 +00:00
.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();
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 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!');
});
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
});
});