salix/e2e/paths/route-module/03_tickets.spec.js

137 lines
4.7 KiB
JavaScript

import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare';
describe('Route basic Data path', () => {
const nightmare = createNightmare();
beforeAll(() => {
nightmare
.loginAndModule('delivery', 'route')
.accessToSearchResult(1)
.accessToSection('route.card.tickets');
});
it('should modify the first ticket priority', async() => {
const result = await nightmare
.write(selectors.routeTickets.firstTicketPriority, 5)
.write('body', '\u000d') // simulates enter
.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
it('should now modify the first ticket priority', async() => {
const result = await nightmare
.write(selectors.routeTickets.firstTicketPriority, 4)
.write('body', '\u000d') // simulates enter
.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
it('should next modify the first ticket priority', async() => {
const result = await nightmare
.write(selectors.routeTickets.firstTicketPriority, 3)
.write('body', '\u000d') // simulates enter
.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
it('should once more modify the first ticket priority', async() => {
const result = await nightmare
.write(selectors.routeTickets.firstTicketPriority, 2)
.write('body', '\u000d') // simulates enter
.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
it('should finally modify the first ticket priority', async() => {
const result = await nightmare
.write(selectors.routeTickets.firstTicketPriority, 1)
.write('body', '\u000d') // simulates enter
.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
it('should reload the section as a pre-step to check the first ticket priority', async() => {
const result = await nightmare
.reloadSection('route.card.tickets')
.waitToGetProperty(selectors.routeTickets.firstTicketPriority, 'value');
expect(result).toEqual('1');
});
it('should confirm the second ticket priority', async() => {
const result = await nightmare
.waitToGetProperty(selectors.routeTickets.secondTicketPriority, 'value');
expect(result).toEqual('2');
});
it('should confirm the third ticket priority', async() => {
const result = await nightmare
.waitToGetProperty(selectors.routeTickets.thirdTicketPriority, 'value');
expect(result).toEqual('3');
});
it('should confirm the fourth ticket priority', async() => {
const result = await nightmare
.waitToGetProperty(selectors.routeTickets.fourthTicketPriority, 'value');
expect(result).toEqual('4');
});
it('should confirm the fifth ticket priority', async() => {
const result = await nightmare
.waitToGetProperty(selectors.routeTickets.fifthTicketPriority, 'value');
expect(result).toEqual('5');
});
it('should confirm the buscamanButton is disabled', async() => {
const result = await nightmare
.evaluate(selector => {
return document.querySelector(selector);
}, `${selectors.routeTickets.buscamanButton} :disabled`);
expect(result).toBeTruthy();
});
it('should check the first ticket checkbox and confirm the buscamanButton button isnt disabled anymore', async() => {
const result = await nightmare
.waitToClick(selectors.routeTickets.firstTicketCheckbox)
.evaluate(selector => {
return document.querySelector(selector);
}, `${selectors.routeTickets.buscamanButton} :disabled`);
expect(result).toBeFalsy();
});
it('should count how many tickets are in route', async() => {
const result = await nightmare
.countElement('vn-route-tickets vn-textfield[model="ticket.priority"]');
expect(result).toEqual(5);
});
it('should delete the first ticket in route', async() => {
const result = await nightmare
.waitToClick(selectors.routeTickets.firstTicketDeleteButton)
.waitToClick(selectors.routeTickets.confirmButton)
.waitForLastSnackbar();
expect(result).toEqual('Ticket deleted from route');
});
it('should now count how many tickets are in route to find one less', async() => {
const result = await nightmare
.countElement('vn-route-tickets vn-textfield[model="ticket.priority"]');
expect(result).toEqual(4);
});
});