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

197 lines
8.0 KiB
JavaScript
Raw Normal View History

2018-03-02 13:45:22 +00:00
import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare';
2018-03-02 13:45:22 +00:00
describe('Client lock verified data path', () => {
const nightmare = createNightmare();
describe('as salesPerson', () => {
beforeAll(() => {
2018-11-20 13:22:00 +00:00
nightmare
.loginAndModule('salesPerson', 'client')
2019-06-19 12:40:47 +00:00
.accessToSearchResult('Hank Pym')
.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 for salesPerson', async() => {
2018-10-29 11:35:25 +00:00
const result = await nightmare
2018-12-14 10:39:41 +00:00
.wait(200)
.wait(selectors.clientFiscalData.verifiedDataCheckbox)
2018-11-06 13:27:16 +00:00
.evaluate(selector => {
return document.querySelector(selector).getAttribute('disabled');
2018-10-29 11:35:25 +00:00
}, selectors.clientFiscalData.verifiedDataCheckbox);
expect(result).toBeTruthy();
});
2019-01-16 14:02:50 +00:00
it('should edit the social name', async() => {
2018-10-29 11:35:25 +00:00
const result = await nightmare
.wait(selectors.clientFiscalData.socialNameInput)
.clearInput(selectors.clientFiscalData.socialNameInput)
2019-06-19 12:40:47 +00:00
.write(selectors.clientFiscalData.socialNameInput, 'Captain America Civil War')
2019-01-23 15:00:56 +00:00
.waitToClick(selectors.clientFiscalData.saveButton)
2018-10-29 11:35:25 +00:00
.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
2019-01-16 14:02:50 +00:00
it('should confirm the social name have been edited', async() => {
2018-10-29 11:35:25 +00:00
const result = await nightmare
.reloadSection('client.card.fiscalData')
.waitToGetProperty(selectors.clientFiscalData.socialNameInput, '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', () => {
beforeAll(() => {
2018-11-20 13:22:00 +00:00
nightmare
2019-06-19 12:40:47 +00:00
.loginAndModule('administrative', 'client')
.accessToSearchResult('Hank Pym')
.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() => {
2018-10-29 11:35:25 +00:00
const result = await nightmare
.wait(selectors.clientFiscalData.verifiedDataCheckbox)
2018-11-06 13:27:16 +00:00
.evaluate(selector => {
2018-10-29 11:35:25 +00:00
return document.querySelector(selector).disabled;
}, selectors.clientFiscalData.verifiedDataCheckbox);
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() => {
2018-10-29 11:35:25 +00:00
const result = await nightmare
.waitToClick(selectors.clientFiscalData.verifiedDataCheckbox)
2018-10-29 11:35:25 +00:00
.waitToClick(selectors.clientFiscalData.saveButton)
.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
2019-01-16 14:02:50 +00:00
it('should confirm Verified data checkbox is checked', async() => {
2019-06-19 12:40:47 +00:00
const isChecked = await nightmare
.reloadSection('client.card.fiscalData')
.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() => {
2018-10-29 11:35:25 +00:00
const result = await nightmare
.wait(selectors.clientFiscalData.socialNameInput)
.clearInput(selectors.clientFiscalData.socialNameInput)
2019-06-19 12:40:47 +00:00
.write(selectors.clientFiscalData.socialNameInput, 'Ant-Man and the Wasp')
2019-01-23 15:00:56 +00:00
.waitToClick(selectors.clientFiscalData.saveButton)
2018-10-29 11:35:25 +00:00
.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
2019-01-16 14:02:50 +00:00
it('should again confirm the social name have been edited', async() => {
2018-10-29 11:35:25 +00:00
const result = await nightmare
.reloadSection('client.card.fiscalData')
.waitToGetProperty(selectors.clientFiscalData.socialNameInput, 'value');
2018-10-29 11:35:25 +00:00
2019-06-19 12:40:47 +00:00
expect(result).toEqual('Ant-Man and the Wasp');
});
});
describe('as salesPerson second run', () => {
beforeAll(() => {
2018-11-20 13:22:00 +00:00
nightmare
2019-06-19 12:40:47 +00:00
.loginAndModule('salesPerson', 'client')
.accessToSearchResult('Hank Pym')
.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-06-19 12:40:47 +00:00
const isChecked = await nightmare
.waitForClassPresent(selectors.clientFiscalData.verifiedDataCheckbox, 'md-checked')
2018-11-06 13:27:16 +00:00
.evaluate(selector => {
return document.querySelector(selector).getAttribute('disabled');
2018-10-29 11:35:25 +00:00
}, selectors.clientFiscalData.verifiedDataCheckbox);
2019-06-19 12:40:47 +00:00
expect(isChecked).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() => {
2018-10-29 11:35:25 +00:00
const result = await nightmare
.clearInput(selectors.clientFiscalData.socialNameInput)
2019-06-19 12:40:47 +00:00
.write(selectors.clientFiscalData.socialNameInput, 'This wont happen')
2019-01-23 15:00:56 +00:00
.waitToClick(selectors.clientFiscalData.saveButton)
2018-10-29 11:35:25 +00:00
.waitForSnackbar();
expect(result).toEqual(jasmine.arrayContaining([`You can't make changes on a client with verified data`]));
});
});
describe('as salesAssistant', () => {
beforeAll(() => {
2018-11-20 13:22:00 +00:00
nightmare
.forceReloadSection('client.card.fiscalData')
2019-06-19 12:40:47 +00:00
.loginAndModule('salesAssistant', 'client')
.accessToSearchResult('Hank Pym')
.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-06-19 12:40:47 +00:00
const isDisabled = await nightmare
.waitForClassPresent(selectors.clientFiscalData.verifiedDataCheckbox, 'md-checked')
2018-11-06 13:27:16 +00:00
.evaluate(selector => {
2019-06-19 12:40:47 +00:00
return document.querySelector(selector).getAttribute('aria-disabled');
2018-10-29 11:35:25 +00:00
}, selectors.clientFiscalData.verifiedDataCheckbox);
2019-06-19 12:40:47 +00:00
expect(isDisabled).toEqual('false');
2018-10-29 11:35:25 +00:00
});
2019-01-16 14:02:50 +00:00
it('should now edit the social name', async() => {
2018-10-29 11:35:25 +00:00
const result = await nightmare
.clearInput(selectors.clientFiscalData.socialNameInput)
2019-06-19 12:40:47 +00:00
.write(selectors.clientFiscalData.socialNameInput, 'new social name edition')
2019-01-23 15:00:56 +00:00
.waitToClick(selectors.clientFiscalData.saveButton)
2018-10-29 11:35:25 +00:00
.waitForLastSnackbar();
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() => {
2018-10-29 11:35:25 +00:00
const result = await nightmare
.reloadSection('client.card.fiscalData')
.waitToGetProperty(selectors.clientFiscalData.socialNameInput, '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', () => {
beforeAll(() => {
2018-11-20 13:22:00 +00:00
nightmare
2019-06-19 12:40:47 +00:00
.loginAndModule('salesPerson', 'client')
.accessToSearchResult('Hank Pym')
.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-06-19 12:40:47 +00:00
const isChecked = await nightmare
.waitForClassPresent(selectors.clientFiscalData.verifiedDataCheckbox, 'md-checked')
2018-11-06 13:27:16 +00:00
.evaluate(selector => {
return document.querySelector(selector).getAttribute('disabled');
2018-10-29 11:35:25 +00:00
}, selectors.clientFiscalData.verifiedDataCheckbox);
2019-06-19 12:40:47 +00:00
expect(isChecked).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() => {
2018-10-29 11:35:25 +00:00
const result = await nightmare
.wait(selectors.clientFiscalData.socialNameInput)
2018-11-06 13:27:16 +00:00
.evaluate(selector => {
2018-10-29 11:35:25 +00:00
return document.querySelector(selector).disabled;
}, 'vn-textfield[field="$ctrl.client.socialName"] > div');
expect(result).toBeFalsy();
});
});
2018-03-02 13:45:22 +00:00
});