164 lines
6.0 KiB
JavaScript
164 lines
6.0 KiB
JavaScript
import selectors from '../../helpers/selectors.js';
|
|
import createNightmare from '../../helpers/nightmare';
|
|
|
|
describe('Client balance path', () => {
|
|
const nightmare = createNightmare();
|
|
|
|
beforeAll(() => {
|
|
nightmare
|
|
.loginAndModule('administrative', 'client')
|
|
.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!');
|
|
});
|
|
|
|
it('should access to the balance section to check the data shown matches the local settings', async() => {
|
|
let result = await nightmare
|
|
.accessToSection('client.card.balance.index')
|
|
.waitToGetProperty(`${selectors.clientBalance.companyAutocomplete} input`, 'value');
|
|
|
|
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!');
|
|
});
|
|
|
|
it('should click the new payment button', async() => {
|
|
let url = await nightmare
|
|
.reloadSection('client.card.balance.index')
|
|
.waitToClick(selectors.clientBalance.newPaymentButton)
|
|
.waitForURL('/balance')
|
|
.parsedUrl();
|
|
|
|
expect(url.hash).toContain('/balance');
|
|
});
|
|
|
|
it('should create a new payment that clears the debt', async() => {
|
|
let result = await nightmare
|
|
.clearInput(selectors.clientBalance.newPaymentBankInut)
|
|
.write(selectors.clientBalance.newPaymentBankInut, '2')
|
|
.waitToClick(selectors.clientBalance.saveButton)
|
|
.waitForLastSnackbar();
|
|
|
|
expect(result).toContain('Data saved!');
|
|
});
|
|
|
|
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
|
|
.waitToGetProperty(`${selectors.clientBalance.companyAutocomplete} input`, 'value');
|
|
|
|
let firstBalanceLine = await nightmare
|
|
.waitToGetProperty(selectors.clientBalance.firstBalanceLine, 'innerText');
|
|
|
|
|
|
expect(company).toEqual('VNL');
|
|
expect(firstBalanceLine).toContain('0.00');
|
|
});
|
|
|
|
it('should now click the new payment button', async() => {
|
|
let url = await nightmare
|
|
.waitToClick(selectors.clientBalance.newPaymentButton)
|
|
.waitForURL('/balance')
|
|
.parsedUrl();
|
|
|
|
expect(url.hash).toContain('/balance');
|
|
});
|
|
|
|
it('should create a new payment that sets the balance to positive value', async() => {
|
|
let result = await nightmare
|
|
.clearInput(selectors.clientBalance.newPaymentAmountInput)
|
|
.write(selectors.clientBalance.newPaymentAmountInput, '100')
|
|
.waitToClick(selectors.clientBalance.saveButton)
|
|
.waitForLastSnackbar();
|
|
|
|
expect(result).toContain('Data saved!');
|
|
});
|
|
|
|
it('should check balance is now 100', async() => {
|
|
let result = await nightmare
|
|
.waitToGetProperty(selectors.clientBalance.firstBalanceLine, 'innerText');
|
|
|
|
expect(result).toContain('100.00');
|
|
});
|
|
|
|
it('should again click the new payment button', async() => {
|
|
let url = await nightmare
|
|
.waitToClick(selectors.clientBalance.newPaymentButton)
|
|
.waitForURL('/balance')
|
|
.parsedUrl();
|
|
|
|
expect(url.hash).toContain('/balance');
|
|
});
|
|
|
|
it('should create a new payment that sets the balance back to the original negative value', async() => {
|
|
let result = await nightmare
|
|
.clearInput(selectors.clientBalance.newPaymentAmountInput)
|
|
.write(selectors.clientBalance.newPaymentAmountInput, '-150')
|
|
.wait(1999)
|
|
.waitToClick(selectors.clientBalance.saveButton)
|
|
.waitForLastSnackbar();
|
|
|
|
expect(result).toContain('Data saved!');
|
|
});
|
|
|
|
it('should check balance is now -50', async() => {
|
|
let result = await nightmare
|
|
.waitToGetProperty(selectors.clientBalance.firstBalanceLine, 'innerText');
|
|
|
|
expect(result).toContain('€50.00');
|
|
});
|
|
|
|
it('should now click on the Clients button of the top bar menu', async() => {
|
|
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');
|
|
});
|
|
|
|
it('should now search for the user Petter Parker', async() => {
|
|
let resultCount = await nightmare
|
|
.write(selectors.clientsIndex.searchClientInput, 'Petter Parker')
|
|
.waitToClick(selectors.clientsIndex.searchButton)
|
|
.waitForNumberOfElements(selectors.clientsIndex.searchResult, 1)
|
|
.countElement(selectors.clientsIndex.searchResult);
|
|
|
|
expect(resultCount).toEqual(1);
|
|
});
|
|
|
|
it(`should click on the search result to access to the client's balance`, async() => {
|
|
let url = await nightmare
|
|
.waitForTextInElement(selectors.clientsIndex.searchResult, 'Petter Parker')
|
|
.waitToClick(selectors.clientsIndex.searchResult)
|
|
.waitToClick(selectors.clientBalance.balanceButton)
|
|
.waitForURL('/balance')
|
|
.parsedUrl();
|
|
|
|
expect(url.hash).toContain('/balance');
|
|
});
|
|
|
|
it('should not be able to click the new payment button as it isnt present', async() => {
|
|
let result = await nightmare
|
|
.exists(selectors.clientBalance.newPaymentButton);
|
|
|
|
expect(result).toBeFalsy();
|
|
});
|
|
});
|