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

119 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 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 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();
});
2019-07-01 11:41:38 +00:00
it('should check the route volume on the descriptor', async() => {
const result = await nightmare
.waitToGetProperty(selectors.routeDescriptor.volume, 'innerText');
expect(result).toEqual('0.9 / 50 m³');
});
2019-04-08 13:38:47 +00:00
it('should count how many tickets are in route', async() => {
const result = await nightmare
.countElement('vn-route-tickets vn-textfield[model="ticket.priority"]');
2019-06-19 07:03:45 +00:00
expect(result).toEqual(3);
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-06-19 07:03:45 +00:00
expect(result).toEqual(2);
2019-04-08 13:38:47 +00:00
});
2019-07-01 11:41:38 +00:00
it('should confirm the route volume on the descriptor has been updated by the changes made', async() => {
const result = await nightmare
.waitToGetProperty(selectors.routeDescriptor.volume, 'innerText');
expect(result).toEqual('0.7 / 50 m³');
});
2019-04-08 13:38:47 +00:00
});