53 lines
2.0 KiB
JavaScript
53 lines
2.0 KiB
JavaScript
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.waitForURL('greuge/create');
|
|
const url = await page.parsedUrl();
|
|
|
|
expect(url.hash).toContain('greuge/create');
|
|
});
|
|
|
|
it(`should receive an error if all fields are empty but date and type on submit`, async() => {
|
|
await page.autocompleteSearch(selectors.clientGreuge.typeAutocomplete, 'Diff');
|
|
await page.waitToClick(selectors.clientGreuge.saveButton);
|
|
const result = await page.waitForLastSnackbar();
|
|
|
|
expect(result).toEqual('Some fields are invalid');
|
|
});
|
|
|
|
it(`should create a new greuge with all its data`, async() => {
|
|
await page.write(selectors.clientGreuge.amountInput, '999');
|
|
await page.waitForTextInInput(selectors.clientGreuge.amountInput, '999');
|
|
await page.write(selectors.clientGreuge.descriptionInput, 'new armor for Batman!');
|
|
await page.waitToClick(selectors.clientGreuge.saveButton);
|
|
const result = await page.waitForLastSnackbar();
|
|
|
|
expect(result).toEqual('Data saved!');
|
|
});
|
|
|
|
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');
|
|
});
|
|
});
|