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

288 lines
14 KiB
JavaScript
Raw Normal View History

import selectors from '../../helpers/selectors.js';
2019-12-12 07:37:35 +00:00
import openPage from '../../helpers/puppeteer';
2018-09-05 06:27:50 +00:00
describe('Client Edit fiscalData path', () => {
2019-12-31 11:00:16 +00:00
let page;
beforeAll(async() => {
page = await openPage();
await page.loginAndModule('employee', 'client');
await page.accessToSearchResult('Bruce Banner');
await page.accessToSection('client.card.address.index');
});
2018-09-05 06:27:50 +00:00
2019-12-31 11:00:16 +00:00
afterAll(async() => {
page.close();
});
describe('as employee', () => {
// 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() => {
2019-12-31 11:00:16 +00:00
await page.waitToClick(selectors.clientAddresses.firstEditAddress);
const result = await page.checkboxState(selectors.clientAddresses.equalizationTaxCheckbox);
2018-11-02 12:36:20 +00:00
expect(result).toBe('unchecked');
});
// 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() => {
2019-12-31 11:00:16 +00:00
await page.waitToClick(selectors.clientAddresses.addressesButton);
await page.waitToClick(selectors.clientAddresses.secondEditAddress);
const result = await page.checkboxState(selectors.clientAddresses.equalizationTaxCheckbox);
expect(result).toBe('unchecked');
});
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() => {
2019-12-31 11:00:16 +00:00
await page.waitToClick(selectors.clientFiscalData.fiscalDataButton);
await page.waitForURL('fiscal-data');
const url = await page.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() => {
2019-12-31 11:00:16 +00:00
await page.wait(selectors.clientFiscalData.verifiedDataCheckbox);
const result = await page.isDisabled(selectors.clientFiscalData.verifiedDataCheckbox);
2018-11-02 12:36:20 +00:00
expect(result).toBeTruthy();
});
2018-11-02 12:36:20 +00:00
});
2018-11-02 12:36:20 +00:00
describe('as administrative', () => {
2019-12-31 11:00:16 +00:00
beforeAll(async() => {
await page.loginAndModule('administrative', 'client');
await page.accessToSearchResult('Bruce Banner');
await page.accessToSection('client.card.fiscalData');
2018-11-02 12:36:20 +00:00
});
it(`should edit the fiscal data but fail as the fiscal id ain't valid`, async() => {
2019-12-31 11:00:16 +00:00
await page.wait(selectors.clientFiscalData.socialNameInput);
await page.clearInput(selectors.clientFiscalData.socialNameInput);
await page.write(selectors.clientFiscalData.socialNameInput, 'SMASH');
await page.clearInput(selectors.clientFiscalData.fiscalIdInput);
await page.write(selectors.clientFiscalData.fiscalIdInput, 'INVALID!');
await page.clearInput(selectors.clientFiscalData.addressInput);
await page.write(selectors.clientFiscalData.addressInput, 'Somewhere edited');
await page.autocompleteSearch(selectors.clientFiscalData.countryAutocomplete, 'España');
await page.autocompleteSearch(selectors.clientFiscalData.provinceAutocomplete, 'Province one');
await page.clearInput(selectors.clientFiscalData.cityInput);
await page.write(selectors.clientFiscalData.cityInput, 'Valencia');
await page.clearInput(selectors.clientFiscalData.postcodeInput);
await page.write(selectors.clientFiscalData.postcodeInput, '46000');
await page.waitToClick(selectors.clientFiscalData.activeCheckbox);
await page.waitToClick(selectors.clientFiscalData.frozenCheckbox);
await page.waitToClick(selectors.clientFiscalData.hasToInvoiceCheckbox);
await page.waitToClick(selectors.clientFiscalData.viesCheckbox);
await page.waitToClick(selectors.clientFiscalData.invoiceByMailCheckbox);
await page.waitToClick(selectors.clientFiscalData.invoiceByAddressCheckbox);
await page.waitToClick(selectors.clientFiscalData.equalizationTaxCheckbox);
await page.waitToClick(selectors.clientFiscalData.verifiedDataCheckbox);
await page.waitToClick(selectors.clientFiscalData.saveButton);
const result = await page.waitForLastSnackbar();
2019-02-27 09:54:38 +00:00
expect(result).toEqual('Invalid Tax number');
2019-08-06 10:07:48 +00:00
});
2019-02-27 09:54:38 +00:00
it(`should edit the fiscal this time with a valid fiscal id`, async() => {
2019-12-31 11:00:16 +00:00
await page.clearInput(selectors.clientFiscalData.fiscalIdInput);
await page.write(selectors.clientFiscalData.fiscalIdInput, '94980061C');
await page.waitToClick(selectors.clientFiscalData.saveButton);
const result = await page.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
it('should propagate the Equalization tax', async() => {
2019-12-31 11:00:16 +00:00
await page.waitToClick(selectors.clientFiscalData.acceptPropagationButton);
const result = await page.waitForLastSnackbar();
expect(result).toEqual('Equivalent tax spreaded');
});
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() => {
2019-12-31 11:00:16 +00:00
await page.waitToClick(selectors.clientFiscalData.viesCheckbox);
await page.clearInput(selectors.clientFiscalData.fiscalIdInput);
await page.write(selectors.clientFiscalData.fiscalIdInput, 'A94980061C');
await page.waitToClick(selectors.clientFiscalData.saveButton);
const result = await page.waitForLastSnackbar();
2018-11-20 13:21:24 +00:00
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() => {
2019-12-31 11:00:16 +00:00
await page.clearInput(selectors.clientFiscalData.fiscalIdInput);
await page.write(selectors.clientFiscalData.fiscalIdInput, '94980061C');
await page.waitToClick(selectors.clientFiscalData.saveButton);
const result = await page.waitForLastSnackbar();
2018-11-02 12:36:20 +00:00
expect(result).toEqual('Data saved!');
});
// 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() => {
2019-12-31 11:00:16 +00:00
await page.waitToClick(selectors.clientAddresses.addressesButton);
await page.waitForURL('/address/index');
const url = await page.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() => {
2019-12-31 11:00:16 +00:00
await page.waitToClick(selectors.clientAddresses.firstEditAddress);
await page.waitForWatcherData(selectors.clientAddresses.watcher);
const result = await page.checkboxState(selectors.clientAddresses.equalizationTaxCheckbox);
2018-11-02 12:36:20 +00:00
expect(result).toBe('checked');
});
// 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() => {
2019-12-31 11:00:16 +00:00
await page.waitToClick(selectors.clientAddresses.addressesButton);
await page.waitToClick(selectors.clientAddresses.secondEditAddress);
await page.waitForWatcherData(selectors.clientAddresses.watcher);
const result = await page.checkboxState(selectors.clientAddresses.equalizationTaxCheckbox);
2018-11-02 12:36:20 +00:00
expect(result).toBe('checked');
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() => {
2019-12-31 11:00:16 +00:00
await page.waitToClick(selectors.clientFiscalData.fiscalDataButton);
await page.waitToClick(selectors.clientFiscalData.viesCheckbox);
await page.waitToClick(selectors.clientFiscalData.equalizationTaxCheckbox);
await page.waitToClick(selectors.clientFiscalData.saveButton);
const result = await page.waitForLastSnackbar();
2018-11-20 13:21:24 +00:00
expect(result).toEqual('Data saved!');
});
2019-01-07 08:33:07 +00:00
it('should propagate the Equalization tax changes', async() => {
2019-12-31 11:00:16 +00:00
await page.waitToClick(selectors.clientFiscalData.acceptPropagationButton);
const result = await page.waitForLastSnackbar();
2018-11-20 13:21:24 +00:00
expect(result).toEqual('Equivalent tax spreaded');
});
2019-01-07 08:33:07 +00:00
it('should confirm its name have been edited', async() => {
2019-12-31 11:00:16 +00:00
await page.waitToClick(selectors.clientFiscalData.fiscalDataButton);
const result = await page.waitToGetProperty(`${selectors.clientFiscalData.socialNameInput} input`, '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() => {
const result = await page.waitToGetProperty(`${selectors.clientFiscalData.fiscalIdInput} input`, '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() => {
const result = await page.waitToGetProperty(`${selectors.clientFiscalData.addressInput} input`, '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() => {
const result = await page.waitToGetProperty(`${selectors.clientFiscalData.postcodeInput} input`, 'value');
2018-11-02 12:36:20 +00:00
expect(result).toContain('46000');
});
it('should confirm the city have been autocompleted', async() => {
const result = await page.waitToGetProperty(`${selectors.clientFiscalData.cityInput} input`, 'value');
2018-11-02 12:36:20 +00:00
expect(result).toEqual('Valencia');
});
it(`should confirm the province have been autocompleted`, async() => {
2019-12-31 11:00:16 +00:00
const result = await page.waitToGetProperty(`${selectors.clientFiscalData.provinceAutocomplete} input`, 'value');
2018-11-02 12:36:20 +00:00
expect(result).toEqual('Province one');
});
it('should confirm the country have been autocompleted', async() => {
2019-12-31 11:00:16 +00:00
const result = await page.waitToGetProperty(`${selectors.clientFiscalData.countryAutocomplete} input`, 'value');
expect(result).toEqual('España');
});
2019-01-07 08:33:07 +00:00
it('should confirm active checkbox is unchecked', async() => {
2019-12-31 11:00:16 +00:00
const result = await page.checkboxState(selectors.clientFiscalData.activeCheckbox);
2018-11-02 12:36:20 +00:00
expect(result).toBe('unchecked');
});
2019-06-12 09:38:31 +00:00
it('should confirm frozen checkbox is checked', async() => {
2019-12-31 11:00:16 +00:00
const result = await page.checkboxState(selectors.clientFiscalData.frozenCheckbox);
2018-11-02 12:36:20 +00:00
2019-06-12 09:38:31 +00:00
expect(result).toBe('checked');
});
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() => {
2019-12-31 11:00:16 +00:00
const result = await page.checkboxState(selectors.clientFiscalData.hasToInvoiceCheckbox);
2018-11-02 12:36:20 +00:00
expect(result).toBe('unchecked');
});
2019-01-07 08:33:07 +00:00
it('should confirm Vies checkbox is checked', async() => {
2019-12-31 11:00:16 +00:00
const result = await page.checkboxState(selectors.clientFiscalData.viesCheckbox);
2018-11-20 13:21:24 +00:00
expect(result).toBe('checked');
2018-11-20 13:21:24 +00:00
});
2019-01-07 08:33:07 +00:00
it('should confirm Invoice by mail checkbox is unchecked', async() => {
2019-12-31 11:00:16 +00:00
const result = await page.checkboxState(selectors.clientFiscalData.invoiceByMailCheckbox);
2018-11-02 12:36:20 +00:00
expect(result).toBe('unchecked');
});
2019-01-07 08:33:07 +00:00
it('should confirm invoice by address checkbox is unchecked', async() => {
2019-12-31 11:00:16 +00:00
const result = await page.checkboxState(selectors.clientFiscalData.invoiceByAddressCheckbox);
2018-11-02 12:36:20 +00:00
expect(result).toBe('unchecked');
});
2019-01-07 08:33:07 +00:00
it('should confirm Equalization tax checkbox is unchecked', async() => {
2019-12-31 11:00:16 +00:00
const result = await page.checkboxState(selectors.clientFiscalData.equalizationTaxCheckbox);
2018-11-02 12:36:20 +00:00
expect(result).toBe('unchecked');
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() => {
2019-12-31 11:00:16 +00:00
const result = await page.checkboxState(selectors.clientFiscalData.verifiedDataCheckbox);
2018-11-02 12:36:20 +00:00
expect(result).toBe('checked');
});
// 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() => {
2019-12-31 11:00:16 +00:00
await page.waitToClick(selectors.clientAddresses.addressesButton);
await page.waitForURL('/address/index');
const url = await page.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() => {
2019-12-31 11:00:16 +00:00
await page.waitToClick(selectors.clientAddresses.firstEditAddress);
await page.waitForTextInInput(selectors.clientAddresses.cityInput, 'Silla');
await page.waitToClick(selectors.clientAddresses.equalizationTaxCheckbox);
await page.waitToClick(selectors.clientAddresses.saveButton);
const result = await page.waitForLastSnackbar();
2018-11-20 13:21:24 +00:00
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() => {
2019-12-31 11:00:16 +00:00
await page.waitToClick(selectors.clientFiscalData.fiscalDataButton);
await page.waitForWatcherData(selectors.clientFiscalData.watcher);
const result = await page.checkboxState(selectors.clientFiscalData.invoiceByAddressCheckbox);
2018-11-02 12:36:20 +00:00
expect(result).toBe('checked');
});
});
});