diff --git a/e2e/paths/client-module/03_edit_fiscal_data.spec.js b/e2e/paths/client-module/03_edit_fiscal_data.spec.js index ad57f39ae..59fd99883 100644 --- a/e2e/paths/client-module/03_edit_fiscal_data.spec.js +++ b/e2e/paths/client-module/03_edit_fiscal_data.spec.js @@ -34,7 +34,7 @@ describe('Client', () => { }); }); - describe('Confirm all addresses have EQtax false for future propagation test', () => { + describe('Confirms all addresses have EQtax false for future propagation test', () => { it(`should click on the search result to access to the client's addresses`, () => { return nightmare .waitForTextInElement(selectors.clientsIndex.searchResult, 'Bruce Banner') @@ -47,7 +47,7 @@ describe('Client', () => { }); }); - it(`should click on the 1st edit icon to check EQtax is checked`, () => { + it(`should click on the 1st edit icon to check EQtax isnt checked`, () => { return nightmare .waitToClick(selectors.clientAddresses.firstEditButton) .wait(selectors.clientAddresses.equalizationTaxCheckboxLabel) @@ -59,7 +59,7 @@ describe('Client', () => { }); }); - it(`should go back to addresses then select the second one and confirm the EQtax is checked`, () => { + it(`should go back to addresses then select the second one and confirm the EQtax isnt checked`, () => { return nightmare .waitToClick(selectors.clientAddresses.addressesButton) .waitToClick(selectors.clientAddresses.secondEditButton) @@ -91,22 +91,24 @@ describe('Client', () => { .waitForTextInInput(selectors.clientFiscalData.socialNameInput, 'SMASH!') .clearInput(selectors.clientFiscalData.fiscalIdInput) .type(selectors.clientFiscalData.fiscalIdInput, '94980061C') - .waitToClick(selectors.clientFiscalData.equalizationTaxCheckboxLabel) .clearInput(selectors.clientFiscalData.addressInput) .type(selectors.clientFiscalData.addressInput, 'Somewhere edited') - .clearInput(selectors.clientFiscalData.cityInput) - .type(selectors.clientFiscalData.cityInput, 'N/A') .clearInput(selectors.clientFiscalData.postcodeInput) .type(selectors.clientFiscalData.postcodeInput, '12345') + .clearInput(selectors.clientFiscalData.cityInput) + .type(selectors.clientFiscalData.cityInput, 'N/A') + .waitToClick(selectors.clientFiscalData.countryInput) + .waitToClick(selectors.clientFiscalData.countryThirdOption) .waitToClick(selectors.clientFiscalData.provinceInput) .waitToClick(selectors.clientFiscalData.provinceFifthOption) .waitToClick(selectors.clientFiscalData.activeCheckboxLabel) .waitToClick(selectors.clientFiscalData.frozenCheckboxLabel) - .waitToClick(selectors.clientFiscalData.invoiceByAddressCheckboxInput) - .waitToClick(selectors.clientFiscalData.verifiedDataCheckboxInput) .waitToClick(selectors.clientFiscalData.hasToInvoiceCheckboxLabel) - .waitToClick(selectors.clientFiscalData.invoiceByMailCheckboxLabel) .waitToClick(selectors.clientFiscalData.viesCheckboxInput) + .waitToClick(selectors.clientFiscalData.invoiceByMailCheckboxLabel) + .waitToClick(selectors.clientFiscalData.invoiceByAddressCheckboxInput) + .waitToClick(selectors.clientFiscalData.equalizationTaxCheckboxLabel) + .waitToClick(selectors.clientFiscalData.verifiedDataCheckboxInput) .click(selectors.clientFiscalData.saveButton) .waitForSnackbar() .then(result => { @@ -160,7 +162,7 @@ describe('Client', () => { }); }); - it('should navigate back to fiscal data to confirm it have been edited', () => { + it('should navigate back to fiscal data to confirm its name have been edited', () => { return nightmare .waitToClick(selectors.clientFiscalData.fiscalDataButton) .wait(selectors.clientFiscalData.socialNameInput) @@ -178,16 +180,6 @@ describe('Client', () => { }); }); - it('should confirm Equalization tax checkbox is checked', () => { - return nightmare - .evaluate(selector => { - return document.querySelector(selector).checked; - }, selectors.clientFiscalData.equalizationTaxCheckboxLabel) - .then(value => { - expect(value).toBeTruthy(); - }); - }); - it('should confirm the address have been edited', () => { return nightmare .getInputValue(selectors.clientFiscalData.addressInput) @@ -196,6 +188,14 @@ describe('Client', () => { }); }); + it('should confirm the postcode have been edited', () => { + return nightmare + .getInputValue(selectors.clientFiscalData.postcodeInput) + .then(result => { + expect(result).toEqual('12345'); + }); + }); + it('should confirm the city have been edited', () => { return nightmare .getInputValue(selectors.clientFiscalData.cityInput) @@ -204,11 +204,11 @@ describe('Client', () => { }); }); - it('should confirm the postcode have been edited', () => { + it(`should confirm the country have been selected`, () => { return nightmare - .getInputValue(selectors.clientFiscalData.postcodeInput) + .getInputValue(selectors.clientFiscalData.countryInput) .then(result => { - expect(result).toEqual('12345'); + expect(result).toEqual('Francia'); }); }); @@ -240,26 +240,6 @@ describe('Client', () => { }); }); - it('should confirm invoice by address checkbox is unchecked', () => { - return nightmare - .evaluate(selector => { - return document.querySelector(selector).checked; - }, selectors.clientFiscalData.invoiceByAddressCheckboxInput) - .then(value => { - expect(value).toBeFalsy(); - }); - }); - - it('should confirm Verified data checkbox is checked', () => { - return nightmare - .evaluate(selector => { - return document.querySelector(selector).checked; - }, selectors.clientFiscalData.verifiedDataCheckboxInput) - .then(value => { - expect(value).toBeTruthy(); - }); - }); - it('should confirm Has to invoice checkbox is unchecked', () => { return nightmare .evaluate(selector => { @@ -270,16 +250,6 @@ describe('Client', () => { }); }); - it('should confirm Invoice by mail checkbox is unchecked', () => { - return nightmare - .evaluate(selector => { - return document.querySelector(selector).checked; - }, selectors.clientFiscalData.invoiceByMailCheckboxLabel) - .then(value => { - expect(value).toBeFalsy(); - }); - }); - it('should confirm Vies checkbox is checked', () => { return nightmare .evaluate(selector => { @@ -289,5 +259,80 @@ describe('Client', () => { expect(value).toBeTruthy(); }); }); + + it('should confirm Invoice by mail checkbox is unchecked', () => { + return nightmare + .evaluate(selector => { + return document.querySelector(selector).checked; + }, selectors.clientFiscalData.invoiceByMailCheckboxLabel) + .then(value => { + expect(value).toBeFalsy(); + }); + }); + + it('should confirm invoice by address checkbox is unchecked', () => { + return nightmare + .evaluate(selector => { + return document.querySelector(selector).checked; + }, selectors.clientFiscalData.invoiceByAddressCheckboxInput) + .then(value => { + expect(value).toBeFalsy(); + }); + }); + + it('should confirm Equalization tax checkbox is checked', () => { + return nightmare + .evaluate(selector => { + return document.querySelector(selector).checked; + }, selectors.clientFiscalData.equalizationTaxCheckboxLabel) + .then(value => { + expect(value).toBeTruthy(); + }); + }); + + it('should confirm Verified data checkbox is checked', () => { + return nightmare + .evaluate(selector => { + return document.querySelector(selector).checked; + }, selectors.clientFiscalData.verifiedDataCheckboxInput) + .then(value => { + expect(value).toBeTruthy(); + }); + }); + + describe('confirm invoice by address checkbox gets checked if the EQtax differs between addresses', () => { + it(`should click on the addresses button to access to the client's addresses`, () => { + return nightmare + .waitToClick(selectors.clientAddresses.addressesButton) + .waitForURL('/address/index') + .url() + .then(url => { + expect(url).toContain('/address/index'); + }); + }); + + it(`should click on the 1st edit icon to access the address details and uncheck EQtax checkbox`, () => { + return nightmare + .waitToClick(selectors.clientAddresses.firstEditButton) + .waitToClick(selectors.clientAddresses.equalizationTaxCheckboxLabel) + .click(selectors.clientAddresses.saveButton) + .waitForSnackbar() + .then(result => { + expect(result).toEqual(jasmine.arrayContaining(['Data saved!'])); + }); + }); + + it('should navigate back to fiscal data to confirm invoice by address is now checked', () => { + return nightmare + .waitToClick(selectors.clientFiscalData.fiscalDataButton) + .wait(selectors.clientFiscalData.invoiceByAddressCheckboxInput) + .evaluate(selector => { + return document.querySelector(selector).checked; + }, selectors.clientFiscalData.invoiceByAddressCheckboxInput) + .then(value => { + expect(value).toBeTruthy(); + }); + }); + }); }); });