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(6); }); 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('Ororo Munroe'); expect(salesPersonName).toEqual('salesperson'); }); it('should first observation not changed', async() => { const expectedObservation = 'Madness, as you know, is like gravity, all it takes is a little push'; 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); }); });