import selectors from '../../helpers/selectors.js'; import createNightmare from '../../helpers/nightmare'; describe('Ticket', () => { describe('Create new tracking state path', () => { const nightmare = createNightmare(); beforeAll(() => { return nightmare .waitForLogin('production'); }); it('should click on the Tickets button of the top bar menu', (done) => { return nightmare .waitToClick(selectors.globalItems.applicationsMenuButton) .wait(selectors.globalItems.applicationsMenuVisible) .waitToClick(selectors.globalItems.ticketsButton) .wait(selectors.ticketsIndex.searchResult) .parsedUrl() .then((url) => { expect(url.hash).toEqual('#!/ticket/index'); done(); }).catch(done.fail); }); it('should search for the ticket 1', (done) => { return nightmare .wait(selectors.ticketsIndex.searchResult) .type(selectors.ticketsIndex.searchTicketInput, 'id:1') .click(selectors.ticketsIndex.searchButton) .waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1) .countElement(selectors.ticketsIndex.searchResult) .then((result) => { expect(result).toEqual(1); done(); }).catch(done.fail); }); it(`should click on the search result to access to the ticket Tracking`, (done) => { return nightmare .waitForTextInElement(selectors.ticketsIndex.searchResult, 'address 21') .waitToClick(selectors.ticketsIndex.searchResult) .waitToClick(selectors.ticketTracking.trackingButton) .waitForURL('tracking/index') .url() .then((url) => { expect(url).toContain('tracking/index'); done(); }).catch(done.fail); }); it('should access to the create state view by clicking the create floating button', (done) => { return nightmare .click(selectors.ticketTracking.createStateButton) .wait(selectors.createStateView.stateInput) .parsedUrl() .then((url) => { expect(url.hash).toContain('tracking/edit'); done(); }).catch(done.fail); }); it(`should attempt create a new state but receive an error if state is empty`, (done) => { return nightmare .click(selectors.createStateView.saveStateButton) .waitForLastSnackbar() .then((result) => { expect(result).toEqual('No changes to save'); done(); }).catch(done.fail); }); it(`should attempt create a new state then clear and save it`, (done) => { return nightmare .waitToClick(selectors.createStateView.stateInput) .waitToClick(selectors.createStateView.stateInputOptionOne) .waitToClick(selectors.createStateView.clearStateInputButton) .click(selectors.createStateView.saveStateButton) .waitForLastSnackbar() .then((result) => { expect(result).toEqual('Data saved!'); done(); }).catch(done.fail); }); it('should again access to the create state view by clicking the create floating button', (done) => { return nightmare .click(selectors.ticketTracking.createStateButton) .wait(selectors.createStateView.stateInput) .parsedUrl() .then((url) => { expect(url.hash).toContain('tracking/edit'); done(); }).catch(done.fail); }); it(`should create a new state`, (done) => { return nightmare .waitToClick(selectors.createStateView.stateInput) .waitToClick(selectors.createStateView.stateInputOptionOne) .click(selectors.createStateView.saveStateButton) .waitForLastSnackbar() .then((result) => { expect(result).toEqual('Data saved!'); done(); }).catch(done.fail); }); }); });