2018-04-06 16:40:24 +00:00
|
|
|
import selectors from '../../helpers/selectors.js';
|
|
|
|
import createNightmare from '../../helpers/helpers';
|
2017-12-15 09:07:52 +00:00
|
|
|
|
2018-04-06 16:40:24 +00:00
|
|
|
describe('Client', () => {
|
|
|
|
describe('Add address notes path', () => {
|
|
|
|
const nightmare = createNightmare();
|
2017-12-15 09:07:52 +00:00
|
|
|
|
2018-04-06 16:40:24 +00:00
|
|
|
beforeAll(() => {
|
|
|
|
return nightmare
|
|
|
|
.waitForLogin('developer');
|
|
|
|
});
|
2018-03-02 11:15:17 +00:00
|
|
|
|
2018-04-06 16:40:24 +00:00
|
|
|
it('should 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 => {
|
2018-05-23 12:26:51 +00:00
|
|
|
expect(url.hash).toEqual('#!/client/index');
|
2018-04-06 16:40:24 +00:00
|
|
|
});
|
|
|
|
});
|
2017-12-15 09:07:52 +00:00
|
|
|
|
2018-04-06 16:40:24 +00:00
|
|
|
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)
|
2018-08-02 12:04:46 +00:00
|
|
|
.countElement(selectors.clientsIndex.searchResult)
|
2018-04-06 16:40:24 +00:00
|
|
|
.then(result => {
|
|
|
|
expect(result).toEqual(1);
|
|
|
|
});
|
|
|
|
});
|
2017-12-15 09:07:52 +00:00
|
|
|
|
2018-04-06 16:40:24 +00:00
|
|
|
it(`should click on the search result to access to the client addresses`, () => {
|
|
|
|
return nightmare
|
|
|
|
.waitForTextInElement(selectors.clientsIndex.searchResult, 'Petter Parker')
|
|
|
|
.waitToClick(selectors.clientsIndex.searchResult)
|
|
|
|
.waitToClick(selectors.clientAddresses.addressesButton)
|
2018-05-23 12:26:51 +00:00
|
|
|
.waitForURL('address/index')
|
2018-04-06 16:40:24 +00:00
|
|
|
.url()
|
|
|
|
.then(url => {
|
2018-05-23 12:26:51 +00:00
|
|
|
expect(url).toContain('address/index');
|
2018-04-06 16:40:24 +00:00
|
|
|
});
|
|
|
|
});
|
2017-12-15 09:07:52 +00:00
|
|
|
|
2018-04-06 16:40:24 +00:00
|
|
|
it(`should click on the edit icon of the default address`, () => {
|
|
|
|
return nightmare
|
|
|
|
.waitForTextInElement(selectors.clientAddresses.defaultAddress, '20 Ingram Street')
|
|
|
|
.waitToClick(selectors.clientAddresses.firstEditButton)
|
|
|
|
.waitForURL('/edit')
|
|
|
|
.url()
|
|
|
|
.then(result => {
|
|
|
|
expect(result).toContain('/edit');
|
|
|
|
});
|
|
|
|
});
|
2017-12-15 09:07:52 +00:00
|
|
|
|
2018-04-06 16:40:24 +00:00
|
|
|
it('should not save a description without observation type', () => {
|
|
|
|
return nightmare
|
|
|
|
.waitToClick(selectors.clientAddresses.addObservationButton)
|
|
|
|
.wait(selectors.clientAddresses.firstObservationDescriptionInput)
|
|
|
|
.type(selectors.clientAddresses.firstObservationDescriptionInput, 'first description')
|
|
|
|
.waitToClick(selectors.clientAddresses.saveButton)
|
|
|
|
.waitForSnackbar()
|
|
|
|
.then(result => {
|
2018-07-06 14:32:23 +00:00
|
|
|
expect(result).toEqual(jasmine.arrayContaining(['Observation type cannot be blank']));
|
2018-04-06 16:40:24 +00:00
|
|
|
});
|
|
|
|
});
|
2018-02-26 15:06:49 +00:00
|
|
|
|
2018-04-06 16:40:24 +00:00
|
|
|
it('should not save an observation type without description', () => {
|
|
|
|
return nightmare
|
|
|
|
.clearInput(selectors.clientAddresses.firstObservationDescriptionInput)
|
|
|
|
.waitToClick(selectors.clientAddresses.firstObservationTypeSelect)
|
|
|
|
.waitToClick(selectors.clientAddresses.firstObservationTypeSelectOptionOne)
|
|
|
|
.waitToClick(selectors.clientAddresses.saveButton)
|
|
|
|
.waitForSnackbar()
|
|
|
|
.then(result => {
|
2018-06-19 06:12:36 +00:00
|
|
|
expect(result).toEqual(jasmine.arrayContaining(['Some fields are invalid']));
|
2018-04-06 16:40:24 +00:00
|
|
|
});
|
|
|
|
});
|
2018-02-26 15:06:49 +00:00
|
|
|
|
2018-04-06 16:40:24 +00:00
|
|
|
it('should create two new observations', () => {
|
|
|
|
return nightmare
|
|
|
|
.type(selectors.clientAddresses.firstObservationDescriptionInput, 'first description')
|
|
|
|
.waitToClick(selectors.clientAddresses.addObservationButton)
|
|
|
|
.waitToClick(selectors.clientAddresses.secondObservationTypeSelect)
|
|
|
|
.waitToClick(selectors.clientAddresses.secondObservationTypeSelectOptionTwo)
|
|
|
|
.type(selectors.clientAddresses.secondObservationDescriptionInput, 'second description')
|
|
|
|
.waitToClick(selectors.clientAddresses.saveButton)
|
|
|
|
.waitForSnackbar()
|
|
|
|
.then(result => {
|
2018-06-19 06:12:36 +00:00
|
|
|
expect(result).toEqual(jasmine.arrayContaining(['Data saved!']));
|
2018-04-06 16:40:24 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2018-02-26 15:06:49 +00:00
|
|
|
|