client balance path updated

This commit is contained in:
Carlos Jimenez Ruiz 2021-01-29 16:33:23 +01:00
parent c442eaa0c7
commit 0e0ff94b43
2 changed files with 16 additions and 6 deletions

View File

@ -187,8 +187,10 @@ export default {
company: 'vn-client-balance-index vn-autocomplete[ng-model="$ctrl.companyId"]', company: 'vn-client-balance-index vn-autocomplete[ng-model="$ctrl.companyId"]',
newPaymentButton: `vn-float-button`, newPaymentButton: `vn-float-button`,
newPaymentBank: '.vn-dialog.shown vn-autocomplete[ng-model="$ctrl.bankFk"]', newPaymentBank: '.vn-dialog.shown vn-autocomplete[ng-model="$ctrl.bankFk"]',
newPaymentAmount: '.vn-dialog.shown vn-input-number[ng-model="$ctrl.receipt.amountPaid"]', newPaymentAmount: '.vn-dialog.shown vn-input-number[ng-model="$ctrl.amountPaid"]',
newDescription: 'vn-textfield[ng-model="$ctrl.receipt.description"]', newDescription: 'vn-textfield[ng-model="$ctrl.receipt.description"]',
deliveredAmount: '.vn-dialog vn-input-number[ng-model="$ctrl.deliveredAmount"]',
refundAmount: '.vn-dialog vn-input-number[ng-model="$ctrl.amountToReturn"]',
saveButton: '.vn-dialog.shown [response="accept"]', saveButton: '.vn-dialog.shown [response="accept"]',
firstLineBalance: 'vn-client-balance-index vn-tbody > vn-tr:nth-child(1) > vn-td:nth-child(8)', 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', firstLineReference: 'vn-client-balance-index vn-tbody > vn-tr:nth-child(1) > vn-td-editable',

View File

@ -1,7 +1,7 @@
import selectors from '../../helpers/selectors'; import selectors from '../../helpers/selectors';
import getBrowser from '../../helpers/puppeteer'; import getBrowser from '../../helpers/puppeteer';
fdescribe('Client balance path', () => { describe('Client balance path', () => {
let browser; let browser;
let page; let page;
beforeAll(async() => { beforeAll(async() => {
@ -48,7 +48,7 @@ fdescribe('Client balance path', () => {
await page.waitToClick(selectors.clientBalance.newPaymentButton); await page.waitToClick(selectors.clientBalance.newPaymentButton);
await page.autocompleteSearch(selectors.clientBalance.newPaymentBank, 'Cash'); await page.autocompleteSearch(selectors.clientBalance.newPaymentBank, 'Cash');
await page.write(selectors.clientBalance.newDescription, 'Description'); await page.write(selectors.clientBalance.newDescription, 'Description');
await page.waitToClick(selectors.clientBalance.saveButton); // app crashing await page.waitToClick(selectors.clientBalance.saveButton);
const message = await page.waitForSnackbar(); const message = await page.waitForSnackbar();
expect(message.text).toContain('Data saved!'); expect(message.text).toContain('Data saved!');
@ -79,16 +79,24 @@ fdescribe('Client balance path', () => {
expect(firstBalanceLine).toContain('0.00'); expect(firstBalanceLine).toContain('0.00');
}); });
it('should create a new payment that sets the balance to positive value', async() => { it('should create a new payment and check the cash comparison works correctly', async() => {
const amountPaid = '100';
const cashHanded = '500';
const expectedRefund = '400';
await page.waitToClick(selectors.clientBalance.newPaymentButton); await page.waitToClick(selectors.clientBalance.newPaymentButton);
await page.overwrite(selectors.clientBalance.newPaymentAmount, '100'); await page.write(selectors.clientBalance.newPaymentAmount, amountPaid);
await page.write(selectors.clientBalance.newDescription, 'Payment');
await page.write(selectors.clientBalance.deliveredAmount, cashHanded);
const refund = await page.waitToGetProperty(selectors.clientBalance.refundAmount, 'value');
await page.waitToClick(selectors.clientBalance.saveButton); await page.waitToClick(selectors.clientBalance.saveButton);
const message = await page.waitForSnackbar(); const message = await page.waitForSnackbar();
expect(refund).toEqual(expectedRefund);
expect(message.text).toContain('Data saved!'); expect(message.text).toContain('Data saved!');
}); });
it('should check balance is now -100', async() => { it('should check the balance value is now -100', async() => {
let result = await page let result = await page
.waitToGetProperty(selectors.clientBalance.firstLineBalance, 'innerText'); .waitToGetProperty(selectors.clientBalance.firstLineBalance, 'innerText');