import selectors from '../../helpers/selectors.js'; import createNightmare from '../../helpers/nightmare'; describe('Ticket purchase request path', () => { const nightmare = createNightmare(); beforeAll(() => { nightmare .loginAndModule('salesPerson', 'ticket') .accessToSearchResult('16') .accessToSection('ticket.card.request.index'); }); it(`should add a new request`, async() => { const result = await nightmare .waitToClick(selectors.ticketRequests.addRequestButton) .write(selectors.ticketRequests.descriptionInput, 'New stuff') .write(selectors.ticketRequests.quantityInput, 99) .autocompleteSearch(selectors.ticketRequests.atenderAutocomplete, 'buyerNick') .write(selectors.ticketRequests.priceInput, 999) .waitToClick(selectors.ticketRequests.saveButton) .waitForLastSnackbar(); expect(result).toEqual('Data saved!'); }); it(`should have been redirected to the request index`, async() => { const url = await nightmare .waitForURL('/request') .parsedUrl(); expect(url.hash).toContain('/request'); }); it(`should confirm the new request was added`, async() => { const result = await nightmare .reloadSection('ticket.card.request.index') .waitToGetProperty(selectors.ticketRequests.firstDescription, 'innerText'); expect(result).toEqual('New stuff'); }); it(`should delete the added request`, async() => { const result = await nightmare .waitToClick(selectors.ticketRequests.firstRemoveRequestButton) .waitForLastSnackbar(); expect(result).toEqual('Data saved!'); }); it(`should confirm the request was deleted`, async() => { const result = await nightmare .reloadSection('ticket.card.request.index') .wait(selectors.ticketRequests.addRequestButton) .exists(selectors.ticketRequests.request); expect(result).toBeFalsy(); }); });