#781 implemented waittoGetProperty and nightmare extensions registration

This commit is contained in:
Carlos Jimenez 2018-11-22 12:34:20 +01:00
parent 45920f9673
commit b0d531756e
13 changed files with 343 additions and 330 deletions

View File

@ -4,89 +4,6 @@ import config from './config.js';
import Nightmare from 'nightmare'; import Nightmare from 'nightmare';
import {URL} from 'url'; import {URL} from 'url';
Nightmare.action('login', function(userName, done) {
this.goto(`${config.url}auth/?apiKey=salix`)
.wait(`vn-login input[name=user]`)
.write(`vn-login input[name=user]`, userName)
.write(`vn-login input[name=password]`, 'nightmare')
.click(`vn-login input[type=submit]`)
// FIXME: Wait for dom to be ready: https://github.com/segmentio/nightmare/issues/481
.wait(1000)
.then(done)
.catch(done);
});
Nightmare.action('changeLanguageToEnglish', function(done) {
this.wait('#lang')
.evaluate(selector => {
return document.querySelector(selector).title;
}, '#lang')
.then(title => {
if (title === 'Change language') {
this.then(done)
.catch(done);
} else {
this.click('#lang')
.click('vn-main-menu [vn-id="langs-menu"] ul > li[name="en"]')
.then(done)
.catch(done);
}
});
});
Nightmare.action('waitForLogin', function(userName, done) {
this.login(userName)
.waitForURL('#!/')
.url()
.changeLanguageToEnglish()
.then(done)
.catch(done);
});
Nightmare.action('parsedUrl', function(done) {
this.url()
.then(url => {
done(null, new URL(url));
}).catch(done);
});
Nightmare.action('getProperty', function(selector, property, done) {
this.evaluate_now((selector, property) => {
return document.querySelector(selector)[property].replace(/\s+/g, ' ').trim();
}, done, selector, property);
});
Nightmare.action('waitPropertyLength', function(selector, property, minLength, done) {
this.wait((selector, property, minLength) => {
const element = document.querySelector(selector);
return element && element[property] != null && element[property] !== '' && element[property].length >= minLength;
}, selector, property, minLength)
.getProperty(selector, property)
.then(result => done(null, result), done);
});
Nightmare.action('waitProperty', function(selector, property, done) {
this.wait((selector, property) => {
const element = document.querySelector(selector);
return element && element[property] != null && element[property] !== '';
}, selector, property)
.getProperty(selector, property)
.then(result => done(null, result), done);
});
Nightmare.action('getInnerText', function(selector, done) {
this.wait(selector)
.evaluate_now(function(elementToSelect) {
return document.querySelector(elementToSelect).innerText;
}, done, selector);
});
Nightmare.action('getInputValue', function(selector, done) {
this.wait(selector)
.evaluate_now(function(elementToSelect) {
return document.querySelector(elementToSelect).value;
}, done, selector);
});
Nightmare.asyncAction = function(name, func) { Nightmare.asyncAction = function(name, func) {
Nightmare.action(name, function(...args) { Nightmare.action(name, function(...args) {
@ -106,192 +23,283 @@ Nightmare.asyncAction('clearInput', async function(selector) {
.type(selector, backSpaces.join('')); .type(selector, backSpaces.join(''));
}); });
Nightmare.action('write', function(selector, text, done) { let actions = {
this.wait(selector) login: function(userName, done) {
.type(selector, text) this.goto(`${config.url}auth/?apiKey=salix`)
.then(done) .wait(`vn-login input[name=user]`)
.catch(done); .write(`vn-login input[name=user]`, userName)
}); .write(`vn-login input[name=password]`, 'nightmare')
.click(`vn-login input[type=submit]`)
// FIXME: Wait for dom to be ready: https://github.com/segmentio/nightmare/issues/481
.wait(1000)
.then(done)
.catch(done);
},
Nightmare.action('waitToClick', function(selector, done) { changeLanguageToEnglish: function(done) {
this.wait(selector) this.wait('#lang')
.click(selector) .evaluate(selector => {
.then(done) return document.querySelector(selector).title;
.catch(done); }, '#lang')
}); .then(title => {
if (title === 'Change language') {
this.then(done)
.catch(done);
} else {
this.click('#lang')
.click('vn-main-menu [vn-id="langs-menu"] ul > li[name="en"]')
.then(done)
.catch(done);
}
});
},
Nightmare.action('isVisible', function(selector, done) { waitForLogin: function(userName, done) {
this.wait(selector) this.login(userName)
.evaluate_now(elementSelector => { .waitForURL('#!/')
const selectorMatches = document.querySelectorAll(elementSelector); .url()
const element = selectorMatches[0]; .changeLanguageToEnglish()
if (selectorMatches.length > 1) .then(done)
throw new Error(`multiple matches of ${elementSelector} found`); .catch(done);
},
let isVisible = false; parsedUrl: function(done) {
if (element) { this.url()
const eventHandler = event => { .then(url => {
event.preventDefault(); done(null, new URL(url));
isVisible = true; }).catch(done);
}; },
element.addEventListener('mouseover', eventHandler);
const elementBoundaries = element.getBoundingClientRect();
const x = elementBoundaries.left + element.offsetWidth / 2;
const y = elementBoundaries.top + element.offsetHeight / 2;
const elementInCenter = document.elementFromPoint(x, y);
const elementInTopLeft = document.elementFromPoint(elementBoundaries.left, elementBoundaries.top);
const elementInBottomRight = document.elementFromPoint(elementBoundaries.right, elementBoundaries.bottom);
const e = new MouseEvent('mouseover', {
view: window,
bubbles: true,
cancelable: true,
});
if (elementInCenter)
elementInCenter.dispatchEvent(e);
if (elementInTopLeft) getProperty: function(selector, property, done) {
elementInTopLeft.dispatchEvent(e); this.evaluate_now((selector, property) => {
return document.querySelector(selector)[property].replace(/\s+/g, ' ').trim();
}, done, selector, property);
},
if (elementInBottomRight) waitPropertyLength: function(selector, property, minLength, done) {
elementInBottomRight.dispatchEvent(e); this.wait((selector, property, minLength) => {
const element = document.querySelector(selector);
return element && element[property] != null && element[property] !== '' && element[property].length >= minLength;
}, selector, property, minLength)
.getProperty(selector, property)
.then(result => done(null, result), done);
},
element.removeEventListener('mouseover', eventHandler); waitToGetProperty: function(selector, property, done) {
} this.wait((selector, property) => {
return isVisible; const element = document.querySelector(selector);
return element && element[property] != null && element[property] !== '';
}, selector, property)
.getProperty(selector, property)
.then(result => done(null, result), done);
},
getInnerText: function(selector, done) {
this.wait(selector)
.evaluate_now(function(elementToSelect) {
return document.querySelector(elementToSelect).innerText;
}, done, selector);
},
getInputValue: function(selector, done) {
this.wait(selector)
.evaluate_now(function(elementToSelect) {
return document.querySelector(elementToSelect).value;
}, done, selector);
},
write: function(selector, text, done) {
this.wait(selector)
.type(selector, text)
.then(done)
.catch(done);
},
waitToClick: function(selector, done) {
this.wait(selector)
.click(selector)
.then(done)
.catch(done);
},
isVisible: function(selector, done) {
this.wait(selector)
.evaluate_now(elementSelector => {
const selectorMatches = document.querySelectorAll(elementSelector);
const element = selectorMatches[0];
if (selectorMatches.length > 1)
throw new Error(`multiple matches of ${elementSelector} found`);
let isVisible = false;
if (element) {
const eventHandler = event => {
event.preventDefault();
isVisible = true;
};
element.addEventListener('mouseover', eventHandler);
const elementBoundaries = element.getBoundingClientRect();
const x = elementBoundaries.left + element.offsetWidth / 2;
const y = elementBoundaries.top + element.offsetHeight / 2;
const elementInCenter = document.elementFromPoint(x, y);
const elementInTopLeft = document.elementFromPoint(elementBoundaries.left, elementBoundaries.top);
const elementInBottomRight = document.elementFromPoint(elementBoundaries.right, elementBoundaries.bottom);
const e = new MouseEvent('mouseover', {
view: window,
bubbles: true,
cancelable: true,
});
if (elementInCenter)
elementInCenter.dispatchEvent(e);
if (elementInTopLeft)
elementInTopLeft.dispatchEvent(e);
if (elementInBottomRight)
elementInBottomRight.dispatchEvent(e);
element.removeEventListener('mouseover', eventHandler);
}
return isVisible;
}, done, selector);
},
selectText: function(selector, done) {
this.wait(selector)
.evaluate(elementToSelect => {
const range = document.createRange();
range.selectNodeContents(document.querySelector(elementToSelect));
const sel = window.getSelection();
sel.removeAllRanges();
sel.addRange(range);
}, selector)
.mouseup(selector)
.then(done)
.catch(done);
},
countElement: function(selector, done) {
this.evaluate_now(selector => {
return document.querySelectorAll(selector).length;
}, done, selector); }, done, selector);
}); },
Nightmare.action('selectText', function(selector, done) { waitForNumberOfElements: function(selector, count, done) {
this.wait(selector) this.wait((selector, count) => {
.evaluate(elementToSelect => { return document.querySelectorAll(selector).length === count;
const range = document.createRange(); }, selector, count)
range.selectNodeContents(document.querySelector(elementToSelect)); .then(done)
const sel = window.getSelection(); .catch(err => {
sel.removeAllRanges(); console.error(err.name, err.message);
sel.addRange(range); done(new Error(`.waitForNumberOfElements() for ${selector}, count ${count} timed out`));
});
},
waitForClassNotPresent: function(selector, className, done) {
this.wait(selector)
.wait((selector, className) => {
if (!document.querySelector(selector).classList.contains(className))
return true;
}, selector, className)
.then(done)
.catch(() => {
done(new Error(`.waitForClassNotPresent() for ${selector}, class ${className} timed out`));
});
},
waitForClassPresent: function(selector, className, done) {
this.wait(selector)
.wait((selector, className) => {
if (document.querySelector(selector).classList.contains(className))
return true;
}, selector, className)
.then(done)
.catch(done);
},
waitForTextInElement: function(selector, name, done) {
this.wait(selector)
.wait((selector, name) => {
return document.querySelector(selector).innerText.toLowerCase().includes(name.toLowerCase());
}, selector, name)
.then(done)
.catch(done);
},
waitForTextInInput: function(selector, name, done) {
this.wait(selector)
.wait((selector, name) => {
return document.querySelector(selector).value.toLowerCase().includes(name.toLowerCase());
}, selector, name)
.then(done)
.catch(done);
},
waitForInnerText: function(selector, done) {
this.wait(selector)
.wait(selector => {
const innerText = document.querySelector(selector).innerText;
return innerText != null && innerText != '';
}, selector)
.evaluate_now(selector => {
return document.querySelector(selector).innerText;
}, done, selector);
},
waitForEmptyInnerText: function(selector, done) {
this.wait(selector => {
return document.querySelector(selector).innerText == '';
}, selector) }, selector)
.mouseup(selector) .then(done)
.then(done) .catch(done);
.catch(done); },
});
waitForURL: function(hashURL, done) {
Nightmare.action('countElement', function(selector, done) { this.wait(hash => {
this.evaluate_now(selector => { return document.location.hash.includes(hash);
return document.querySelectorAll(selector).length; }, hashURL)
}, done, selector); .then(done)
}); .catch(done);
},
Nightmare.action('waitForNumberOfElements', function(selector, count, done) {
this.wait((selector, count) => { waitForShapes: function(selector, done) {
return document.querySelectorAll(selector).length === count; this.wait(selector)
}, selector, count) .evaluate_now(selector => {
.then(done) const shapes = document.querySelectorAll(selector);
.catch(err => { const shapesList = [];
console.error(err.name, err.message);
done(new Error(`.waitForNumberOfElements() for ${selector}, count ${count} timed out`)); for (const shape of shapes)
}); shapesList.push(shape.innerText);
});
Nightmare.action('waitForClassNotPresent', function(selector, className, done) { return shapesList;
this.wait(selector) }, done, selector);
.wait((selector, className) => { },
if (!document.querySelector(selector).classList.contains(className))
return true; waitForSnackbar: function(done) {
}, selector, className) this.wait(500).waitForShapes('vn-snackbar .shape .text')
.then(done) .then(shapes => {
.catch(() => { done(null, shapes);
done(new Error(`.waitForClassNotPresent() for ${selector}, class ${className} timed out`)); }).catch(done);
}); },
});
waitForLastShape: function(selector, done) {
Nightmare.action('waitForClassPresent', function(selector, className, done) { this.wait(selector)
this.wait(selector) .evaluate_now(selector => {
.wait((selector, className) => { const shape = document.querySelector(selector);
if (document.querySelector(selector).classList.contains(className))
return true; return shape.innerText;
}, selector, className) }, done, selector);
.then(done) },
.catch(done);
}); waitForLastSnackbar: function(done) {
this.wait(500).waitForLastShape('vn-snackbar .shape .text')
Nightmare.action('waitForTextInElement', function(selector, name, done) { .then(shapes => {
this.wait(selector) done(null, shapes);
.wait((selector, name) => { }).catch(done);
return document.querySelector(selector).innerText.toLowerCase().includes(name.toLowerCase()); }
}, selector, name) };
.then(done)
.catch(done); Object.keys(actions).forEach(function(name) {
}); let fn = actions[name];
Nightmare.action(name, fn);
Nightmare.action('waitForTextInInput', function(selector, name, done) {
this.wait(selector)
.wait((selector, name) => {
return document.querySelector(selector).value.toLowerCase().includes(name.toLowerCase());
}, selector, name)
.then(done)
.catch(done);
});
Nightmare.action('waitForInnerText', function(selector, done) {
this.wait(selector)
.wait(selector => {
const innerText = document.querySelector(selector).innerText;
return innerText != null && innerText != '';
}, selector)
.evaluate_now(selector => {
return document.querySelector(selector).innerText;
}, done, selector);
});
Nightmare.action('waitForEmptyInnerText', function(selector, done) {
this.wait(selector => {
return document.querySelector(selector).innerText == '';
}, selector)
.then(done)
.catch(done);
});
Nightmare.action('waitForURL', function(hashURL, done) {
this.wait(hash => {
return document.location.hash.includes(hash);
}, hashURL)
.then(done)
.catch(done);
});
Nightmare.action('waitForShapes', function(selector, done) {
this.wait(selector)
.evaluate_now(selector => {
const shapes = document.querySelectorAll(selector);
const shapesList = [];
for (const shape of shapes)
shapesList.push(shape.innerText);
return shapesList;
}, done, selector);
});
Nightmare.action('waitForSnackbar', function(done) {
this.wait(500).waitForShapes('vn-snackbar .shape .text')
.then(shapes => {
done(null, shapes);
}).catch(done);
});
Nightmare.action('waitForLastShape', function(selector, done) {
this.wait(selector)
.evaluate_now(selector => {
const shape = document.querySelector(selector);
return shape.innerText;
}, done, selector);
});
Nightmare.action('waitForLastSnackbar', function(done) {
this.wait(500).waitForLastShape('vn-snackbar .shape .text')
.then(shapes => {
done(null, shapes);
}).catch(done);
}); });

View File

@ -65,8 +65,8 @@ describe('Client Edit pay method path', () => {
it(`should add the IBAN but fail as it requires a BIC code`, async () => { it(`should add the IBAN but fail as it requires a BIC code`, async () => {
const snackbarMessage = await nightmare const snackbarMessage = await nightmare
.clearInput(selectors.clientPayMethod.IBANInput) .clearInput(selectors.clientPayMethod.IBANInput)
.type(selectors.clientPayMethod.IBANInput, 'ES91 2100 0418 4502 0005 1332') .type(selectors.clientPayMethod.IBANInput, 'ES9121000418450200051332')
.waitForTextInInput(selectors.clientPayMethod.IBANInput, 'ES91 2100 0418 4502 0005 1332') .waitForTextInInput(selectors.clientPayMethod.IBANInput, 'ES9121000418450200051332')
.waitToClick(selectors.clientPayMethod.clearswiftBicButton) .waitToClick(selectors.clientPayMethod.clearswiftBicButton)
.waitToClick(selectors.clientPayMethod.saveButton) .waitToClick(selectors.clientPayMethod.saveButton)
.waitForLastSnackbar(); .waitForLastSnackbar();
@ -101,16 +101,14 @@ describe('Client Edit pay method path', () => {
it('should confirm the IBAN was saved', async () => { it('should confirm the IBAN was saved', async () => {
const IBAN = await nightmare const IBAN = await nightmare
.waitProperty(selectors.clientPayMethod.IBANInput, 'value') .waitToGetProperty(selectors.clientPayMethod.IBANInput, 'value');
.getProperty(selectors.clientPayMethod.IBANInput, 'value');
expect(IBAN).toEqual('ES91 2100 0418 4502 0005 1332'); expect(IBAN).toEqual('ES91 2100 0418 4502 0005 1332');
}); });
it('should confirm the swift / BIC code was saved', async () => { it('should confirm the swift / BIC code was saved', async () => {
const code = await nightmare const code = await nightmare
.waitProperty(selectors.clientPayMethod.swiftBicInput, 'value') .waitToGetProperty(selectors.clientPayMethod.swiftBicInput, 'value');
.getProperty(selectors.clientPayMethod.swiftBicInput, 'value');
expect(code).toEqual('GTHMCT Gotham City Banks'); expect(code).toEqual('GTHMCT Gotham City Banks');
}); });

View File

@ -100,8 +100,7 @@ describe('Client Add address path', () => {
it(`should click on the addresses button confirm the new address exists and it's the default one`, async () => { it(`should click on the addresses button confirm the new address exists and it's the default one`, async () => {
const result = await nightmare const result = await nightmare
.waitToClick(selectors.clientAddresses.addressesButton) .waitToClick(selectors.clientAddresses.addressesButton)
.wait(selectors.clientAddresses.defaultAddress) .waitToGetProperty(selectors.clientAddresses.defaultAddress, 'innerText');
.getInnerText(selectors.clientAddresses.defaultAddress);
expect(result).toContain('320 Park Avenue New York'); expect(result).toContain('320 Park Avenue New York');
}); });
@ -110,7 +109,7 @@ describe('Client Add address path', () => {
const result = await nightmare const result = await nightmare
.waitToClick(selectors.clientAddresses.secondMakeDefaultStar) .waitToClick(selectors.clientAddresses.secondMakeDefaultStar)
.waitForTextInElement(selectors.clientAddresses.defaultAddress, 'Somewhere in Thailand') .waitForTextInElement(selectors.clientAddresses.defaultAddress, 'Somewhere in Thailand')
.getInnerText(selectors.clientAddresses.defaultAddress); .waitToGetProperty(selectors.clientAddresses.defaultAddress, 'innerText');
expect(result).toContain('Somewhere in Thailand'); expect(result).toContain('Somewhere in Thailand');
}); });

View File

@ -63,8 +63,7 @@ describe('Client risk path', () => {
it('should check balance is now 0', async () => { it('should check balance is now 0', async () => {
let result = await nightmare let result = await nightmare
.waitProperty(selectors.clientRisk.firstRiskLineBalance, 'innerText') .waitToGetProperty(selectors.clientRisk.firstRiskLineBalance, 'innerText');
.getProperty(selectors.clientRisk.firstRiskLineBalance, 'innerText');
expect(result).toEqual('0.00 €'); expect(result).toEqual('0.00 €');
}); });
@ -90,8 +89,7 @@ describe('Client risk path', () => {
it('should check balance is now 100', async () => { it('should check balance is now 100', async () => {
let result = await nightmare let result = await nightmare
.waitProperty(selectors.clientRisk.firstRiskLineBalance, 'innerText') .waitToGetProperty(selectors.clientRisk.firstRiskLineBalance, 'innerText');
.getProperty(selectors.clientRisk.firstRiskLineBalance, 'innerText');
expect(result).toEqual('100.00 €'); expect(result).toEqual('100.00 €');
}); });
@ -117,8 +115,7 @@ describe('Client risk path', () => {
it('should check balance is now -50', async () => { it('should check balance is now -50', async () => {
let result = await nightmare let result = await nightmare
.waitProperty(selectors.clientRisk.firstRiskLineBalance, 'innerText') .waitToGetProperty(selectors.clientRisk.firstRiskLineBalance, 'innerText');
.getProperty(selectors.clientRisk.firstRiskLineBalance, 'innerText');
expect(result).toEqual('-50.00 €'); expect(result).toEqual('-50.00 €');
}); });

View File

@ -68,56 +68,49 @@ describe('Item Edit basic data path', () => {
.click(selectors.itemNiches.nicheButton) .click(selectors.itemNiches.nicheButton)
.wait(selectors.itemNiches.firstWarehouseDisabled) .wait(selectors.itemNiches.firstWarehouseDisabled)
.waitToClick(selectors.itemBasicData.basicDataButton) .waitToClick(selectors.itemBasicData.basicDataButton)
.waitProperty(selectors.itemBasicData.nameInput, 'value') .waitToGetProperty(selectors.itemBasicData.nameInput, 'value');
.getProperty(selectors.itemBasicData.nameInput, 'value');
expect(result).toEqual('Rose of Purity'); expect(result).toEqual('Rose of Purity');
}); });
it(`should confirm the item type was edited`, async () => { it(`should confirm the item type was edited`, async () => {
const result = await nightmare const result = await nightmare
.waitProperty(selectors.itemBasicData.typeSelect, 'value') .waitToGetProperty(selectors.itemBasicData.typeSelect, 'value');
.getProperty(selectors.itemBasicData.typeSelect, 'value');
expect(result).toEqual('Crisantemo'); expect(result).toEqual('Crisantemo');
}); });
it(`should confirm the item intrastad was edited`, async () => { it(`should confirm the item intrastad was edited`, async () => {
const result = await nightmare const result = await nightmare
.waitProperty(selectors.itemBasicData.intrastatSelect, 'value') .waitToGetProperty(selectors.itemBasicData.intrastatSelect, 'value');
.getProperty(selectors.itemBasicData.intrastatSelect, 'value');
expect(result).toEqual('5080000 Coral y materiales similares'); expect(result).toEqual('5080000 Coral y materiales similares');
}); });
it(`should confirm the item relevancy was edited`, async () => { it(`should confirm the item relevancy was edited`, async () => {
const result = await nightmare const result = await nightmare
.waitProperty(selectors.itemBasicData.relevancyInput, 'value') .waitToGetProperty(selectors.itemBasicData.relevancyInput, 'value');
.getProperty(selectors.itemBasicData.relevancyInput, 'value');
expect(result).toEqual('1'); expect(result).toEqual('1');
}); });
it(`should confirm the item origin was edited`, async () => { it(`should confirm the item origin was edited`, async () => {
const result = await nightmare const result = await nightmare
.waitProperty(selectors.itemBasicData.originSelect, 'value') .waitToGetProperty(selectors.itemBasicData.originSelect, 'value');
.getProperty(selectors.itemBasicData.originSelect, 'value');
expect(result).toEqual('Spain'); expect(result).toEqual('Spain');
}); });
it(`should confirm the item expence was edited`, async () => { it(`should confirm the item expence was edited`, async () => {
const result = await nightmare const result = await nightmare
.waitProperty(selectors.itemBasicData.expenceSelect, 'value') .waitToGetProperty(selectors.itemBasicData.expenceSelect, 'value');
.getProperty(selectors.itemBasicData.expenceSelect, 'value');
expect(result).toEqual('Adquisición mercancia Extracomunitaria'); expect(result).toEqual('Adquisición mercancia Extracomunitaria');
}); });
it(`should confirm the item long name was edited`, async () => { it(`should confirm the item long name was edited`, async () => {
const result = await nightmare const result = await nightmare
.waitProperty(selectors.itemBasicData.longNameInput, 'value') .waitToGetProperty(selectors.itemBasicData.longNameInput, 'value');
.getProperty(selectors.itemBasicData.longNameInput, 'value');
expect(result).toEqual('RS Rose of Purity'); expect(result).toEqual('RS Rose of Purity');
}); });

View File

@ -61,21 +61,30 @@ describe('Item create tags path', () => {
.wait(selectors.itemBasicData.nameInput) .wait(selectors.itemBasicData.nameInput)
.click(selectors.itemTags.tagsButton) .click(selectors.itemTags.tagsButton)
.wait('vn-item-tags') .wait('vn-item-tags')
.getProperty(selectors.itemTags.firstTagSelect, 'value'); .waitToGetProperty(selectors.itemTags.firstTagSelect, 'value');
expect(result).toEqual('Ancho de la base'); expect(result).toEqual('Ancho de la base');
result = await nightmare.getProperty(selectors.itemTags.firstValueInput, 'value');
result = await nightmare
.waitToGetProperty(selectors.itemTags.firstValueInput, 'value');
expect(result).toEqual('50'); expect(result).toEqual('50');
result = await nightmare.getProperty(selectors.itemTags.firstRelevancyInput, 'value');
result = await nightmare
.waitToGetProperty(selectors.itemTags.firstRelevancyInput, 'value');
expect(result).toEqual('1'); expect(result).toEqual('1');
}); });
it(`should confirm the second row data is the expected one`, async () => { it(`should confirm the second row data is the expected one`, async () => {
let tag = await nightmare.getProperty(selectors.itemTags.secondTagSelect, 'value'); let tag = await nightmare
let value = await nightmare.getProperty(selectors.itemTags.secondValueInput, 'value'); .waitToGetProperty(selectors.itemTags.secondTagSelect, 'value');
let relevancy = await nightmare.getProperty(selectors.itemTags.secondRelevancyInput, 'value');
let value = await nightmare
.waitToGetProperty(selectors.itemTags.secondValueInput, 'value');
let relevancy = await nightmare
.waitToGetProperty(selectors.itemTags.secondRelevancyInput, 'value');
expect(tag).toEqual('Variedad'); expect(tag).toEqual('Variedad');
expect(value).toEqual('Gem1'); expect(value).toEqual('Gem1');
@ -83,9 +92,14 @@ describe('Item create tags path', () => {
}); });
it(`should confirm the third row data is the expected one`, async () => { it(`should confirm the third row data is the expected one`, async () => {
let tag = await nightmare.getProperty(selectors.itemTags.thirdTagSelect, 'value'); let tag = await nightmare
let value = await nightmare.getProperty(selectors.itemTags.thirdValueInput, 'value'); .waitToGetProperty(selectors.itemTags.thirdTagSelect, 'value');
let relevancy = await nightmare.getProperty(selectors.itemTags.thirdRelevancyInput, 'value');
let value = await nightmare
.waitToGetProperty(selectors.itemTags.thirdValueInput, 'value');
let relevancy = await nightmare
.waitToGetProperty(selectors.itemTags.thirdRelevancyInput, 'value');
expect(tag).toEqual('Longitud(cm)'); expect(tag).toEqual('Longitud(cm)');
expect(value).toEqual('5'); expect(value).toEqual('5');
@ -93,9 +107,14 @@ describe('Item create tags path', () => {
}); });
it(`should confirm the fourth row data is the expected one`, async () => { it(`should confirm the fourth row data is the expected one`, async () => {
let tag = await nightmare.getProperty(selectors.itemTags.fourthTagSelect, 'value'); let tag = await nightmare
let value = await nightmare.getProperty(selectors.itemTags.fourthValueInput, 'value'); .waitToGetProperty(selectors.itemTags.fourthTagSelect, 'value');
let relevancy = await nightmare.getProperty(selectors.itemTags.fourthRelevancyInput, 'value');
let value = await nightmare
.waitToGetProperty(selectors.itemTags.fourthValueInput, 'value');
let relevancy = await nightmare
.waitToGetProperty(selectors.itemTags.fourthRelevancyInput, 'value');
expect(tag).toEqual('Proveedor'); expect(tag).toEqual('Proveedor');
expect(value).toEqual('Marvel1'); expect(value).toEqual('Marvel1');
@ -103,9 +122,14 @@ describe('Item create tags path', () => {
}); });
it(`should confirm the fifth row data is the expected one`, async () => { it(`should confirm the fifth row data is the expected one`, async () => {
let tag = await nightmare.getProperty(selectors.itemTags.fifthTagSelect, 'value'); let tag = await nightmare
let value = await nightmare.getProperty(selectors.itemTags.fifthValueInput, 'value'); .waitToGetProperty(selectors.itemTags.fifthTagSelect, 'value');
let relevancy = await nightmare.getProperty(selectors.itemTags.fifthRelevancyInput, 'value');
let value = await nightmare
.waitToGetProperty(selectors.itemTags.fifthValueInput, 'value');
let relevancy = await nightmare
.waitToGetProperty(selectors.itemTags.fifthRelevancyInput, 'value');
expect(tag).toEqual('Color'); expect(tag).toEqual('Color');
expect(value).toEqual('Yellow'); expect(value).toEqual('Yellow');

View File

@ -85,8 +85,7 @@ describe('Item Create/Clone path', () => {
expect(result).toEqual('Crisantemo'); expect(result).toEqual('Crisantemo');
result = await nightmare result = await nightmare
.waitProperty(selectors.itemBasicData.intrastatSelect, 'value') .waitToGetProperty(selectors.itemBasicData.intrastatSelect, 'value');
.getProperty(selectors.itemBasicData.intrastatSelect, 'value');
expect(result).toEqual('6021010 Plantas vivas: Esqueje/injerto, Vid'); expect(result).toEqual('6021010 Plantas vivas: Esqueje/injerto, Vid');

View File

@ -67,11 +67,11 @@ describe('Ticket', () => {
.click(selectors.ticketPackages.packagesButton) .click(selectors.ticketPackages.packagesButton)
.wait(selectors.ticketPackages.firstPackageSelect) .wait(selectors.ticketPackages.firstPackageSelect)
.click(selectors.ticketNotes.notesButton) .click(selectors.ticketNotes.notesButton)
.waitProperty(selectors.ticketNotes.firstNoteSelect, 'value') .waitToGetProperty(selectors.ticketNotes.firstNoteSelect, 'value')
.then(result => { .then(result => {
expect(result).toEqual('observation one'); expect(result).toEqual('observation one');
return nightmare return nightmare
.getProperty(selectors.ticketNotes.firstDescriptionInput, 'value'); .waitToGetProperty(selectors.ticketNotes.firstDescriptionInput, 'value');
}) })
.then(result => { .then(result => {
expect(result).toEqual('description'); expect(result).toEqual('description');

View File

@ -48,7 +48,7 @@ describe('Ticket List components path', () => {
const base = await nightmare const base = await nightmare
.waitPropertyLength(selectors.ticketComponents.base, 'innerText', minLength) .waitPropertyLength(selectors.ticketComponents.base, 'innerText', minLength)
.getProperty(selectors.ticketComponents.base, 'innerText'); .waitToGetProperty(selectors.ticketComponents.base, 'innerText');
expect(base).toContain('Base'); expect(base).toContain('Base');
@ -61,7 +61,7 @@ describe('Ticket List components path', () => {
const margin = await nightmare const margin = await nightmare
.waitPropertyLength(selectors.ticketComponents.margin, 'innerText', minLength) .waitPropertyLength(selectors.ticketComponents.margin, 'innerText', minLength)
.getProperty(selectors.ticketComponents.margin, 'innerText'); .waitToGetProperty(selectors.ticketComponents.margin, 'innerText');
expect(margin).toContain('Margin'); expect(margin).toContain('Margin');
@ -74,7 +74,7 @@ describe('Ticket List components path', () => {
const total = await nightmare const total = await nightmare
.waitPropertyLength(selectors.ticketComponents.total, 'innerText', minLength) .waitPropertyLength(selectors.ticketComponents.total, 'innerText', minLength)
.getProperty(selectors.ticketComponents.total, 'innerText'); .waitToGetProperty(selectors.ticketComponents.total, 'innerText');
expect(total).toContain('Total'); expect(total).toContain('Total');

View File

@ -86,8 +86,7 @@ describe('Ticket descriptor path', () => {
const result = await nightmare const result = await nightmare
.waitToClick(selectors.ticketsIndex.moreMenu) .waitToClick(selectors.ticketsIndex.moreMenu)
.waitToClick(selectors.ticketsIndex.moreMenuTurns) .waitToClick(selectors.ticketsIndex.moreMenuTurns)
.waitProperty(selectors.ticketsIndex.sixthWeeklyTicketTurn, 'value') .waitToGetProperty(selectors.ticketsIndex.sixthWeeklyTicketTurn, 'value');
.getProperty(selectors.ticketsIndex.sixthWeeklyTicketTurn, 'value');
expect(result).toEqual('Thursday'); expect(result).toEqual('Thursday');
}); });
@ -148,8 +147,7 @@ describe('Ticket descriptor path', () => {
const result = await nightmare const result = await nightmare
.waitToClick(selectors.ticketsIndex.moreMenu) .waitToClick(selectors.ticketsIndex.moreMenu)
.waitToClick(selectors.ticketsIndex.moreMenuTurns) .waitToClick(selectors.ticketsIndex.moreMenuTurns)
.waitProperty(selectors.ticketsIndex.sixthWeeklyTicketTurn, 'value') .waitToGetProperty(selectors.ticketsIndex.sixthWeeklyTicketTurn, 'value');
.getProperty(selectors.ticketsIndex.sixthWeeklyTicketTurn, 'value');
expect(result).toEqual('Saturday'); expect(result).toEqual('Saturday');
}); });

View File

@ -70,8 +70,7 @@ describe('Ticket purchase request path', () => {
.waitToClick(selectors.ticketBasicData.basicDataButton) .waitToClick(selectors.ticketBasicData.basicDataButton)
.wait(selectors.ticketBasicData.clientSelect) .wait(selectors.ticketBasicData.clientSelect)
.waitToClick(selectors.ticketRequests.requestButton) .waitToClick(selectors.ticketRequests.requestButton)
.waitProperty(selectors.ticketRequests.firstDescription, 'innerText') .waitToGetProperty(selectors.ticketRequests.firstDescription, 'innerText');
.getProperty(selectors.ticketRequests.firstDescription, 'innerText');
expect(result).toEqual('New stuff'); expect(result).toEqual('New stuff');
}); });

View File

@ -55,15 +55,14 @@ describe('Ticket diary path', () => {
it(`should check the seventh line id is marked as counter`, async () => { it(`should check the seventh line id is marked as counter`, async () => {
const result = await nightmare const result = await nightmare
.waitProperty(selectors.itemDiary.thirdTicketId, 'className') .waitToGetProperty(selectors.itemDiary.thirdTicketId, 'className');
.getProperty(selectors.itemDiary.thirdTicketId, 'className');
expect(result).toContain('counter'); expect(result).toContain('counter');
}); });
it(`should check the fifth line balance is marked as counter`, async () => { it(`should check the fifth line balance is marked as counter`, async () => {
const result = await nightmare const result = await nightmare
.getProperty(selectors.itemDiary.fifthBalance, 'className'); .waitToGetProperty(selectors.itemDiary.fifthBalance, 'className');
expect(result).toContain('counter'); expect(result).toContain('counter');
}); });
@ -72,8 +71,7 @@ describe('Ticket diary path', () => {
const result = await nightmare const result = await nightmare
.waitToClick(selectors.itemDiary.warehouseSelect) .waitToClick(selectors.itemDiary.warehouseSelect)
.waitToClick(selectors.itemDiary.warehouseSelectFourthOption) .waitToClick(selectors.itemDiary.warehouseSelectFourthOption)
.waitProperty(selectors.itemDiary.firstBalance, 'className') .waitToGetProperty(selectors.itemDiary.firstBalance, 'className');
.getProperty(selectors.itemDiary.firstBalance, 'className');
expect(result).toContain('balance'); expect(result).toContain('balance');
}); });

View File

@ -6,15 +6,15 @@ process.on('warning', warning => {
console.log(warning.stack); console.log(warning.stack);
}); });
var verbose = false; let verbose = false;
if (process.argv[2] === '--v') { if (process.argv[2] === '--v')
verbose = true; verbose = true;
}
var Jasmine = require('jasmine');
var jasmine = new Jasmine(); let Jasmine = require('jasmine');
var SpecReporter = require('jasmine-spec-reporter').SpecReporter; let jasmine = new Jasmine();
let SpecReporter = require('jasmine-spec-reporter').SpecReporter;
jasmine.loadConfig({ jasmine.loadConfig({
spec_files: [ spec_files: [