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

334 lines
15 KiB
JavaScript
Raw Normal View History

import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare';
2018-09-05 06:27:50 +00:00
describe('Client Edit fiscalData path', () => {
const nightmare = createNightmare();
describe('as employee', () => {
beforeAll(() => {
2018-11-20 13:21:24 +00:00
nightmare
.loginAndModule('employee', 'client')
.accessToSearchResult('Bruce Banner')
.accessToSection('client.card.address.index');
2018-09-05 06:27:50 +00:00
});
// Confirms all addresses have EQtax false for future propagation test step 1
2019-01-07 08:33:07 +00:00
it(`should click on the 1st edit icon to check EQtax isnt checked`, async() => {
2018-11-02 12:36:20 +00:00
const result = await nightmare
.waitToClick(selectors.clientAddresses.firstEditButton)
.wait(selectors.clientAddresses.equalizationTaxCheckboxLabel)
.evaluate(selector => {
return document.querySelector(selector).checked;
}, selectors.clientAddresses.equalizationTaxCheckboxLabel);
expect(result).toBeFalsy();
});
// Confirms all addresses have EQtax false for future propagation test step 2
2019-01-07 08:33:07 +00:00
it(`should go back to addresses then select the second one and confirm the EQtax isnt checked`, async() => {
2018-11-02 12:36:20 +00:00
const result = await nightmare
.waitToClick(selectors.clientAddresses.addressesButton)
.waitToClick(selectors.clientAddresses.secondEditButton)
.wait(selectors.clientAddresses.equalizationTaxCheckboxLabel)
.evaluate(selector => {
return document.querySelector(selector).checked;
}, selectors.clientAddresses.equalizationTaxCheckboxLabel);
2018-11-02 12:36:20 +00:00
expect(result).toBeFalsy();
});
2018-09-05 06:27:50 +00:00
2019-01-07 08:33:07 +00:00
it(`should click on the fiscal data button`, async() => {
2018-11-02 12:36:20 +00:00
const url = await nightmare
.waitToClick(selectors.clientFiscalData.fiscalDataButton)
.waitForURL('fiscal-data')
.parsedUrl();
2018-11-02 12:36:20 +00:00
expect(url.hash).toContain('fiscal-data');
});
2019-01-07 08:33:07 +00:00
it('should not be able to edit the verified data checkbox', async() => {
2018-11-02 12:36:20 +00:00
const result = await nightmare
.evaluate(selector => {
return document.querySelector(selector).disabled;
}, selectors.clientFiscalData.verifiedDataCheckboxInput);
expect(result).toBeTruthy();
});
2018-11-02 12:36:20 +00:00
});
2018-11-02 12:36:20 +00:00
describe('as administrative', () => {
beforeAll(() => {
2018-11-20 13:21:24 +00:00
nightmare
.loginAndModule('administrative', 'client')
.accessToSearchResult('Bruce Banner')
.accessToSection('client.card.fiscalData');
2018-11-02 12:36:20 +00:00
});
2019-01-07 08:33:07 +00:00
it('should receive an error if VIES and EQtax are being ticked together', async() => {
2018-11-02 12:36:20 +00:00
const result = await nightmare
.wait(selectors.clientFiscalData.socialNameInput)
.clearInput(selectors.clientFiscalData.socialNameInput)
2019-01-23 14:33:25 +00:00
.write(selectors.clientFiscalData.socialNameInput, 'SMASH!')
2018-11-02 12:36:20 +00:00
.clearInput(selectors.clientFiscalData.fiscalIdInput)
2019-01-23 14:33:25 +00:00
.write(selectors.clientFiscalData.fiscalIdInput, '94980061C')
2018-11-02 12:36:20 +00:00
.clearInput(selectors.clientFiscalData.addressInput)
2019-01-23 14:33:25 +00:00
.write(selectors.clientFiscalData.addressInput, 'Somewhere edited')
2018-11-02 12:36:20 +00:00
.clearInput(selectors.clientFiscalData.postcodeInput)
2019-01-23 14:33:25 +00:00
.write(selectors.clientFiscalData.postcodeInput, '12345')
2018-11-02 12:36:20 +00:00
.clearInput(selectors.clientFiscalData.cityInput)
2019-01-23 14:33:25 +00:00
.write(selectors.clientFiscalData.cityInput, 'N/A')
2019-01-07 08:33:07 +00:00
.autocompleteSearch(selectors.clientFiscalData.countryAutocomplete, 'Francia')
.autocompleteSearch(selectors.clientFiscalData.provinceAutocomplete, 'Province two')
2018-11-02 12:36:20 +00:00
.waitToClick(selectors.clientFiscalData.activeCheckboxLabel)
.waitToClick(selectors.clientFiscalData.frozenCheckboxLabel)
.waitToClick(selectors.clientFiscalData.hasToInvoiceCheckboxLabel)
2018-11-20 13:21:24 +00:00
.waitToClick(selectors.clientFiscalData.viesCheckboxInput)
2018-11-02 12:36:20 +00:00
.waitToClick(selectors.clientFiscalData.invoiceByMailCheckboxLabel)
.waitToClick(selectors.clientFiscalData.invoiceByAddressCheckboxInput)
.waitToClick(selectors.clientFiscalData.equalizationTaxCheckboxLabel)
.waitToClick(selectors.clientFiscalData.verifiedDataCheckboxInput)
2018-11-20 13:21:24 +00:00
.waitToClick(selectors.clientFiscalData.saveButton)
.waitForLastSnackbar();
expect(result).toEqual('Cannot check VIES and Equalization Tax');
2019-01-10 06:26:10 +00:00
}, 15000);
2018-11-20 13:21:24 +00:00
2019-01-07 08:33:07 +00:00
it('should receive an error if the fiscal id contains A or B at the beginning', async() => {
2018-11-20 13:21:24 +00:00
const result = await nightmare
.waitToClick(selectors.clientFiscalData.viesCheckboxInput)
.clearInput(selectors.clientFiscalData.fiscalIdInput)
2019-01-23 14:33:25 +00:00
.write(selectors.clientFiscalData.fiscalIdInput, 'A94980061C')
2018-11-20 13:21:24 +00:00
.waitToClick(selectors.clientFiscalData.saveButton)
.waitForLastSnackbar();
expect(result).toEqual('Cannot check Equalization Tax in this NIF/CIF');
});
2019-01-07 08:33:07 +00:00
it('should finally edit the fixcal data correctly as VIES isnt checked and fiscal id is valid for EQtax', async() => {
2018-11-20 13:21:24 +00:00
const result = await nightmare
.clearInput(selectors.clientFiscalData.fiscalIdInput)
2019-01-23 14:33:25 +00:00
.write(selectors.clientFiscalData.fiscalIdInput, '94980061C')
2018-11-20 13:21:24 +00:00
.waitToClick(selectors.clientFiscalData.saveButton)
2018-11-02 12:36:20 +00:00
.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
2019-01-07 08:33:07 +00:00
it('should propagate the Equalization tax', async() => {
2018-11-02 12:36:20 +00:00
const result = await nightmare
.waitToClick(selectors.clientFiscalData.acceptPropagationButton)
.waitForLastSnackbar();
expect(result).toEqual('Equivalent tax spreaded');
});
// confirm all addresses have now EQtax checked step 1
2019-01-07 08:33:07 +00:00
it(`should click on the addresses button to access to the client's addresses`, async() => {
2018-11-02 12:36:20 +00:00
const url = await nightmare
.waitToClick(selectors.clientAddresses.addressesButton)
.waitForURL('/address/index')
.parsedUrl();
2018-11-02 12:36:20 +00:00
expect(url.hash).toContain('/address/index');
});
// confirm all addresses have now EQtax checked step 2
2019-01-07 08:33:07 +00:00
it(`should click on the 1st edit icon to confirm EQtax is checked`, async() => {
2018-11-02 12:36:20 +00:00
const result = await nightmare
.waitToClick(selectors.clientAddresses.firstEditButton)
.wait(selectors.clientAddresses.equalizationTaxCheckboxLabel)
.evaluate(selector => {
return document.querySelector(selector).checked;
}, selectors.clientAddresses.equalizationTaxCheckboxLabel);
expect(result).toBeTruthy();
});
// confirm all addresses have now EQtax checked step 3
2019-01-07 08:33:07 +00:00
it(`should go back to addresses then select the second one and confirm the EQtax is checked`, async() => {
2018-11-02 12:36:20 +00:00
const result = await nightmare
.waitToClick(selectors.clientAddresses.addressesButton)
.waitToClick(selectors.clientAddresses.secondEditButton)
.wait(selectors.clientAddresses.equalizationTaxCheckboxLabel)
.evaluate(selector => {
return document.querySelector(selector).checked;
}, selectors.clientAddresses.equalizationTaxCheckboxLabel);
expect(result).toBeTruthy();
2018-09-05 06:27:50 +00:00
});
2019-01-07 08:33:07 +00:00
it('should navigate back to fiscal data and uncheck EQtax then check VIES', async() => {
2018-11-20 13:21:24 +00:00
const result = await nightmare
.waitToClick(selectors.clientFiscalData.fiscalDataButton)
.waitToClick(selectors.clientFiscalData.viesCheckboxInput)
.waitToClick(selectors.clientFiscalData.equalizationTaxCheckboxLabel)
.waitToClick(selectors.clientFiscalData.saveButton)
.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
2019-01-07 08:33:07 +00:00
it('should propagate the Equalization tax changes', async() => {
2018-11-20 13:21:24 +00:00
const result = await nightmare
.waitToClick(selectors.clientFiscalData.acceptPropagationButton)
.waitForLastSnackbar();
expect(result).toEqual('Equivalent tax spreaded');
});
2019-01-07 08:33:07 +00:00
it('should confirm its name have been edited', async() => {
2018-11-02 12:36:20 +00:00
const result = await nightmare
.waitToClick(selectors.clientFiscalData.fiscalDataButton)
.waitToGetProperty(selectors.clientFiscalData.socialNameInput, 'value');
2018-11-02 12:36:20 +00:00
expect(result).toEqual('SMASH!');
2018-09-05 06:27:50 +00:00
});
2019-01-07 08:33:07 +00:00
it('should confirm the fiscal id have been edited', async() => {
2018-11-02 12:36:20 +00:00
const result = await nightmare
.waitToGetProperty(selectors.clientFiscalData.fiscalIdInput, 'value');
2018-11-02 12:36:20 +00:00
expect(result).toEqual('94980061C');
});
2017-11-08 14:43:34 +00:00
2019-01-07 08:33:07 +00:00
it('should confirm the address have been edited', async() => {
2018-11-02 12:36:20 +00:00
const result = await nightmare
.waitToGetProperty(selectors.clientFiscalData.addressInput, 'value');
2018-11-02 12:36:20 +00:00
expect(result).toEqual('Somewhere edited');
});
2019-01-07 08:33:07 +00:00
it('should confirm the postcode have been edited', async() => {
2018-11-02 12:36:20 +00:00
const result = await nightmare
.waitToGetProperty(selectors.clientFiscalData.postcodeInput, 'value');
2018-11-02 12:36:20 +00:00
expect(result).toEqual('12345');
});
2019-01-07 08:33:07 +00:00
it('should confirm the city have been edited', async() => {
2018-11-02 12:36:20 +00:00
const result = await nightmare
.waitToGetProperty(selectors.clientFiscalData.cityInput, 'value');
2018-11-02 12:36:20 +00:00
expect(result).toEqual('N/A');
});
2019-01-07 08:33:07 +00:00
it(`should confirm the country have been selected`, async() => {
2018-11-02 12:36:20 +00:00
const result = await nightmare
2019-01-07 08:33:07 +00:00
.waitToGetProperty(`${selectors.clientFiscalData.countryAutocomplete} input`, 'value');
2018-11-02 12:36:20 +00:00
expect(result).toEqual('Francia');
});
2019-01-07 08:33:07 +00:00
it(`should confirm the province have been selected`, async() => {
2018-11-02 12:36:20 +00:00
const result = await nightmare
2019-01-07 08:33:07 +00:00
.waitToGetProperty(`${selectors.clientFiscalData.provinceAutocomplete} input`, 'value');
2018-11-02 12:36:20 +00:00
expect(result).toEqual('Province two');
});
2019-01-07 08:33:07 +00:00
it('should confirm active checkbox is unchecked', async() => {
2018-11-02 12:36:20 +00:00
const result = await nightmare
.evaluate(selector => {
return document.querySelector(selector).checked;
}, selectors.clientFiscalData.activeCheckboxLabel);
expect(result).toBeFalsy();
});
2019-01-07 08:33:07 +00:00
it('should confirm frozen checkbox is unchecked', async() => {
2018-11-02 12:36:20 +00:00
const result = await nightmare
.evaluate(selector => {
return document.querySelector(selector).checked;
}, selectors.clientFiscalData.frozenCheckboxLabel);
expect(result).toBeFalsy();
});
2017-11-09 13:47:09 +00:00
2019-01-07 08:33:07 +00:00
it('should confirm Has to invoice checkbox is unchecked', async() => {
2018-11-02 12:36:20 +00:00
const result = await nightmare
.evaluate(selector => {
return document.querySelector(selector).checked;
}, selectors.clientFiscalData.hasToInvoiceCheckboxLabel);
expect(result).toBeFalsy();
});
2019-01-07 08:33:07 +00:00
it('should confirm Vies checkbox is checked', async() => {
2018-11-20 13:21:24 +00:00
const result = await nightmare
.evaluate(selector => {
return document.querySelector(selector).checked;
}, selectors.clientFiscalData.viesCheckboxInput);
expect(result).toBeTruthy();
});
2019-01-07 08:33:07 +00:00
it('should confirm Invoice by mail checkbox is unchecked', async() => {
2018-11-02 12:36:20 +00:00
const result = await nightmare
.evaluate(selector => {
return document.querySelector(selector).checked;
}, selectors.clientFiscalData.invoiceByMailCheckboxLabel);
expect(result).toBeFalsy();
});
2019-01-07 08:33:07 +00:00
it('should confirm invoice by address checkbox is unchecked', async() => {
2018-11-02 12:36:20 +00:00
const result = await nightmare
.evaluate(selector => {
return document.querySelector(selector).checked;
}, selectors.clientFiscalData.invoiceByAddressCheckboxInput);
expect(result).toBeFalsy();
});
2019-01-07 08:33:07 +00:00
it('should confirm Equalization tax checkbox is unchecked', async() => {
2018-11-02 12:36:20 +00:00
const result = await nightmare
.evaluate(selector => {
return document.querySelector(selector).checked;
}, selectors.clientFiscalData.equalizationTaxCheckboxLabel);
2018-11-20 13:21:24 +00:00
expect(result).toBeFalsy();
2018-11-02 12:36:20 +00:00
});
2019-01-07 08:33:07 +00:00
it('should confirm Verified data checkbox is checked', async() => {
2018-11-02 12:36:20 +00:00
const result = await nightmare
.evaluate(selector => {
return document.querySelector(selector).checked;
}, selectors.clientFiscalData.verifiedDataCheckboxInput);
expect(result).toBeTruthy();
});
// confirm invoice by address checkbox gets checked if the EQtax differs between addresses step 1
2019-01-07 08:33:07 +00:00
it(`should click on the addresses button to access to the client's addresses`, async() => {
2018-11-02 12:36:20 +00:00
const url = await nightmare
.waitToClick(selectors.clientAddresses.addressesButton)
.waitForURL('/address/index')
.parsedUrl();
2018-11-02 12:36:20 +00:00
expect(url.hash).toContain('/address/index');
});
// confirm invoice by address checkbox gets checked if the EQtax differs between addresses step 2
2019-01-07 08:33:07 +00:00
it(`should click on the 1st edit icon to access the address details and uncheck EQtax checkbox`, async() => {
2018-11-02 12:36:20 +00:00
const result = await nightmare
.waitToClick(selectors.clientAddresses.firstEditButton)
.waitToClick(selectors.clientAddresses.equalizationTaxCheckboxLabel)
.click(selectors.clientAddresses.saveButton)
2018-11-20 13:21:24 +00:00
.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
// confirm invoice by address checkbox gets checked if the EQtax differs between addresses step 3
2019-01-07 08:33:07 +00:00
it('should navigate back to fiscal data to confirm invoice by address is now checked', async() => {
2018-11-02 12:36:20 +00:00
const result = await nightmare
.waitToClick(selectors.clientFiscalData.fiscalDataButton)
.wait(selectors.clientFiscalData.invoiceByAddressCheckboxInput)
.evaluate(selector => {
return document.querySelector(selector).checked;
}, selectors.clientFiscalData.invoiceByAddressCheckboxInput);
expect(result).toBeTruthy();
});
});
});