too many nested callbacks warning corrected

This commit is contained in:
Carlos Jimenez 2018-09-05 08:24:15 +02:00
parent 566c8e619e
commit e00d054fe9
1 changed files with 440 additions and 442 deletions

View File

@ -1,474 +1,472 @@
import selectors from '../../helpers/selectors.js'; import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/helpers'; import createNightmare from '../../helpers/helpers';
describe('Client', () => { describe('Client lock verified data path', () => {
describe('lock verified data path', () => { const nightmare = createNightmare();
const nightmare = createNightmare();
describe('as salesPerson', () => { describe('as salesPerson', () => {
beforeAll(() => { beforeAll(() => {
return nightmare return nightmare
.waitForLogin('salesPerson'); .waitForLogin('salesPerson');
}); });
it('should click on the Clients button of the top bar menu', () => { it('should click on the Clients button of the top bar menu', () => {
return nightmare return nightmare
.waitToClick(selectors.globalItems.applicationsMenuButton) .waitToClick(selectors.globalItems.applicationsMenuButton)
.wait(selectors.globalItems.applicationsMenuVisible) .wait(selectors.globalItems.applicationsMenuVisible)
.waitToClick(selectors.globalItems.clientsButton) .waitToClick(selectors.globalItems.clientsButton)
.wait(selectors.clientsIndex.createClientButton) .wait(selectors.clientsIndex.createClientButton)
.parsedUrl() .parsedUrl()
.then(url => { .then(url => {
expect(url.hash).toEqual('#!/client/index'); expect(url.hash).toEqual('#!/client/index');
});
});
it('should search for the user Petter Parker', () => {
return nightmare
.wait(selectors.clientsIndex.searchResult)
.type(selectors.clientsIndex.searchClientInput, 'Petter Parker')
.click(selectors.clientsIndex.searchButton)
.waitForNumberOfElements(selectors.clientsIndex.searchResult, 1)
.countElement(selectors.clientsIndex.searchResult)
.then(result => {
expect(result).toEqual(1);
});
});
it(`should click on the search result to access to the client's fiscal data`, () => {
return nightmare
.waitForTextInElement(selectors.clientsIndex.searchResult, 'Petter Parker')
.waitToClick(selectors.clientsIndex.searchResult)
.waitToClick(selectors.clientFiscalData.fiscalDataButton)
.waitForURL('fiscal-data')
.parsedUrl()
.then(url => {
expect(url.hash).toContain('fiscal-data');
});
});
it(`should click on the fiscal data button to start editing`, () => {
return nightmare
.waitToClick(selectors.clientFiscalData.fiscalDataButton)
.waitForURL('fiscal-data')
.parsedUrl()
.then(url => {
expect(url.hash).toContain('fiscal-data');
});
});
it('should confirm verified data button is disabled for salesPerson', () => {
return nightmare
.wait(selectors.clientFiscalData.verifiedDataCheckboxInput)
.evaluate(selector => {
console.log(document.querySelector(selector));
return document.querySelector(selector).disabled;
}, selectors.clientFiscalData.verifiedDataCheckbox)
.then(result => {
expect(result).toBe(true);
});
});
it('should edit the social name', () => {
return nightmare
.wait(selectors.clientFiscalData.socialNameInput)
.clearInput(selectors.clientFiscalData.socialNameInput)
.type(selectors.clientFiscalData.socialNameInput, 'salesPerson was here')
.click(selectors.clientFiscalData.saveButton)
.waitForSnackbar()
.then(result => {
expect(result).toEqual(jasmine.arrayContaining(['Data saved!']));
});
});
it('should confirm the social name have been edited', () => {
return nightmare
.waitToClick(selectors.clientBasicData.basicDataButton)
.wait(selectors.clientBasicData.nameInput)
.waitToClick(selectors.clientFiscalData.fiscalDataButton)
.wait(selectors.clientFiscalData.socialNameInput)
.getInputValue(selectors.clientFiscalData.socialNameInput)
.then(result => {
expect(result).toEqual('salesPerson was here');
});
}); });
}); });
describe('as administrative', () => { it('should search for the user Petter Parker', () => {
beforeAll(() => { return nightmare
return nightmare .wait(selectors.clientsIndex.searchResult)
.waitToClick(selectors.globalItems.logOutButton) .type(selectors.clientsIndex.searchClientInput, 'Petter Parker')
.waitForLogin('administrative'); .click(selectors.clientsIndex.searchButton)
}); .waitForNumberOfElements(selectors.clientsIndex.searchResult, 1)
.countElement(selectors.clientsIndex.searchResult)
it('should navigate to clients index', () => { .then(result => {
return nightmare expect(result).toEqual(1);
.waitToClick(selectors.globalItems.applicationsMenuButton)
.wait(selectors.globalItems.applicationsMenuVisible)
.waitToClick(selectors.globalItems.clientsButton)
.wait(selectors.clientsIndex.createClientButton)
.parsedUrl()
.then(url => {
expect(url.hash).toEqual('#!/client/index');
});
});
it('should search again for the user Petter Parker', () => {
return nightmare
.wait(selectors.clientsIndex.searchResult)
.type(selectors.clientsIndex.searchClientInput, 'Petter Parker')
.click(selectors.clientsIndex.searchButton)
.waitForNumberOfElements(selectors.clientsIndex.searchResult, 1)
.countElement(selectors.clientsIndex.searchResult)
.then(result => {
expect(result).toEqual(1);
});
});
it(`should click on the search result to access to the Petter Parkers fiscal data`, () => {
return nightmare
.waitForTextInElement(selectors.clientsIndex.searchResult, 'Petter Parker')
.waitToClick(selectors.clientsIndex.searchResult)
.waitToClick(selectors.clientFiscalData.fiscalDataButton)
.waitForURL('fiscal-data')
.parsedUrl()
.then(url => {
expect(url.hash).toContain('fiscal-data');
});
});
it(`should click on the fiscal data button`, () => {
return nightmare
.waitToClick(selectors.clientFiscalData.fiscalDataButton)
.waitForURL('fiscal-data')
.parsedUrl()
.then(url => {
expect(url.hash).toContain('fiscal-data');
});
});
it('should confirm verified data button is enabled for administrative', () => {
return nightmare
.wait(selectors.clientFiscalData.verifiedDataCheckboxInput)
.evaluate(selector => {
return document.querySelector(selector).disabled;
}, selectors.clientFiscalData.verifiedDataCheckbox)
.then(result => {
expect(result).not.toBe(true);
});
});
it('should check the Verified data checkbox', () => {
return nightmare
.waitToClick(selectors.clientFiscalData.verifiedDataCheckboxInput)
.waitToClick(selectors.clientFiscalData.saveButton)
.waitForSnackbar()
.then(result => {
expect(result).toEqual(jasmine.arrayContaining(['Data saved!']));
});
});
it('should confirm Verified data checkbox is checked', () => {
return nightmare
.waitToClick(selectors.clientBasicData.basicDataButton)
.wait(selectors.clientBasicData.nameInput)
.waitToClick(selectors.clientFiscalData.fiscalDataButton)
.wait(selectors.clientFiscalData.verifiedDataCheckboxInput)
.evaluate(selector => {
return document.querySelector(selector).checked;
}, selectors.clientFiscalData.verifiedDataCheckboxInput)
.then(value => {
expect(value).toBeTruthy();
});
});
it('should again edit the social name', () => {
return nightmare
.wait(selectors.clientFiscalData.socialNameInput)
.clearInput(selectors.clientFiscalData.socialNameInput)
.type(selectors.clientFiscalData.socialNameInput, 'administrative was here')
.click(selectors.clientFiscalData.saveButton)
.waitForSnackbar()
.then(result => {
expect(result).toEqual(jasmine.arrayContaining(['Data saved!']));
});
});
it('should confirm the social name have been edited once and for all', () => {
return nightmare
.waitToClick(selectors.clientBasicData.basicDataButton)
.wait(selectors.clientBasicData.nameInput)
.waitToClick(selectors.clientFiscalData.fiscalDataButton)
.wait(selectors.clientFiscalData.socialNameInput)
.getInputValue(selectors.clientFiscalData.socialNameInput)
.then(result => {
expect(result).toEqual('administrative was here');
});
}); });
}); });
describe('as salesPerson second run', () => { it(`should click on the search result to access to the client's fiscal data`, () => {
beforeAll(() => { return nightmare
return nightmare .waitForTextInElement(selectors.clientsIndex.searchResult, 'Petter Parker')
.waitToClick(selectors.globalItems.logOutButton) .waitToClick(selectors.clientsIndex.searchResult)
.waitForLogin('salesPerson'); .waitToClick(selectors.clientFiscalData.fiscalDataButton)
}); .waitForURL('fiscal-data')
.parsedUrl()
it('should again click on the Clients button of the top bar menu', () => { .then(url => {
return nightmare expect(url.hash).toContain('fiscal-data');
.waitToClick(selectors.globalItems.applicationsMenuButton)
.wait(selectors.globalItems.applicationsMenuVisible)
.waitToClick(selectors.globalItems.clientsButton)
.wait(selectors.clientsIndex.createClientButton)
.parsedUrl()
.then(url => {
expect(url.hash).toEqual('#!/client/index');
});
});
it('should again search for the user Petter Parker', () => {
return nightmare
.wait(selectors.clientsIndex.searchResult)
.type(selectors.clientsIndex.searchClientInput, 'Petter Parker')
.click(selectors.clientsIndex.searchButton)
.waitForNumberOfElements(selectors.clientsIndex.searchResult, 1)
.countElement(selectors.clientsIndex.searchResult)
.then(result => {
expect(result).toEqual(1);
});
});
it(`should click on the search result to access to the client's fiscal data`, () => {
return nightmare
.waitForTextInElement(selectors.clientsIndex.searchResult, 'Petter Parker')
.waitToClick(selectors.clientsIndex.searchResult)
.waitToClick(selectors.clientFiscalData.fiscalDataButton)
.waitForURL('fiscal-data')
.parsedUrl()
.then(url => {
expect(url.hash).toContain('fiscal-data');
});
});
it(`should click on the fiscal data button to start editing`, () => {
return nightmare
.waitToClick(selectors.clientFiscalData.fiscalDataButton)
.waitForURL('fiscal-data')
.parsedUrl()
.then(url => {
expect(url.hash).toContain('fiscal-data');
});
});
it('should confirm verified data button is disabled once again for salesPerson', () => {
return nightmare
.wait(selectors.clientFiscalData.verifiedDataCheckboxInput)
.evaluate(selector => {
return document.querySelector(selector).disabled;
}, selectors.clientFiscalData.verifiedDataCheckbox)
.then(result => {
expect(result).toBe(true);
});
});
it('should confirm the form have been disabled for salesPerson', () => {
return nightmare
.wait(selectors.clientFiscalData.socialNameInput)
.evaluate(selector => {
return document.querySelector(selector).disabled;
}, 'vn-textfield[field="$ctrl.client.socialName"] input')
.then(result => {
expect(result).toEqual(true);
});
}); });
}); });
describe('as salesAssistant', () => { it(`should click on the fiscal data button to start editing`, () => {
beforeAll(() => { return nightmare
return nightmare .waitToClick(selectors.clientFiscalData.fiscalDataButton)
.waitToClick(selectors.globalItems.logOutButton) .waitForURL('fiscal-data')
.waitForLogin('salesAssistant'); .parsedUrl()
}); .then(url => {
expect(url.hash).toContain('fiscal-data');
it('should navigate to clients index', () => {
return nightmare
.waitToClick(selectors.globalItems.applicationsMenuButton)
.wait(selectors.globalItems.applicationsMenuVisible)
.waitToClick(selectors.globalItems.clientsButton)
.wait(selectors.clientsIndex.createClientButton)
.parsedUrl()
.then(url => {
expect(url.hash).toEqual('#!/client/index');
});
});
it('should search again for the user Petter Parker', () => {
return nightmare
.wait(selectors.clientsIndex.searchResult)
.type(selectors.clientsIndex.searchClientInput, 'Petter Parker')
.click(selectors.clientsIndex.searchButton)
.waitForNumberOfElements(selectors.clientsIndex.searchResult, 1)
.countElement(selectors.clientsIndex.searchResult)
.then(result => {
expect(result).toEqual(1);
});
});
it(`should click on the search result to access to the Petter Parkers fiscal data`, () => {
return nightmare
.waitForTextInElement(selectors.clientsIndex.searchResult, 'Petter Parker')
.waitToClick(selectors.clientsIndex.searchResult)
.waitToClick(selectors.clientFiscalData.fiscalDataButton)
.waitForURL('fiscal-data')
.parsedUrl()
.then(url => {
expect(url.hash).toContain('fiscal-data');
});
});
it(`should click on the fiscal data button`, () => {
return nightmare
.waitToClick(selectors.clientFiscalData.fiscalDataButton)
.waitForURL('fiscal-data')
.parsedUrl()
.then(url => {
expect(url.hash).toContain('fiscal-data');
});
});
it('should confirm verified data button is enabled for salesAssistant', () => {
return nightmare
.wait(selectors.clientFiscalData.verifiedDataCheckboxInput)
.evaluate(selector => {
return document.querySelector(selector).disabled;
}, selectors.clientFiscalData.verifiedDataCheckbox)
.then(result => {
expect(result).not.toBe(true);
});
});
it('should uncheck the Verified data checkbox', () => {
return nightmare
.waitToClick(selectors.clientFiscalData.verifiedDataCheckboxInput)
.waitToClick(selectors.clientFiscalData.saveButton)
.waitForSnackbar()
.then(result => {
expect(result).toEqual(jasmine.arrayContaining(['Data saved!']));
});
});
it('should confirm Verified data checkbox is unchecked', () => {
return nightmare
.waitToClick(selectors.clientBasicData.basicDataButton)
.wait(selectors.clientBasicData.nameInput)
.waitToClick(selectors.clientFiscalData.fiscalDataButton)
.wait(selectors.clientFiscalData.verifiedDataCheckboxInput)
.evaluate(selector => {
return document.querySelector(selector).checked;
}, selectors.clientFiscalData.verifiedDataCheckboxInput)
.then(value => {
expect(value).toBeFalsy();
});
});
it('should again edit the social name', () => {
return nightmare
.wait(selectors.clientFiscalData.socialNameInput)
.clearInput(selectors.clientFiscalData.socialNameInput)
.type(selectors.clientFiscalData.socialNameInput, 'salesAssistant was here')
.click(selectors.clientFiscalData.saveButton)
.waitForSnackbar()
.then(result => {
expect(result).toEqual(jasmine.arrayContaining(['Data saved!']));
});
});
it('should confirm the social name have been edited once and for all', () => {
return nightmare
.waitToClick(selectors.clientBasicData.basicDataButton)
.wait(selectors.clientBasicData.nameInput)
.waitToClick(selectors.clientFiscalData.fiscalDataButton)
.wait(selectors.clientFiscalData.socialNameInput)
.getInputValue(selectors.clientFiscalData.socialNameInput)
.then(result => {
expect(result).toEqual('salesAssistant was here');
});
}); });
}); });
describe('as salesPerson third run', () => { it('should confirm verified data button is disabled for salesPerson', () => {
beforeAll(() => { return nightmare
return nightmare .wait(selectors.clientFiscalData.verifiedDataCheckboxInput)
.waitToClick(selectors.globalItems.logOutButton) .evaluate(selector => {
.waitForLogin('salesPerson'); console.log(document.querySelector(selector));
return document.querySelector(selector).disabled;
}, selectors.clientFiscalData.verifiedDataCheckbox)
.then(result => {
expect(result).toBe(true);
}); });
});
it('should again click on the Clients button of the top bar menu', () => { it('should edit the social name', () => {
return nightmare return nightmare
.waitToClick(selectors.globalItems.applicationsMenuButton) .wait(selectors.clientFiscalData.socialNameInput)
.wait(selectors.globalItems.applicationsMenuVisible) .clearInput(selectors.clientFiscalData.socialNameInput)
.waitToClick(selectors.globalItems.clientsButton) .type(selectors.clientFiscalData.socialNameInput, 'salesPerson was here')
.wait(selectors.clientsIndex.createClientButton) .click(selectors.clientFiscalData.saveButton)
.parsedUrl() .waitForSnackbar()
.then(url => { .then(result => {
expect(url.hash).toEqual('#!/client/index'); expect(result).toEqual(jasmine.arrayContaining(['Data saved!']));
});
}); });
});
it('should once again search for the user Petter Parker', () => { it('should confirm the social name have been edited', () => {
return nightmare return nightmare
.wait(selectors.clientsIndex.searchResult) .waitToClick(selectors.clientBasicData.basicDataButton)
.type(selectors.clientsIndex.searchClientInput, 'Petter Parker') .wait(selectors.clientBasicData.nameInput)
.click(selectors.clientsIndex.searchButton) .waitToClick(selectors.clientFiscalData.fiscalDataButton)
.waitForNumberOfElements(selectors.clientsIndex.searchResult, 1) .wait(selectors.clientFiscalData.socialNameInput)
.countElement(selectors.clientsIndex.searchResult) .getInputValue(selectors.clientFiscalData.socialNameInput)
.then(result => { .then(result => {
expect(result).toEqual(1); expect(result).toEqual('salesPerson was here');
});
}); });
});
});
it(`should click on the search result to access to the client's fiscal data`, () => { describe('as administrative', () => {
return nightmare beforeAll(() => {
.waitForTextInElement(selectors.clientsIndex.searchResult, 'Petter Parker') return nightmare
.waitToClick(selectors.clientsIndex.searchResult) .waitToClick(selectors.globalItems.logOutButton)
.waitToClick(selectors.clientFiscalData.fiscalDataButton) .waitForLogin('administrative');
.waitForURL('fiscal-data') });
.parsedUrl()
.then(url => { it('should navigate to clients index', () => {
expect(url.hash).toContain('fiscal-data'); return nightmare
}); .waitToClick(selectors.globalItems.applicationsMenuButton)
.wait(selectors.globalItems.applicationsMenuVisible)
.waitToClick(selectors.globalItems.clientsButton)
.wait(selectors.clientsIndex.createClientButton)
.parsedUrl()
.then(url => {
expect(url.hash).toEqual('#!/client/index');
}); });
});
it(`should click on the fiscal data button to start editing`, () => { it('should search again for the user Petter Parker', () => {
return nightmare return nightmare
.waitToClick(selectors.clientFiscalData.fiscalDataButton) .wait(selectors.clientsIndex.searchResult)
.waitForURL('fiscal-data') .type(selectors.clientsIndex.searchClientInput, 'Petter Parker')
.parsedUrl() .click(selectors.clientsIndex.searchButton)
.then(url => { .waitForNumberOfElements(selectors.clientsIndex.searchResult, 1)
expect(url.hash).toContain('fiscal-data'); .countElement(selectors.clientsIndex.searchResult)
}); .then(result => {
expect(result).toEqual(1);
}); });
});
it('should confirm verified data button is enabled once again', () => { it(`should click on the search result to access to the Petter Parkers fiscal data`, () => {
return nightmare return nightmare
.wait(selectors.clientFiscalData.verifiedDataCheckboxInput) .waitForTextInElement(selectors.clientsIndex.searchResult, 'Petter Parker')
.evaluate(selector => { .waitToClick(selectors.clientsIndex.searchResult)
return document.querySelector(selector).disabled; .waitToClick(selectors.clientFiscalData.fiscalDataButton)
}, selectors.clientFiscalData.verifiedDataCheckbox) .waitForURL('fiscal-data')
.then(result => { .parsedUrl()
expect(result).toBe(true); .then(url => {
}); expect(url.hash).toContain('fiscal-data');
}); });
});
it('should confirm the form is enabled for salesPerson', () => { it(`should click on the fiscal data button`, () => {
return nightmare return nightmare
.wait(selectors.clientFiscalData.socialNameInput) .waitToClick(selectors.clientFiscalData.fiscalDataButton)
.evaluate(selector => { .waitForURL('fiscal-data')
return document.querySelector(selector).disabled; .parsedUrl()
}, 'vn-textfield[field="$ctrl.client.socialName"] > div') .then(url => {
.then(result => { expect(url.hash).toContain('fiscal-data');
expect(result).not.toBe(true); });
}); });
it('should confirm verified data button is enabled for administrative', () => {
return nightmare
.wait(selectors.clientFiscalData.verifiedDataCheckboxInput)
.evaluate(selector => {
return document.querySelector(selector).disabled;
}, selectors.clientFiscalData.verifiedDataCheckbox)
.then(result => {
expect(result).not.toBe(true);
});
});
it('should check the Verified data checkbox', () => {
return nightmare
.waitToClick(selectors.clientFiscalData.verifiedDataCheckboxInput)
.waitToClick(selectors.clientFiscalData.saveButton)
.waitForSnackbar()
.then(result => {
expect(result).toEqual(jasmine.arrayContaining(['Data saved!']));
});
});
it('should confirm Verified data checkbox is checked', () => {
return nightmare
.waitToClick(selectors.clientBasicData.basicDataButton)
.wait(selectors.clientBasicData.nameInput)
.waitToClick(selectors.clientFiscalData.fiscalDataButton)
.wait(selectors.clientFiscalData.verifiedDataCheckboxInput)
.evaluate(selector => {
return document.querySelector(selector).checked;
}, selectors.clientFiscalData.verifiedDataCheckboxInput)
.then(value => {
expect(value).toBeTruthy();
});
});
it('should again edit the social name', () => {
return nightmare
.wait(selectors.clientFiscalData.socialNameInput)
.clearInput(selectors.clientFiscalData.socialNameInput)
.type(selectors.clientFiscalData.socialNameInput, 'administrative was here')
.click(selectors.clientFiscalData.saveButton)
.waitForSnackbar()
.then(result => {
expect(result).toEqual(jasmine.arrayContaining(['Data saved!']));
});
});
it('should confirm the social name have been edited once and for all', () => {
return nightmare
.waitToClick(selectors.clientBasicData.basicDataButton)
.wait(selectors.clientBasicData.nameInput)
.waitToClick(selectors.clientFiscalData.fiscalDataButton)
.wait(selectors.clientFiscalData.socialNameInput)
.getInputValue(selectors.clientFiscalData.socialNameInput)
.then(result => {
expect(result).toEqual('administrative was here');
});
});
});
describe('as salesPerson second run', () => {
beforeAll(() => {
return nightmare
.waitToClick(selectors.globalItems.logOutButton)
.waitForLogin('salesPerson');
});
it('should again click on the Clients button of the top bar menu', () => {
return nightmare
.waitToClick(selectors.globalItems.applicationsMenuButton)
.wait(selectors.globalItems.applicationsMenuVisible)
.waitToClick(selectors.globalItems.clientsButton)
.wait(selectors.clientsIndex.createClientButton)
.parsedUrl()
.then(url => {
expect(url.hash).toEqual('#!/client/index');
});
});
it('should again search for the user Petter Parker', () => {
return nightmare
.wait(selectors.clientsIndex.searchResult)
.type(selectors.clientsIndex.searchClientInput, 'Petter Parker')
.click(selectors.clientsIndex.searchButton)
.waitForNumberOfElements(selectors.clientsIndex.searchResult, 1)
.countElement(selectors.clientsIndex.searchResult)
.then(result => {
expect(result).toEqual(1);
});
});
it(`should click on the search result to access to the client's fiscal data`, () => {
return nightmare
.waitForTextInElement(selectors.clientsIndex.searchResult, 'Petter Parker')
.waitToClick(selectors.clientsIndex.searchResult)
.waitToClick(selectors.clientFiscalData.fiscalDataButton)
.waitForURL('fiscal-data')
.parsedUrl()
.then(url => {
expect(url.hash).toContain('fiscal-data');
});
});
it(`should click on the fiscal data button to start editing`, () => {
return nightmare
.waitToClick(selectors.clientFiscalData.fiscalDataButton)
.waitForURL('fiscal-data')
.parsedUrl()
.then(url => {
expect(url.hash).toContain('fiscal-data');
});
});
it('should confirm verified data button is disabled once again for salesPerson', () => {
return nightmare
.wait(selectors.clientFiscalData.verifiedDataCheckboxInput)
.evaluate(selector => {
return document.querySelector(selector).disabled;
}, selectors.clientFiscalData.verifiedDataCheckbox)
.then(result => {
expect(result).toBe(true);
});
});
it('should confirm the form have been disabled for salesPerson', () => {
return nightmare
.wait(selectors.clientFiscalData.socialNameInput)
.evaluate(selector => {
return document.querySelector(selector).disabled;
}, 'vn-textfield[field="$ctrl.client.socialName"] input')
.then(result => {
expect(result).toEqual(true);
});
});
});
describe('as salesAssistant', () => {
beforeAll(() => {
return nightmare
.waitToClick(selectors.globalItems.logOutButton)
.waitForLogin('salesAssistant');
});
it('should navigate to clients index', () => {
return nightmare
.waitToClick(selectors.globalItems.applicationsMenuButton)
.wait(selectors.globalItems.applicationsMenuVisible)
.waitToClick(selectors.globalItems.clientsButton)
.wait(selectors.clientsIndex.createClientButton)
.parsedUrl()
.then(url => {
expect(url.hash).toEqual('#!/client/index');
});
});
it('should search again for the user Petter Parker', () => {
return nightmare
.wait(selectors.clientsIndex.searchResult)
.type(selectors.clientsIndex.searchClientInput, 'Petter Parker')
.click(selectors.clientsIndex.searchButton)
.waitForNumberOfElements(selectors.clientsIndex.searchResult, 1)
.countElement(selectors.clientsIndex.searchResult)
.then(result => {
expect(result).toEqual(1);
});
});
it(`should click on the search result to access to the Petter Parkers fiscal data`, () => {
return nightmare
.waitForTextInElement(selectors.clientsIndex.searchResult, 'Petter Parker')
.waitToClick(selectors.clientsIndex.searchResult)
.waitToClick(selectors.clientFiscalData.fiscalDataButton)
.waitForURL('fiscal-data')
.parsedUrl()
.then(url => {
expect(url.hash).toContain('fiscal-data');
});
});
it(`should click on the fiscal data button`, () => {
return nightmare
.waitToClick(selectors.clientFiscalData.fiscalDataButton)
.waitForURL('fiscal-data')
.parsedUrl()
.then(url => {
expect(url.hash).toContain('fiscal-data');
});
});
it('should confirm verified data button is enabled for salesAssistant', () => {
return nightmare
.wait(selectors.clientFiscalData.verifiedDataCheckboxInput)
.evaluate(selector => {
return document.querySelector(selector).disabled;
}, selectors.clientFiscalData.verifiedDataCheckbox)
.then(result => {
expect(result).not.toBe(true);
});
});
it('should uncheck the Verified data checkbox', () => {
return nightmare
.waitToClick(selectors.clientFiscalData.verifiedDataCheckboxInput)
.waitToClick(selectors.clientFiscalData.saveButton)
.waitForSnackbar()
.then(result => {
expect(result).toEqual(jasmine.arrayContaining(['Data saved!']));
});
});
it('should confirm Verified data checkbox is unchecked', () => {
return nightmare
.waitToClick(selectors.clientBasicData.basicDataButton)
.wait(selectors.clientBasicData.nameInput)
.waitToClick(selectors.clientFiscalData.fiscalDataButton)
.wait(selectors.clientFiscalData.verifiedDataCheckboxInput)
.evaluate(selector => {
return document.querySelector(selector).checked;
}, selectors.clientFiscalData.verifiedDataCheckboxInput)
.then(value => {
expect(value).toBeFalsy();
});
});
it('should again edit the social name', () => {
return nightmare
.wait(selectors.clientFiscalData.socialNameInput)
.clearInput(selectors.clientFiscalData.socialNameInput)
.type(selectors.clientFiscalData.socialNameInput, 'salesAssistant was here')
.click(selectors.clientFiscalData.saveButton)
.waitForSnackbar()
.then(result => {
expect(result).toEqual(jasmine.arrayContaining(['Data saved!']));
});
});
it('should confirm the social name have been edited once and for all', () => {
return nightmare
.waitToClick(selectors.clientBasicData.basicDataButton)
.wait(selectors.clientBasicData.nameInput)
.waitToClick(selectors.clientFiscalData.fiscalDataButton)
.wait(selectors.clientFiscalData.socialNameInput)
.getInputValue(selectors.clientFiscalData.socialNameInput)
.then(result => {
expect(result).toEqual('salesAssistant was here');
});
});
});
describe('as salesPerson third run', () => {
beforeAll(() => {
return nightmare
.waitToClick(selectors.globalItems.logOutButton)
.waitForLogin('salesPerson');
});
it('should again click on the Clients button of the top bar menu', () => {
return nightmare
.waitToClick(selectors.globalItems.applicationsMenuButton)
.wait(selectors.globalItems.applicationsMenuVisible)
.waitToClick(selectors.globalItems.clientsButton)
.wait(selectors.clientsIndex.createClientButton)
.parsedUrl()
.then(url => {
expect(url.hash).toEqual('#!/client/index');
});
});
it('should once again search for the user Petter Parker', () => {
return nightmare
.wait(selectors.clientsIndex.searchResult)
.type(selectors.clientsIndex.searchClientInput, 'Petter Parker')
.click(selectors.clientsIndex.searchButton)
.waitForNumberOfElements(selectors.clientsIndex.searchResult, 1)
.countElement(selectors.clientsIndex.searchResult)
.then(result => {
expect(result).toEqual(1);
});
});
it(`should click on the search result to access to the client's fiscal data`, () => {
return nightmare
.waitForTextInElement(selectors.clientsIndex.searchResult, 'Petter Parker')
.waitToClick(selectors.clientsIndex.searchResult)
.waitToClick(selectors.clientFiscalData.fiscalDataButton)
.waitForURL('fiscal-data')
.parsedUrl()
.then(url => {
expect(url.hash).toContain('fiscal-data');
});
});
it(`should click on the fiscal data button to start editing`, () => {
return nightmare
.waitToClick(selectors.clientFiscalData.fiscalDataButton)
.waitForURL('fiscal-data')
.parsedUrl()
.then(url => {
expect(url.hash).toContain('fiscal-data');
});
});
it('should confirm verified data button is enabled once again', () => {
return nightmare
.wait(selectors.clientFiscalData.verifiedDataCheckboxInput)
.evaluate(selector => {
return document.querySelector(selector).disabled;
}, selectors.clientFiscalData.verifiedDataCheckbox)
.then(result => {
expect(result).toBe(true);
});
});
it('should confirm the form is enabled for salesPerson', () => {
return nightmare
.wait(selectors.clientFiscalData.socialNameInput)
.evaluate(selector => {
return document.querySelector(selector).disabled;
}, 'vn-textfield[field="$ctrl.client.socialName"] > div')
.then(result => {
expect(result).not.toBe(true);
}); });
}); });
}); });