2020-01-14 08:20:14 +00:00
|
|
|
import selectors from '../../helpers/selectors';
|
|
|
|
import getBrowser from '../../helpers/puppeteer';
|
2018-03-02 13:45:22 +00:00
|
|
|
|
2018-09-05 06:24:15 +00:00
|
|
|
describe('Client lock verified data path', () => {
|
2020-01-14 08:20:14 +00:00
|
|
|
let browser;
|
2019-12-31 11:00:16 +00:00
|
|
|
let page;
|
|
|
|
beforeAll(async() => {
|
2020-01-14 08:20:14 +00:00
|
|
|
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');
|
|
|
|
});
|
2018-09-05 06:24:15 +00:00
|
|
|
|
2019-12-31 11:00:16 +00:00
|
|
|
afterAll(async() => {
|
2020-01-14 08:40:50 +00:00
|
|
|
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() => {
|
2019-12-31 11:00:16 +00:00
|
|
|
await page.wait(200);
|
|
|
|
await page.wait(selectors.clientFiscalData.verifiedDataCheckbox);
|
|
|
|
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() => {
|
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, 'Captain America Civil War');
|
|
|
|
await page.waitToClick(selectors.clientFiscalData.saveButton);
|
|
|
|
const result = await page.waitForLastSnackbar();
|
2018-10-29 11:35:25 +00:00
|
|
|
|
|
|
|
expect(result).toEqual('Data saved!');
|
|
|
|
});
|
|
|
|
|
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-01-02 10:37:25 +00:00
|
|
|
const result = await page.waitToGetProperty(`${selectors.clientFiscalData.socialNameInput} input`, 'value');
|
2018-10-29 11:35:25 +00:00
|
|
|
|
2019-06-19 12:40:47 +00:00
|
|
|
expect(result).toEqual('Captain America Civil War');
|
2018-09-05 06:24:15 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
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
|
|
|
|
2019-02-14 19:17:22 +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() => {
|
2019-12-31 11:00:16 +00:00
|
|
|
await page.waitToClick(selectors.clientFiscalData.verifiedDataCheckbox);
|
|
|
|
await page.waitToClick(selectors.clientFiscalData.saveButton);
|
|
|
|
const result = await page.waitForLastSnackbar();
|
2018-10-29 11:35:25 +00:00
|
|
|
|
|
|
|
expect(result).toEqual('Data saved!');
|
|
|
|
});
|
|
|
|
|
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() => {
|
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, 'Ant man and the Wasp');
|
|
|
|
await page.waitToClick(selectors.clientFiscalData.saveButton);
|
|
|
|
const result = await page.waitForLastSnackbar();
|
2018-10-29 11:35:25 +00:00
|
|
|
|
|
|
|
expect(result).toEqual('Data saved!');
|
|
|
|
});
|
|
|
|
|
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-01-02 10:37:25 +00:00
|
|
|
const result = await page.waitToGetProperty(`${selectors.clientFiscalData.socialNameInput} input`, 'value');
|
2018-10-29 11:35:25 +00:00
|
|
|
|
2019-09-09 07:05:13 +00:00
|
|
|
expect(result).toEqual('Ant man and the Wasp');
|
2018-09-05 06:24:15 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
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
|
|
|
|
2019-09-30 18:46:22 +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() => {
|
2019-12-31 11:00:16 +00:00
|
|
|
await page.clearInput(selectors.clientFiscalData.socialNameInput);
|
|
|
|
await page.write(selectors.clientFiscalData.socialNameInput, 'This wont happen');
|
|
|
|
await page.waitToClick(selectors.clientFiscalData.saveButton);
|
|
|
|
const result = await page.waitForLastSnackbar();
|
2018-10-29 11:35:25 +00:00
|
|
|
|
|
|
|
expect(result).toEqual(jasmine.arrayContaining([`You can't make changes on a client with verified data`]));
|
2018-09-05 06:24:15 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('as salesAssistant', () => {
|
2019-12-31 11:00:16 +00:00
|
|
|
beforeAll(async() => {
|
|
|
|
await page.forceReloadSection('client.card.fiscalData');
|
|
|
|
await page.loginAndModule('salesAssistant', '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 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
|
|
|
|
2019-09-30 18:46:22 +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() => {
|
2019-12-31 11:00:16 +00:00
|
|
|
await page.clearInput(selectors.clientFiscalData.socialNameInput);
|
|
|
|
await page.write(selectors.clientFiscalData.socialNameInput, 'new social name edition');
|
|
|
|
await page.waitToClick(selectors.clientFiscalData.saveButton);
|
|
|
|
const result = await page.waitForLastSnackbar();
|
2018-10-29 11:35:25 +00:00
|
|
|
|
|
|
|
expect(result).toEqual('Data saved!');
|
|
|
|
});
|
|
|
|
|
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-01-02 10:37:25 +00:00
|
|
|
const result = await page.waitToGetProperty(`${selectors.clientFiscalData.socialNameInput} input`, 'value');
|
2018-10-29 11:35:25 +00:00
|
|
|
|
2019-06-19 12:40:47 +00:00
|
|
|
expect(result).toEqual('new social name edition');
|
2018-09-05 06:24:15 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
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
|
|
|
|
2019-09-30 18:46:22 +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() => {
|
2019-12-31 11:00:16 +00:00
|
|
|
await page.wait(selectors.clientFiscalData.socialNameInput);
|
|
|
|
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
|
|
|
|
2019-02-14 19:17:22 +00:00
|
|
|
expect(result).toBeFalsy();
|
2018-03-12 10:10:05 +00:00
|
|
|
});
|
|
|
|
});
|
2018-03-02 13:45:22 +00:00
|
|
|
});
|