import selectors from '../../helpers/selectors.js'; import getBrowser from '../../helpers/puppeteer'; describe('Client defaulter path', () => { let browser; let page; beforeAll(async() => { browser = await getBrowser(); page = browser.page; await page.loginAndModule('insurance', 'client'); await page.accessToSection('client.defaulter'); }); afterAll(async() => { await browser.close(); }); it('should count the amount of clients in the turns section', async() => { const result = await page.countElement(selectors.clientDefaulter.anyClient); expect(result).toEqual(5); }); it('should check contain expected client', async() => { const clientName = await page.waitToGetProperty(selectors.clientDefaulter.firstClientName, 'innerText'); const salesPersonName = await page.waitToGetProperty(selectors.clientDefaulter.firstSalesPersonName, 'innerText'); expect(clientName).toEqual('Bruce Banner'); expect(salesPersonName).toEqual('developer'); }); it('should first observation not changed', async() => { const expectedObservation = 'Meeting with Black Widow 21st 9am'; const result = await page.waitToGetProperty(selectors.clientDefaulter.firstObservation, 'value'); expect(result).toContain(expectedObservation); }); it('should not add empty observation', async() => { await page.waitToClick(selectors.clientDefaulter.allDefaulterCheckbox); await page.waitToClick(selectors.clientDefaulter.addObservationButton); await page.write(selectors.clientDefaulter.observation, ''); await page.waitToClick(selectors.clientDefaulter.saveButton); const message = await page.waitForSnackbar(); expect(message.text).toContain(`The message can't be empty`); }); it('should checked all defaulters', async() => { await page.loginAndModule('insurance', 'client'); await page.accessToSection('client.defaulter'); await page.waitToClick(selectors.clientDefaulter.allDefaulterCheckbox); }); it('should add observation for all clients', async() => { await page.waitToClick(selectors.clientDefaulter.addObservationButton); await page.write(selectors.clientDefaulter.observation, 'My new observation'); await page.waitToClick(selectors.clientDefaulter.saveButton); }); it('should first observation changed', async() => { const message = await page.waitForSnackbar(); await page.waitForSelector(selectors.clientDefaulter.firstObservation); const result = await page.waitToGetProperty(selectors.clientDefaulter.firstObservation, 'value'); expect(message.text).toContain('Observation saved!'); expect(result).toContain('My new observation'); }); });