salix/e2e/paths/02-client/20_credit_insurance.spec.js

94 lines
4.2 KiB
JavaScript
Raw Permalink Normal View History

2020-10-21 12:25:40 +00:00
import selectors from '../../helpers/selectors.js';
import getBrowser from '../../helpers/puppeteer';
describe('Client credit insurance path', () => {
let browser;
let page;
2023-01-16 14:18:24 +00:00
let previousMonth = Date.vnNew();
2020-10-21 12:25:40 +00:00
previousMonth.setMonth(previousMonth.getMonth() - 1);
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
await page.loginAndModule('insurance', 'client');
await page.accessToSearchResult('Tony Stark');
await page.accessToSection('client.card.creditInsurance.index');
});
afterAll(async() => {
await browser.close();
});
it('should open the create a new credit contract form', async() => {
await page.waitToClick(selectors.clientCreditInsurance.addNewContract);
await page.waitForState('client.card.creditInsurance.create');
});
it('should create a new credit contract', async() => {
2020-10-22 12:33:51 +00:00
await page.write(selectors.clientCreditInsurance.newCreditClassification, '1000');
await page.write(selectors.clientCreditInsurance.newClassificationGrade, '1');
await page.pickDate(selectors.clientCreditInsurance.newClassificationStartingDate, previousMonth);
2020-10-21 12:25:40 +00:00
await page.waitToClick(selectors.clientCreditInsurance.saveNewContract);
await page.waitForState('client.card.creditInsurance.index');
});
it(`should verify the addNewContract button is not present since there's an active contract`, async() => {
await page.waitForSelector(selectors.clientCreditInsurance.addNewContract, {hidden: true});
});
2020-10-22 12:33:51 +00:00
it(`should click the view credits button`, async() => {
await page.waitToClick(selectors.clientCreditInsurance.firstContratViewCreditButton);
await page.waitForState('client.card.creditInsurance.insurance.index');
});
it('should click the add new credit button which opens the new credit form', async() => {
await page.waitToClick(selectors.clientCreditInsurance.addNewCredit);
await page.waitForState('client.card.creditInsurance.insurance.create');
});
it('should fill the form but provide no grade to the new credit hence fail', async() => {
await page.write(selectors.clientCreditInsurance.newInsuranceCredit, '2000');
await page.pickDate(selectors.clientCreditInsurance.newInsuranceStartingDate, previousMonth);
await page.waitToClick(selectors.clientCreditInsurance.saveNewInsuranceCredit);
const message = await page.waitForSnackbar();
expect(message.text).toEqual('The grade must be similar to the last one');
});
2020-10-23 13:34:09 +00:00
it('should provide a correct grade and succesfully save a new credit', async() => {
2020-10-22 12:33:51 +00:00
await page.write(selectors.clientCreditInsurance.newInsuranceGrade, '999');
await page.waitToClick(selectors.clientCreditInsurance.saveNewInsuranceCredit);
const message = await page.waitForSnackbar();
expect(message.text).toEqual('Data saved!');
});
2020-10-23 13:34:09 +00:00
it('should be redirected to the credit index', async() => {
await page.waitForState('client.card.creditInsurance.insurance.index');
});
2020-10-22 12:33:51 +00:00
it('should check the amount of credits is the expected', async() => {
const result = await page.countElement(selectors.clientCreditInsurance.anyCreditInsuranceLine);
expect(result).toEqual(2);
});
it('should navigate to the credit insurance section', async() => {
await page.waitToClick(`vn-left-menu li > a[ui-sref="client.card.creditInsurance.index"]`);
await page.waitForState('client.card.creditInsurance.index');
});
it('should bring the current contract to an end', async() => {
2020-10-21 12:25:40 +00:00
await page.waitToClick(selectors.clientCreditInsurance.endCurrentContract);
await page.waitToClick(selectors.globalItems.acceptButton);
});
it(`should verify the addNewContract button is now present since there's no active contract`, async() => {
await page.waitForSelector(selectors.clientCreditInsurance.addNewContract, {visible: true});
});
it(`should verify the endCurrentContract button is not present since there's no active contract`, async() => {
await page.waitForSelector(selectors.clientCreditInsurance.endCurrentContract, {hidden: true});
});
});