197 lines
8.0 KiB
JavaScript
197 lines
8.0 KiB
JavaScript
import selectors from '../../helpers/selectors.js';
|
|
import createNightmare from '../../helpers/nightmare';
|
|
|
|
describe('Client lock verified data path', () => {
|
|
const nightmare = createNightmare();
|
|
|
|
describe('as salesPerson', () => {
|
|
beforeAll(() => {
|
|
nightmare
|
|
.loginAndModule('salesPerson', 'client')
|
|
.accessToSearchResult('Hank Pym')
|
|
.accessToSection('client.card.fiscalData');
|
|
});
|
|
|
|
it('should confirm verified data button is disabled for salesPerson', async() => {
|
|
const result = await nightmare
|
|
.wait(200)
|
|
.wait(selectors.clientFiscalData.verifiedDataCheckbox)
|
|
.evaluate(selector => {
|
|
return document.querySelector(selector).getAttribute('disabled');
|
|
}, selectors.clientFiscalData.verifiedDataCheckbox);
|
|
|
|
expect(result).toBeTruthy();
|
|
});
|
|
|
|
it('should edit the social name', async() => {
|
|
const result = await nightmare
|
|
.wait(selectors.clientFiscalData.socialNameInput)
|
|
.clearInput(selectors.clientFiscalData.socialNameInput)
|
|
.write(selectors.clientFiscalData.socialNameInput, 'Captain America Civil War')
|
|
.waitToClick(selectors.clientFiscalData.saveButton)
|
|
.waitForLastSnackbar();
|
|
|
|
expect(result).toEqual('Data saved!');
|
|
});
|
|
|
|
it('should confirm the social name have been edited', async() => {
|
|
const result = await nightmare
|
|
.reloadSection('client.card.fiscalData')
|
|
.waitToGetProperty(selectors.clientFiscalData.socialNameInput, 'value');
|
|
|
|
expect(result).toEqual('Captain America Civil War');
|
|
});
|
|
});
|
|
|
|
describe('as administrative', () => {
|
|
beforeAll(() => {
|
|
nightmare
|
|
.loginAndModule('administrative', 'client')
|
|
.accessToSearchResult('Hank Pym')
|
|
.accessToSection('client.card.fiscalData');
|
|
});
|
|
|
|
it('should confirm verified data button is enabled for administrative', async() => {
|
|
const result = await nightmare
|
|
.wait(selectors.clientFiscalData.verifiedDataCheckbox)
|
|
.evaluate(selector => {
|
|
return document.querySelector(selector).disabled;
|
|
}, selectors.clientFiscalData.verifiedDataCheckbox);
|
|
|
|
expect(result).toBeFalsy();
|
|
});
|
|
|
|
it('should check the Verified data checkbox', async() => {
|
|
const result = await nightmare
|
|
.waitToClick(selectors.clientFiscalData.verifiedDataCheckbox)
|
|
.waitToClick(selectors.clientFiscalData.saveButton)
|
|
.waitForLastSnackbar();
|
|
|
|
expect(result).toEqual('Data saved!');
|
|
});
|
|
|
|
it('should confirm Verified data checkbox is checked', async() => {
|
|
const isChecked = await nightmare
|
|
.reloadSection('client.card.fiscalData')
|
|
.checkboxState(selectors.clientFiscalData.verifiedDataCheckbox);
|
|
|
|
expect(isChecked).toEqual('checked');
|
|
});
|
|
|
|
it('should again edit the social name', async() => {
|
|
const result = await nightmare
|
|
.wait(selectors.clientFiscalData.socialNameInput)
|
|
.clearInput(selectors.clientFiscalData.socialNameInput)
|
|
.write(selectors.clientFiscalData.socialNameInput, 'Ant-Man and the Wasp')
|
|
.waitToClick(selectors.clientFiscalData.saveButton)
|
|
.waitForLastSnackbar();
|
|
|
|
expect(result).toEqual('Data saved!');
|
|
});
|
|
|
|
it('should again confirm the social name have been edited', async() => {
|
|
const result = await nightmare
|
|
.reloadSection('client.card.fiscalData')
|
|
.waitToGetProperty(selectors.clientFiscalData.socialNameInput, 'value');
|
|
|
|
expect(result).toEqual('Ant-Man and the Wasp');
|
|
});
|
|
});
|
|
|
|
describe('as salesPerson second run', () => {
|
|
beforeAll(() => {
|
|
nightmare
|
|
.loginAndModule('salesPerson', 'client')
|
|
.accessToSearchResult('Hank Pym')
|
|
.accessToSection('client.card.fiscalData');
|
|
});
|
|
|
|
it('should confirm verified data button is disabled once again for salesPerson', async() => {
|
|
const isChecked = await nightmare
|
|
.waitForClassPresent(selectors.clientFiscalData.verifiedDataCheckbox, 'md-checked')
|
|
.evaluate(selector => {
|
|
return document.querySelector(selector).getAttribute('disabled');
|
|
}, selectors.clientFiscalData.verifiedDataCheckbox);
|
|
|
|
expect(isChecked).toBeTruthy();
|
|
});
|
|
|
|
it('should not be able to save change throwing a verified data error', async() => {
|
|
const result = await nightmare
|
|
.clearInput(selectors.clientFiscalData.socialNameInput)
|
|
.write(selectors.clientFiscalData.socialNameInput, 'This wont happen')
|
|
.waitToClick(selectors.clientFiscalData.saveButton)
|
|
.waitForSnackbar();
|
|
|
|
expect(result).toEqual(jasmine.arrayContaining([`You can't make changes on a client with verified data`]));
|
|
});
|
|
});
|
|
|
|
describe('as salesAssistant', () => {
|
|
beforeAll(() => {
|
|
nightmare
|
|
.forceReloadSection('client.card.fiscalData')
|
|
.loginAndModule('salesAssistant', 'client')
|
|
.accessToSearchResult('Hank Pym')
|
|
.accessToSection('client.card.fiscalData');
|
|
});
|
|
|
|
it('should confirm verified data button is enabled for salesAssistant', async() => {
|
|
const isDisabled = await nightmare
|
|
.waitForClassPresent(selectors.clientFiscalData.verifiedDataCheckbox, 'md-checked')
|
|
.evaluate(selector => {
|
|
return document.querySelector(selector).getAttribute('aria-disabled');
|
|
}, selectors.clientFiscalData.verifiedDataCheckbox);
|
|
|
|
expect(isDisabled).toEqual('false');
|
|
});
|
|
|
|
it('should now edit the social name', async() => {
|
|
const result = await nightmare
|
|
.clearInput(selectors.clientFiscalData.socialNameInput)
|
|
.write(selectors.clientFiscalData.socialNameInput, 'new social name edition')
|
|
.waitToClick(selectors.clientFiscalData.saveButton)
|
|
.waitForLastSnackbar();
|
|
|
|
expect(result).toEqual('Data saved!');
|
|
});
|
|
|
|
it('should now confirm the social name have been edited once and for all', async() => {
|
|
const result = await nightmare
|
|
.reloadSection('client.card.fiscalData')
|
|
.waitToGetProperty(selectors.clientFiscalData.socialNameInput, 'value');
|
|
|
|
expect(result).toEqual('new social name edition');
|
|
});
|
|
});
|
|
|
|
describe('as salesPerson third run', () => {
|
|
beforeAll(() => {
|
|
nightmare
|
|
.loginAndModule('salesPerson', 'client')
|
|
.accessToSearchResult('Hank Pym')
|
|
.accessToSection('client.card.fiscalData');
|
|
});
|
|
|
|
it('should confirm verified data button is enabled once again', async() => {
|
|
const isChecked = await nightmare
|
|
.waitForClassPresent(selectors.clientFiscalData.verifiedDataCheckbox, 'md-checked')
|
|
.evaluate(selector => {
|
|
return document.querySelector(selector).getAttribute('disabled');
|
|
}, selectors.clientFiscalData.verifiedDataCheckbox);
|
|
|
|
expect(isChecked).toBeTruthy();
|
|
});
|
|
|
|
it('should confirm the form is enabled for salesPerson', async() => {
|
|
const result = await nightmare
|
|
.wait(selectors.clientFiscalData.socialNameInput)
|
|
.evaluate(selector => {
|
|
return document.querySelector(selector).disabled;
|
|
}, 'vn-textfield[field="$ctrl.client.socialName"] > div');
|
|
|
|
expect(result).toBeFalsy();
|
|
});
|
|
});
|
|
});
|