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
|
|
|
|
2023-05-08 10:03:27 +00:00
|
|
|
const $ = {
|
|
|
|
company: 'vn-client-balance-index vn-autocomplete[ng-model="$ctrl.companyId"]',
|
|
|
|
newPaymentButton: `vn-float-button`,
|
|
|
|
newPayment: '.vn-dialog.shown',
|
|
|
|
refundAmount: '.vn-dialog.shown [vn-name="amountToReturn"]',
|
|
|
|
saveButton: '.vn-dialog.shown [response="accept"]',
|
|
|
|
firstLineBalance: 'vn-client-balance-index vn-tbody > vn-tr:nth-child(1) > vn-td:nth-child(8)',
|
|
|
|
firstLineReference: 'vn-client-balance-index vn-tbody > vn-tr:nth-child(1) > vn-td-editable',
|
|
|
|
firstLineReferenceInput: 'vn-client-balance-index vn-tbody > vn-tr:nth-child(1) > vn-td-editable vn-textfield',
|
|
|
|
};
|
|
|
|
|
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');
|
2023-05-08 10:03:27 +00:00
|
|
|
const companyMessage = await page.waitForSnackbar();
|
2019-01-30 08:40:38 +00:00
|
|
|
|
2019-12-31 11:00:16 +00:00
|
|
|
await page.accessToSection('client.card.balance.index');
|
2023-05-08 10:03:27 +00:00
|
|
|
const company = await page.getValue($.company);
|
2019-01-30 08:40:38 +00:00
|
|
|
|
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-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');
|
2023-05-08 10:03:27 +00:00
|
|
|
|
|
|
|
expect(companyMessage.isSuccess).toBeTrue();
|
|
|
|
expect(company).toEqual('CCs');
|
|
|
|
expect(message.isSuccess).toBeTrue();
|
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() => {
|
2023-05-08 10:03:27 +00:00
|
|
|
await page.waitToClick($.newPaymentButton);
|
|
|
|
await page.fillForm($.newPayment, {
|
|
|
|
bank: 'Cash',
|
|
|
|
description: 'Description',
|
|
|
|
viewReceipt: false
|
|
|
|
});
|
|
|
|
await page.respondToDialog('accept');
|
2020-04-08 09:24:40 +00:00
|
|
|
const message = await page.waitForSnackbar();
|
2018-11-19 13:33:18 +00:00
|
|
|
|
2023-05-08 10:03:27 +00:00
|
|
|
expect(message.isSuccess).toBeTrue();
|
2018-11-19 13:33:18 +00:00
|
|
|
});
|
|
|
|
|
2023-05-08 10:03:27 +00:00
|
|
|
it('should edit the 1st line reference and check data', async() => {
|
|
|
|
await page.waitToClick($.firstLineReference);
|
|
|
|
await page.write($.firstLineReferenceInput, 'Miscellaneous payment');
|
2020-08-31 13:00:11 +00:00
|
|
|
await page.keyboard.press('Enter');
|
|
|
|
const message = await page.waitForSnackbar();
|
|
|
|
|
2019-12-31 11:00:16 +00:00
|
|
|
await page.waitForSpinnerLoad();
|
2023-05-08 10:03:27 +00:00
|
|
|
let company = await page.getValue($.company);
|
|
|
|
let reference = await page.innerText($.firstLineReference);
|
|
|
|
let firstBalanceLine = await page.innerText($.firstLineBalance);
|
2018-11-19 13:33:18 +00:00
|
|
|
|
2023-05-08 10:03:27 +00:00
|
|
|
expect(message.isSuccess).toBeTrue();
|
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
|
|
|
});
|
|
|
|
|
2023-05-08 10:03:27 +00:00
|
|
|
it('should create a new payment, check the cash comparison works correctly and balance value is -100', async() => {
|
|
|
|
await page.waitToClick($.newPaymentButton);
|
|
|
|
await page.fillForm($.newPayment, {
|
|
|
|
amountPaid: 100,
|
|
|
|
description: 'Payment',
|
|
|
|
deliveredAmount: 500,
|
|
|
|
viewReceipt: false
|
|
|
|
});
|
|
|
|
const refund = await page.getValue($.refundAmount);
|
|
|
|
await page.respondToDialog('accept');
|
2020-04-08 09:24:40 +00:00
|
|
|
const message = await page.waitForSnackbar();
|
2018-11-19 13:33:18 +00:00
|
|
|
|
2023-05-08 10:03:27 +00:00
|
|
|
const result = await page.innerText($.firstLineBalance);
|
2021-11-10 08:20:54 +00:00
|
|
|
|
2023-05-08 10:03:27 +00:00
|
|
|
expect(refund).toEqual('400');
|
|
|
|
expect(message.isSuccess).toBeTrue();
|
2021-11-10 08:20:54 +00:00
|
|
|
expect(result).toContain('-€100.00');
|
|
|
|
});
|
|
|
|
|
2021-11-09 13:36:39 +00:00
|
|
|
it('should create a new payment and check the cash exceeded the maximum', async() => {
|
2023-05-08 10:03:27 +00:00
|
|
|
await page.waitToClick($.newPaymentButton);
|
|
|
|
await page.fillForm($.newPayment, {
|
|
|
|
bank: 'Cash',
|
|
|
|
amountPaid: 1001,
|
|
|
|
description: 'Payment'
|
|
|
|
});
|
|
|
|
await page.waitToClick($.saveButton);
|
2021-11-09 13:36:39 +00:00
|
|
|
const message = await page.waitForSnackbar();
|
|
|
|
|
|
|
|
expect(message.text).toContain('Amount exceeded');
|
|
|
|
});
|
|
|
|
|
2023-05-08 10:03:27 +00:00
|
|
|
it('should create a new payment that sets the balance back to negative value and check it', async() => {
|
2021-11-10 08:20:54 +00:00
|
|
|
await page.closePopup();
|
2023-05-08 10:03:27 +00:00
|
|
|
await page.waitToClick($.newPaymentButton);
|
|
|
|
|
|
|
|
await page.fillForm($.newPayment, {
|
|
|
|
bank: 'Pay on receipt',
|
|
|
|
amountPaid: -150,
|
|
|
|
description: 'Description'
|
|
|
|
});
|
|
|
|
await page.respondToDialog('accept');
|
2020-04-08 09:24:40 +00:00
|
|
|
const message = await page.waitForSnackbar();
|
2018-11-19 13:33:18 +00:00
|
|
|
|
2023-05-08 10:03:27 +00:00
|
|
|
const result = await page.innerText($.firstLineBalance);
|
2018-11-19 13:33:18 +00:00
|
|
|
|
2023-05-08 10:03:27 +00:00
|
|
|
expect(message.isSuccess).toBeTrue();
|
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
|
|
|
});
|
|
|
|
|
2023-05-08 10:03:27 +00:00
|
|
|
it('should now search for the user Petter Parker not check the payment button is not present', 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');
|
2023-05-08 10:03:27 +00:00
|
|
|
await page.waitForSelector($.newPaymentButton, {hidden: true});
|
2018-11-19 13:33:18 +00:00
|
|
|
});
|
|
|
|
});
|