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

144 lines
5.6 KiB
JavaScript
Raw Permalink Normal View History

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', () => {
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');
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');
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();
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.waitForSelector(selectors.globalItems.applicationsMenuVisible);
2019-12-31 11:00:16 +00:00
await page.waitToClick(selectors.globalItems.clientsButton);
await page.waitForSelector(selectors.clientsIndex.createClientButton);
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');
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
});
});