salix/e2e/paths/ticket-module/10_ticket_request.spec.js

65 lines
2.4 KiB
JavaScript
Raw Normal View History

2018-11-13 15:30:19 +00:00
import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare';
2018-11-21 13:09:22 +00:00
describe('Ticket purchase request path', () => {
2018-11-13 15:30:19 +00:00
const nightmare = createNightmare();
beforeAll(() => {
nightmare
.loginAndModule('salesPerson', 'ticket')
.accessToSearchResult('id:16')
.accessToSection('ticket.card.request.index');
2018-11-13 15:30:19 +00:00
});
2019-01-07 09:55:23 +00:00
it(`should add a new request`, async() => {
2018-11-13 15:30:19 +00:00
const result = await nightmare
.waitToClick(selectors.ticketRequests.addRequestButton)
2019-01-23 14:33:25 +00:00
.write(selectors.ticketRequests.descriptionInput, 'New stuff')
.write(selectors.ticketRequests.quantityInput, 99)
2018-11-21 13:09:22 +00:00
.waitToClick(selectors.ticketRequests.atenderSelect)
.waitToClick(selectors.ticketRequests.atenderSelectSecondOption)
2019-01-23 14:33:25 +00:00
.write(selectors.ticketRequests.priceInput, 999)
2018-11-13 15:30:19 +00:00
.waitToClick(selectors.ticketRequests.saveButton)
.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
2019-01-07 09:55:23 +00:00
it(`should have been redirected to the request index`, async() => {
2018-11-21 13:09:22 +00:00
const url = await nightmare
.waitForURL('/request')
.parsedUrl();
2018-11-13 15:30:19 +00:00
expect(url.hash).toContain('/request');
2018-11-13 15:30:19 +00:00
});
2019-01-07 09:55:23 +00:00
it(`should confirm the new request was added`, async() => {
2018-11-13 15:30:19 +00:00
const result = await nightmare
.waitToClick(selectors.ticketBasicData.basicDataButton)
2019-01-07 09:55:23 +00:00
.wait(selectors.ticketBasicData.clientAutocomplete)
2018-11-13 15:30:19 +00:00
.waitToClick(selectors.ticketRequests.requestButton)
.waitToGetProperty(selectors.ticketRequests.firstDescription, 'innerText');
2018-11-13 15:30:19 +00:00
2018-11-21 13:09:22 +00:00
expect(result).toEqual('New stuff');
2018-11-13 15:30:19 +00:00
});
2019-01-07 09:55:23 +00:00
it(`should delete the added request`, async() => {
2018-11-13 15:30:19 +00:00
const result = await nightmare
2018-11-21 13:09:22 +00:00
.waitToClick(selectors.ticketRequests.firstRemoveRequestButton)
2018-11-13 15:30:19 +00:00
.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
2019-01-07 09:55:23 +00:00
it(`should confirm the request was deleted`, async() => {
2018-11-13 15:30:19 +00:00
const result = await nightmare
.waitToClick(selectors.ticketBasicData.basicDataButton)
2019-01-07 09:55:23 +00:00
.wait(selectors.ticketBasicData.clientAutocomplete)
2018-11-13 15:30:19 +00:00
.waitToClick(selectors.ticketRequests.requestButton)
2018-11-21 13:09:22 +00:00
.wait(selectors.ticketRequests.addRequestButton)
.exists(selectors.ticketRequests.request);
2018-11-13 15:30:19 +00:00
2018-11-21 13:09:22 +00:00
expect(result).toBeFalsy();
2018-11-13 15:30:19 +00:00
});
});