salix/e2e/paths/02-client/14_balance.spec.js

132 lines
5.3 KiB
JavaScript
Raw Normal View History

import selectors from '../../helpers/selectors';
import getBrowser from '../../helpers/puppeteer';
2018-11-19 13:33:18 +00:00
2020-08-27 10:43:57 +00:00
describe('Client balance path', () => {
let browser;
2019-12-31 11:00:16 +00:00
let page;
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
2019-12-31 11:00:16 +00:00
await page.loginAndModule('administrative', 'client');
await page.accessToSearchResult('Petter Parker');
});
2018-11-19 13:33:18 +00:00
2019-12-31 11:00:16 +00:00
afterAll(async() => {
await browser.close();
2019-01-30 08:40:38 +00:00
});
it('should now edit the local user config data', async() => {
2019-12-31 11:00:16 +00:00
await page.waitToClick(selectors.globalItems.userMenuButton);
await page.autocompleteSearch(selectors.globalItems.userLocalCompany, 'CCs');
2020-04-08 09:24:40 +00:00
const message = await page.waitForSnackbar();
2019-01-30 08:40:38 +00:00
2020-10-30 16:09:11 +00:00
expect(message.text).toBe('Data saved!');
2019-01-30 08:40:38 +00:00
});
it('should access to the balance section to check the data shown matches the local settings', async() => {
2019-12-31 11:00:16 +00:00
await page.accessToSection('client.card.balance.index');
2020-02-03 14:55:11 +00:00
let result = await page.waitToGetProperty(selectors.clientBalance.company, 'value');
2019-01-30 08:40:38 +00:00
expect(result).toEqual('CCs');
});
it('should now clear the user local settings', async() => {
2019-12-31 11:00:16 +00:00
await page.waitToClick(selectors.globalItems.userMenuButton);
await page.clearInput(selectors.globalItems.userConfigThirdAutocomplete);
2020-04-08 09:24:40 +00:00
const message = await page.waitForSnackbar();
2019-01-30 08:40:38 +00:00
2020-10-30 16:09:11 +00:00
expect(message.text).toBe('Data saved!');
2018-11-19 13:33:18 +00:00
});
2019-01-16 14:02:50 +00:00
it('should click the new payment button', async() => {
2020-02-12 13:36:05 +00:00
await page.closePopup();
2019-12-31 11:00:16 +00:00
await page.reloadSection('client.card.balance.index');
await page.waitForState('client.card.balance.index');
2018-11-19 13:33:18 +00:00
});
2019-01-16 14:02:50 +00:00
it('should create a new payment that clears the debt', async() => {
2020-09-18 09:50:20 +00:00
await page.closePopup();
2020-02-03 14:55:11 +00:00
await page.waitToClick(selectors.clientBalance.newPaymentButton);
2019-12-31 11:00:16 +00:00
await page.autocompleteSearch(selectors.clientBalance.newPaymentBank, 'Pay on receipt');
await page.waitToClick(selectors.clientBalance.saveButton);
2020-04-08 09:24:40 +00:00
const message = await page.waitForSnackbar();
2018-11-19 13:33:18 +00:00
2020-10-30 16:09:11 +00:00
expect(message.text).toBe('Data saved!');
2018-11-19 13:33:18 +00:00
});
2020-08-31 13:00:11 +00:00
it('should edit the 1st line reference', async() => {
await page.waitToClick(selectors.clientBalance.firstLineReference);
await page.write(selectors.clientBalance.firstLineReferenceInput, 'Miscellaneous payment');
await page.keyboard.press('Enter');
const message = await page.waitForSnackbar();
2020-10-30 16:09:11 +00:00
expect(message.text).toBe('Data saved!');
2020-08-31 13:00:11 +00:00
});
it('should check balance is now 0, the reference was saved and the company is now VNL becouse the user local settings were removed', async() => {
2019-12-31 11:00:16 +00:00
await page.waitForSpinnerLoad();
let company = await page
2020-02-03 14:55:11 +00:00
.waitToGetProperty(selectors.clientBalance.company, 'value');
2019-01-30 08:40:38 +00:00
2020-08-31 13:00:11 +00:00
let reference = await page
.waitToGetProperty(selectors.clientBalance.firstLineReference, 'innerText');
2019-12-31 11:00:16 +00:00
let firstBalanceLine = await page
2020-08-31 13:00:11 +00:00
.waitToGetProperty(selectors.clientBalance.firstLineBalance, 'innerText');
2018-11-19 13:33:18 +00:00
2019-01-30 08:40:38 +00:00
expect(company).toEqual('VNL');
2020-08-31 13:00:11 +00:00
expect(reference).toEqual('Miscellaneous payment');
expect(firstBalanceLine).toContain('0.00');
2018-11-19 13:33:18 +00:00
});
2019-01-16 14:02:50 +00:00
it('should create a new payment that sets the balance to positive value', async() => {
await page.waitToClick(selectors.clientBalance.newPaymentButton);
2020-03-30 15:30:03 +00:00
await page.overwrite(selectors.clientBalance.newPaymentAmount, '100');
2019-12-31 11:00:16 +00:00
await page.waitToClick(selectors.clientBalance.saveButton);
2020-04-08 09:24:40 +00:00
const message = await page.waitForSnackbar();
2018-11-19 13:33:18 +00:00
2020-10-30 16:09:11 +00:00
expect(message.text).toBe('Data saved!');
2018-11-19 13:33:18 +00:00
});
it('should check balance is now -100', async() => {
2019-12-31 11:00:16 +00:00
let result = await page
2020-08-31 13:00:11 +00:00
.waitToGetProperty(selectors.clientBalance.firstLineBalance, 'innerText');
2018-11-19 13:33:18 +00:00
expect(result).toContain('-€100.00');
2018-11-19 13:33:18 +00:00
});
2019-01-16 14:02:50 +00:00
it('should create a new payment that sets the balance back to the original negative value', async() => {
2019-12-31 11:00:16 +00:00
await page.waitToClick(selectors.clientBalance.newPaymentButton);
2020-03-30 15:30:03 +00:00
await page.overwrite(selectors.clientBalance.newPaymentAmount, '-150');
2019-12-31 11:00:16 +00:00
await page.waitToClick(selectors.clientBalance.saveButton);
2020-04-08 09:24:40 +00:00
const message = await page.waitForSnackbar();
2018-11-19 13:33:18 +00:00
2020-10-30 16:09:11 +00:00
expect(message.text).toBe('Data saved!');
2018-11-19 13:33:18 +00:00
});
it('should check balance is now 50', async() => {
2019-12-31 11:00:16 +00:00
let result = await page
2020-08-31 13:00:11 +00:00
.waitToGetProperty(selectors.clientBalance.firstLineBalance, 'innerText');
2018-11-19 13:33:18 +00:00
expect(result).toEqual('€50.00');
2018-11-19 13:33:18 +00:00
});
2019-01-16 14:02:50 +00:00
it('should now click on the Clients button of the top bar menu', async() => {
2019-12-31 11:00:16 +00:00
await page.login('employee');
await page.waitToClick(selectors.globalItems.applicationsMenuButton);
await page.wait(selectors.globalItems.applicationsMenuVisible);
await page.waitToClick(selectors.globalItems.clientsButton);
await page.wait(selectors.clientsIndex.createClientButton);
await page.waitForState('client.index');
2018-11-19 13:33:18 +00:00
});
2019-01-16 14:02:50 +00:00
it('should now search for the user Petter Parker', async() => {
2020-03-17 13:01:25 +00:00
await page.accessToSearchResult('Petter Parker');
await page.accessToSection('client.card.balance.index');
2018-11-19 13:33:18 +00:00
});
2019-01-16 14:02:50 +00:00
it('should not be able to click the new payment button as it isnt present', async() => {
2019-12-31 11:00:16 +00:00
await page.waitFor(selectors.clientBalance.newPaymentButton, {hidden: true});
2018-11-19 13:33:18 +00:00
});
});