salix/e2e/paths/client-module/06_add_address_notes.spec.js

104 lines
4.0 KiB
JavaScript
Raw Normal View History

import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/helpers';
2017-12-15 09:07:52 +00:00
2018-09-05 06:27:50 +00:00
describe('Client add address notes path', () => {
const nightmare = createNightmare();
2017-12-15 09:07:52 +00:00
2018-09-05 06:27:50 +00:00
beforeAll(() => {
return nightmare
2018-10-11 07:14:26 +00:00
.waitForLogin('employee');
2018-09-05 06:27:50 +00:00
});
2018-10-22 15:12:41 +00:00
it('should click on the Clients button of the top bar menu', done => {
2018-09-05 06:27:50 +00:00
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');
2018-10-22 15:12:41 +00:00
done();
}).catch(done.fail);
2018-09-05 06:27:50 +00:00
});
2017-12-15 09:07:52 +00:00
2018-10-22 15:12:41 +00:00
it('should search for the user Petter Parker', done => {
2018-09-05 06:27:50 +00:00
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);
2018-10-22 15:12:41 +00:00
done();
}).catch(done.fail);
2018-09-05 06:27:50 +00:00
});
2017-12-15 09:07:52 +00:00
2018-10-22 15:12:41 +00:00
it(`should click on the search result to access to the client addresses`, done => {
2018-09-05 06:27:50 +00:00
return nightmare
.waitForTextInElement(selectors.clientsIndex.searchResult, 'Petter Parker')
.waitToClick(selectors.clientsIndex.searchResult)
.waitToClick(selectors.clientAddresses.addressesButton)
.waitForURL('address/index')
.url()
.then(url => {
expect(url).toContain('address/index');
2018-10-22 15:12:41 +00:00
done();
}).catch(done.fail);
2018-09-05 06:27:50 +00:00
});
2017-12-15 09:07:52 +00:00
2018-10-22 15:12:41 +00:00
it(`should click on the edit icon of the default address`, done => {
2018-09-05 06:27:50 +00:00
return nightmare
.waitForTextInElement(selectors.clientAddresses.defaultAddress, '20 Ingram Street')
.waitToClick(selectors.clientAddresses.firstEditButton)
.waitForURL('/edit')
.url()
.then(result => {
expect(result).toContain('/edit');
2018-10-22 15:12:41 +00:00
done();
}).catch(done.fail);
2018-09-05 06:27:50 +00:00
});
2017-12-15 09:07:52 +00:00
2018-10-22 15:12:41 +00:00
it('should not save a description without observation type', done => {
2018-09-05 06:27:50 +00:00
return nightmare
.waitToClick(selectors.clientAddresses.addObservationButton)
.wait(selectors.clientAddresses.firstObservationDescriptionInput)
.type(selectors.clientAddresses.firstObservationDescriptionInput, 'first description')
.waitToClick(selectors.clientAddresses.saveButton)
.waitForLastSnackbar()
2018-09-05 06:27:50 +00:00
.then(result => {
expect(result).toEqual('Observation type cannot be blank');
2018-10-22 15:12:41 +00:00
done();
}).catch(done.fail);
2018-09-05 06:27:50 +00:00
});
2018-10-22 15:12:41 +00:00
it('should not save an observation type without description', done => {
2018-09-05 06:27:50 +00:00
return nightmare
.clearInput(selectors.clientAddresses.firstObservationDescriptionInput)
.waitToClick(selectors.clientAddresses.firstObservationTypeSelect)
.waitToClick(selectors.clientAddresses.firstObservationTypeSelectOptionOne)
.waitToClick(selectors.clientAddresses.saveButton)
.waitForLastSnackbar()
2018-09-05 06:27:50 +00:00
.then(result => {
expect(result).toEqual('Some fields are invalid');
2018-10-22 15:12:41 +00:00
done();
}).catch(done.fail);
2018-09-05 06:27:50 +00:00
});
2018-10-22 15:12:41 +00:00
it('should create two new observations', done => {
2018-09-05 06:27:50 +00:00
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)
.waitForLastSnackbar()
2018-09-05 06:27:50 +00:00
.then(result => {
expect(result).toEqual('Data saved!');
2018-10-22 15:12:41 +00:00
done();
}).catch(done.fail);
});
});