2018-02-15 11:28:05 +00:00
|
|
|
import selectors from '../../helpers/selectors.js';
|
2019-12-12 07:37:35 +00:00
|
|
|
import openPage from '../../helpers/puppeteer';
|
2018-01-08 14:06:20 +00:00
|
|
|
|
2018-11-20 13:22:00 +00:00
|
|
|
describe('Client Add greuge path', () => {
|
2019-12-31 11:00:16 +00:00
|
|
|
let page;
|
|
|
|
beforeAll(async() => {
|
|
|
|
page = await openPage();
|
|
|
|
await page.loginAndModule('salesAssistant', 'client');
|
|
|
|
await page.accessToSearchResult('Petter Parker');
|
|
|
|
await page.accessToSection('client.card.greuge.index');
|
|
|
|
});
|
2018-11-20 13:22:00 +00:00
|
|
|
|
2019-12-31 11:00:16 +00:00
|
|
|
afterAll(async() => {
|
|
|
|
page.close();
|
2018-11-20 13:22:00 +00:00
|
|
|
});
|
|
|
|
|
2019-01-07 08:33:07 +00:00
|
|
|
it(`should click on the add greuge button`, async() => {
|
2019-12-31 11:00:16 +00:00
|
|
|
await page.waitToClick(selectors.clientGreuge.addGreugeFloatButton);
|
|
|
|
await page.waitForURL('greuge/create');
|
|
|
|
const url = await page.parsedUrl();
|
2018-11-20 13:22:00 +00:00
|
|
|
|
2018-11-22 14:44:33 +00:00
|
|
|
expect(url.hash).toContain('greuge/create');
|
2018-11-20 13:22:00 +00:00
|
|
|
});
|
|
|
|
|
2019-01-07 08:33:07 +00:00
|
|
|
it(`should receive an error if all fields are empty but date and type on submit`, async() => {
|
2019-12-31 11:00:16 +00:00
|
|
|
await page.autocompleteSearch(selectors.clientGreuge.typeAutocomplete, 'Diff');
|
|
|
|
await page.waitToClick(selectors.clientGreuge.saveButton);
|
|
|
|
const result = await page.waitForLastSnackbar();
|
2018-11-20 13:22:00 +00:00
|
|
|
|
|
|
|
expect(result).toEqual('Some fields are invalid');
|
|
|
|
});
|
|
|
|
|
2019-01-07 08:33:07 +00:00
|
|
|
it(`should create a new greuge with all its data`, async() => {
|
2019-12-31 11:00:16 +00:00
|
|
|
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();
|
2018-11-20 13:22:00 +00:00
|
|
|
|
|
|
|
expect(result).toEqual('Data saved!');
|
|
|
|
});
|
|
|
|
|
2019-01-07 08:33:07 +00:00
|
|
|
it('should confirm the greuge was added to the list', async() => {
|
2019-12-31 11:00:16 +00:00
|
|
|
const result = await page.waitToGetProperty(selectors.clientGreuge.firstGreugeText, 'innerText');
|
2018-11-20 13:22:00 +00:00
|
|
|
|
|
|
|
expect(result).toContain(999);
|
|
|
|
expect(result).toContain('new armor for Batman!');
|
|
|
|
expect(result).toContain('Diff');
|
2018-01-12 08:47:51 +00:00
|
|
|
});
|
2018-01-08 14:06:20 +00:00
|
|
|
});
|