salix/e2e/paths/02-client-module/10_add_greuge.spec.js

52 lines
1.9 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);
let url = await page.expectURL('greuge/create');
expect(url).toBe(true);
});
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 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.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 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');
});
});