diff --git a/e2e/helpers/extensions.js b/e2e/helpers/extensions.js index 9aa1c039b..a812728b3 100644 --- a/e2e/helpers/extensions.js +++ b/e2e/helpers/extensions.js @@ -4,89 +4,6 @@ import config from './config.js'; import Nightmare from 'nightmare'; 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.action(name, function(...args) { @@ -106,192 +23,283 @@ Nightmare.asyncAction('clearInput', async function(selector) { .type(selector, backSpaces.join('')); }); -Nightmare.action('write', function(selector, text, done) { - this.wait(selector) - .type(selector, text) - .then(done) - .catch(done); -}); +let actions = { + 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('waitToClick', function(selector, done) { - this.wait(selector) - .click(selector) - .then(done) - .catch(done); -}); + 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('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`); + waitForLogin: function(userName, done) { + this.login(userName) + .waitForURL('#!/') + .url() + .changeLanguageToEnglish() + .then(done) + .catch(done); + }, - 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); + parsedUrl: function(done) { + this.url() + .then(url => { + done(null, new URL(url)); + }).catch(done); + }, - if (elementInTopLeft) - elementInTopLeft.dispatchEvent(e); + getProperty: function(selector, property, done) { + this.evaluate_now((selector, property) => { + return document.querySelector(selector)[property].replace(/\s+/g, ' ').trim(); + }, done, selector, property); + }, - if (elementInBottomRight) - elementInBottomRight.dispatchEvent(e); + 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); + }, - element.removeEventListener('mouseover', eventHandler); - } - return isVisible; + waitToGetProperty: 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); + }, + + 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); -}); + }, -Nightmare.action('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); + waitForNumberOfElements: function(selector, count, done) { + this.wait((selector, count) => { + return document.querySelectorAll(selector).length === count; + }, selector, count) + .then(done) + .catch(err => { + console.error(err.name, err.message); + 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) - .mouseup(selector) - .then(done) - .catch(done); -}); - -Nightmare.action('countElement', function(selector, done) { - this.evaluate_now(selector => { - return document.querySelectorAll(selector).length; - }, done, selector); -}); - -Nightmare.action('waitForNumberOfElements', function(selector, count, done) { - this.wait((selector, count) => { - return document.querySelectorAll(selector).length === count; - }, selector, count) - .then(done) - .catch(err => { - console.error(err.name, err.message); - done(new Error(`.waitForNumberOfElements() for ${selector}, count ${count} timed out`)); - }); -}); - -Nightmare.action('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`)); - }); -}); - -Nightmare.action('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); -}); - -Nightmare.action('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); -}); - -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); + .then(done) + .catch(done); + }, + + waitForURL: function(hashURL, done) { + this.wait(hash => { + return document.location.hash.includes(hash); + }, hashURL) + .then(done) + .catch(done); + }, + + 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); + }, + + waitForSnackbar: function(done) { + this.wait(500).waitForShapes('vn-snackbar .shape .text') + .then(shapes => { + done(null, shapes); + }).catch(done); + }, + + waitForLastShape: function(selector, done) { + this.wait(selector) + .evaluate_now(selector => { + const shape = document.querySelector(selector); + + return shape.innerText; + }, done, selector); + }, + + waitForLastSnackbar: function(done) { + this.wait(500).waitForLastShape('vn-snackbar .shape .text') + .then(shapes => { + done(null, shapes); + }).catch(done); + } +}; + +Object.keys(actions).forEach(function(name) { + let fn = actions[name]; + Nightmare.action(name, fn); }); diff --git a/e2e/paths/client-module/04_edit_pay_method.spec.js b/e2e/paths/client-module/04_edit_pay_method.spec.js index 612995949..659fa07bc 100644 --- a/e2e/paths/client-module/04_edit_pay_method.spec.js +++ b/e2e/paths/client-module/04_edit_pay_method.spec.js @@ -65,8 +65,8 @@ describe('Client Edit pay method path', () => { it(`should add the IBAN but fail as it requires a BIC code`, async () => { const snackbarMessage = await nightmare .clearInput(selectors.clientPayMethod.IBANInput) - .type(selectors.clientPayMethod.IBANInput, 'ES91 2100 0418 4502 0005 1332') - .waitForTextInInput(selectors.clientPayMethod.IBANInput, 'ES91 2100 0418 4502 0005 1332') + .type(selectors.clientPayMethod.IBANInput, 'ES9121000418450200051332') + .waitForTextInInput(selectors.clientPayMethod.IBANInput, 'ES9121000418450200051332') .waitToClick(selectors.clientPayMethod.clearswiftBicButton) .waitToClick(selectors.clientPayMethod.saveButton) .waitForLastSnackbar(); @@ -101,16 +101,14 @@ describe('Client Edit pay method path', () => { it('should confirm the IBAN was saved', async () => { const IBAN = await nightmare - .waitProperty(selectors.clientPayMethod.IBANInput, 'value') - .getProperty(selectors.clientPayMethod.IBANInput, 'value'); + .waitToGetProperty(selectors.clientPayMethod.IBANInput, 'value'); expect(IBAN).toEqual('ES91 2100 0418 4502 0005 1332'); }); it('should confirm the swift / BIC code was saved', async () => { const code = await nightmare - .waitProperty(selectors.clientPayMethod.swiftBicInput, 'value') - .getProperty(selectors.clientPayMethod.swiftBicInput, 'value'); + .waitToGetProperty(selectors.clientPayMethod.swiftBicInput, 'value'); expect(code).toEqual('GTHMCT Gotham City Banks'); }); diff --git a/e2e/paths/client-module/05_add_address.spec.js b/e2e/paths/client-module/05_add_address.spec.js index 0e8b54d9b..382f6fb7d 100644 --- a/e2e/paths/client-module/05_add_address.spec.js +++ b/e2e/paths/client-module/05_add_address.spec.js @@ -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 () => { const result = await nightmare .waitToClick(selectors.clientAddresses.addressesButton) - .wait(selectors.clientAddresses.defaultAddress) - .getInnerText(selectors.clientAddresses.defaultAddress); + .waitToGetProperty(selectors.clientAddresses.defaultAddress, 'innerText'); expect(result).toContain('320 Park Avenue New York'); }); @@ -110,7 +109,7 @@ describe('Client Add address path', () => { const result = await nightmare .waitToClick(selectors.clientAddresses.secondMakeDefaultStar) .waitForTextInElement(selectors.clientAddresses.defaultAddress, 'Somewhere in Thailand') - .getInnerText(selectors.clientAddresses.defaultAddress); + .waitToGetProperty(selectors.clientAddresses.defaultAddress, 'innerText'); expect(result).toContain('Somewhere in Thailand'); }); diff --git a/e2e/paths/client-module/14_risk.spec.js b/e2e/paths/client-module/14_risk.spec.js index c605cbbf6..369dcd83a 100644 --- a/e2e/paths/client-module/14_risk.spec.js +++ b/e2e/paths/client-module/14_risk.spec.js @@ -63,8 +63,7 @@ describe('Client risk path', () => { it('should check balance is now 0', async () => { let result = await nightmare - .waitProperty(selectors.clientRisk.firstRiskLineBalance, 'innerText') - .getProperty(selectors.clientRisk.firstRiskLineBalance, 'innerText'); + .waitToGetProperty(selectors.clientRisk.firstRiskLineBalance, 'innerText'); expect(result).toEqual('0.00 €'); }); @@ -90,8 +89,7 @@ describe('Client risk path', () => { it('should check balance is now 100', async () => { let result = await nightmare - .waitProperty(selectors.clientRisk.firstRiskLineBalance, 'innerText') - .getProperty(selectors.clientRisk.firstRiskLineBalance, 'innerText'); + .waitToGetProperty(selectors.clientRisk.firstRiskLineBalance, 'innerText'); expect(result).toEqual('100.00 €'); }); @@ -117,8 +115,7 @@ describe('Client risk path', () => { it('should check balance is now -50', async () => { let result = await nightmare - .waitProperty(selectors.clientRisk.firstRiskLineBalance, 'innerText') - .getProperty(selectors.clientRisk.firstRiskLineBalance, 'innerText'); + .waitToGetProperty(selectors.clientRisk.firstRiskLineBalance, 'innerText'); expect(result).toEqual('-50.00 €'); }); diff --git a/e2e/paths/item-module/02_edit_item_basic_data.spec.js b/e2e/paths/item-module/02_edit_item_basic_data.spec.js index 86ed10ba4..a446877b0 100644 --- a/e2e/paths/item-module/02_edit_item_basic_data.spec.js +++ b/e2e/paths/item-module/02_edit_item_basic_data.spec.js @@ -68,56 +68,49 @@ describe('Item Edit basic data path', () => { .click(selectors.itemNiches.nicheButton) .wait(selectors.itemNiches.firstWarehouseDisabled) .waitToClick(selectors.itemBasicData.basicDataButton) - .waitProperty(selectors.itemBasicData.nameInput, 'value') - .getProperty(selectors.itemBasicData.nameInput, 'value'); + .waitToGetProperty(selectors.itemBasicData.nameInput, 'value'); expect(result).toEqual('Rose of Purity'); }); it(`should confirm the item type was edited`, async () => { const result = await nightmare - .waitProperty(selectors.itemBasicData.typeSelect, 'value') - .getProperty(selectors.itemBasicData.typeSelect, 'value'); + .waitToGetProperty(selectors.itemBasicData.typeSelect, 'value'); expect(result).toEqual('Crisantemo'); }); it(`should confirm the item intrastad was edited`, async () => { const result = await nightmare - .waitProperty(selectors.itemBasicData.intrastatSelect, 'value') - .getProperty(selectors.itemBasicData.intrastatSelect, 'value'); + .waitToGetProperty(selectors.itemBasicData.intrastatSelect, 'value'); expect(result).toEqual('5080000 Coral y materiales similares'); }); it(`should confirm the item relevancy was edited`, async () => { const result = await nightmare - .waitProperty(selectors.itemBasicData.relevancyInput, 'value') - .getProperty(selectors.itemBasicData.relevancyInput, 'value'); + .waitToGetProperty(selectors.itemBasicData.relevancyInput, 'value'); expect(result).toEqual('1'); }); it(`should confirm the item origin was edited`, async () => { const result = await nightmare - .waitProperty(selectors.itemBasicData.originSelect, 'value') - .getProperty(selectors.itemBasicData.originSelect, 'value'); + .waitToGetProperty(selectors.itemBasicData.originSelect, 'value'); expect(result).toEqual('Spain'); }); it(`should confirm the item expence was edited`, async () => { const result = await nightmare - .waitProperty(selectors.itemBasicData.expenceSelect, 'value') - .getProperty(selectors.itemBasicData.expenceSelect, 'value'); + .waitToGetProperty(selectors.itemBasicData.expenceSelect, 'value'); expect(result).toEqual('Adquisición mercancia Extracomunitaria'); }); it(`should confirm the item long name was edited`, async () => { const result = await nightmare - .waitProperty(selectors.itemBasicData.longNameInput, 'value') - .getProperty(selectors.itemBasicData.longNameInput, 'value'); + .waitToGetProperty(selectors.itemBasicData.longNameInput, 'value'); expect(result).toEqual('RS Rose of Purity'); }); diff --git a/e2e/paths/item-module/04_create_item_tags.spec.js b/e2e/paths/item-module/04_create_item_tags.spec.js index 2830077d3..486f42f7c 100644 --- a/e2e/paths/item-module/04_create_item_tags.spec.js +++ b/e2e/paths/item-module/04_create_item_tags.spec.js @@ -61,21 +61,30 @@ describe('Item create tags path', () => { .wait(selectors.itemBasicData.nameInput) .click(selectors.itemTags.tagsButton) .wait('vn-item-tags') - .getProperty(selectors.itemTags.firstTagSelect, 'value'); + .waitToGetProperty(selectors.itemTags.firstTagSelect, 'value'); 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'); - result = await nightmare.getProperty(selectors.itemTags.firstRelevancyInput, 'value'); + + result = await nightmare + .waitToGetProperty(selectors.itemTags.firstRelevancyInput, 'value'); expect(result).toEqual('1'); }); it(`should confirm the second row data is the expected one`, async () => { - let tag = await nightmare.getProperty(selectors.itemTags.secondTagSelect, 'value'); - let value = await nightmare.getProperty(selectors.itemTags.secondValueInput, 'value'); - let relevancy = await nightmare.getProperty(selectors.itemTags.secondRelevancyInput, 'value'); + let tag = await nightmare + .waitToGetProperty(selectors.itemTags.secondTagSelect, 'value'); + + let value = await nightmare + .waitToGetProperty(selectors.itemTags.secondValueInput, 'value'); + + let relevancy = await nightmare + .waitToGetProperty(selectors.itemTags.secondRelevancyInput, 'value'); expect(tag).toEqual('Variedad'); 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 () => { - let tag = await nightmare.getProperty(selectors.itemTags.thirdTagSelect, 'value'); - let value = await nightmare.getProperty(selectors.itemTags.thirdValueInput, 'value'); - let relevancy = await nightmare.getProperty(selectors.itemTags.thirdRelevancyInput, 'value'); + let tag = await nightmare + .waitToGetProperty(selectors.itemTags.thirdTagSelect, '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(value).toEqual('5'); @@ -93,9 +107,14 @@ describe('Item create tags path', () => { }); it(`should confirm the fourth row data is the expected one`, async () => { - let tag = await nightmare.getProperty(selectors.itemTags.fourthTagSelect, 'value'); - let value = await nightmare.getProperty(selectors.itemTags.fourthValueInput, 'value'); - let relevancy = await nightmare.getProperty(selectors.itemTags.fourthRelevancyInput, 'value'); + let tag = await nightmare + .waitToGetProperty(selectors.itemTags.fourthTagSelect, 'value'); + + let value = await nightmare + .waitToGetProperty(selectors.itemTags.fourthValueInput, 'value'); + + let relevancy = await nightmare + .waitToGetProperty(selectors.itemTags.fourthRelevancyInput, 'value'); expect(tag).toEqual('Proveedor'); 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 () => { - let tag = await nightmare.getProperty(selectors.itemTags.fifthTagSelect, 'value'); - let value = await nightmare.getProperty(selectors.itemTags.fifthValueInput, 'value'); - let relevancy = await nightmare.getProperty(selectors.itemTags.fifthRelevancyInput, 'value'); + let tag = await nightmare + .waitToGetProperty(selectors.itemTags.fifthTagSelect, 'value'); + + let value = await nightmare + .waitToGetProperty(selectors.itemTags.fifthValueInput, 'value'); + + let relevancy = await nightmare + .waitToGetProperty(selectors.itemTags.fifthRelevancyInput, 'value'); expect(tag).toEqual('Color'); expect(value).toEqual('Yellow'); diff --git a/e2e/paths/item-module/08_item_create_and_clone.spec.js b/e2e/paths/item-module/08_item_create_and_clone.spec.js index f7cb7024e..3959b4c67 100644 --- a/e2e/paths/item-module/08_item_create_and_clone.spec.js +++ b/e2e/paths/item-module/08_item_create_and_clone.spec.js @@ -85,8 +85,7 @@ describe('Item Create/Clone path', () => { expect(result).toEqual('Crisantemo'); result = await nightmare - .waitProperty(selectors.itemBasicData.intrastatSelect, 'value') - .getProperty(selectors.itemBasicData.intrastatSelect, 'value'); + .waitToGetProperty(selectors.itemBasicData.intrastatSelect, 'value'); expect(result).toEqual('6021010 Plantas vivas: Esqueje/injerto, Vid'); diff --git a/e2e/paths/ticket-module/01_create_ticket_observations.spec.js b/e2e/paths/ticket-module/01_create_ticket_observations.spec.js index 3f7b973c7..4073e9ea4 100644 --- a/e2e/paths/ticket-module/01_create_ticket_observations.spec.js +++ b/e2e/paths/ticket-module/01_create_ticket_observations.spec.js @@ -67,11 +67,11 @@ describe('Ticket', () => { .click(selectors.ticketPackages.packagesButton) .wait(selectors.ticketPackages.firstPackageSelect) .click(selectors.ticketNotes.notesButton) - .waitProperty(selectors.ticketNotes.firstNoteSelect, 'value') + .waitToGetProperty(selectors.ticketNotes.firstNoteSelect, 'value') .then(result => { expect(result).toEqual('observation one'); return nightmare - .getProperty(selectors.ticketNotes.firstDescriptionInput, 'value'); + .waitToGetProperty(selectors.ticketNotes.firstDescriptionInput, 'value'); }) .then(result => { expect(result).toEqual('description'); diff --git a/e2e/paths/ticket-module/08_list_components.spec.js b/e2e/paths/ticket-module/08_list_components.spec.js index 41ac6d5af..9a83eae6a 100644 --- a/e2e/paths/ticket-module/08_list_components.spec.js +++ b/e2e/paths/ticket-module/08_list_components.spec.js @@ -48,7 +48,7 @@ describe('Ticket List components path', () => { const base = await nightmare .waitPropertyLength(selectors.ticketComponents.base, 'innerText', minLength) - .getProperty(selectors.ticketComponents.base, 'innerText'); + .waitToGetProperty(selectors.ticketComponents.base, 'innerText'); expect(base).toContain('Base'); @@ -61,7 +61,7 @@ describe('Ticket List components path', () => { const margin = await nightmare .waitPropertyLength(selectors.ticketComponents.margin, 'innerText', minLength) - .getProperty(selectors.ticketComponents.margin, 'innerText'); + .waitToGetProperty(selectors.ticketComponents.margin, 'innerText'); expect(margin).toContain('Margin'); @@ -74,7 +74,7 @@ describe('Ticket List components path', () => { const total = await nightmare .waitPropertyLength(selectors.ticketComponents.total, 'innerText', minLength) - .getProperty(selectors.ticketComponents.total, 'innerText'); + .waitToGetProperty(selectors.ticketComponents.total, 'innerText'); expect(total).toContain('Total'); diff --git a/e2e/paths/ticket-module/09_ticket_weekly.spec.js b/e2e/paths/ticket-module/09_ticket_weekly.spec.js index d729b8428..3c55a0178 100644 --- a/e2e/paths/ticket-module/09_ticket_weekly.spec.js +++ b/e2e/paths/ticket-module/09_ticket_weekly.spec.js @@ -86,8 +86,7 @@ describe('Ticket descriptor path', () => { const result = await nightmare .waitToClick(selectors.ticketsIndex.moreMenu) .waitToClick(selectors.ticketsIndex.moreMenuTurns) - .waitProperty(selectors.ticketsIndex.sixthWeeklyTicketTurn, 'value') - .getProperty(selectors.ticketsIndex.sixthWeeklyTicketTurn, 'value'); + .waitToGetProperty(selectors.ticketsIndex.sixthWeeklyTicketTurn, 'value'); expect(result).toEqual('Thursday'); }); @@ -148,8 +147,7 @@ describe('Ticket descriptor path', () => { const result = await nightmare .waitToClick(selectors.ticketsIndex.moreMenu) .waitToClick(selectors.ticketsIndex.moreMenuTurns) - .waitProperty(selectors.ticketsIndex.sixthWeeklyTicketTurn, 'value') - .getProperty(selectors.ticketsIndex.sixthWeeklyTicketTurn, 'value'); + .waitToGetProperty(selectors.ticketsIndex.sixthWeeklyTicketTurn, 'value'); expect(result).toEqual('Saturday'); }); diff --git a/e2e/paths/ticket-module/10_ticket_request.spec.js b/e2e/paths/ticket-module/10_ticket_request.spec.js index 2989e5505..3cd3ecb62 100644 --- a/e2e/paths/ticket-module/10_ticket_request.spec.js +++ b/e2e/paths/ticket-module/10_ticket_request.spec.js @@ -70,8 +70,7 @@ describe('Ticket purchase request path', () => { .waitToClick(selectors.ticketBasicData.basicDataButton) .wait(selectors.ticketBasicData.clientSelect) .waitToClick(selectors.ticketRequests.requestButton) - .waitProperty(selectors.ticketRequests.firstDescription, 'innerText') - .getProperty(selectors.ticketRequests.firstDescription, 'innerText'); + .waitToGetProperty(selectors.ticketRequests.firstDescription, 'innerText'); expect(result).toEqual('New stuff'); }); diff --git a/e2e/paths/ticket-module/11_ticket_diary.spec.js b/e2e/paths/ticket-module/11_ticket_diary.spec.js index 39904786e..0543ceee0 100644 --- a/e2e/paths/ticket-module/11_ticket_diary.spec.js +++ b/e2e/paths/ticket-module/11_ticket_diary.spec.js @@ -55,15 +55,14 @@ describe('Ticket diary path', () => { it(`should check the seventh line id is marked as counter`, async () => { const result = await nightmare - .waitProperty(selectors.itemDiary.thirdTicketId, 'className') - .getProperty(selectors.itemDiary.thirdTicketId, 'className'); + .waitToGetProperty(selectors.itemDiary.thirdTicketId, 'className'); expect(result).toContain('counter'); }); it(`should check the fifth line balance is marked as counter`, async () => { const result = await nightmare - .getProperty(selectors.itemDiary.fifthBalance, 'className'); + .waitToGetProperty(selectors.itemDiary.fifthBalance, 'className'); expect(result).toContain('counter'); }); @@ -72,8 +71,7 @@ describe('Ticket diary path', () => { const result = await nightmare .waitToClick(selectors.itemDiary.warehouseSelect) .waitToClick(selectors.itemDiary.warehouseSelectFourthOption) - .waitProperty(selectors.itemDiary.firstBalance, 'className') - .getProperty(selectors.itemDiary.firstBalance, 'className'); + .waitToGetProperty(selectors.itemDiary.firstBalance, 'className'); expect(result).toContain('balance'); }); diff --git a/e2e_tests.js b/e2e_tests.js index dd1d7a079..c50e35c1d 100644 --- a/e2e_tests.js +++ b/e2e_tests.js @@ -6,15 +6,15 @@ process.on('warning', warning => { console.log(warning.stack); }); -var verbose = false; +let verbose = false; -if (process.argv[2] === '--v') { +if (process.argv[2] === '--v') verbose = true; -} -var Jasmine = require('jasmine'); -var jasmine = new Jasmine(); -var SpecReporter = require('jasmine-spec-reporter').SpecReporter; + +let Jasmine = require('jasmine'); +let jasmine = new Jasmine(); +let SpecReporter = require('jasmine-spec-reporter').SpecReporter; jasmine.loadConfig({ spec_files: [