144 lines
6.0 KiB
JavaScript
144 lines
6.0 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.waitForContentLoaded();
|
|
await page.autocompleteSearch(selectors.globalItems.userLocalCompany, 'CCs');
|
|
let result = await page.waitForLastSnackbar();
|
|
|
|
expect(result).toEqual('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);
|
|
let result = await page.waitForLastSnackbar();
|
|
|
|
expect(result).toEqual('Data saved!');
|
|
});
|
|
|
|
it('should click the new payment button', async() => {
|
|
await page.keyboard.press('Escape');
|
|
await page.reloadSection('client.card.balance.index');
|
|
let url = await page.expectURL('/balance');
|
|
|
|
expect(url).toBe(true);
|
|
});
|
|
|
|
it('should create a new payment that clears the debt', async() => {
|
|
await page.waitToClick(selectors.clientBalance.newPaymentButton);
|
|
await page.autocompleteSearch(selectors.clientBalance.newPaymentBank, 'Pay on receipt');
|
|
await page.waitToClick(selectors.clientBalance.saveButton);
|
|
let result = await page.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() => {
|
|
await page.waitForSpinnerLoad();
|
|
let company = await page
|
|
.waitToGetProperty(selectors.clientBalance.company, 'value');
|
|
|
|
let firstBalanceLine = await page
|
|
.waitToGetProperty(selectors.clientBalance.firstBalanceLine, 'innerText');
|
|
|
|
|
|
expect(company).toEqual('VNL');
|
|
expect(firstBalanceLine).toContain('0.00');
|
|
});
|
|
|
|
it('should create a new payment that sets the balance to positive value', async() => {
|
|
await page.waitToClick(selectors.clientBalance.newPaymentButton);
|
|
await page.waitFor(3000); // didn't manage to make this dynamic to allow clearInput to find the icon clear... :(
|
|
await page.clearInput(selectors.clientBalance.newPaymentAmount);
|
|
await page.write(selectors.clientBalance.newPaymentAmount, '100');
|
|
await page.waitToClick(selectors.clientBalance.saveButton);
|
|
let result = await page.waitForLastSnackbar();
|
|
|
|
expect(result).toContain('Data saved!');
|
|
});
|
|
|
|
it('should check balance is now -100', async() => {
|
|
let result = await page
|
|
.waitToGetProperty(selectors.clientBalance.firstBalanceLine, 'innerText');
|
|
|
|
expect(result).toContain('-€100.00');
|
|
});
|
|
|
|
it('should create a new payment that sets the balance back to the original negative value', async() => {
|
|
await page.waitToClick(selectors.clientBalance.newPaymentButton);
|
|
await page.waitFor(3000); // didn't manage to make this dynamic to allow clearInput to find the icon clear... :(
|
|
await page.waitForSelector('.vn-dialog.vn-popup.shown', {visible: true});
|
|
await page.clearInput(selectors.clientBalance.newPaymentAmount);
|
|
await page.write(selectors.clientBalance.newPaymentAmount, '-150');
|
|
await page.waitToClick(selectors.clientBalance.saveButton);
|
|
let result = await page.waitForLastSnackbar();
|
|
|
|
expect(result).toContain('Data saved!');
|
|
});
|
|
|
|
it('should check balance is now 50', async() => {
|
|
let result = await page
|
|
.waitToGetProperty(selectors.clientBalance.firstBalanceLine, '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.wait(selectors.globalItems.applicationsMenuVisible);
|
|
await page.waitToClick(selectors.globalItems.clientsButton);
|
|
await page.wait(selectors.clientsIndex.createClientButton);
|
|
let url = await page.expectURL('#!/client/index');
|
|
|
|
expect(url).toBe(true);
|
|
});
|
|
|
|
it('should now search for the user Petter Parker', async() => {
|
|
await page.waitForContentLoaded();
|
|
await page.write(selectors.clientsIndex.topbarSearch, 'Petter Parker');
|
|
await page.waitToClick(selectors.clientsIndex.searchButton);
|
|
await page.waitForNumberOfElements(selectors.clientsIndex.searchResult, 1);
|
|
let resultCount = await page.countElement(selectors.clientsIndex.searchResult);
|
|
|
|
expect(resultCount).toEqual(1);
|
|
});
|
|
|
|
it(`should click on the search result to access to the client's balance`, async() => {
|
|
await page.waitForTextInElement(selectors.clientsIndex.searchResult, 'Petter Parker');
|
|
await page.waitToClick(selectors.clientsIndex.searchResult);
|
|
await page.waitForContentLoaded();
|
|
await page.waitToClick(selectors.clientBalance.balanceButton);
|
|
let url = await page.expectURL('/balance');
|
|
|
|
expect(url).toBe(true);
|
|
});
|
|
|
|
it('should not be able to click the new payment button as it isnt present', async() => {
|
|
await page.waitFor(selectors.clientBalance.newPaymentButton, {hidden: true});
|
|
});
|
|
});
|