salix/e2e/paths/client-module/14_risk.spec.js

133 lines
4.7 KiB
JavaScript
Raw Normal View History

2018-11-19 13:33:18 +00:00
import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare';
describe('Client risk path', () => {
const nightmare = createNightmare();
beforeAll(() => {
2018-11-20 13:22:00 +00:00
nightmare
.loginAndModule('administrative', 'client')
.accessToSearchResult('Petter Parker')
.accessToSection('client.card.risk.index');
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
.waitToClick(selectors.clientRisk.newPaymentButton)
.waitForURL('/risk')
.parsedUrl();
expect(url.hash).toContain('/risk');
});
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
.clearInput(selectors.clientRisk.newPaymentBankInut)
.type(selectors.clientRisk.newPaymentBankInut, '2')
.waitToClick(selectors.clientRisk.saveButton)
.waitForLastSnackbar();
expect(result).toContain('Data saved!');
});
2019-01-16 14:02:50 +00:00
it('should check balance is now 0', async() => {
2018-11-19 13:33:18 +00:00
let result = await nightmare
.waitToGetProperty(selectors.clientRisk.firstRiskLineBalance, 'innerText');
2018-11-19 13:33:18 +00:00
expect(result).toEqual('0.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
.waitToClick(selectors.clientRisk.newPaymentButton)
.waitForURL('/risk')
.parsedUrl();
expect(url.hash).toContain('/risk');
});
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
.clearInput(selectors.clientRisk.newPaymentAmountInput)
.type(selectors.clientRisk.newPaymentAmountInput, '100')
.waitToClick(selectors.clientRisk.saveButton)
.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
.waitToGetProperty(selectors.clientRisk.firstRiskLineBalance, 'innerText');
2018-11-19 13:33:18 +00:00
expect(result).toEqual('100.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
.waitToClick(selectors.clientRisk.newPaymentButton)
.waitForURL('/risk')
.parsedUrl();
expect(url.hash).toContain('/risk');
});
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
.clearInput(selectors.clientRisk.newPaymentAmountInput)
.type(selectors.clientRisk.newPaymentAmountInput, '-150')
.waitToClick(selectors.clientRisk.saveButton)
.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
.waitToGetProperty(selectors.clientRisk.firstRiskLineBalance, 'innerText');
2018-11-19 13:33:18 +00:00
expect(result).toEqual('-50.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
.wait(selectors.clientsIndex.searchClientInput)
2018-11-19 13:33:18 +00:00
.type(selectors.clientsIndex.searchClientInput, 'Petter Parker')
.click(selectors.clientsIndex.searchButton)
.waitForNumberOfElements(selectors.clientsIndex.searchResult, 1)
.countElement(selectors.clientsIndex.searchResult);
expect(resultCount).toEqual(1);
});
2019-01-16 14:02:50 +00:00
it(`should click on the search result to access to the client's risk`, async() => {
2018-11-19 13:33:18 +00:00
let url = await nightmare
.waitForTextInElement(selectors.clientsIndex.searchResult, 'Petter Parker')
.waitToClick(selectors.clientsIndex.searchResult)
.waitToClick(selectors.clientRisk.riskButton)
.waitForURL('/risk')
.parsedUrl();
expect(url.hash).toContain('/risk');
});
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
.exists(selectors.clientRisk.newPaymentButton);
expect(result).toBeFalsy();
});
});