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

56 lines
2.3 KiB
JavaScript
Raw Normal View History

import selectors from '../../helpers/selectors.js';
2019-12-12 07:37:35 +00:00
import openPage from '../../helpers/puppeteer';
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
.loginAndModule('employee', 'client')
.accessToSearchResult('Petter Parker')
.accessToSection('client.card.address.index');
2018-09-05 06:27:50 +00:00
});
2017-12-15 09:07:52 +00:00
2019-01-07 08:33:07 +00:00
it(`should click on the edit icon of the default address`, async() => {
2018-10-30 07:51:18 +00:00
const url = await nightmare
.waitForTextInElement(selectors.clientAddresses.defaultAddress, '20 Ingram Street')
2019-09-02 07:25:18 +00:00
.waitToClick(selectors.clientAddresses.firstEditAddress)
2018-10-30 07:51:18 +00:00
.waitForURL('/edit')
.parsedUrl();
2018-10-30 07:51:18 +00:00
expect(url.hash).toContain('/edit');
2018-09-05 06:27:50 +00:00
});
2017-12-15 09:07:52 +00:00
2019-01-07 08:33:07 +00:00
it('should not save a description without observation type', async() => {
2018-10-30 07:51:18 +00:00
const result = await nightmare
.waitToClick(selectors.clientAddresses.addObservationButton)
2019-01-23 14:33:25 +00:00
.write(selectors.clientAddresses.firstObservationDescriptionInput, 'first description')
2018-10-30 07:51:18 +00:00
.waitToClick(selectors.clientAddresses.saveButton)
.waitForLastSnackbar();
2019-11-12 07:51:50 +00:00
expect(result).toEqual('Some fields are invalid');
2018-09-05 06:27:50 +00:00
});
2019-01-07 08:33:07 +00:00
it('should not save an observation type without description', async() => {
2018-10-30 07:51:18 +00:00
const result = await nightmare
.clearInput(selectors.clientAddresses.firstObservationDescriptionInput)
2019-01-07 08:33:07 +00:00
.autocompleteSearch(selectors.clientAddresses.firstObservationTypeAutocomplete, 'comercial')
2018-10-30 07:51:18 +00:00
.waitToClick(selectors.clientAddresses.saveButton)
.waitForLastSnackbar();
expect(result).toEqual('Some fields are invalid');
2018-09-05 06:27:50 +00:00
});
2019-01-07 08:33:07 +00:00
it('should create two new observations', async() => {
2018-10-30 07:51:18 +00:00
const result = await nightmare
2019-01-23 14:33:25 +00:00
.write(selectors.clientAddresses.firstObservationDescriptionInput, 'first description')
2018-10-30 07:51:18 +00:00
.waitToClick(selectors.clientAddresses.addObservationButton)
2019-01-07 08:33:07 +00:00
.autocompleteSearch(selectors.clientAddresses.secondObservationTypeAutocomplete, 'observation one')
2019-01-23 14:33:25 +00:00
.write(selectors.clientAddresses.secondObservationDescriptionInput, 'second description')
2018-10-30 07:51:18 +00:00
.waitToClick(selectors.clientAddresses.saveButton)
.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
});