From d45f4e4eb6e02e10605f57bc4cc537f24a408718 Mon Sep 17 00:00:00 2001 From: Carlos Jimenez <=> Date: Wed, 13 Dec 2017 11:25:50 +0100 Subject: [PATCH] e2e edit addresses path plus jasmine default timeout increased to 10seconds --- e2e/helpers/components_selectors.js | 3 +- e2e/helpers/selectors.js | 20 ++ e2e/paths/create_client_path.spec.js | 2 + e2e/paths/edit_addresses.spec.js | 300 +++++++++++++++++++++++++++ e2e/paths/edit_basic_data.spec.js | 2 + e2e/paths/edit_fiscal_data.spec.js | 2 + e2e/paths/edit_pay_method.spec.js | 4 +- 7 files changed, 331 insertions(+), 2 deletions(-) create mode 100644 e2e/paths/edit_addresses.spec.js diff --git a/e2e/helpers/components_selectors.js b/e2e/helpers/components_selectors.js index 87dc22c69..8b13b14be 100644 --- a/e2e/helpers/components_selectors.js +++ b/e2e/helpers/components_selectors.js @@ -14,5 +14,6 @@ export default { vnFloatButton: 'vn-float-button > button', vnMenuItem: 'vn-menu-item > li > a', vnAutocomplete: 'vn-autocomplete', - vnCheck: 'vn-check' + vnCheck: 'vn-check', + vnIconButton: 'vn-icon-button' }; diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 33fea5696..fa1ae9b2a 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -79,5 +79,25 @@ export default { 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}` + }, + addresses: { + addressesButton: `${components.vnMenuItem}[ui-sref="clientCard.addresses.list"]`, + createAddress: `${components.vnFloatButton}`, + defaultCheckboxInput: `${components.vnCheck}[label='Default'] > label > input`, + consigneeInput: `${components.vnTextfield}[name="consignee"]`, + streetAddressInput: `${components.vnTextfield}[name="street"]`, + postcodeInput: `${components.vnTextfield}[name="postcode"]`, + cityInput: `${components.vnTextfield}[name="city"]`, + provinceInput: `${components.vnAutocomplete}[field="$ctrl.address.provinceFk"] > vn-vertical > ${components.vnTextfield}`, + provinceSecondOption: `${components.vnAutocomplete}[field="$ctrl.address.provinceFk"] > vn-vertical > vn-drop-down > vn-vertical:not(.ng-hide) > vn-auto:nth-child(2) > ul > li:nth-child(2)`, + agencyInput: `${components.vnAutocomplete}[field="$ctrl.address.agencyFk"] > vn-vertical > ${components.vnTextfield}`, + agenctySecondOption: `${components.vnAutocomplete}[field="$ctrl.address.agencyFk"] > vn-vertical > vn-drop-down > vn-vertical:not(.ng-hide) > vn-auto:nth-child(2) > ul > li:nth-child(2)`, + phoneInput: `${components.vnTextfield}[name="phone"]`, + mobileInput: `${components.vnTextfield}[name="mobile"]`, + defaultAddress: 'body > vn-app > vn-vertical > vn-vertical > vn-client-card > vn-horizontal > vn-one > vn-vertical > ui-view > vn-client-addresses > vn-vertical > vn-card > div > vn-vertical > vn-horizontal:nth-child(2) > vn-one > vn-horizontal > vn-one > div:nth-child(2)', + secondMakeDefaultStar: 'body > vn-app > vn-vertical > vn-vertical > vn-client-card > vn-horizontal > vn-one > vn-vertical > ui-view > vn-client-addresses > vn-vertical > vn-card > div > vn-vertical > vn-horizontal:nth-child(3) > vn-one > vn-horizontal > vn-none > i', + firstEditButton: `${components.vnIconButton}[icon='edit']`, + activeCheckboxLabel: `${components.vnCheck}[label='Enabled'] > label > input`, + saveButton: `${components.vnSubmit}` } }; diff --git a/e2e/paths/create_client_path.spec.js b/e2e/paths/create_client_path.spec.js index 0868c2239..50b5b56d1 100644 --- a/e2e/paths/create_client_path.spec.js +++ b/e2e/paths/create_client_path.spec.js @@ -5,6 +5,8 @@ import {catchErrors} from '../../services/utils/jasmineHelpers'; const nightmare = createNightmare(); const moduleAccessViewHashURL = '#!/'; +jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000; + describe('create client path', () => { describe('warm up', () => { it('should warm up login and fixtures', done => { diff --git a/e2e/paths/edit_addresses.spec.js b/e2e/paths/edit_addresses.spec.js new file mode 100644 index 000000000..60f6d9a52 --- /dev/null +++ b/e2e/paths/edit_addresses.spec.js @@ -0,0 +1,300 @@ +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 = '#!/'; + +jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000; + +describe('Edit addresses 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.addresses.addressesButton) + .waitForURL('addresses/list') + .url() + .then(url => { + expect(url).toContain('addresses/list'); + done(); + }) + .catch(catchErrors(done)); + }); + + it(`should click on the add new address button to access to the new address form`, done => { + nightmare + .waitToClick(selectors.addresses.createAddress) + .waitForURL('addresses/create') + .url() + .then(url => { + expect(url).toContain('addresses/create'); + done(); + }) + .catch(catchErrors(done)); + }); + + it('should check the default checkbox then receive an error after clicking save button as the form is empty', done => { + nightmare + .waitToClick(selectors.addresses.defaultCheckboxInput) + .waitToClick(selectors.fiscalData.saveButton) + .wait(selectors.globalItems.snackbarIsActive) + .getInnerText(selectors.globalItems.snackbarIsActive) + .then(result => { + expect(result).toContain(`Error: La instancia`); + done(); + }) + .catch(catchErrors(done)); + }); + + it('should receive an error when clicking the save button having all the form fields empty but consignee', done => { + nightmare + .waitForSnackbarReset() + .type(selectors.addresses.consigneeInput, 'Bruce Bunner') + .click(selectors.createClientView.createButton) + .wait(selectors.globalItems.snackbarIsActive) + .getInnerText(selectors.globalItems.snackbarIsActive) + .then(result => { + expect(result).toContain(`Error: La instancia`); + done(); + }) + .catch(catchErrors(done)); + }); + + it('should receive an error when clicking the save button having all the form fields empty but Street', done => { + nightmare + .waitForSnackbarReset() + .clearInput(selectors.addresses.consigneeInput) + .type(selectors.addresses.streetAddressInput, '320 Park Avenue New York') + .click(selectors.createClientView.createButton) + .wait(selectors.globalItems.snackbarIsActive) + .getInnerText(selectors.globalItems.snackbarIsActive) + .then(result => { + expect(result).toContain(`Error: La instancia`); + done(); + }) + .catch(catchErrors(done)); + }); + + it('should receive an error when clicking the save button having all the form fields empty but postcode', done => { + nightmare + .waitForSnackbarReset() + .clearInput(selectors.addresses.streetAddressInput) + .type(selectors.addresses.postcodeInput, '10022') + .click(selectors.createClientView.createButton) + .wait(selectors.globalItems.snackbarIsActive) + .getInnerText(selectors.globalItems.snackbarIsActive) + .then(result => { + expect(result).toContain(`Error: La instancia`); + done(); + }) + .catch(catchErrors(done)); + }); + + it('should receive an error when clicking the save button having all the form fields empty but city', done => { + nightmare + .waitForSnackbarReset() + .clearInput(selectors.addresses.postcodeInput) + .type(selectors.addresses.cityInput, 'New York') + .click(selectors.createClientView.createButton) + .wait(selectors.globalItems.snackbarIsActive) + .getInnerText(selectors.globalItems.snackbarIsActive) + .then(result => { + expect(result).toContain(`Error: La instancia`); + done(); + }) + .catch(catchErrors(done)); + }); + + it('should receive an error when clicking the save button having all the form fields empty but province', done => { + nightmare + .waitForSnackbarReset() + .clearInput(selectors.addresses.cityInput) + .waitToClick(selectors.addresses.provinceInput) + .waitToClick(selectors.addresses.provinceSecondOption) + .click(selectors.createClientView.createButton) + .wait(selectors.globalItems.snackbarIsActive) + .getInnerText(selectors.globalItems.snackbarIsActive) + .then(result => { + expect(result).toContain(`Error: La instancia`); + done(); + }) + .catch(catchErrors(done)); + }); + + it('should receive an error when clicking the save button having all the form fields empty but province and agency', done => { + nightmare + .waitForSnackbarReset() + .waitToClick(selectors.addresses.agencyInput) + .waitToClick(selectors.addresses.agenctySecondOption) + .click(selectors.createClientView.createButton) + .wait(selectors.globalItems.snackbarIsActive) + .getInnerText(selectors.globalItems.snackbarIsActive) + .then(result => { + expect(result).toContain(`Error: La instancia`); + done(); + }) + .catch(catchErrors(done)); + }); + + it('should receive an error when clicking the save button having all the form fields empty but province, agency and phone', done => { + nightmare + .waitForSnackbarReset() + .type(selectors.addresses.phoneInput, '999887744') + .click(selectors.createClientView.createButton) + .wait(selectors.globalItems.snackbarIsActive) + .getInnerText(selectors.globalItems.snackbarIsActive) + .then(result => { + expect(result).toContain(`Error: La instancia`); + done(); + }) + .catch(catchErrors(done)); + }); + + it('should receive an error when clicking the save button having all the form fields empty but province, agency and mobile', done => { + nightmare + .waitForSnackbarReset() + .clearInput(selectors.addresses.phoneInput) + .type(selectors.addresses.mobileInput, '999887744') + .click(selectors.createClientView.createButton) + .wait(selectors.globalItems.snackbarIsActive) + .getInnerText(selectors.globalItems.snackbarIsActive) + .then(result => { + expect(result).toContain(`Error: La instancia`); + done(); + }) + .catch(catchErrors(done)); + }); + + it(`should create a new address with all it's data`, done => { + nightmare + .waitForSnackbarReset() + .type(selectors.addresses.consigneeInput, 'Bruce Bunner') + .type(selectors.addresses.streetAddressInput, '320 Park Avenue New York') + .type(selectors.addresses.postcodeInput, '10022') + .type(selectors.addresses.cityInput, 'New York') + .type(selectors.addresses.phoneInput, '999887744') + .click(selectors.addresses.saveButton) + .wait(selectors.globalItems.snackbarIsActive) + .getInnerText(selectors.globalItems.snackbarIsActive) + .then(result => { + expect(result).toContain('Data saved!'); + done(); + }) + .catch(catchErrors(done)); + }); + + it(`should click on the addresses button confirm the new address exists and it's the default one`, done => { + nightmare + .waitForSnackbarReset() + .waitToClick(selectors.addresses.addressesButton) + .wait(selectors.addresses.defaultAddress) + .getInnerText(selectors.addresses.defaultAddress) + .then(result => { + expect(result).toContain('320 Park Avenue New York'); + done(); + }) + .catch(catchErrors(done)); + }); + + it(`should click on the make default icon of the second address then confirm it is the default one now`, done => { + nightmare + .waitForSnackbarReset() + .waitToClick(selectors.addresses.secondMakeDefaultStar) + .waitForTextInElement(selectors.addresses.defaultAddress, 'Somewhere in Thailand') + .getInnerText(selectors.addresses.defaultAddress) + .then(result => { + expect(result).toContain('Somewhere in Thailand'); + done(); + }) + .catch(catchErrors(done)); + }); + + it(`should click on the edit icon of the default address`, done => { + nightmare + .waitForTextInElement(selectors.addresses.defaultAddress, 'Somewhere in Thailand') + .waitToClick(selectors.addresses.firstEditButton) + .waitForURL('/edit') + .url() + .then(result => { + expect(result).toContain('/edit'); + done(); + }) + .catch(catchErrors(done)); + }); + + // it(`should click on the active checkbox and receive an error to save it becouse it is the default address`, done => { + // nightmare + // .waitToClick(selectors.addresses.activeCheckboxLabel) + // .waitToClick(selectors.addresses.saveButton) // is it saving over the default? + // .wait(selectors.globalItems.snackbarIsActive) + // .getInnerText(selectors.globalItems.snackbarIsActive) + // .then(result => { + // expect(result).toContain(`Error: La instancia`); + // done(); + // }) + // .catch(catchErrors(done)); + // }); +}); diff --git a/e2e/paths/edit_basic_data.spec.js b/e2e/paths/edit_basic_data.spec.js index db1058ba8..2150fe4c9 100644 --- a/e2e/paths/edit_basic_data.spec.js +++ b/e2e/paths/edit_basic_data.spec.js @@ -5,6 +5,8 @@ import {catchErrors} from '../../services/utils/jasmineHelpers'; const nightmare = createNightmare(); const moduleAccessViewHashURL = '#!/'; +jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000; + describe('Edit basicData path', () => { describe('warm up', () => { it('should warm up login and fixtures', done => { diff --git a/e2e/paths/edit_fiscal_data.spec.js b/e2e/paths/edit_fiscal_data.spec.js index d88af12b0..7ccc176bb 100644 --- a/e2e/paths/edit_fiscal_data.spec.js +++ b/e2e/paths/edit_fiscal_data.spec.js @@ -5,6 +5,8 @@ import {catchErrors} from '../../services/utils/jasmineHelpers'; const nightmare = createNightmare(); const moduleAccessViewHashURL = '#!/'; +jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000; + describe('Edit fiscalData path', () => { describe('warm up', () => { it('should warm up login and fixtures', done => { diff --git a/e2e/paths/edit_pay_method.spec.js b/e2e/paths/edit_pay_method.spec.js index 8018377cd..816b8e089 100644 --- a/e2e/paths/edit_pay_method.spec.js +++ b/e2e/paths/edit_pay_method.spec.js @@ -5,7 +5,9 @@ import {catchErrors} from '../../services/utils/jasmineHelpers'; const nightmare = createNightmare(); const moduleAccessViewHashURL = '#!/'; -describe('Edit fiscalData path', () => { +jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000; + +describe('Edit pay method path', () => { describe('warm up', () => { it('should warm up login and fixtures', done => { nightmare