salix/e2e/paths/02-client/12_lock_of_verified_data.sp...

173 lines
7.4 KiB
JavaScript
Raw Normal View History

import selectors from '../../helpers/selectors';
import getBrowser from '../../helpers/puppeteer';
2018-03-02 13:45:22 +00:00
2020-03-17 10:00:16 +00:00
describe('Client lock verified data path', () => {
let browser;
2019-12-31 11:00:16 +00:00
let page;
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
2019-12-31 11:00:16 +00:00
await page.loginAndModule('salesPerson', 'client');
await page.accessToSearchResult('Hank Pym');
await page.accessToSection('client.card.fiscalData');
});
2019-12-31 11:00:16 +00:00
afterAll(async() => {
await browser.close();
2019-12-31 11:00:16 +00:00
});
2018-10-29 11:35:25 +00:00
2019-12-31 11:00:16 +00:00
describe('as salesPerson', () => {
2019-01-16 14:02:50 +00:00
it('should confirm verified data button is disabled for salesPerson', async() => {
await page.waitForTimeout(200);
await page.waitForSelector(selectors.clientFiscalData.verifiedDataCheckbox);
2019-12-31 11:00:16 +00:00
const result = await page.isDisabled(selectors.clientFiscalData.verifiedDataCheckbox);
2018-10-29 11:35:25 +00:00
expect(result).toBeTruthy();
});
2019-01-16 14:02:50 +00:00
it('should edit the social name', async() => {
await page.waitForSelector(selectors.clientFiscalData.socialName);
2020-02-03 14:55:11 +00:00
await page.clearInput(selectors.clientFiscalData.socialName);
await page.write(selectors.clientFiscalData.socialName, 'Captain America Civil War');
2019-12-31 11:00:16 +00:00
await page.waitToClick(selectors.clientFiscalData.saveButton);
2020-04-08 09:24:40 +00:00
const message = await page.waitForSnackbar();
2018-10-29 11:35:25 +00:00
2020-11-10 11:06:21 +00:00
expect(message.text).toContain('Data saved!');
2018-10-29 11:35:25 +00:00
});
2019-01-16 14:02:50 +00:00
it('should confirm the social name have been edited', async() => {
2019-12-31 11:00:16 +00:00
await page.reloadSection('client.card.fiscalData');
2020-02-03 14:55:11 +00:00
const result = await page.waitToGetProperty(selectors.clientFiscalData.socialName, 'value');
2018-10-29 11:35:25 +00:00
2019-06-19 12:40:47 +00:00
expect(result).toEqual('Captain America Civil War');
});
});
describe('as administrative', () => {
2019-12-31 11:00:16 +00:00
beforeAll(async() => {
await page.loginAndModule('administrative', 'client');
await page.accessToSearchResult('Hank Pym');
await page.accessToSection('client.card.fiscalData');
2018-10-29 11:35:25 +00:00
});
2019-01-16 14:02:50 +00:00
it('should confirm verified data button is enabled for administrative', async() => {
2019-12-31 11:00:16 +00:00
const result = await page.isDisabled(selectors.clientFiscalData.verifiedDataCheckbox);
2018-10-29 11:35:25 +00:00
expect(result).toBeFalsy();
2018-10-29 11:35:25 +00:00
});
2019-01-16 14:02:50 +00:00
it('should check the Verified data checkbox', async() => {
await page.autocompleteSearch(selectors.clientFiscalData.sageTax, 'operaciones no sujetas');
await page.autocompleteSearch(selectors.clientFiscalData.sageTransaction, 'regularización de inversiones');
2019-12-31 11:00:16 +00:00
await page.waitToClick(selectors.clientFiscalData.verifiedDataCheckbox);
await page.waitToClick(selectors.clientFiscalData.saveButton);
2020-10-01 06:53:31 +00:00
await page.waitToClick(selectors.globalItems.acceptButton);
2020-04-08 09:24:40 +00:00
const message = await page.waitForSnackbar();
2018-10-29 11:35:25 +00:00
2020-11-10 11:06:21 +00:00
expect(message.text).toContain('Data saved!');
2018-10-29 11:35:25 +00:00
});
2019-01-16 14:02:50 +00:00
it('should confirm Verified data checkbox is checked', async() => {
2019-12-31 11:00:16 +00:00
await page.reloadSection('client.card.fiscalData');
const isChecked = await page.checkboxState(selectors.clientFiscalData.verifiedDataCheckbox);
2018-10-29 11:35:25 +00:00
2019-06-19 12:40:47 +00:00
expect(isChecked).toEqual('checked');
2018-10-29 11:35:25 +00:00
});
2019-01-16 14:02:50 +00:00
it('should again edit the social name', async() => {
await page.waitForSelector(selectors.clientFiscalData.socialName);
2020-02-03 14:55:11 +00:00
await page.clearInput(selectors.clientFiscalData.socialName);
await page.write(selectors.clientFiscalData.socialName, 'Ant man and the Wasp');
2019-12-31 11:00:16 +00:00
await page.waitToClick(selectors.clientFiscalData.saveButton);
2020-04-08 09:24:40 +00:00
const message = await page.waitForSnackbar();
2018-10-29 11:35:25 +00:00
2020-11-10 11:06:21 +00:00
expect(message.text).toContain('Data saved!');
2018-10-29 11:35:25 +00:00
});
2019-01-16 14:02:50 +00:00
it('should again confirm the social name have been edited', async() => {
2019-12-31 11:00:16 +00:00
await page.reloadSection('client.card.fiscalData');
2020-02-03 14:55:11 +00:00
const result = await page.waitToGetProperty(selectors.clientFiscalData.socialName, 'value');
2018-10-29 11:35:25 +00:00
expect(result).toEqual('Ant man and the Wasp');
});
});
describe('as salesPerson second run', () => {
2019-12-31 11:00:16 +00:00
beforeAll(async() => {
await page.loginAndModule('salesPerson', 'client');
await page.accessToSearchResult('Hank Pym');
await page.accessToSection('client.card.fiscalData');
2018-10-29 11:35:25 +00:00
});
2019-01-16 14:02:50 +00:00
it('should confirm verified data button is disabled once again for salesPerson', async() => {
2019-12-31 11:00:16 +00:00
const isDisabled = await page.isDisabled(selectors.clientFiscalData.verifiedDataCheckbox);
2018-10-29 11:35:25 +00:00
expect(isDisabled).toBeTruthy();
2018-10-29 11:35:25 +00:00
});
2019-01-16 14:02:50 +00:00
it('should not be able to save change throwing a verified data error', async() => {
2020-02-03 14:55:11 +00:00
await page.clearInput(selectors.clientFiscalData.socialName);
await page.write(selectors.clientFiscalData.socialName, 'This wont happen');
2019-12-31 11:00:16 +00:00
await page.waitToClick(selectors.clientFiscalData.saveButton);
2020-04-08 09:24:40 +00:00
const message = await page.waitForSnackbar();
2018-10-29 11:35:25 +00:00
2020-11-10 11:06:21 +00:00
expect(message.text).toContain(`You can't make changes on a client with verified data`);
});
});
2020-03-17 10:00:16 +00:00
describe('as salesAssistant', () => {
2020-02-04 15:21:10 +00:00
it('should log in as salesAssistant then get to the client fiscal data', async() => {
2019-12-31 11:00:16 +00:00
await page.forceReloadSection('client.card.fiscalData');
await page.loginAndModule('salesAssistant', 'client');
await page.accessToSearchResult('Hank Pym');
await page.accessToSection('client.card.fiscalData');
2020-02-04 15:21:10 +00:00
}, 20000);
2018-10-29 11:35:25 +00:00
2019-01-16 14:02:50 +00:00
it('should confirm verified data button is enabled for salesAssistant', async() => {
2019-12-31 11:00:16 +00:00
const isDisabled = await page.isDisabled(selectors.clientFiscalData.verifiedDataCheckbox);
2018-10-29 11:35:25 +00:00
expect(isDisabled).toBeFalsy();
2018-10-29 11:35:25 +00:00
});
2019-01-16 14:02:50 +00:00
it('should now edit the social name', async() => {
2020-02-03 14:55:11 +00:00
await page.clearInput(selectors.clientFiscalData.socialName);
await page.write(selectors.clientFiscalData.socialName, 'new social name edition');
2019-12-31 11:00:16 +00:00
await page.waitToClick(selectors.clientFiscalData.saveButton);
2020-04-08 09:24:40 +00:00
const message = await page.waitForSnackbar();
2018-10-29 11:35:25 +00:00
2020-11-10 11:06:21 +00:00
expect(message.text).toContain('Data saved!');
2018-10-29 11:35:25 +00:00
});
2019-01-16 14:02:50 +00:00
it('should now confirm the social name have been edited once and for all', async() => {
2019-12-31 11:00:16 +00:00
await page.reloadSection('client.card.fiscalData');
2020-02-03 14:55:11 +00:00
const result = await page.waitToGetProperty(selectors.clientFiscalData.socialName, 'value');
2018-10-29 11:35:25 +00:00
2019-06-19 12:40:47 +00:00
expect(result).toEqual('new social name edition');
});
});
describe('as salesPerson third run', () => {
2019-12-31 11:00:16 +00:00
beforeAll(async() => {
await page.loginAndModule('salesPerson', 'client');
await page.accessToSearchResult('Hank Pym');
await page.accessToSection('client.card.fiscalData');
2018-10-29 11:35:25 +00:00
});
2019-01-16 14:02:50 +00:00
it('should confirm verified data button is enabled once again', async() => {
2019-12-31 11:00:16 +00:00
const isDisabled = await page;
await page.isDisabled(selectors.clientFiscalData.verifiedDataCheckbox);
2018-10-29 11:35:25 +00:00
expect(isDisabled).toBeTruthy();
2018-10-29 11:35:25 +00:00
});
2019-01-16 14:02:50 +00:00
it('should confirm the form is enabled for salesPerson', async() => {
await page.waitForSelector(selectors.clientFiscalData.socialName);
2019-12-31 11:00:16 +00:00
const result = await page.evaluate(selector => {
return document.querySelector(selector).disabled;
}, 'vn-textfield[ng-model="$ctrl.client.socialName"] > div');
2018-10-29 11:35:25 +00:00
expect(result).toBeFalsy();
});
});
2018-03-02 13:45:22 +00:00
});