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
|
|
|
|
2020-01-02 10:37:25 +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');
|
|
|
|
}, 30000);
|
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');
|
|
|
|
let result = await page.waitForLastSnackbar();
|
2019-01-30 08:40:38 +00:00
|
|
|
|
|
|
|
expect(result).toEqual('Data saved!');
|
|
|
|
});
|
|
|
|
|
2019-04-16 11:40:26 +00:00
|
|
|
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');
|
2020-01-16 12:40:51 +00:00
|
|
|
|
2019-12-31 11:00:16 +00:00
|
|
|
let url = await page.parsedUrl();
|
2018-11-19 13:33:18 +00:00
|
|
|
|
2019-04-16 11:40:26 +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() => {
|
2020-01-16 12:40:51 +00:00
|
|
|
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
|
2019-04-16 11:40:26 +00:00
|
|
|
.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
|
2019-04-16 11:40:26 +00:00
|
|
|
.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');
|
2019-04-16 11:40:26 +00:00
|
|
|
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() => {
|
2020-01-16 12:40:51 +00:00
|
|
|
await page.waitToClick(selectors.clientBalance.newPaymentButton);
|
2020-01-27 17:35:39 +00:00
|
|
|
await page.waitFor(3000); // 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!');
|
|
|
|
});
|
|
|
|
|
2019-05-15 13:26:13 +00:00
|
|
|
it('should check balance is now -100', async() => {
|
2019-12-31 11:00:16 +00:00
|
|
|
let result = await page
|
2019-04-16 11:40:26 +00:00
|
|
|
.waitToGetProperty(selectors.clientBalance.firstBalanceLine, 'innerText');
|
2018-11-19 13:33:18 +00:00
|
|
|
|
2019-05-15 13:26:13 +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);
|
2020-01-27 17:35:39 +00:00
|
|
|
await page.waitFor(3000); // didn't manage to make this dynamic to allow clearInput to find the icon clear... :(
|
2020-01-16 12:40:51 +00:00
|
|
|
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!');
|
|
|
|
});
|
|
|
|
|
2019-05-15 13:26:13 +00:00
|
|
|
it('should check balance is now 50', async() => {
|
2019-12-31 11:00:16 +00:00
|
|
|
let result = await page
|
2019-04-16 11:40:26 +00:00
|
|
|
.waitToGetProperty(selectors.clientBalance.firstBalanceLine, 'innerText');
|
2018-11-19 13:33:18 +00:00
|
|
|
|
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);
|
|
|
|
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);
|
|
|
|
});
|
|
|
|
|
2019-04-16 11:40:26 +00:00
|
|
|
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);
|
2020-01-23 15:01:29 +00:00
|
|
|
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
|
|
|
|
2019-04-16 11:40:26 +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
|
|
|
});
|
|
|
|
});
|