salix/e2e/paths/client-module/03_edit_fiscal_data.spec.js

567 lines
21 KiB
JavaScript
Raw Normal View History

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 fiscalData path', () => {
it('should log in', done => {
nightmare
.login()
.waitForURL(moduleAccessViewHashURL)
.url()
.then(url => {
2017-11-08 14:43:34 +00:00
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 => {
2017-11-08 14:43:34 +00:00
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 => {
2017-11-08 14:43:34 +00:00
expect(result).toEqual(1);
done();
})
.catch(catchErrors(done));
});
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`, done => {
nightmare
.waitForTextInElement(selectors.clientsIndex.searchResult, 'Bruce Banner')
.waitToClick(selectors.clientsIndex.searchResult)
.waitToClick(selectors.clientAddresses.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.clientAddresses.firstEditButton)
.wait(selectors.clientAddresses.equalizationTaxCheckboxLabel)
.wait(200)
.evaluate(selector => {
return document.querySelector(selector).checked;
}, selectors.clientAddresses.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.clientAddresses.addressesButton)
.waitToClick(selectors.clientAddresses.secondEditButton)
.wait(selectors.clientAddresses.equalizationTaxCheckboxLabel)
.wait(200)
.evaluate(selector => {
return document.querySelector(selector).checked;
}, selectors.clientAddresses.equalizationTaxCheckboxLabel)
.then(value => {
expect(value).toBeFalsy();
done();
})
.catch(catchErrors(done));
});
});
it(`should click on the fiscal data button to start editing`, done => {
nightmare
.waitToClick(selectors.clientFiscalData.fiscalDataButton)
.waitForURL('fiscal-data')
.url()
.then(url => {
expect(url).toContain('fiscal-data');
done();
})
.catch(catchErrors(done));
});
it('should edit the social name', done => {
nightmare
.wait(selectors.clientFiscalData.socialNameInput)
.clearInput(selectors.clientFiscalData.socialNameInput)
.type(selectors.clientFiscalData.socialNameInput, 'Hulk edited')
.click(selectors.clientFiscalData.saveButton)
.wait(selectors.globalItems.snackbarIsActive)
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => {
expect(result).toEqual('Data saved!');
done();
})
.catch(catchErrors(done));
});
it('should confirm the social name have been edited', done => {
nightmare
.waitForSnackbarReset()
.waitToClick(selectors.clientBasicData.basicDataButton)
.wait(selectors.clientBasicData.nameInput)
.waitToClick(selectors.clientFiscalData.fiscalDataButton)
.wait(selectors.clientFiscalData.socialNameInput)
.getInputValue(selectors.clientFiscalData.socialNameInput)
.then(result => {
expect(result).toEqual('Hulk edited');
done();
})
.catch(catchErrors(done));
});
it('should edit the fiscal id', done => {
nightmare
.wait(selectors.clientFiscalData.fiscalIdInput)
.clearInput(selectors.clientFiscalData.fiscalIdInput)
.type(selectors.clientFiscalData.fiscalIdInput, '94980061C')
.click(selectors.clientFiscalData.saveButton)
.wait(selectors.globalItems.snackbarIsActive)
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => {
expect(result).toEqual('Data saved!');
done();
})
.catch(catchErrors(done));
});
it('should confirm the fiscal id have been edited', done => {
nightmare
.waitForSnackbarReset()
.waitToClick(selectors.clientBasicData.basicDataButton)
.wait(selectors.clientBasicData.nameInput)
.waitToClick(selectors.clientFiscalData.fiscalDataButton)
.wait(selectors.clientFiscalData.fiscalIdInput)
.getInputValue(selectors.clientFiscalData.fiscalIdInput)
.then(result => {
expect(result).toEqual('94980061C');
done();
})
.catch(catchErrors(done));
});
it('should check the Equalization tax checkbox', done => {
nightmare
.waitToClick(selectors.clientFiscalData.equalizationTaxCheckboxLabel)
.waitToClick(selectors.clientFiscalData.saveButton)
.wait(selectors.globalItems.snackbarIsActive)
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => {
expect(result).toEqual('Data saved!');
done();
})
.catch(catchErrors(done));
});
it('should propagate the Equalization tax', done => {
2017-11-08 14:43:34 +00:00
nightmare
.waitToClick(selectors.clientFiscalData.acceptPropagationButton)
2017-11-08 14:43:34 +00:00
.wait(selectors.globalItems.snackbarIsActive)
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => {
expect(result).toEqual('Data saved!');
2017-11-08 14:43:34 +00:00
done();
})
.catch(catchErrors(done));
});
it('should confirm Equalization tax checkbox is checked', done => {
2017-11-08 14:43:34 +00:00
nightmare
.waitForSnackbarReset()
.waitToClick(selectors.clientBasicData.basicDataButton)
.wait(selectors.clientBasicData.nameInput)
.waitToClick(selectors.clientFiscalData.fiscalDataButton)
.wait(selectors.clientFiscalData.equalizationTaxCheckboxLabel)
.evaluate(selector => {
return document.querySelector(selector).checked;
}, selectors.clientFiscalData.equalizationTaxCheckboxLabel)
.then(value => {
expect(value).toBeTruthy();
done();
})
.catch(catchErrors(done));
});
describe('Confirm all addresses have now EQtax checked', () => {
it(`should click on the addresses button to access to the client's addresses`, done => {
nightmare
.waitToClick(selectors.clientAddresses.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 confirm EQtax is checked`, done => {
nightmare
.waitToClick(selectors.clientAddresses.firstEditButton)
.wait(selectors.clientAddresses.equalizationTaxCheckboxLabel)
.wait(200)
.evaluate(selector => {
return document.querySelector(selector).checked;
}, selectors.clientAddresses.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.clientAddresses.addressesButton)
.waitToClick(selectors.clientAddresses.secondEditButton)
.wait(selectors.clientAddresses.equalizationTaxCheckboxLabel)
.wait(200)
.evaluate(selector => {
return document.querySelector(selector).checked;
}, selectors.clientAddresses.equalizationTaxCheckboxLabel)
.then(value => {
expect(value).toBeTruthy();
done();
})
.catch(catchErrors(done));
});
});
it('should go to fiscal data then edit the address', done => {
nightmare
.waitToClick(selectors.clientFiscalData.fiscalDataButton)
.wait(selectors.clientFiscalData.addressInput)
.clearInput(selectors.clientFiscalData.addressInput)
.type(selectors.clientFiscalData.addressInput, 'Somewhere edited')
.click(selectors.clientFiscalData.saveButton)
.wait(selectors.globalItems.snackbarIsActive)
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => {
expect(result).toEqual('Data saved!');
done();
})
.catch(catchErrors(done));
});
it('should confirm the address have been edited', done => {
nightmare
.waitForSnackbarReset()
.click(selectors.clientBasicData.basicDataButton)
.wait(selectors.clientBasicData.nameInput)
.click(selectors.clientFiscalData.fiscalDataButton)
.wait(selectors.clientFiscalData.addressInput)
.getInputValue(selectors.clientFiscalData.addressInput)
.then(result => {
expect(result).toEqual('Somewhere edited');
done();
})
.catch(catchErrors(done));
});
it('should edit the city', done => {
nightmare
.wait(selectors.clientFiscalData.cityInput)
.clearInput(selectors.clientFiscalData.cityInput)
.type(selectors.clientFiscalData.cityInput, 'N/A')
.click(selectors.clientFiscalData.saveButton)
.wait(selectors.globalItems.snackbarIsActive)
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => {
expect(result).toEqual('Data saved!');
done();
})
.catch(catchErrors(done));
});
it('should confirm the city have been edited', done => {
nightmare
.waitForSnackbarReset()
.click(selectors.clientBasicData.basicDataButton)
.wait(selectors.clientBasicData.nameInput)
.click(selectors.clientFiscalData.fiscalDataButton)
.wait(selectors.clientFiscalData.cityInput)
.getInputValue(selectors.clientFiscalData.cityInput)
.then(result => {
expect(result).toEqual('N/A');
done();
})
.catch(catchErrors(done));
});
it('should edit the postcode', done => {
nightmare
.wait(selectors.clientFiscalData.postcodeInput)
.clearInput(selectors.clientFiscalData.postcodeInput)
.type(selectors.clientFiscalData.postcodeInput, '12345')
.click(selectors.clientFiscalData.saveButton)
.wait(selectors.globalItems.snackbarIsActive)
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => {
expect(result).toEqual('Data saved!');
done();
})
.catch(catchErrors(done));
});
it('should confirm the postcode have been edited', done => {
nightmare
.waitForSnackbarReset()
.click(selectors.clientBasicData.basicDataButton)
.wait(selectors.clientBasicData.nameInput)
.click(selectors.clientFiscalData.fiscalDataButton)
.wait(selectors.clientFiscalData.postcodeInput)
.getInputValue(selectors.clientFiscalData.postcodeInput)
.then(result => {
expect(result).toEqual('12345');
done();
})
.catch(catchErrors(done));
});
2017-11-09 13:47:09 +00:00
it(`should edit the province`, done => {
nightmare
.waitToClick(selectors.clientFiscalData.provinceInput)
.waitToClick(selectors.clientFiscalData.provinceFifthOption)
.wait(200)
.waitToClick(selectors.clientFiscalData.saveButton)
2017-11-09 13:47:09 +00:00
.wait(selectors.globalItems.snackbarIsActive)
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => {
expect(result).toEqual('Data saved!');
2017-11-09 13:47:09 +00:00
done();
})
.catch(catchErrors(done));
});
it(`should confirm the province have been selected`, done => {
nightmare
.waitForSnackbarReset()
.click(selectors.clientBasicData.basicDataButton)
.wait(selectors.clientBasicData.nameInput)
.click(selectors.clientFiscalData.fiscalDataButton)
.wait(200)
.getInputValue(selectors.clientFiscalData.provinceInput)
2017-11-09 13:47:09 +00:00
.then(result => {
expect(result).toEqual('Province two');
done();
})
.catch(catchErrors(done));
});
it('should uncheck the active checkbox', done => {
nightmare
.waitToClick(selectors.clientFiscalData.activeCheckboxLabel)
.waitToClick(selectors.clientFiscalData.saveButton)
.wait(selectors.globalItems.snackbarIsActive)
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => {
expect(result).toEqual('Data saved!');
done();
})
.catch(catchErrors(done));
});
it('should confirm active checkbox is unchecked', done => {
nightmare
.waitForSnackbarReset()
.waitToClick(selectors.clientBasicData.basicDataButton)
.wait(selectors.clientBasicData.nameInput)
.waitToClick(selectors.clientFiscalData.fiscalDataButton)
.wait(selectors.clientFiscalData.activeCheckboxLabel)
.evaluate(selector => {
return document.querySelector(selector).checked;
}, selectors.clientFiscalData.activeCheckboxLabel)
.then(value => {
expect(value).toBeFalsy();
done();
})
.catch(catchErrors(done));
});
it('should uncheck the invoice by address checkbox', done => {
nightmare
.waitToClick(selectors.clientFiscalData.invoiceByAddressCheckboxInput)
.waitToClick(selectors.clientFiscalData.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 unchecked', done => {
nightmare
.waitForSnackbarReset()
.waitToClick(selectors.clientBasicData.basicDataButton)
.wait(selectors.clientBasicData.nameInput)
.waitToClick(selectors.clientFiscalData.fiscalDataButton)
.wait(selectors.clientFiscalData.invoiceByAddressCheckboxInput)
.evaluate(selector => {
return document.querySelector(selector).checked;
}, selectors.clientFiscalData.invoiceByAddressCheckboxInput)
.then(value => {
expect(value).toBeFalsy();
done();
})
.catch(catchErrors(done));
});
it('should check the Verified data checkbox', done => {
nightmare
.waitToClick(selectors.clientFiscalData.verifiedDataCheckboxInput)
.waitToClick(selectors.clientFiscalData.saveButton)
.wait(selectors.globalItems.snackbarIsActive)
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => {
expect(result).toEqual('Data saved!');
done();
})
.catch(catchErrors(done));
});
it('should confirm Verified data checkbox is unchecked', done => {
nightmare
.waitForSnackbarReset()
.waitToClick(selectors.clientBasicData.basicDataButton)
.wait(selectors.clientBasicData.nameInput)
.waitToClick(selectors.clientFiscalData.fiscalDataButton)
.wait(selectors.clientFiscalData.verifiedDataCheckboxInput)
.evaluate(selector => {
return document.querySelector(selector).checked;
}, selectors.clientFiscalData.verifiedDataCheckboxInput)
.then(value => {
expect(value).toBeFalsy();
done();
})
.catch(catchErrors(done));
});
it('should uncheck the Has to invoice checkbox', done => {
nightmare
.waitToClick(selectors.clientFiscalData.hasToInvoiceCheckboxLabel)
.waitToClick(selectors.clientFiscalData.saveButton)
.wait(selectors.globalItems.snackbarIsActive)
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => {
expect(result).toEqual('Data saved!');
done();
})
.catch(catchErrors(done));
});
it('should confirm Has to invoice checkbox is unchecked', done => {
nightmare
.waitForSnackbarReset()
.waitToClick(selectors.clientBasicData.basicDataButton)
.wait(selectors.clientBasicData.nameInput)
.waitToClick(selectors.clientFiscalData.fiscalDataButton)
.wait(selectors.clientFiscalData.hasToInvoiceCheckboxLabel)
.evaluate(selector => {
return document.querySelector(selector).checked;
}, selectors.clientFiscalData.hasToInvoiceCheckboxLabel)
.then(value => {
expect(value).toBeFalsy();
done();
})
.catch(catchErrors(done));
});
it('should uncheck the Invoice by mail checkbox', done => {
nightmare
.waitToClick(selectors.clientFiscalData.invoiceByMailCheckboxLabel)
.waitToClick(selectors.clientFiscalData.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 mail checkbox is unchecked', done => {
nightmare
.waitForSnackbarReset()
.waitToClick(selectors.clientBasicData.basicDataButton)
.wait(selectors.clientBasicData.nameInput)
.waitToClick(selectors.clientFiscalData.fiscalDataButton)
.wait(selectors.clientFiscalData.invoiceByMailCheckboxLabel)
.evaluate(selector => {
return document.querySelector(selector).checked;
}, selectors.clientFiscalData.invoiceByMailCheckboxLabel)
.then(value => {
expect(value).toBeFalsy();
done();
})
.catch(catchErrors(done));
});
it('should check the Vies checkbox', done => {
nightmare
.waitToClick(selectors.clientFiscalData.viesCheckboxInput)
.waitToClick(selectors.clientFiscalData.saveButton)
.wait(selectors.globalItems.snackbarIsActive)
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => {
expect(result).toEqual('Data saved!');
done();
})
.catch(catchErrors(done));
});
it('should confirm Vies checkbox is checked', done => {
nightmare
.waitForSnackbarReset()
.waitToClick(selectors.clientBasicData.basicDataButton)
.wait(selectors.clientBasicData.nameInput)
.waitToClick(selectors.clientFiscalData.fiscalDataButton)
.wait(selectors.clientFiscalData.viesCheckboxInput)
.evaluate(selector => {
return document.querySelector(selector).checked;
}, selectors.clientFiscalData.viesCheckboxInput)
.then(value => {
expect(value).toBeTruthy();
done();
})
.catch(catchErrors(done));
});
});