import selectors from '../../helpers/selectors'; import getBrowser from '../../helpers/puppeteer'; describe('Client Add greuge path', () => { let browser; let page; beforeAll(async() => { browser = await getBrowser(); page = browser.page; await page.loginAndModule('salesAssistant', 'client'); await page.accessToSearchResult('Petter Parker'); await page.accessToSection('client.card.greuge.index'); }); afterAll(async() => { await browser.close(); }); it(`should click on the add greuge button`, async() => { await page.waitToClick(selectors.clientGreuge.addGreugeFloatButton); await page.waitForState('client.card.greuge.create'); }); it(`should receive an error if all fields are empty but date and type on submit`, async() => { await page.autocompleteSearch(selectors.clientGreuge.type, 'Diff'); await page.waitToClick(selectors.clientGreuge.saveButton); const message = await page.waitForSnackbar(); expect(message.text).toBe('Some fields are invalid'); }); it(`should create a new greuge with all its data`, async() => { await page.write(selectors.clientGreuge.amount, '999'); await page.waitForTextInField(selectors.clientGreuge.amount, '999'); await page.write(selectors.clientGreuge.description, 'new armor for Batman!'); await page.waitToClick(selectors.clientGreuge.saveButton); const message = await page.waitForSnackbar(); expect(message.type).toBe('success'); }); it('should confirm the greuge was added to the list', async() => { const result = await page.waitToGetProperty(selectors.clientGreuge.firstGreugeText, 'innerText'); expect(result).toContain(999); expect(result).toContain('new armor for Batman!'); expect(result).toContain('Diff'); }); });