2018-04-06 16:40:24 +00:00
|
|
|
import selectors from '../../helpers/selectors.js';
|
2018-10-24 08:57:14 +00:00
|
|
|
import createNightmare from '../../helpers/nightmare';
|
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(() => {
|
2018-11-20 13:22:00 +00:00
|
|
|
nightmare
|
2018-10-30 07:51:18 +00:00
|
|
|
.waitForLogin('employee');
|
2018-09-05 06:27:50 +00:00
|
|
|
});
|
2018-03-02 11:15:17 +00:00
|
|
|
|
2018-10-30 07:51:18 +00:00
|
|
|
it('should click on the Clients button of the top bar menu', async () => {
|
|
|
|
const url = await nightmare
|
|
|
|
.waitToClick(selectors.globalItems.applicationsMenuButton)
|
|
|
|
.wait(selectors.globalItems.applicationsMenuVisible)
|
|
|
|
.waitToClick(selectors.globalItems.clientsButton)
|
|
|
|
.wait(selectors.clientsIndex.createClientButton)
|
|
|
|
.parsedUrl();
|
|
|
|
|
|
|
|
expect(url.hash).toEqual('#!/client/index');
|
2018-09-05 06:27:50 +00:00
|
|
|
});
|
2017-12-15 09:07:52 +00:00
|
|
|
|
2018-10-30 07:51:18 +00:00
|
|
|
it('should search for the user Petter Parker', async () => {
|
|
|
|
const resultCount = await nightmare
|
|
|
|
.wait(selectors.clientsIndex.searchResult)
|
|
|
|
.type(selectors.clientsIndex.searchClientInput, 'Petter Parker')
|
|
|
|
.click(selectors.clientsIndex.searchButton)
|
|
|
|
.waitForNumberOfElements(selectors.clientsIndex.searchResult, 1)
|
|
|
|
.countElement(selectors.clientsIndex.searchResult);
|
|
|
|
|
|
|
|
expect(resultCount).toEqual(1);
|
2018-09-05 06:27:50 +00:00
|
|
|
});
|
2017-12-15 09:07:52 +00:00
|
|
|
|
2018-10-30 07:51:18 +00:00
|
|
|
it(`should click on the search result to access to the client addresses`, async () => {
|
|
|
|
const url = await nightmare
|
|
|
|
.waitForTextInElement(selectors.clientsIndex.searchResult, 'Petter Parker')
|
|
|
|
.waitToClick(selectors.clientsIndex.searchResult)
|
|
|
|
.waitToClick(selectors.clientAddresses.addressesButton)
|
|
|
|
.waitForURL('address/index')
|
|
|
|
.url();
|
|
|
|
|
|
|
|
expect(url).toContain('address/index');
|
2018-09-05 06:27:50 +00:00
|
|
|
});
|
2017-12-15 09:07:52 +00:00
|
|
|
|
2018-10-30 07:51:18 +00:00
|
|
|
it(`should click on the edit icon of the default address`, async () => {
|
|
|
|
const url = await nightmare
|
|
|
|
.waitForTextInElement(selectors.clientAddresses.defaultAddress, '20 Ingram Street')
|
|
|
|
.waitToClick(selectors.clientAddresses.firstEditButton)
|
|
|
|
.waitForURL('/edit')
|
|
|
|
.url();
|
|
|
|
|
|
|
|
expect(url).toContain('/edit');
|
2018-09-05 06:27:50 +00:00
|
|
|
});
|
2017-12-15 09:07:52 +00:00
|
|
|
|
2018-10-30 07:51:18 +00:00
|
|
|
it('should not save a description without observation type', async () => {
|
|
|
|
const result = await nightmare
|
|
|
|
.waitToClick(selectors.clientAddresses.addObservationButton)
|
|
|
|
.wait(selectors.clientAddresses.firstObservationDescriptionInput)
|
|
|
|
.type(selectors.clientAddresses.firstObservationDescriptionInput, 'first description')
|
|
|
|
.waitToClick(selectors.clientAddresses.saveButton)
|
|
|
|
.waitForLastSnackbar();
|
|
|
|
|
|
|
|
expect(result).toEqual('Observation type cannot be blank');
|
2018-09-05 06:27:50 +00:00
|
|
|
});
|
2018-02-26 15:06:49 +00:00
|
|
|
|
2018-10-30 07:51:18 +00:00
|
|
|
it('should not save an observation type without description', async () => {
|
|
|
|
const result = await nightmare
|
|
|
|
.clearInput(selectors.clientAddresses.firstObservationDescriptionInput)
|
|
|
|
.waitToClick(selectors.clientAddresses.firstObservationTypeSelect)
|
|
|
|
.waitToClick(selectors.clientAddresses.firstObservationTypeSelectOptionOne)
|
|
|
|
.waitToClick(selectors.clientAddresses.saveButton)
|
|
|
|
.waitForLastSnackbar();
|
|
|
|
|
|
|
|
expect(result).toEqual('Some fields are invalid');
|
2018-09-05 06:27:50 +00:00
|
|
|
});
|
2018-02-26 15:06:49 +00:00
|
|
|
|
2018-10-30 07:51:18 +00:00
|
|
|
it('should create two new observations', async () => {
|
|
|
|
const result = await 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();
|
|
|
|
|
|
|
|
expect(result).toEqual('Data saved!');
|
2018-04-06 16:40:24 +00:00
|
|
|
});
|
|
|
|
});
|