2018-11-19 13:33:18 +00:00
|
|
|
import selectors from '../../helpers/selectors.js';
|
|
|
|
import createNightmare from '../../helpers/nightmare';
|
|
|
|
|
2019-04-16 11:40:26 +00:00
|
|
|
describe('Client balance path', () => {
|
2018-11-19 13:33:18 +00:00
|
|
|
const nightmare = createNightmare();
|
|
|
|
|
|
|
|
beforeAll(() => {
|
2018-11-20 13:22:00 +00:00
|
|
|
nightmare
|
2018-12-02 23:45:34 +00:00
|
|
|
.loginAndModule('administrative', 'client')
|
2019-01-30 08:40:38 +00:00
|
|
|
.accessToSearchResult('Petter Parker');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should now edit the local user config data', async() => {
|
|
|
|
let result = await nightmare
|
|
|
|
.waitToClick(selectors.globalItems.userMenuButton)
|
|
|
|
.autocompleteSearch(selectors.globalItems.userLocalCompany, 'CCs')
|
|
|
|
.waitForLastSnackbar();
|
|
|
|
|
|
|
|
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-01-30 08:40:38 +00:00
|
|
|
let result = await nightmare
|
2019-04-16 11:40:26 +00:00
|
|
|
.accessToSection('client.card.balance.index')
|
|
|
|
.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() => {
|
|
|
|
let result = await nightmare
|
|
|
|
.waitToClick(selectors.globalItems.userMenuButton)
|
|
|
|
.waitToClick(selectors.globalItems.userConfigThirdAutocompleteClear)
|
|
|
|
.waitForLastSnackbar();
|
|
|
|
|
|
|
|
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() => {
|
2018-11-19 13:33:18 +00:00
|
|
|
let url = await nightmare
|
2019-04-16 11:40:26 +00:00
|
|
|
.reloadSection('client.card.balance.index')
|
|
|
|
.waitToClick(selectors.clientBalance.newPaymentButton)
|
|
|
|
.waitForURL('/balance')
|
2018-11-19 13:33:18 +00:00
|
|
|
.parsedUrl();
|
|
|
|
|
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() => {
|
2018-11-19 13:33:18 +00:00
|
|
|
let result = await nightmare
|
2019-04-16 11:40:26 +00:00
|
|
|
.clearInput(selectors.clientBalance.newPaymentBankInut)
|
|
|
|
.write(selectors.clientBalance.newPaymentBankInut, '2')
|
|
|
|
.waitToClick(selectors.clientBalance.saveButton)
|
2018-11-19 13:33:18 +00:00
|
|
|
.waitForLastSnackbar();
|
|
|
|
|
|
|
|
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() => {
|
|
|
|
let company = await nightmare
|
2019-04-16 11:40:26 +00:00
|
|
|
.waitToGetProperty(`${selectors.clientBalance.companyAutocomplete} input`, 'value');
|
2019-01-30 08:40:38 +00:00
|
|
|
|
2019-04-16 11:40:26 +00:00
|
|
|
let firstBalanceLine = await nightmare
|
|
|
|
.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 now click the new payment button', async() => {
|
2018-11-19 13:33:18 +00:00
|
|
|
let url = await nightmare
|
2019-04-16 11:40:26 +00:00
|
|
|
.waitToClick(selectors.clientBalance.newPaymentButton)
|
|
|
|
.waitForURL('/balance')
|
2018-11-19 13:33:18 +00:00
|
|
|
.parsedUrl();
|
|
|
|
|
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 sets the balance to positive value', async() => {
|
2018-11-19 13:33:18 +00:00
|
|
|
let result = await nightmare
|
2019-04-16 11:40:26 +00:00
|
|
|
.clearInput(selectors.clientBalance.newPaymentAmountInput)
|
|
|
|
.write(selectors.clientBalance.newPaymentAmountInput, '100')
|
|
|
|
.waitToClick(selectors.clientBalance.saveButton)
|
2018-11-19 13:33:18 +00:00
|
|
|
.waitForLastSnackbar();
|
|
|
|
|
|
|
|
expect(result).toContain('Data saved!');
|
|
|
|
});
|
|
|
|
|
2019-01-16 14:02:50 +00:00
|
|
|
it('should check balance is now 100', async() => {
|
2018-11-19 13:33:18 +00:00
|
|
|
let result = await nightmare
|
2019-04-16 11:40:26 +00:00
|
|
|
.waitToGetProperty(selectors.clientBalance.firstBalanceLine, 'innerText');
|
2018-11-19 13:33:18 +00:00
|
|
|
|
2019-01-31 10:44:03 +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 again click the new payment button', async() => {
|
2018-11-19 13:33:18 +00:00
|
|
|
let url = await nightmare
|
2019-04-16 11:40:26 +00:00
|
|
|
.waitToClick(selectors.clientBalance.newPaymentButton)
|
|
|
|
.waitForURL('/balance')
|
2018-11-19 13:33:18 +00:00
|
|
|
.parsedUrl();
|
|
|
|
|
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 sets the balance back to the original negative value', async() => {
|
2018-11-19 13:33:18 +00:00
|
|
|
let result = await nightmare
|
2019-04-16 11:40:26 +00:00
|
|
|
.clearInput(selectors.clientBalance.newPaymentAmountInput)
|
|
|
|
.write(selectors.clientBalance.newPaymentAmountInput, '-150')
|
2019-04-05 07:20:22 +00:00
|
|
|
.wait(1999)
|
2019-04-16 11:40:26 +00:00
|
|
|
.waitToClick(selectors.clientBalance.saveButton)
|
2018-11-19 13:33:18 +00:00
|
|
|
.waitForLastSnackbar();
|
|
|
|
|
|
|
|
expect(result).toContain('Data saved!');
|
|
|
|
});
|
|
|
|
|
2019-01-16 14:02:50 +00:00
|
|
|
it('should check balance is now -50', async() => {
|
2018-11-19 13:33:18 +00:00
|
|
|
let result = await nightmare
|
2019-04-16 11:40:26 +00:00
|
|
|
.waitToGetProperty(selectors.clientBalance.firstBalanceLine, 'innerText');
|
2018-11-19 13:33:18 +00:00
|
|
|
|
2019-04-10 07:39:35 +00:00
|
|
|
expect(result).toContain('€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() => {
|
2018-11-19 13:33:18 +00:00
|
|
|
let url = await nightmare
|
|
|
|
.waitForLogin('employee')
|
|
|
|
.waitToClick(selectors.globalItems.applicationsMenuButton)
|
|
|
|
.wait(selectors.globalItems.applicationsMenuVisible)
|
|
|
|
.waitToClick(selectors.globalItems.clientsButton)
|
|
|
|
.wait(selectors.clientsIndex.createClientButton)
|
|
|
|
.parsedUrl();
|
|
|
|
|
|
|
|
expect(url.hash).toEqual('#!/client/index');
|
|
|
|
});
|
|
|
|
|
2019-01-16 14:02:50 +00:00
|
|
|
it('should now search for the user Petter Parker', async() => {
|
2018-11-19 13:33:18 +00:00
|
|
|
let resultCount = await nightmare
|
2019-01-23 14:33:25 +00:00
|
|
|
.write(selectors.clientsIndex.searchClientInput, 'Petter Parker')
|
2019-01-23 15:00:56 +00:00
|
|
|
.waitToClick(selectors.clientsIndex.searchButton)
|
2018-11-19 13:33:18 +00:00
|
|
|
.waitForNumberOfElements(selectors.clientsIndex.searchResult, 1)
|
|
|
|
.countElement(selectors.clientsIndex.searchResult);
|
|
|
|
|
|
|
|
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() => {
|
2018-11-19 13:33:18 +00:00
|
|
|
let url = await nightmare
|
|
|
|
.waitForTextInElement(selectors.clientsIndex.searchResult, 'Petter Parker')
|
|
|
|
.waitToClick(selectors.clientsIndex.searchResult)
|
2019-04-16 11:40:26 +00:00
|
|
|
.waitToClick(selectors.clientBalance.balanceButton)
|
|
|
|
.waitForURL('/balance')
|
2018-11-19 13:33:18 +00:00
|
|
|
.parsedUrl();
|
|
|
|
|
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() => {
|
2018-11-19 13:33:18 +00:00
|
|
|
let result = await nightmare
|
2019-04-16 11:40:26 +00:00
|
|
|
.exists(selectors.clientBalance.newPaymentButton);
|
2018-11-19 13:33:18 +00:00
|
|
|
|
|
|
|
expect(result).toBeFalsy();
|
|
|
|
});
|
|
|
|
});
|