import selectors from '../../helpers/selectors.js'; import createNightmare from '../../helpers/helpers'; xdescribe('Client', () => { describe('Edit pay method path', () => { const nightmare = createNightmare(); beforeAll(() => { return nightmare .waitForLogin('administrative'); }); it('should click on the Clients button of the top bar menu', done => { return nightmare .waitToClick(selectors.globalItems.applicationsMenuButton) .wait(selectors.globalItems.applicationsMenuVisible) .waitToClick(selectors.globalItems.clientsButton) .wait(selectors.clientsIndex.createClientButton) .parsedUrl() .then(url => { expect(url.hash).toEqual('#!/client/index'); done(); }).catch(done.fail); }); it('should search for the user Bruce Banner', done => { return nightmare .wait(selectors.clientsIndex.searchResult) .type(selectors.clientsIndex.searchClientInput, 'Bruce Banner') .click(selectors.clientsIndex.searchButton) .waitForNumberOfElements(selectors.clientsIndex.searchResult, 1) .countElement(selectors.clientsIndex.searchResult) .then(result => { expect(result).toEqual(1); done(); }).catch(done.fail); }); it(`should click on the search result to access to the client's pay method`, done => { return nightmare .waitForTextInElement(selectors.clientsIndex.searchResult, 'Bruce Banner') .waitToClick(selectors.clientsIndex.searchResult) .waitToClick(selectors.clientPayMethod.payMethodButton) .waitForURL('billing-data') .url() .then(url => { expect(url).toContain('billing-data'); done(); }).catch(done.fail); }); it(`should attempt to edit the Pay method without an IBAN but fail`, done => { return nightmare .waitToClick(selectors.clientPayMethod.payMethodInput) .waitToClick(selectors.clientPayMethod.payMethodIBANOption) .waitForTextInInput(selectors.clientPayMethod.payMethodInput, 'PayMethod with IBAN') .clearInput(selectors.clientPayMethod.dueDayInput) .type(selectors.clientPayMethod.dueDayInput, '60') .waitForTextInInput(selectors.clientPayMethod.dueDayInput, '60') .waitToClick(selectors.clientPayMethod.receivedCoreLCRCheckbox) .waitToClick(selectors.clientPayMethod.receivedCoreVNLCheckbox) .waitToClick(selectors.clientPayMethod.receivedB2BVNLCheckbox) .waitToClick(selectors.clientPayMethod.saveButton) .waitForLastSnackbar() .then(result => { expect(result).toEqual('That payment method requires an IBAN'); done(); }).catch(done.fail); }); it(`should add the IBAN`, done => { return nightmare .clearInput(selectors.clientPayMethod.IBANInput) .type(selectors.clientPayMethod.IBANInput, 'ES91 2100 0418 4502 0005 1332') .waitForTextInInput(selectors.clientPayMethod.IBANInput, 'ES91 2100 0418 4502 0005 1332') .waitToClick(selectors.clientPayMethod.saveButton) .waitForSnackbar() .then(result => { expect(result).toEqual(jasmine.arrayContaining(['Data saved!', 'Notification sent!'])); done(); }).catch(done.fail); }); it(`should confirm the IBAN pay method is sucessfully saved`, done => { return nightmare .getInputValue(selectors.clientPayMethod.payMethodInput) .then(result => { expect(result).toEqual('PayMethod with IBAN'); done(); }).catch(done.fail); }); it('should confirm the due day have been edited', done => { return nightmare .getInputValue(selectors.clientPayMethod.dueDayInput) .then(result => { expect(result).toEqual('60'); done(); }).catch(done.fail); }); it('should confirm Received LCR checkbox is checked', done => { return nightmare .evaluate(selector => { return document.querySelector(selector).checked; }, selectors.clientPayMethod.receivedCoreLCRCheckbox) .then(value => { expect(value).toBeTruthy(); done(); }).catch(done.fail); }); it('should confirm Received core VNL checkbox is unchecked', done => { return nightmare .evaluate(selector => { return document.querySelector(selector).checked; }, selectors.clientPayMethod.receivedCoreVNLCheckbox) .then(value => { expect(value).toBeFalsy(); done(); }).catch(done.fail); }); it('should confirm Received B2B VNL checkbox is unchecked', done => { return nightmare .evaluate(selector => { return document.querySelector(selector).checked; }, selectors.clientPayMethod.receivedB2BVNLCheckbox) .then(value => { expect(value).toBeFalsy(); done(); }).catch(done.fail); }); }); });