import selectors from '../../helpers/selectors.js'; import createNightmare from '../../helpers/helpers'; describe('Client', () => { describe('Edit fiscalData path', () => { const nightmare = createNightmare(); beforeAll(() => { return nightmare .waitForLogin('developer'); }); it('should click on the Clients button of the top bar menu', () => { 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'); }); }); it('should search for the user Bruce Banner', () => { return 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); }); }); describe('Confirm 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') .waitToClick(selectors.clientsIndex.searchResult) .waitToClick(selectors.clientAddresses.addressesButton) .waitForURL('/address/index') .url() .then(url => { expect(url).toContain('/address/index'); }); }); it(`should click on the 1st edit icon to check EQtax is checked`, () => { return nightmare .waitToClick(selectors.clientAddresses.firstEditButton) .wait(selectors.clientAddresses.equalizationTaxCheckboxLabel) .evaluate(selector => { return document.querySelector(selector).checked; }, selectors.clientAddresses.equalizationTaxCheckboxLabel) .then(value => { expect(value).toBeFalsy(); }); }); it(`should go back to addresses then select the second one and confirm the EQtax is checked`, () => { return nightmare .waitToClick(selectors.clientAddresses.addressesButton) .waitToClick(selectors.clientAddresses.secondEditButton) .wait(selectors.clientAddresses.equalizationTaxCheckboxLabel) .evaluate(selector => { return document.querySelector(selector).checked; }, selectors.clientAddresses.equalizationTaxCheckboxLabel) .then(value => { expect(value).toBeFalsy(); }); }); }); it(`should click on the fiscal data button to start editing`, () => { return nightmare .waitToClick(selectors.clientFiscalData.fiscalDataButton) .waitForURL('fiscal-data') .url() .then(url => { expect(url).toContain('fiscal-data'); }); }); it('should edit the clients fiscal data', () => { return nightmare .wait(selectors.clientFiscalData.socialNameInput) .clearInput(selectors.clientFiscalData.socialNameInput) .type(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') .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) .click(selectors.clientFiscalData.saveButton) .waitForSnackbar() .then(result => { expect(result).toEqual(jasmine.arrayContaining(['Data saved!'])); }); }); it('should propagate the Equalization tax', () => { return nightmare .waitToClick(selectors.clientFiscalData.acceptPropagationButton) .waitForSnackbar() .then(result => { expect(result).toEqual(jasmine.arrayContaining(['Equivalent tax spreaded'])); }); }); describe('confirm all addresses have now EQtax checked', () => { 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 confirm EQtax is checked`, () => { return nightmare .waitToClick(selectors.clientAddresses.firstEditButton) .wait(selectors.clientAddresses.equalizationTaxCheckboxLabel) .evaluate(selector => { return document.querySelector(selector).checked; }, selectors.clientAddresses.equalizationTaxCheckboxLabel) .then(value => { expect(value).toBeTruthy(); }); }); it(`should go back to addresses then select the second one and confirm the EQtax is checked`, () => { return nightmare .waitToClick(selectors.clientAddresses.addressesButton) .waitToClick(selectors.clientAddresses.secondEditButton) .wait(selectors.clientAddresses.equalizationTaxCheckboxLabel) .evaluate(selector => { return document.querySelector(selector).checked; }, selectors.clientAddresses.equalizationTaxCheckboxLabel) .then(value => { expect(value).toBeTruthy(); }); }); }); it('should navigate back to fiscal data to confirm it have been edited', () => { return nightmare .waitToClick(selectors.clientFiscalData.fiscalDataButton) .wait(selectors.clientFiscalData.socialNameInput) .getInputValue(selectors.clientFiscalData.socialNameInput) .then(result => { expect(result).toEqual('SMASH!'); }); }); it('should confirm the fiscal id have been edited', () => { return nightmare .getInputValue(selectors.clientFiscalData.fiscalIdInput) .then(result => { expect(result).toEqual('94980061C'); }); }); 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) .then(result => { expect(result).toEqual('Somewhere edited'); }); }); it('should confirm the city have been edited', () => { return nightmare .getInputValue(selectors.clientFiscalData.cityInput) .then(result => { expect(result).toEqual('N/A'); }); }); it('should confirm the postcode have been edited', () => { return nightmare .getInputValue(selectors.clientFiscalData.postcodeInput) .then(result => { expect(result).toEqual('12345'); }); }); it(`should confirm the province have been selected`, () => { return nightmare .getInputValue(selectors.clientFiscalData.provinceInput) .then(result => { expect(result).toEqual('Province two'); }); }); it('should confirm active checkbox is unchecked', () => { return nightmare .evaluate(selector => { return document.querySelector(selector).checked; }, selectors.clientFiscalData.activeCheckboxLabel) .then(value => { expect(value).toBeFalsy(); }); }); it('should confirm frozen checkbox is unchecked', () => { return nightmare .evaluate(selector => { return document.querySelector(selector).checked; }, selectors.clientFiscalData.frozenCheckboxLabel) .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 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 => { return document.querySelector(selector).checked; }, selectors.clientFiscalData.hasToInvoiceCheckboxLabel) .then(value => { expect(value).toBeFalsy(); }); }); 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 => { return document.querySelector(selector).checked; }, selectors.clientFiscalData.viesCheckboxInput) .then(value => { expect(value).toBeTruthy(); }); }); }); });