salix/e2e/paths/ticket-module/13_create_ticket_services.s...

77 lines
2.9 KiB
JavaScript

import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare';
describe('Ticket services path', () => {
const nightmare = createNightmare();
beforeAll(() => {
nightmare
.loginAndModule('employee', 'ticket')
.accessToSearchResult('id:1')
.accessToSection('ticket.card.service');
});
it('should edit the first service', async() => {
const result = await nightmare
.clearInput(selectors.ticketService.firstDescriptionInput)
.write(selectors.ticketService.firstDescriptionInput, 'my service')
.clearInput(selectors.ticketService.firstQuantityInput)
.write(selectors.ticketService.firstQuantityInput, 99)
.clearInput(selectors.ticketService.firstPriceInput)
.write(selectors.ticketService.firstPriceInput, 999)
.autocompleteSearch(selectors.ticketService.firstVatTypeAutocomplete, 'General VAT')
.waitToClick(selectors.ticketService.saveServiceButton)
.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
it('should confirm the service description was edited correctly', async() => {
const result = await nightmare
.reloadSection('ticket.card.service')
.waitToGetProperty(selectors.ticketService.firstDescriptionInput, 'value');
expect(result).toEqual('my service');
});
it('should confirm the service quantity was edited correctly', async() => {
const result = await nightmare
.waitToGetProperty(selectors.ticketService.firstQuantityInput, 'value');
expect(result).toEqual('99');
});
it('should confirm the service price was edited correctly', async() => {
const result = await nightmare
.waitToGetProperty(selectors.ticketService.firstPriceInput, 'value');
expect(result).toEqual('999');
});
it('should confirm the service VAT was edited 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 was sucessfully removed', async() => {
const result = await nightmare
.reloadSection('ticket.card.service')
.waitForNumberOfElements(selectors.ticketService.serviceLine, 0)
.countElement(selectors.ticketService.serviceLine);
expect(result).toEqual(0);
});
});