2020-01-14 08:20:14 +00:00
|
|
|
import selectors from '../../helpers/selectors';
|
|
|
|
import getBrowser from '../../helpers/puppeteer';
|
2018-11-19 13:33:18 +00:00
|
|
|
|
2021-01-29 15:33:23 +00:00
|
|
|
describe('Client balance path', () => {
|
2020-01-14 08:20:14 +00:00
|
|
|
let browser;
|
2019-12-31 11:00:16 +00:00
|
|
|
let page;
|
|
|
|
beforeAll(async() => {
|
2020-01-14 08:20:14 +00:00
|
|
|
browser = await getBrowser();
|
|
|
|
page = browser.page;
|
2019-12-31 11:00:16 +00:00
|
|
|
await page.loginAndModule('administrative', 'client');
|
|
|
|
await page.accessToSearchResult('Petter Parker');
|
2020-01-29 13:54:07 +00:00
|
|
|
});
|
2018-11-19 13:33:18 +00:00
|
|
|
|
2019-12-31 11:00:16 +00:00
|
|
|
afterAll(async() => {
|
2020-01-14 08:40:50 +00:00
|
|
|
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-11-10 11:06:21 +00:00
|
|
|
expect(message.text).toContain('Data saved!');
|
2019-01-30 08:40:38 +00:00
|
|
|
});
|
|
|
|
|
2019-04-16 11:40:26 +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-11-10 11:06:21 +00:00
|
|
|
expect(message.text).toContain('Data saved!');
|
2018-11-19 13:33:18 +00:00
|
|
|
});
|
|
|
|
|
2021-01-25 14:27:57 +00:00
|
|
|
it('should reload the section', 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');
|
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);
|
2021-01-25 14:27:57 +00:00
|
|
|
await page.autocompleteSearch(selectors.clientBalance.newPaymentBank, 'Cash');
|
2021-02-12 14:02:30 +00:00
|
|
|
await page.clearInput(selectors.clientBalance.newDescription);
|
2021-01-04 10:49:32 +00:00
|
|
|
await page.write(selectors.clientBalance.newDescription, 'Description');
|
2021-01-29 15:33:23 +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-11-10 11:06:21 +00:00
|
|
|
expect(message.text).toContain('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-11-10 11:06:21 +00:00
|
|
|
expect(message.text).toContain('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');
|
2019-04-16 11:40:26 +00:00
|
|
|
expect(firstBalanceLine).toContain('0.00');
|
2018-11-19 13:33:18 +00:00
|
|
|
});
|
|
|
|
|
2021-01-29 15:33:23 +00:00
|
|
|
it('should create a new payment and check the cash comparison works correctly', async() => {
|
|
|
|
const amountPaid = '100';
|
|
|
|
const cashHanded = '500';
|
|
|
|
const expectedRefund = '400';
|
|
|
|
|
2020-01-16 12:40:51 +00:00
|
|
|
await page.waitToClick(selectors.clientBalance.newPaymentButton);
|
2021-01-29 15:33:23 +00:00
|
|
|
await page.write(selectors.clientBalance.newPaymentAmount, amountPaid);
|
2021-02-12 14:02:30 +00:00
|
|
|
await page.clearInput(selectors.clientBalance.newDescription);
|
2021-01-29 15:33:23 +00:00
|
|
|
await page.write(selectors.clientBalance.newDescription, 'Payment');
|
|
|
|
await page.write(selectors.clientBalance.deliveredAmount, cashHanded);
|
|
|
|
const refund = await page.waitToGetProperty(selectors.clientBalance.refundAmount, 'value');
|
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
|
|
|
|
2021-01-29 15:33:23 +00:00
|
|
|
expect(refund).toEqual(expectedRefund);
|
2020-11-10 11:06:21 +00:00
|
|
|
expect(message.text).toContain('Data saved!');
|
2018-11-19 13:33:18 +00:00
|
|
|
});
|
|
|
|
|
2021-11-09 13:36:39 +00:00
|
|
|
it('should create a new payment and check the cash exceeded the maximum', async() => {
|
|
|
|
const amountPaid = '1001';
|
|
|
|
|
|
|
|
await page.waitToClick(selectors.clientBalance.newPaymentButton);
|
|
|
|
await page.write(selectors.clientBalance.newPaymentAmount, amountPaid);
|
|
|
|
await page.clearInput(selectors.clientBalance.newDescription);
|
|
|
|
await page.write(selectors.clientBalance.newDescription, 'Payment');
|
|
|
|
await page.waitToClick(selectors.clientBalance.saveButton);
|
|
|
|
const message = await page.waitForSnackbar();
|
|
|
|
|
|
|
|
expect(message.text).toContain('Amount exceeded');
|
|
|
|
});
|
|
|
|
|
2021-01-29 15:33:23 +00:00
|
|
|
it('should check the balance value 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
|
|
|
|
2019-05-15 13:26:13 +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-12-16 07:33:08 +00:00
|
|
|
await page.autocompleteSearch(selectors.clientBalance.newPaymentBank, 'Pay on receipt');
|
2020-03-30 15:30:03 +00:00
|
|
|
await page.overwrite(selectors.clientBalance.newPaymentAmount, '-150');
|
2021-02-12 14:02:30 +00:00
|
|
|
await page.clearInput(selectors.clientBalance.newDescription);
|
2021-01-04 10:49:32 +00:00
|
|
|
await page.write(selectors.clientBalance.newDescription, 'Description');
|
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-11-10 11:06:21 +00:00
|
|
|
expect(message.text).toContain('Data saved!');
|
2018-11-19 13:33:18 +00:00
|
|
|
});
|
|
|
|
|
2019-05-15 13:26:13 +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
|
|
|
|
2019-05-29 11:06:42 +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);
|
2020-11-23 17:28:39 +00:00
|
|
|
await page.waitForSelector(selectors.globalItems.applicationsMenuVisible);
|
2019-12-31 11:00:16 +00:00
|
|
|
await page.waitToClick(selectors.globalItems.clientsButton);
|
2020-11-23 17:28:39 +00:00
|
|
|
await page.waitForSelector(selectors.clientsIndex.createClientButton);
|
2020-03-24 15:49:36 +00:00
|
|
|
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');
|
2020-03-31 08:02:25 +00:00
|
|
|
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() => {
|
2020-11-23 17:28:39 +00:00
|
|
|
await page.waitForSelector(selectors.clientBalance.newPaymentButton, {hidden: true});
|
2018-11-19 13:33:18 +00:00
|
|
|
});
|
|
|
|
});
|