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

147 lines
6.1 KiB
JavaScript
Raw Normal View History

import selectors from '../../helpers/selectors';
import getBrowser from '../../helpers/puppeteer';
2018-11-19 13:33:18 +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');
}, 30000);
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');
let result = await page.waitForLastSnackbar();
2019-01-30 08:40:38 +00:00
expect(result).toEqual('Data saved!');
});
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');
let result = await page.waitToGetProperty(`${selectors.clientBalance.companyAutocomplete} input`, '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);
let result = await page.waitForLastSnackbar();
2019-01-30 08:40:38 +00:00
expect(result).toEqual('Data saved!');
2018-11-19 13:33:18 +00:00
});
2019-01-16 14:02:50 +00:00
it('should click the new payment button', async() => {
2019-12-31 11:00:16 +00:00
await page.keyboard.press('Escape');
await page.reloadSection('client.card.balance.index');
await page.waitForURL('/balance');
2019-12-31 11:00:16 +00:00
let url = await page.parsedUrl();
2018-11-19 13:33:18 +00:00
expect(url.hash).toContain('/balance');
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() => {
await Promise.all([
page.waitToClick(selectors.clientBalance.newPaymentButton),
page.waitForSelector('.vn-dialog.vn-popup.shown', {visible: true})
]);
2019-12-31 11:00:16 +00:00
await page.autocompleteSearch(selectors.clientBalance.newPaymentBank, 'Pay on receipt');
await page.waitToClick(selectors.clientBalance.saveButton);
let result = await page.waitForLastSnackbar();
2018-11-19 13:33:18 +00:00
expect(result).toContain('Data saved!');
});
2019-01-30 08:40:38 +00:00
it('should check balance is now 0 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
.waitToGetProperty(`${selectors.clientBalance.companyAutocomplete} input`, 'value');
2019-01-30 08:40:38 +00:00
2019-12-31 11:00:16 +00:00
let firstBalanceLine = await page
.waitToGetProperty(selectors.clientBalance.firstBalanceLine, 'innerText');
2018-11-19 13:33:18 +00:00
2019-01-30 08:40:38 +00:00
expect(company).toEqual('VNL');
expect(firstBalanceLine).toContain('0.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 to positive value', async() => {
await page.waitToClick(selectors.clientBalance.newPaymentButton);
await page.waitFor(1000); // didn't manage to make this dynamic to allow clearInput to find the icon clear... :(
2019-12-31 11:00:16 +00:00
await page.clearInput(selectors.clientBalance.newPaymentAmountInput);
await page.write(selectors.clientBalance.newPaymentAmountInput, '100');
await page.waitToClick(selectors.clientBalance.saveButton);
let result = await page.waitForLastSnackbar();
2018-11-19 13:33:18 +00:00
expect(result).toContain('Data saved!');
});
it('should check balance is now -100', async() => {
2019-12-31 11:00:16 +00:00
let result = await page
.waitToGetProperty(selectors.clientBalance.firstBalanceLine, 'innerText');
2018-11-19 13:33:18 +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);
await page.waitForSelector('.vn-dialog.vn-popup.shown', {visible: true});
2019-12-31 11:00:16 +00:00
await page.clearInput(selectors.clientBalance.newPaymentAmountInput);
await page.write(selectors.clientBalance.newPaymentAmountInput, '-150');
await page.waitToClick(selectors.clientBalance.saveButton);
let result = await page.waitForLastSnackbar();
2018-11-19 13:33:18 +00:00
expect(result).toContain('Data saved!');
});
it('should check balance is now 50', async() => {
2019-12-31 11:00:16 +00:00
let result = await page
.waitToGetProperty(selectors.clientBalance.firstBalanceLine, 'innerText');
2018-11-19 13:33:18 +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);
await page.wait(selectors.globalItems.applicationsMenuVisible);
await page.waitToClick(selectors.globalItems.clientsButton);
await page.wait(selectors.clientsIndex.createClientButton);
let url = await page.parsedUrl();
2018-11-19 13:33:18 +00:00
expect(url.hash).toEqual('#!/client/index');
});
2019-01-16 14:02:50 +00:00
it('should now search for the user Petter Parker', async() => {
2019-12-31 11:00:16 +00:00
await page.write(selectors.clientsIndex.searchClientInput, 'Petter Parker');
await page.waitToClick(selectors.clientsIndex.searchButton);
await page.waitForNumberOfElements(selectors.clientsIndex.searchResult, 1);
let resultCount = await page.countElement(selectors.clientsIndex.searchResult);
2018-11-19 13:33:18 +00:00
expect(resultCount).toEqual(1);
});
it(`should click on the search result to access to the client's balance`, async() => {
2019-12-31 11:00:16 +00:00
await page.waitForTextInElement(selectors.clientsIndex.searchResult, 'Petter Parker');
await page.waitToClick(selectors.clientsIndex.searchResult);
await page.waitForContentLoaded();
2019-12-31 11:00:16 +00:00
await page.waitToClick(selectors.clientBalance.balanceButton);
await page.waitForURL('/balance');
let url = await page.parsedUrl();
2018-11-19 13:33:18 +00:00
expect(url.hash).toContain('/balance');
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() => {
2019-12-31 11:00:16 +00:00
await page.waitFor(selectors.clientBalance.newPaymentButton, {hidden: true});
2018-11-19 13:33:18 +00:00
});
});