From a8d79a578f8650d981bd5f3e1fed599103c5078b Mon Sep 17 00:00:00 2001 From: Carlos Jimenez <=> Date: Mon, 11 Dec 2017 12:33:27 +0100 Subject: [PATCH] e2e pay method path until due day --- e2e/helpers/selectors.js | 10 ++ e2e/paths/edit_pay_method.spec.js | 192 ++++++++++++++++++++++++++++++ services/db/localDB02Inserts.sql | 10 +- 3 files changed, 207 insertions(+), 5 deletions(-) create mode 100644 e2e/paths/edit_pay_method.spec.js diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 42d9722a9..33fea5696 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -69,5 +69,15 @@ export default { invoiceByMailCheckboxLabel: `${components.vnCheck}[label='Invoice by mail'] > label`, viesCheckboxInput: `${components.vnCheck}[label='Vies'] > label > input`, saveButton: `${components.vnSubmit}` + }, + payMethod: { + payMethodButton: `${components.vnMenuItem}[ui-sref="clientCard.billingData"]`, + payMethodInput: `${components.vnAutocomplete}[field="$ctrl.client.payMethodFk"] > vn-vertical > ${components.vnTextfield}`, + payMethodIBANOption: `${components.vnAutocomplete}[field="$ctrl.client.payMethodFk"] > vn-vertical > vn-drop-down > vn-vertical:not(.ng-hide) > vn-auto:nth-child(2) > ul > li:nth-child(5)`, + payMethodOptionOne: `${components.vnAutocomplete}[field="$ctrl.client.payMethodFk"] > vn-vertical > vn-drop-down > vn-vertical:not(.ng-hide) > vn-auto:nth-child(2) > ul > li:nth-child(2)`, + IBANInput: `${components.vnTextfield}[name="iban"]`, + dueDayInput: `${components.vnTextfield}[name="dueDay"]`, + cancelNotificationButton: 'body > vn-app > vn-vertical > vn-vertical > vn-client-card > vn-horizontal > vn-one > vn-vertical > vn-client-billing-data > vn-dialog > div > form > div.button-bar > tpl-buttons > button:nth-child(1)', + saveButton: `${components.vnSubmit}` } }; diff --git a/e2e/paths/edit_pay_method.spec.js b/e2e/paths/edit_pay_method.spec.js new file mode 100644 index 000000000..8018377cd --- /dev/null +++ b/e2e/paths/edit_pay_method.spec.js @@ -0,0 +1,192 @@ +import config from '../helpers/config.js'; +import createNightmare from '../helpers/nightmare'; +import selectors from '../helpers/selectors.js'; +import {catchErrors} from '../../services/utils/jasmineHelpers'; +const nightmare = createNightmare(); +const moduleAccessViewHashURL = '#!/'; + +describe('Edit fiscalData path', () => { + describe('warm up', () => { + it('should warm up login and fixtures', done => { + nightmare + .login() + .waitForURL(moduleAccessViewHashURL) + .waitToClick(selectors.globalItems.logOutButton) + .then(() => { + done(); + }) + .catch(catchErrors(done)); + }); + }); + + it('should log in', done => { + nightmare + .login() + .waitForURL(moduleAccessViewHashURL) + .url() + .then(url => { + expect(url).toEqual(config.url + moduleAccessViewHashURL); + done(); + }) + .catch(catchErrors(done)); + }); + + it('should make sure the language is English', done => { + nightmare + .changeLanguageToEnglish() + .then(() => { + done(); + }) + .catch(catchErrors(done)); + }); + + it('should click on the Clients button of the top bar menu', done => { + nightmare + .waitToClick(selectors.globalItems.applicationsMenuButton) + .wait(selectors.globalItems.applicationsMenuVisible) + .waitToClick(selectors.globalItems.clientsButton) + .wait(selectors.clientsIndex.createClientButton) + .url() + .then(url => { + expect(url).toEqual(config.url + '#!/clients'); + done(); + }) + .catch(catchErrors(done)); + }); + + it('should search for the user Bruce Banner', done => { + nightmare + .wait(selectors.clientsIndex.searchResult) + .type(selectors.clientsIndex.searchClientInput, 'Bruce Banner') + .click(selectors.clientsIndex.searchButton) + .waitForNumberOfElements(selectors.clientsIndex.searchResult, 1) + .countSearchResults(selectors.clientsIndex.searchResult) + .then(result => { + expect(result).toEqual(1); + done(); + }) + .catch(catchErrors(done)); + }); + + it(`should click on the search result to access to the client's pay method`, done => { + nightmare + .waitForTextInElement(selectors.clientsIndex.searchResult, 'Bruce Banner') + .waitToClick(selectors.clientsIndex.searchResult) + .waitToClick(selectors.payMethod.payMethodButton) + .waitForURL('billing-data') + .url() + .then(url => { + expect(url).toContain('billing-data'); + done(); + }) + .catch(catchErrors(done)); + }); + + it(`should edit the Pay method to any without IBAN`, done => { + nightmare + .waitToClick(selectors.payMethod.payMethodInput) + .waitToClick(selectors.payMethod.payMethodOptionOne) + .wait(200) + .waitToClick(selectors.payMethod.saveButton) + .waitToClick(selectors.payMethod.cancelNotificationButton) + .wait(selectors.globalItems.snackbarIsActive) + .getInnerText(selectors.globalItems.snackbarIsActive) + .then(result => { + expect(result).toEqual('Data saved!'); + done(); + }) + .catch(catchErrors(done)); + }); + + it(`should confirm the Pay method have been selected`, done => { + nightmare + .waitForSnackbarReset() + .click(selectors.basicData.basicDataButton) + .wait(selectors.basicData.nameInput) + .click(selectors.payMethod.payMethodButton) + .wait(200) + .getInputValue(selectors.payMethod.payMethodInput) + .then(result => { + expect(result).toEqual('PayMethod one'); + done(); + }) + .catch(catchErrors(done)); + }); + + it(`should receive an error when changing payMethod to IBAN without an IBAN entered`, done => { + nightmare + .waitToClick(selectors.payMethod.payMethodInput) + .waitToClick(selectors.payMethod.payMethodIBANOption) + .wait(200) + .waitToClick(selectors.payMethod.saveButton) + .waitToClick(selectors.payMethod.cancelNotificationButton) + .wait(selectors.globalItems.snackbarIsActive) + .getInnerText(selectors.globalItems.snackbarIsActive) + .then(result => { + expect(result).toContain(`Error: La instancia`); + done(); + }) + .catch(catchErrors(done)); + }); + + it(`should add the IBAN`, done => { + nightmare + .type(selectors.payMethod.IBANInput, 'ES91 2100 0418 4502 0005 1332') + .waitToClick(selectors.payMethod.saveButton) + .waitToClick(selectors.payMethod.cancelNotificationButton) + .wait(selectors.globalItems.snackbarIsActive) + .getInnerText(selectors.globalItems.snackbarIsActive) + .then(result => { + expect(result).toEqual('Data saved!'); + done(); + }) + .catch(catchErrors(done)); + }); + + it(`should confirm the IBAN pay method is sucessfully saved`, done => { + nightmare + .waitForSnackbarReset() + .click(selectors.basicData.basicDataButton) + .wait(selectors.basicData.nameInput) + .click(selectors.payMethod.payMethodButton) + .wait(200) + .getInputValue(selectors.payMethod.payMethodInput) + .then(result => { + expect(result).toEqual('PayMethod with IBAN'); + done(); + }) + .catch(catchErrors(done)); + }); + + // BUG IBAN validation seems to break down whenever the due day is edited plus due day shouldnt accep values above 31. + + // it(`should edit the due day`, done => { + // nightmare + // .clearInput(selectors.payMethod.dueDayInput) + // .type(selectors.payMethod.dueDayInput, '25') + // .waitToClick(selectors.payMethod.saveButton) + // .waitToClick(selectors.payMethod.cancelNotificationButton) + // .wait(selectors.globalItems.snackbarIsActive) + // .getInnerText(selectors.globalItems.snackbarIsActive) + // .then(result => { + // expect(result).toEqual('Data saved!'); + // done(); + // }) + // .catch(catchErrors(done)); + // }); + + // it('should confirm the due day have been edited', done => { + // nightmare + // .waitForSnackbarReset() + // .waitToClick(selectors.basicData.basicDataButton) + // .wait(selectors.basicData.nameInput) + // .waitToClick(selectors.payMethod.payMethodButton) + // .wait(selectors.payMethod.dueDayInput) + // .getInputValue(selectors.payMethod.dueDayInput) + // .then(result => { + // expect(result).toEqual('25'); + // done(); + // }) + // .catch(catchErrors(done)); + // }); +}); diff --git a/services/db/localDB02Inserts.sql b/services/db/localDB02Inserts.sql index 90fbc0fa2..66011091d 100644 --- a/services/db/localDB02Inserts.sql +++ b/services/db/localDB02Inserts.sql @@ -321,11 +321,11 @@ UPDATE `salix`.`AgencyMode` SET `id` = 6 WHERE `name` = 'Walking'; INSERT INTO `salix`.`PayMethod`(`id`, `name`, `graceDays`, `outstandingDebt`, `ibanRequired`) VALUES - (1, 'PayMethod one', 0, 001, 0), - (2, 'PayMethod two', 10, 001, 0), - (3, 'PayMethod three', 0, 001, 0), - (4, 'PayMethod four', 0, 001, 1), - (5, 'PayMethod five', 10, 001, 0); + (1, 'PayMethod one', 0, 001, 0), + (2, 'PayMethod two', 10, 001, 0), + (3, 'PayMethod three', 0, 001, 0), + (4, 'PayMethod with IBAN', 0, 001, 1), + (5, 'PayMethod five', 10, 001, 0); INSERT INTO `salix`.`Zone`(`id`, `name`, `printingOrder`) VALUES