client credit insurance e2e path
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Carlos Jimenez Ruiz 2020-10-21 14:25:40 +02:00
parent 5daee49382
commit da68ab3ffc
3 changed files with 65 additions and 6 deletions

View File

@ -399,16 +399,16 @@ let actions = {
pickDate: async function(selector, date) {
date = date || new Date();
const tzoffset = date.getTimezoneOffset() * 60000;
const localIso = (new Date(date.getTime() - tzoffset))
.toISOString();
const timeZoneOffset = date.getTimezoneOffset() * 60000;
const localDate = (new Date(date.getTime() - timeZoneOffset))
.toISOString().substr(0, 10);
await this.wait(selector);
await this.evaluate((selector, localIso) => {
await this.evaluate((selector, localDate) => {
let input = document.querySelector(selector).$ctrl.input;
input.value = localIso.substr(0, 10);
input.value = localDate;
input.dispatchEvent(new Event('change'));
}, selector, localIso);
}, selector, localDate);
},
pickTime: async function(selector, time) {

View File

@ -202,6 +202,14 @@ export default {
firstDocWorker: 'vn-client-dms-index vn-td:nth-child(8) > span',
firstDocWorkerDescriptor: '.vn-popover.shown vn-worker-descriptor'
},
clientCreditInsurance: {
addNewContract: 'vn-client-credit-insurance-index vn-float-button[ui-sref="client.card.creditInsurance.create"]',
newCredit: 'vn-client-credit-insurance-create vn-input-number[ng-model="$ctrl.creditClassification.credit"]',
newGrade: 'vn-client-credit-insurance-create vn-input-number[ng-model="$ctrl.creditClassification.grade"]',
newStartingDate: 'vn-client-credit-insurance-create vn-date-picker[ng-model="$ctrl.creditClassification.started"]',
endCurrentContract: 'vn-client-credit-insurance-index vn-icon-button[icon="lock"]',
saveNewContract: 'vn-client-credit-insurance-create vn-submit'
},
clientContacts: {
addContactButton: 'vn-client-contact vn-icon[icon="add_circle"]',
name: 'vn-client-contact vn-textfield[ng-model="contact.name"]',

View File

@ -0,0 +1,51 @@
import selectors from '../../helpers/selectors.js';
import getBrowser from '../../helpers/puppeteer';
describe('Client credit insurance path', () => {
let browser;
let page;
let previousMonth = new Date();
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() => {
await page.write(selectors.clientCreditInsurance.newCredit, '1000');
await page.write(selectors.clientCreditInsurance.newGrade, '1');
await page.pickDate(selectors.clientCreditInsurance.newStartingDate, previousMonth);
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});
});
it(`should bring the current contract to an end`, async() => {
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});
});
});