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

121 lines
4.2 KiB
JavaScript
Raw Normal View History

2019-04-08 13:38:47 +00:00
import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare';
describe('Route basic Data path', () => {
const nightmare = createNightmare();
beforeAll(() => {
nightmare
.loginAndModule('delivery', 'route')
2019-04-10 11:19:28 +00:00
.accessToSearchResult(2)
2019-04-08 13:38:47 +00:00
.accessToSection('route.card.tickets');
});
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 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"]');
2019-04-10 11:19:28 +00:00
expect(result).toEqual(4);
2019-04-08 13:38:47 +00:00
});
it('should delete the first ticket in route', async() => {
const result = await nightmare
.waitToClick(selectors.routeTickets.firstTicketDeleteButton)
.waitToClick(selectors.routeTickets.confirmButton)
.waitForLastSnackbar();
2019-06-06 11:50:12 +00:00
expect(result).toEqual('Ticket removed from route');
2019-04-08 13:38:47 +00:00
});
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"]');
2019-04-10 11:19:28 +00:00
expect(result).toEqual(3);
2019-04-08 13:38:47 +00:00
});
});