161 lines
6.9 KiB
JavaScript
161 lines
6.9 KiB
JavaScript
import selectors from '../../helpers/selectors';
|
|
import getBrowser from '../../helpers/puppeteer';
|
|
|
|
describe('Client balance path', () => {
|
|
let browser;
|
|
let page;
|
|
beforeAll(async() => {
|
|
browser = await getBrowser();
|
|
page = browser.page;
|
|
await page.loginAndModule('administrative', 'client');
|
|
await page.accessToSearchResult('Petter Parker');
|
|
});
|
|
|
|
afterAll(async() => {
|
|
await browser.close();
|
|
});
|
|
|
|
it('should now edit the local user config data', async() => {
|
|
await page.waitToClick(selectors.globalItems.userMenuButton);
|
|
await page.autocompleteSearch(selectors.globalItems.userLocalCompany, 'CCs');
|
|
const message = await page.waitForSnackbar();
|
|
|
|
expect(message.text).toContain('Data saved!');
|
|
});
|
|
|
|
it('should access to the balance section to check the data shown matches the local settings', async() => {
|
|
await page.accessToSection('client.card.balance.index');
|
|
let result = await page.waitToGetProperty(selectors.clientBalance.company, 'value');
|
|
|
|
expect(result).toEqual('CCs');
|
|
});
|
|
|
|
it('should now clear the user local settings', async() => {
|
|
await page.waitToClick(selectors.globalItems.userMenuButton);
|
|
await page.clearInput(selectors.globalItems.userConfigThirdAutocomplete);
|
|
const message = await page.waitForSnackbar();
|
|
|
|
expect(message.text).toContain('Data saved!');
|
|
});
|
|
|
|
it('should reload the section', async() => {
|
|
await page.closePopup();
|
|
await page.reloadSection('client.card.balance.index');
|
|
});
|
|
|
|
it('should create a new payment that clears the debt', async() => {
|
|
await page.closePopup();
|
|
await page.waitToClick(selectors.clientBalance.newPaymentButton);
|
|
await page.autocompleteSearch(selectors.clientBalance.newPaymentBank, 'Cash');
|
|
await page.clearInput(selectors.clientBalance.newDescription);
|
|
await page.write(selectors.clientBalance.newDescription, 'Description');
|
|
await page.waitToClick(selectors.clientBalance.saveButton);
|
|
const message = await page.waitForSnackbar();
|
|
|
|
expect(message.text).toContain('Data saved!');
|
|
});
|
|
|
|
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();
|
|
|
|
expect(message.text).toContain('Data saved!');
|
|
});
|
|
|
|
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() => {
|
|
await page.waitForSpinnerLoad();
|
|
let company = await page
|
|
.waitToGetProperty(selectors.clientBalance.company, 'value');
|
|
|
|
let reference = await page
|
|
.waitToGetProperty(selectors.clientBalance.firstLineReference, 'innerText');
|
|
|
|
let firstBalanceLine = await page
|
|
.waitToGetProperty(selectors.clientBalance.firstLineBalance, 'innerText');
|
|
|
|
expect(company).toEqual('VNL');
|
|
expect(reference).toEqual('Miscellaneous payment');
|
|
expect(firstBalanceLine).toContain('0.00');
|
|
});
|
|
|
|
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.write(selectors.clientBalance.newPaymentAmount, amountPaid);
|
|
await page.clearInput(selectors.clientBalance.newDescription);
|
|
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);
|
|
const message = await page.waitForSnackbar();
|
|
|
|
expect(refund).toEqual(expectedRefund);
|
|
expect(message.text).toContain('Data saved!');
|
|
});
|
|
|
|
it('should check the balance value is now -100', async() => {
|
|
let result = await page
|
|
.waitToGetProperty(selectors.clientBalance.firstLineBalance, 'innerText');
|
|
|
|
expect(result).toContain('-€100.00');
|
|
});
|
|
|
|
it('should create a new payment and check the cash exceeded the maximum', async() => {
|
|
const amountPaid = '1001';
|
|
|
|
await page.closePopup();
|
|
await page.waitToClick(selectors.clientBalance.newPaymentButton);
|
|
await page.autocompleteSearch(selectors.clientBalance.newPaymentBank, 'Cash');
|
|
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');
|
|
});
|
|
|
|
it('should create a new payment that sets the balance back to the original negative value', async() => {
|
|
await page.closePopup();
|
|
await page.waitToClick(selectors.clientBalance.newPaymentButton);
|
|
await page.autocompleteSearch(selectors.clientBalance.newPaymentBank, 'Pay on receipt');
|
|
await page.overwrite(selectors.clientBalance.newPaymentAmount, '-150');
|
|
await page.clearInput(selectors.clientBalance.newDescription);
|
|
await page.write(selectors.clientBalance.newDescription, 'Description');
|
|
await page.waitToClick(selectors.clientBalance.saveButton);
|
|
const message = await page.waitForSnackbar();
|
|
|
|
expect(message.text).toContain('Data saved!');
|
|
});
|
|
|
|
it('should check balance is now 50', async() => {
|
|
let result = await page
|
|
.waitToGetProperty(selectors.clientBalance.firstLineBalance, 'innerText');
|
|
|
|
expect(result).toEqual('€50.00');
|
|
});
|
|
|
|
it('should now click on the Clients button of the top bar menu', async() => {
|
|
await page.login('employee');
|
|
await page.waitToClick(selectors.globalItems.applicationsMenuButton);
|
|
await page.waitForSelector(selectors.globalItems.applicationsMenuVisible);
|
|
await page.waitToClick(selectors.globalItems.clientsButton);
|
|
await page.waitForSelector(selectors.clientsIndex.createClientButton);
|
|
await page.waitForState('client.index');
|
|
});
|
|
|
|
it('should now search for the user Petter Parker', async() => {
|
|
await page.accessToSearchResult('Petter Parker');
|
|
await page.accessToSection('client.card.balance.index');
|
|
});
|
|
|
|
it('should not be able to click the new payment button as it isnt present', async() => {
|
|
await page.waitForSelector(selectors.clientBalance.newPaymentButton, {hidden: true});
|
|
});
|
|
});
|