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
|
|
|
|
.waitForLogin('salesPerson');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should click on the Tickets button of the top bar menu', async () => {
|
|
|
|
const url = await nightmare
|
|
|
|
.waitToClick(selectors.globalItems.applicationsMenuButton)
|
|
|
|
.wait(selectors.globalItems.applicationsMenuVisible)
|
|
|
|
.waitToClick(selectors.globalItems.ticketsButton)
|
2018-11-21 13:30:32 +00:00
|
|
|
.wait(selectors.ticketsIndex.searchTicketInput)
|
2018-11-13 15:30:19 +00:00
|
|
|
.parsedUrl();
|
|
|
|
|
|
|
|
expect(url.hash).toEqual('#!/ticket/index');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should search for a specific ticket', async () => {
|
|
|
|
const result = await nightmare
|
2018-11-21 13:30:32 +00:00
|
|
|
.wait(selectors.ticketsIndex.searchTicketInput)
|
2018-11-13 15:30:19 +00:00
|
|
|
.type(selectors.ticketsIndex.searchTicketInput, 'id:16')
|
|
|
|
.click(selectors.ticketsIndex.searchButton)
|
|
|
|
.waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1)
|
|
|
|
.countElement(selectors.ticketsIndex.searchResult);
|
|
|
|
|
|
|
|
expect(result).toEqual(1);
|
|
|
|
});
|
|
|
|
|
|
|
|
it(`should click on the search result to access to the ticket Purchase request`, async () => {
|
|
|
|
const url = await nightmare
|
|
|
|
.waitForTextInElement(selectors.ticketsIndex.searchResult, 'address 21')
|
|
|
|
.waitToClick(selectors.ticketsIndex.searchResult)
|
|
|
|
.waitToClick(selectors.ticketRequests.requestButton)
|
|
|
|
.waitForURL('/request')
|
|
|
|
.url();
|
|
|
|
|
|
|
|
expect(url).toContain('/request');
|
|
|
|
});
|
|
|
|
|
|
|
|
it(`should add a new request`, async () => {
|
|
|
|
const result = await nightmare
|
|
|
|
.waitToClick(selectors.ticketRequests.addRequestButton)
|
2018-11-21 13:09:22 +00:00
|
|
|
.wait(selectors.ticketRequests.descriptionInput)
|
|
|
|
.type(selectors.ticketRequests.descriptionInput, 'New stuff')
|
|
|
|
.type(selectors.ticketRequests.quantityInput, 99)
|
|
|
|
.waitToClick(selectors.ticketRequests.atenderSelect)
|
|
|
|
.waitToClick(selectors.ticketRequests.atenderSelectSecondOption)
|
|
|
|
.type(selectors.ticketRequests.priceInput, 999)
|
2018-11-13 15:30:19 +00:00
|
|
|
.waitToClick(selectors.ticketRequests.saveButton)
|
|
|
|
.waitForLastSnackbar();
|
|
|
|
|
|
|
|
expect(result).toEqual('Data saved!');
|
|
|
|
});
|
|
|
|
|
2018-11-21 13:09:22 +00:00
|
|
|
it(`should have been redirected to the request index`, async () => {
|
|
|
|
const url = await nightmare
|
|
|
|
.waitForURL('/request')
|
|
|
|
.url();
|
2018-11-13 15:30:19 +00:00
|
|
|
|
2018-11-21 13:09:22 +00:00
|
|
|
expect(url).toContain('/request');
|
2018-11-13 15:30:19 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it(`should confirm the new request was added`, async () => {
|
|
|
|
const result = await nightmare
|
|
|
|
.waitToClick(selectors.ticketBasicData.basicDataButton)
|
|
|
|
.wait(selectors.ticketBasicData.clientSelect)
|
|
|
|
.waitToClick(selectors.ticketRequests.requestButton)
|
2018-11-21 13:09:22 +00:00
|
|
|
.waitProperty(selectors.ticketRequests.firstDescription, 'innerText')
|
|
|
|
.getProperty(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
|
|
|
});
|
|
|
|
|
|
|
|
it(`should delete the added request`, async () => {
|
|
|
|
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!');
|
|
|
|
});
|
|
|
|
|
2018-11-21 13:09:22 +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)
|
|
|
|
.wait(selectors.ticketBasicData.clientSelect)
|
|
|
|
.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
|
|
|
});
|
|
|
|
});
|