import selectors from '../../helpers/selectors'; import getBrowser from '../../helpers/puppeteer'; describe('Client Add credit path', () => { let browser; let page; beforeAll(async() => { browser = await getBrowser(); page = browser.page; await page.loginAndModule('salesAssistant', 'client'); await page.accessToSearchResult('Hank Pym'); await page.accessToSection('client.card.credit.index'); }); afterAll(async() => { await browser.close(); }); it(`should click on the add credit button`, async() => { await page.waitToClick(selectors.clientCredit.addCreditFloatButton); await page.waitForURL('/credit/create'); const url = await page.parsedUrl(); expect(url.hash).toContain('/credit/create'); }); it(`should edit the credit`, async() => { await page.waitForContentLoaded(); await page.clearInput(selectors.clientCredit.credit); await page.write(selectors.clientCredit.credit, '999'); await page.waitToClick(selectors.clientCredit.saveButton); const result = await page.waitForLastSnackbar(); expect(result).toEqual('Data saved!'); }); it('should confirm the credit was updated', async() => { await page.waitForContentLoaded(); const result = await page.waitToGetProperty(selectors.clientCredit.firstCreditText, 'innerText'); expect(result).toContain(999); expect(result).toContain('salesAssistant'); }); });