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

171 lines
7.2 KiB
JavaScript
Raw Normal View History

import selectors from '../../helpers/selectors';
import getBrowser from '../../helpers/puppeteer';
2018-03-02 13:45:22 +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() => {
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() => {
2020-02-03 14:55:11 +00:00
await page.wait(selectors.clientFiscalData.socialName);
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);
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-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() => {
2019-12-31 11:00:16 +00:00
await page.waitToClick(selectors.clientFiscalData.verifiedDataCheckbox);
await page.waitToClick(selectors.clientFiscalData.saveButton);
2020-02-04 10:25:15 +00:00
await page.waitToClick(selectors.clientFiscalData.acceptDuplicationButton);
2019-12-31 11:00:16 +00:00
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() => {
2020-02-03 14:55:11 +00:00
await page.wait(selectors.clientFiscalData.socialName);
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);
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-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);
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`]));
});
});
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);
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-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() => {
2020-02-03 14:55:11 +00:00
await page.wait(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
});