From 3bffedf86df8629189081f585d5e5dbe307213a9 Mon Sep 17 00:00:00 2001 From: Carlos Jimenez <=> Date: Thu, 14 Dec 2017 14:56:20 +0100 Subject: [PATCH 1/2] refactor on all e2e paths plus addresses path test for EQtax propagation --- .../client/src/fiscal-data/fiscal-data.html | 2 +- e2e/helpers/selectors.js | 6 +- ....spec.js => 01_create_client_path.spec.js} | 0 ...ata.spec.js => 02_edit_basic_data.spec.js} | 0 ...ta.spec.js => 03_edit_fiscal_data.spec.js} | 194 ++++++++++++------ ...hod.spec.js => 04_edit_pay_method.spec.js} | 0 ...sses.spec.js => 05_edit_addresses.spec.js} | 0 7 files changed, 132 insertions(+), 70 deletions(-) rename e2e/paths/{create_client_path.spec.js => 01_create_client_path.spec.js} (100%) rename e2e/paths/{edit_basic_data.spec.js => 02_edit_basic_data.spec.js} (100%) rename e2e/paths/{edit_fiscal_data.spec.js => 03_edit_fiscal_data.spec.js} (76%) rename e2e/paths/{edit_pay_method.spec.js => 04_edit_pay_method.spec.js} (100%) rename e2e/paths/{edit_addresses.spec.js => 05_edit_addresses.spec.js} (100%) diff --git a/client/client/src/fiscal-data/fiscal-data.html b/client/client/src/fiscal-data/fiscal-data.html index 8f0aea0c2..75bc6d09a 100644 --- a/client/client/src/fiscal-data/fiscal-data.html +++ b/client/client/src/fiscal-data/fiscal-data.html @@ -12,7 +12,7 @@ - + diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index fa1ae9b2a..7e7db8208 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -53,8 +53,8 @@ export default { fiscalDataButton: `${components.vnMenuItem}[ui-sref="clientCard.fiscalData"]`, socialNameInput: `${components.vnTextfield}[name="socialName"]`, fiscalIdInput: `${components.vnTextfield}[name="fi"]`, - equalizationTaxCheckboxLabel: `${components.vnCheck}[label='Equalization tax'] > label`, - cancelPropagationButton: `body > vn-app > vn-vertical > vn-vertical > vn-client-card > vn-horizontal > vn-one > vn-vertical > vn-client-fiscal-data > vn-dialog > div > form > div.button-bar > tpl-buttons > button:nth-child(1)`, + equalizationTaxCheckboxLabel: `${components.vnCheck}[label='Is equalizated'] > label > input`, + acceptPropagationButton: `body > vn-app > vn-vertical > vn-vertical > vn-client-card > vn-horizontal > vn-one > vn-vertical > vn-client-fiscal-data > vn-dialog > div > form > div.button-bar > tpl-buttons > button:nth-child(2)`, addressInput: `${components.vnTextfield}[name="street"]`, cityInput: `${components.vnTextfield}[name="city"]`, postcodeInput: `${components.vnTextfield}[name="postcode"]`, @@ -97,7 +97,9 @@ export default { 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']`, + secondEditButton: `vn-horizontal:nth-child(3) > vn-one > vn-horizontal > a > ${components.vnIconButton}[icon='edit']`, activeCheckboxLabel: `${components.vnCheck}[label='Enabled'] > label > input`, + equalizationTaxCheckboxLabel: `${components.vnCheck}[label='Is equalizated'] > label > input`, saveButton: `${components.vnSubmit}` } }; diff --git a/e2e/paths/create_client_path.spec.js b/e2e/paths/01_create_client_path.spec.js similarity index 100% rename from e2e/paths/create_client_path.spec.js rename to e2e/paths/01_create_client_path.spec.js diff --git a/e2e/paths/edit_basic_data.spec.js b/e2e/paths/02_edit_basic_data.spec.js similarity index 100% rename from e2e/paths/edit_basic_data.spec.js rename to e2e/paths/02_edit_basic_data.spec.js diff --git a/e2e/paths/edit_fiscal_data.spec.js b/e2e/paths/03_edit_fiscal_data.spec.js similarity index 76% rename from e2e/paths/edit_fiscal_data.spec.js rename to e2e/paths/03_edit_fiscal_data.spec.js index 7ccc176bb..6c024f7a7 100644 --- a/e2e/paths/edit_fiscal_data.spec.js +++ b/e2e/paths/03_edit_fiscal_data.spec.js @@ -70,10 +70,55 @@ describe('Edit fiscalData path', () => { .catch(catchErrors(done)); }); - it(`should click on the search result to access to the client's fiscal data`, done => { + describe('Confirm all addresses have EQtax for future propagation test', () => { + it(`should click on the search result to access to the client's addresses`, 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 1st edit icon to check EQtax is checked`, done => { + nightmare + .waitToClick(selectors.addresses.firstEditButton) + .wait(selectors.addresses.equalizationTaxCheckboxLabel) + .wait(200) + .evaluate(selector => { + return document.querySelector(selector).checked; + }, selectors.addresses.equalizationTaxCheckboxLabel) + .then(value => { + expect(value).toBeTruthy(); + done(); + }) + .catch(catchErrors(done)); + }); + + it(`should go back to addresses then select the second one and confirm the EQtax is checked`, done => { + nightmare + .waitToClick(selectors.addresses.addressesButton) + .waitToClick(selectors.addresses.secondEditButton) + .wait(selectors.addresses.equalizationTaxCheckboxLabel) + .wait(200) + .evaluate(selector => { + return document.querySelector(selector).checked; + }, selectors.addresses.equalizationTaxCheckboxLabel) + .then(value => { + expect(value).toBeTruthy(); + done(); + }) + .catch(catchErrors(done)); + }); + }); + + it(`should click on the fiscal data button to start editing`, done => { nightmare - .waitForTextInElement(selectors.clientsIndex.searchResult, 'Bruce Banner') - .waitToClick(selectors.clientsIndex.searchResult) .waitToClick(selectors.fiscalData.fiscalDataButton) .waitForURL('fiscal-data') .url() @@ -157,10 +202,9 @@ describe('Edit fiscalData path', () => { .catch(catchErrors(done)); }); -// there should be a test to confirm propagation on addresses view once equalization tax propagation is shown on each address - it('should not propagate the Equalization tax', done => { + it('should propagate the Equalization tax', done => { nightmare - .waitToClick(selectors.fiscalData.cancelPropagationButton) + .waitToClick(selectors.fiscalData.acceptPropagationButton) .wait(selectors.globalItems.snackbarIsActive) .getInnerText(selectors.globalItems.snackbarIsActive) .then(result => { @@ -187,11 +231,57 @@ describe('Edit fiscalData path', () => { .catch(catchErrors(done)); }); - it('should edit the address', done => { + describe('Confirm all addresses havent got EQtax as uncheck was propagated', () => { + it(`should click on the addresses button to access to the client's addresses`, done => { + nightmare + .waitToClick(selectors.addresses.addressesButton) + .waitForURL('/addresses/list') + .url() + .then(url => { + expect(url).toContain('/addresses/list'); + done(); + }) + .catch(catchErrors(done)); + }); + + it(`should click on the 1st edit icon to check EQtax is unchecked`, done => { + nightmare + .waitToClick(selectors.addresses.firstEditButton) + .wait(selectors.addresses.equalizationTaxCheckboxLabel) + .wait(200) + .evaluate(selector => { + return document.querySelector(selector).checked; + }, selectors.addresses.equalizationTaxCheckboxLabel) + .then(value => { + expect(value).toBeFalsy(); + done(); + }) + .catch(catchErrors(done)); + }); + + it(`should go back to addresses then select the second one and confirm the EQtax is checked`, done => { + nightmare + .waitToClick(selectors.addresses.addressesButton) + .waitToClick(selectors.addresses.secondEditButton) + .wait(selectors.addresses.equalizationTaxCheckboxLabel) + .wait(200) + .evaluate(selector => { + return document.querySelector(selector).checked; + }, selectors.addresses.equalizationTaxCheckboxLabel) + .then(value => { + expect(value).toBeFalsy(); + done(); + }) + .catch(catchErrors(done)); + }); + }); + + it('should go to fiscal data then edit the address', done => { nightmare + .waitToClick(selectors.fiscalData.fiscalDataButton) .wait(selectors.fiscalData.addressInput) .clearInput(selectors.fiscalData.addressInput) - .type(selectors.fiscalData.addressInput, 'Somewhere in New York edited') + .type(selectors.fiscalData.addressInput, 'Somewhere edited') .click(selectors.fiscalData.saveButton) .wait(selectors.globalItems.snackbarIsActive) .getInnerText(selectors.globalItems.snackbarIsActive) @@ -211,7 +301,7 @@ describe('Edit fiscalData path', () => { .wait(selectors.fiscalData.addressInput) .getInputValue(selectors.fiscalData.addressInput) .then(result => { - expect(result).toEqual('Somewhere in New York edited'); + expect(result).toEqual('Somewhere edited'); done(); }) .catch(catchErrors(done)); @@ -307,36 +397,6 @@ describe('Edit fiscalData path', () => { .catch(catchErrors(done)); }); - it(`should edit the country`, done => { - nightmare - .waitToClick(selectors.fiscalData.countryInput) - .waitToClick(selectors.fiscalData.countryThirdOption) - .wait(200) - .waitToClick(selectors.fiscalData.saveButton) - .wait(selectors.globalItems.snackbarIsActive) - .getInnerText(selectors.globalItems.snackbarIsActive) - .then(result => { - expect(result).toEqual('Data saved!'); - done(); - }) - .catch(catchErrors(done)); - }); - - it(`should confirm the country have been selected`, done => { - nightmare - .waitForSnackbarReset() - .click(selectors.basicData.basicDataButton) - .wait(selectors.basicData.nameInput) - .click(selectors.fiscalData.fiscalDataButton) - .wait(200) - .getInputValue(selectors.fiscalData.countryInput) - .then(result => { - expect(result).toEqual('Holanda'); - done(); - }) - .catch(catchErrors(done)); - }); - it('should uncheck the active checkbox', done => { nightmare .waitToClick(selectors.fiscalData.activeCheckboxLabel) @@ -367,35 +427,35 @@ describe('Edit fiscalData path', () => { .catch(catchErrors(done)); }); - it('should check the invoice by address checkbox', done => { - nightmare - .waitToClick(selectors.fiscalData.invoiceByAddressCheckboxInput) - .waitToClick(selectors.fiscalData.saveButton) - .wait(selectors.globalItems.snackbarIsActive) - .getInnerText(selectors.globalItems.snackbarIsActive) - .then(result => { - expect(result).toEqual('Data saved!'); - done(); - }) - .catch(catchErrors(done)); - }); + // it('should check the invoice by address checkbox', done => { + // nightmare + // .waitToClick(selectors.fiscalData.invoiceByAddressCheckboxInput) + // .waitToClick(selectors.fiscalData.saveButton) + // .wait(selectors.globalItems.snackbarIsActive) + // .getInnerText(selectors.globalItems.snackbarIsActive) + // .then(result => { + // expect(result).toEqual('Data saved!'); + // done(); + // }) + // .catch(catchErrors(done)); + // }); - it('should confirm invoice by address checkbox is checked', done => { - nightmare - .waitForSnackbarReset() - .waitToClick(selectors.basicData.basicDataButton) - .wait(selectors.basicData.nameInput) - .waitToClick(selectors.fiscalData.fiscalDataButton) - .wait(selectors.fiscalData.invoiceByAddressCheckboxInput) - .evaluate(selector => { - return document.querySelector(selector).checked; - }, selectors.fiscalData.invoiceByAddressCheckboxInput) - .then(value => { - expect(value).toBeTruthy(); - done(); - }) - .catch(catchErrors(done)); - }); + // it('should confirm invoice by address checkbox is checked', done => { + // nightmare + // .waitForSnackbarReset() + // .waitToClick(selectors.basicData.basicDataButton) + // .wait(selectors.basicData.nameInput) + // .waitToClick(selectors.fiscalData.fiscalDataButton) + // .wait(selectors.fiscalData.invoiceByAddressCheckboxInput) + // .evaluate(selector => { + // return document.querySelector(selector).checked; + // }, selectors.fiscalData.invoiceByAddressCheckboxInput) + // .then(value => { + // expect(value).toBeTruthy(); + // done(); + // }) + // .catch(catchErrors(done)); + // }); it('should check the Verified data checkbox', done => { nightmare diff --git a/e2e/paths/edit_pay_method.spec.js b/e2e/paths/04_edit_pay_method.spec.js similarity index 100% rename from e2e/paths/edit_pay_method.spec.js rename to e2e/paths/04_edit_pay_method.spec.js diff --git a/e2e/paths/edit_addresses.spec.js b/e2e/paths/05_edit_addresses.spec.js similarity index 100% rename from e2e/paths/edit_addresses.spec.js rename to e2e/paths/05_edit_addresses.spec.js From 4eda3363936f3a38a9750168276ea7a5df30c32e Mon Sep 17 00:00:00 2001 From: Carlos Jimenez <=> Date: Thu, 14 Dec 2017 14:57:11 +0100 Subject: [PATCH 2/2] e2e repairs as the main HTML structure has been updated --- e2e/helpers/selectors.js | 10 ++--- e2e/paths/03_edit_fiscal_data.spec.js | 56 +++++++++++++-------------- e2e/paths/05_edit_addresses.spec.js | 2 +- 3 files changed, 34 insertions(+), 34 deletions(-) diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index 7e7db8208..0417d1d1e 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -54,7 +54,7 @@ export default { socialNameInput: `${components.vnTextfield}[name="socialName"]`, fiscalIdInput: `${components.vnTextfield}[name="fi"]`, equalizationTaxCheckboxLabel: `${components.vnCheck}[label='Is equalizated'] > label > input`, - acceptPropagationButton: `body > vn-app > vn-vertical > vn-vertical > vn-client-card > vn-horizontal > vn-one > vn-vertical > vn-client-fiscal-data > vn-dialog > div > form > div.button-bar > tpl-buttons > button:nth-child(2)`, + acceptPropagationButton: `body > vn-app > vn-vertical > vn-vertical > vn-client-card > vn-main-block > vn-horizontal > vn-one > vn-vertical > vn-client-fiscal-data > vn-dialog > div > form > div.button-bar > tpl-buttons > button:nth-child(2)`, addressInput: `${components.vnTextfield}[name="street"]`, cityInput: `${components.vnTextfield}[name="city"]`, postcodeInput: `${components.vnTextfield}[name="postcode"]`, @@ -77,7 +77,7 @@ export default { 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)', + cancelNotificationButton: 'body > vn-app > vn-vertical > vn-vertical > vn-client-card > vn-main-block > 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: { @@ -94,11 +94,11 @@ export default { 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', + defaultAddress: 'body > vn-app > vn-vertical > vn-vertical > vn-client-card > vn-main-block > 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-main-block > 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']`, secondEditButton: `vn-horizontal:nth-child(3) > vn-one > vn-horizontal > a > ${components.vnIconButton}[icon='edit']`, - activeCheckboxLabel: `${components.vnCheck}[label='Enabled'] > label > input`, + activeCheckbox: `${components.vnCheck}[label='Enabled'] > label > input`, equalizationTaxCheckboxLabel: `${components.vnCheck}[label='Is equalizated'] > label > input`, saveButton: `${components.vnSubmit}` } diff --git a/e2e/paths/03_edit_fiscal_data.spec.js b/e2e/paths/03_edit_fiscal_data.spec.js index 6c024f7a7..b5c2bcf5c 100644 --- a/e2e/paths/03_edit_fiscal_data.spec.js +++ b/e2e/paths/03_edit_fiscal_data.spec.js @@ -427,35 +427,35 @@ describe('Edit fiscalData path', () => { .catch(catchErrors(done)); }); - // it('should check the invoice by address checkbox', done => { - // nightmare - // .waitToClick(selectors.fiscalData.invoiceByAddressCheckboxInput) - // .waitToClick(selectors.fiscalData.saveButton) - // .wait(selectors.globalItems.snackbarIsActive) - // .getInnerText(selectors.globalItems.snackbarIsActive) - // .then(result => { - // expect(result).toEqual('Data saved!'); - // done(); - // }) - // .catch(catchErrors(done)); - // }); + it('should check the invoice by address checkbox', done => { + nightmare + .waitToClick(selectors.fiscalData.invoiceByAddressCheckboxInput) + .waitToClick(selectors.fiscalData.saveButton) + .wait(selectors.globalItems.snackbarIsActive) + .getInnerText(selectors.globalItems.snackbarIsActive) + .then(result => { + expect(result).toEqual('Data saved!'); + done(); + }) + .catch(catchErrors(done)); + }); - // it('should confirm invoice by address checkbox is checked', done => { - // nightmare - // .waitForSnackbarReset() - // .waitToClick(selectors.basicData.basicDataButton) - // .wait(selectors.basicData.nameInput) - // .waitToClick(selectors.fiscalData.fiscalDataButton) - // .wait(selectors.fiscalData.invoiceByAddressCheckboxInput) - // .evaluate(selector => { - // return document.querySelector(selector).checked; - // }, selectors.fiscalData.invoiceByAddressCheckboxInput) - // .then(value => { - // expect(value).toBeTruthy(); - // done(); - // }) - // .catch(catchErrors(done)); - // }); + it('should confirm invoice by address checkbox is checked', done => { + nightmare + .waitForSnackbarReset() + .waitToClick(selectors.basicData.basicDataButton) + .wait(selectors.basicData.nameInput) + .waitToClick(selectors.fiscalData.fiscalDataButton) + .wait(selectors.fiscalData.invoiceByAddressCheckboxInput) + .evaluate(selector => { + return document.querySelector(selector).checked; + }, selectors.fiscalData.invoiceByAddressCheckboxInput) + .then(value => { + expect(value).toBeTruthy(); + done(); + }) + .catch(catchErrors(done)); + }); it('should check the Verified data checkbox', done => { nightmare diff --git a/e2e/paths/05_edit_addresses.spec.js b/e2e/paths/05_edit_addresses.spec.js index 691c3a3f7..525333e91 100644 --- a/e2e/paths/05_edit_addresses.spec.js +++ b/e2e/paths/05_edit_addresses.spec.js @@ -288,7 +288,7 @@ describe('Edit addresses path', () => { it(`should click on the active checkbox and receive an error to save it becouse it is the default address`, done => { nightmare .waitForSnackbarReset() - .waitToClick(selectors.addresses.activeCheckboxLabel) + .waitToClick(selectors.addresses.activeCheckbox) .waitToClick(selectors.addresses.saveButton) .wait(selectors.globalItems.snackbarIsActive) .getInnerText(selectors.globalItems.snackbarIsActive)