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

97 lines
3.7 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
describe('Add address notes path', () => {
const nightmare = createNightmare();
2017-12-15 09:07:52 +00:00
beforeAll(() => {
return nightmare
.waitForLogin('developer');
});
it('should click on the Clients button of the top bar menu', () => {
return nightmare
2017-12-15 09:07:52 +00:00
.waitToClick(selectors.globalItems.applicationsMenuButton)
.wait(selectors.globalItems.applicationsMenuVisible)
.waitToClick(selectors.globalItems.clientsButton)
.wait(selectors.clientsIndex.createClientButton)
.parsedUrl()
2017-12-15 09:07:52 +00:00
.then(url => {
expect(url.hash).toEqual('#!/clients');
});
2017-12-15 09:07:52 +00:00
});
it('should search for the user Petter Parker', () => {
return nightmare
2017-12-15 09:07:52 +00:00
.wait(selectors.clientsIndex.searchResult)
.type(selectors.clientsIndex.searchClientInput, 'Petter Parker')
2017-12-15 09:07:52 +00:00
.click(selectors.clientsIndex.searchButton)
.waitForNumberOfElements(selectors.clientsIndex.searchResult, 1)
.countSearchResults(selectors.clientsIndex.searchResult)
.then(result => {
expect(result).toEqual(1);
});
2017-12-15 09:07:52 +00:00
});
it(`should click on the search result to access to the client addresses`, () => {
return nightmare
.waitForTextInElement(selectors.clientsIndex.searchResult, 'Petter Parker')
2017-12-15 09:07:52 +00:00
.waitToClick(selectors.clientsIndex.searchResult)
.waitToClick(selectors.clientAddresses.addressesButton)
.waitForURL('addresses/list')
2017-12-15 09:07:52 +00:00
.url()
.then(url => {
expect(url).toContain('addresses/list');
});
2017-12-15 09:07:52 +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')
2017-12-15 11:51:06 +00:00
.url()
2017-12-15 09:07:52 +00:00
.then(result => {
expect(result).toContain('/edit');
});
2017-12-15 09:07:52 +00:00
});
it('should not save a description without observation type', () => {
return nightmare
.wait(selectors.clientAddresses.firstObservationDescriptionInput)
.type(selectors.clientAddresses.firstObservationDescriptionInput, 'first description')
.waitToClick(selectors.clientAddresses.saveButton)
.waitForSnackbar()
.then(result => {
expect(result).toContain('No changes to save');
});
});
it('should not save an observation type without description type', () => {
return nightmare
.clearInput(selectors.clientAddresses.firstObservationDescriptionInput)
.waitToClick(selectors.clientAddresses.firstObservationTypeSelect)
.waitToClick(selectors.clientAddresses.firstObservationTypeSelectOptionOne)
.waitForTextInInput(selectors.clientAddresses.firstObservationTypeSelect, 'observation one')
.waitToClick(selectors.clientAddresses.saveButton)
.waitForSnackbar()
.then(result => {
expect(result).toContain('No changes to save');
});
});
it('should show an error if there are empty fields', () => {
return nightmare
.type(selectors.clientAddresses.firstObservationDescriptionInput, 'first description')
.waitToClick(selectors.clientAddresses.addAddressNoteButton)
.wait(selectors.clientAddresses.secondObservationDescriptionInput)
.type(selectors.clientAddresses.secondObservationDescriptionInput, 'second description')
.waitToClick(selectors.clientAddresses.saveButton)
.waitForSnackbar()
.then(result => {
expect(result).toContain('No changes to save');
});
});
2017-12-15 09:07:52 +00:00
});