import selectors from '../../helpers/selectors.js'; import openPage from '../../helpers/puppeteer'; describe('Client add address notes path', () => { let page; beforeAll(async() => { page = await openPage(); await page.loginAndModule('employee', 'client'); await page.accessToSearchResult('Petter Parker'); await page.accessToSection('client.card.address.index'); }); afterAll(async() => { page.close(); }); it(`should click on the edit icon of the default address`, async() => { await page.waitForTextInElement(selectors.clientAddresses.defaultAddress, '20 Ingram Street'); await page.waitToClick(selectors.clientAddresses.firstEditAddress); await page.waitForURL('/edit'); const url = await page.parsedUrl(); expect(url.hash).toContain('/edit'); }); it('should not save a description without observation type', async() => { await page.waitToClick(selectors.clientAddresses.addObservationButton); await page.write(selectors.clientAddresses.firstObservationDescriptionInput, 'first description'); await page.waitToClick(selectors.clientAddresses.saveButton); const result = await page.waitForLastSnackbar(); expect(result).toEqual('Some fields are invalid'); }); it('should not save an observation type without description', async() => { await page.clearInput(selectors.clientAddresses.firstObservationDescriptionInput); await page.autocompleteSearch(selectors.clientAddresses.firstObservationTypeAutocomplete, 'comercial'); await page.waitToClick(selectors.clientAddresses.saveButton); const result = await page.waitForLastSnackbar(); expect(result).toEqual('Some fields are invalid'); }); it('should create two new observations', async() => { await page.write(selectors.clientAddresses.firstObservationDescriptionInput, 'first description'); await page.waitToClick(selectors.clientAddresses.addObservationButton); await page.autocompleteSearch(selectors.clientAddresses.secondObservationTypeAutocomplete, 'observation one'); await page.write(selectors.clientAddresses.secondObservationDescriptionInput, 'second description'); await page.waitToClick(selectors.clientAddresses.saveButton); const result = await page.waitForLastSnackbar(); expect(result).toEqual('Data saved!'); }); });