import selectors from '../../helpers/selectors.js'; import openPage from '../../helpers/puppeteer'; describe('Client add address notes path', () => { const nightmare = createNightmare(); beforeAll(() => { nightmare .loginAndModule('employee', 'client') .accessToSearchResult('Petter Parker') .accessToSection('client.card.address.index'); }); 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.firstEditAddress) .waitForURL('/edit') .parsedUrl(); expect(url.hash).toContain('/edit'); }); it('should not save a description without observation type', async() => { const result = await nightmare .waitToClick(selectors.clientAddresses.addObservationButton) .write(selectors.clientAddresses.firstObservationDescriptionInput, 'first description') .waitToClick(selectors.clientAddresses.saveButton) .waitForLastSnackbar(); expect(result).toEqual('Some fields are invalid'); }); it('should not save an observation type without description', async() => { const result = await nightmare .clearInput(selectors.clientAddresses.firstObservationDescriptionInput) .autocompleteSearch(selectors.clientAddresses.firstObservationTypeAutocomplete, 'comercial') .waitToClick(selectors.clientAddresses.saveButton) .waitForLastSnackbar(); expect(result).toEqual('Some fields are invalid'); }); it('should create two new observations', async() => { const result = await nightmare .write(selectors.clientAddresses.firstObservationDescriptionInput, 'first description') .waitToClick(selectors.clientAddresses.addObservationButton) .autocompleteSearch(selectors.clientAddresses.secondObservationTypeAutocomplete, 'observation one') .write(selectors.clientAddresses.secondObservationDescriptionInput, 'second description') .waitToClick(selectors.clientAddresses.saveButton) .waitForLastSnackbar(); expect(result).toEqual('Data saved!'); }); });