diff --git a/client/core/src/components/autocomplete/autocomplete.js b/client/core/src/components/autocomplete/autocomplete.js index a8b8ad8f3..aeb117121 100755 --- a/client/core/src/components/autocomplete/autocomplete.js +++ b/client/core/src/components/autocomplete/autocomplete.js @@ -15,9 +15,10 @@ import './style.scss'; * @event change Thrown when value is changed */ export default class Autocomplete extends Input { - constructor($element, $scope, $http, $transclude, $translate) { + constructor($element, $scope, $http, $transclude, $translate, $interpolate) { super($element, $scope); this.$http = $http; + this.$interpolate = $interpolate; this.$transclude = $transclude; this.$translate = $translate; this._field = undefined; @@ -167,36 +168,40 @@ export default class Autocomplete extends Input { } onSelectionRequest(data) { - if (data && data.length > 0) { + if (data && data.length > 0) if (this.multiple) this.selection = data; else this.selection = data[0]; - } else + else this.selection = null; } refreshDisplayed() { let display = ''; + let hasTemplate = this.$transclude && this.$transclude.isSlotFilled('tplItem'); - if (this._selection && this.showField) { + if (this._selection && this.showField) if (this.multiple && Array.isArray(this._selection)) { - for (var item of this._selection) { + for (let item of this._selection) { if (display.length > 0) display += ', '; display += item[this.showField]; } } else { display = this._selection[this.showField]; + if (hasTemplate) { + let template = this.$transclude(() => {}, null, 'tplItem').text(); + display = this.$interpolate(template)(this._selection); + } } - } - + this.input.value = display; - if (this.translateFields) { + if (this.translateFields) if (this.translateFields.indexOf(this.showField) > -1) this.input.value = this.$translate.instant(display); - } + this.mdlUpdate(); } @@ -275,7 +280,7 @@ export default class Autocomplete extends Input { this.$.dropDown.show(this.input, search); } } -Autocomplete.$inject = ['$element', '$scope', '$http', '$transclude', '$translate']; +Autocomplete.$inject = ['$element', '$scope', '$http', '$transclude', '$translate', '$interpolate']; ngModule.component('vnAutocomplete', { template: require('./autocomplete.html'), diff --git a/client/core/src/components/drop-down/drop-down.js b/client/core/src/components/drop-down/drop-down.js index 797b993d4..0e9b79584 100755 --- a/client/core/src/components/drop-down/drop-down.js +++ b/client/core/src/components/drop-down/drop-down.js @@ -26,7 +26,7 @@ export default class DropDown extends Component { this.showLoadMore = true; this.showFilter = true; - this.docKeyDownHandler = e => this.onDocKeyDown(e); + this.docKeyDownHandler = (e) => this.onDocKeyDown(e); } $postLink() { @@ -34,7 +34,7 @@ export default class DropDown extends Component { this.input = this.element.querySelector('.search input'); this.ul = this.element.querySelector('ul'); this.list = this.element.querySelector('.list'); - this.list.addEventListener('scroll', e => this.onScroll(e)); + this.list.addEventListener('scroll', (e) => this.onScroll(e)); } get shown() { @@ -310,9 +310,10 @@ export default class DropDown extends Component { destroyList() { this.ul.innerHTML = ''; - if (this.scopes) + if (this.scopes) { for (let scope of this.scopes) scope.$destroy(); + } this.scopes = []; } @@ -322,9 +323,10 @@ export default class DropDown extends Component { fields.push(this.valueField); fields.push(this.showField); - if (this.fields) + if (this.fields) { for (let field of this.fields) fields.push(field); + } return fields; } @@ -440,9 +442,10 @@ function getPosition(parent, event) { while (target.parentNode !== parent) target = target.parentNode; - for (let i = 0; i < children.length; i++) + for (let i = 0; i < children.length; i++) { if (children[i] === target) return i; + } return -1; } diff --git a/e2e/helpers/extensions.js b/e2e/helpers/extensions.js index 92ce1d665..bf6be6c4c 100644 --- a/e2e/helpers/extensions.js +++ b/e2e/helpers/extensions.js @@ -21,9 +21,9 @@ Nightmare.action('changeLanguageToEnglish', function(done) { return document.querySelector(selector).title; }, '#lang') .then((title) => { - if (title === 'Change language') { + if (title === 'Change language') this.then(done); - } else { + else { this.click('#lang') .click('vn-main-menu [vn-id="langs-menu"] ul > li[name="en"]') .then(done); @@ -48,7 +48,7 @@ Nightmare.action('parsedUrl', function(done) { Nightmare.action('getProperty', function(selector, property, done) { this.evaluate_now((selector, property) => { - return document.querySelector(selector)[property]; + return document.querySelector(selector)[property].replace(/\s+/g, ' ').trim(); }, done, selector, property); }); @@ -86,9 +86,9 @@ Nightmare.action('getInputValue', function(selector, done) { Nightmare.action('clearInput', function(selector, done) { const backSpaces = []; - for (let i = 0; i < 50; i += 1) { + for (let i = 0; i < 50; i += 1) backSpaces.push('\u0008'); - } + this.wait(selector) .type(selector, backSpaces.join('')) .then(done); @@ -111,9 +111,9 @@ Nightmare.action('isVisible', function(selector, done) { .evaluate_now((elementSelector) => { const selectorMatches = document.querySelectorAll(elementSelector); const element = selectorMatches[0]; - if (selectorMatches.length > 1) { + if (selectorMatches.length > 1) throw new Error(`multiple matches of ${elementSelector} found`); - } + let isVisible = false; if (element) { const eventHandler = (event) => { @@ -132,15 +132,15 @@ Nightmare.action('isVisible', function(selector, done) { bubbles: true, cancelable: true, }); - if (elementInCenter) { + if (elementInCenter) elementInCenter.dispatchEvent(e); - } - if (elementInTopLeft) { + + if (elementInTopLeft) elementInTopLeft.dispatchEvent(e); - } - if (elementInBottomRight) { + + if (elementInBottomRight) elementInBottomRight.dispatchEvent(e); - } + element.removeEventListener('mouseover', eventHandler); } return isVisible; @@ -176,9 +176,8 @@ Nightmare.action('waitForNumberOfElements', function(selector, count, done) { Nightmare.action('waitForClassNotPresent', function(selector, className, done) { this.wait(selector) .wait((resultSelector, targetClass) => { - if (!document.querySelector(resultSelector).classList.contains(targetClass)) { + if (!document.querySelector(resultSelector).classList.contains(targetClass)) return true; - } }, selector, className) .then(done); }); @@ -186,9 +185,8 @@ Nightmare.action('waitForClassNotPresent', function(selector, className, done) { Nightmare.action('waitForClassPresent', function(selector, className, done) { this.wait(selector) .wait((resultSelector, targetClass) => { - if (document.querySelector(resultSelector).classList.contains(targetClass)) { + if (document.querySelector(resultSelector).classList.contains(targetClass)) return true; - } }, selector, className) .then(done); }); @@ -240,9 +238,9 @@ Nightmare.action('waitForShapes', function(selector, done) { const shapes = document.querySelectorAll(selector); const shapesList = []; - for (const shape of shapes) { + for (const shape of shapes) shapesList.push(shape.innerText); - } + return shapesList; }, done, selector); diff --git a/e2e/paths/client-module/02_edit_basic_data.spec.js b/e2e/paths/client-module/02_edit_basic_data.spec.js index 345c455ac..687869019 100644 --- a/e2e/paths/client-module/02_edit_basic_data.spec.js +++ b/e2e/paths/client-module/02_edit_basic_data.spec.js @@ -234,7 +234,7 @@ describe('Client Edit basicData path', () => { const result = await nightmare .getInputValue(selectors.clientBasicData.salesPersonInput); - expect(result).toEqual('accessory'); + expect(result).toEqual('accessory accessory'); }); it('should now confirm the channel have been selected', async () => { 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 2daeb70ab..8f0523f3c 100644 --- a/e2e/paths/client-module/04_edit_pay_method.spec.js +++ b/e2e/paths/client-module/04_edit_pay_method.spec.js @@ -1,142 +1,140 @@ import selectors from '../../helpers/selectors.js'; import createNightmare from '../../helpers/nightmare'; -describe('Client', () => { - describe('Edit pay method path', () => { - const nightmare = createNightmare(); +describe('Client Edit pay method path', () => { + const nightmare = createNightmare(); - beforeAll(() => { - nightmare - .waitForLogin('administrative'); - }); + beforeAll(() => { + nightmare + .waitForLogin('administrative'); + }); - it('should click on the Clients button of the top bar menu', async () => { - const url = await nightmare - .waitToClick(selectors.globalItems.applicationsMenuButton) - .wait(selectors.globalItems.applicationsMenuVisible) - .waitToClick(selectors.globalItems.clientsButton) - .wait(selectors.clientsIndex.createClientButton) - .parsedUrl(); + it('should click on the Clients button of the top bar menu', async () => { + const url = await nightmare + .waitToClick(selectors.globalItems.applicationsMenuButton) + .wait(selectors.globalItems.applicationsMenuVisible) + .waitToClick(selectors.globalItems.clientsButton) + .wait(selectors.clientsIndex.createClientButton) + .parsedUrl(); - expect(url.hash).toEqual('#!/client/index'); - }); + expect(url.hash).toEqual('#!/client/index'); + }); - it('should search for the user Bruce Banner', async () => { - const resultCount = await nightmare - .wait(selectors.clientsIndex.searchResult) - .type(selectors.clientsIndex.searchClientInput, 'Bruce Banner') - .click(selectors.clientsIndex.searchButton) - .waitForNumberOfElements(selectors.clientsIndex.searchResult, 1) - .countElement(selectors.clientsIndex.searchResult); + it('should search for the user Bruce Banner', async () => { + const resultCount = await nightmare + .wait(selectors.clientsIndex.searchResult) + .type(selectors.clientsIndex.searchClientInput, 'Bruce Banner') + .click(selectors.clientsIndex.searchButton) + .waitForNumberOfElements(selectors.clientsIndex.searchResult, 1) + .countElement(selectors.clientsIndex.searchResult); - expect(resultCount).toEqual(1); - }); + expect(resultCount).toEqual(1); + }); - it(`should click on the search result to access to the client's pay method`, async () => { - const url = await nightmare - .waitForTextInElement(selectors.clientsIndex.searchResult, 'Bruce Banner') - .waitToClick(selectors.clientsIndex.searchResult) - .waitToClick(selectors.clientPayMethod.payMethodButton) - .waitForURL('billing-data') - .url(); + it(`should click on the search result to access to the client's pay method`, async () => { + const url = await nightmare + .waitForTextInElement(selectors.clientsIndex.searchResult, 'Bruce Banner') + .waitToClick(selectors.clientsIndex.searchResult) + .waitToClick(selectors.clientPayMethod.payMethodButton) + .waitForURL('billing-data') + .url(); - expect(url).toContain('billing-data'); - }); + expect(url).toContain('billing-data'); + }); - it(`should attempt to edit the Pay method without an IBAN but fail`, async () => { - const snackbarMessage = await nightmare - .waitToClick(selectors.clientPayMethod.payMethodInput) - .waitToClick(selectors.clientPayMethod.payMethodIBANOption) - .waitForTextInInput(selectors.clientPayMethod.payMethodInput, 'PayMethod with IBAN') - .clearInput(selectors.clientPayMethod.dueDayInput) - .type(selectors.clientPayMethod.dueDayInput, '60') - .waitForTextInInput(selectors.clientPayMethod.dueDayInput, '60') - .waitToClick(selectors.clientPayMethod.receivedCoreLCRCheckbox) - .waitToClick(selectors.clientPayMethod.receivedCoreVNLCheckbox) - .waitToClick(selectors.clientPayMethod.receivedB2BVNLCheckbox) - .waitToClick(selectors.clientPayMethod.saveButton) - .waitForLastSnackbar(); + it(`should attempt to edit the Pay method without an IBAN but fail`, async () => { + const snackbarMessage = await nightmare + .waitToClick(selectors.clientPayMethod.payMethodInput) + .waitToClick(selectors.clientPayMethod.payMethodIBANOption) + .waitForTextInInput(selectors.clientPayMethod.payMethodInput, 'PayMethod with IBAN') + .clearInput(selectors.clientPayMethod.dueDayInput) + .type(selectors.clientPayMethod.dueDayInput, '60') + .waitForTextInInput(selectors.clientPayMethod.dueDayInput, '60') + .waitToClick(selectors.clientPayMethod.receivedCoreLCRCheckbox) + .waitToClick(selectors.clientPayMethod.receivedCoreVNLCheckbox) + .waitToClick(selectors.clientPayMethod.receivedB2BVNLCheckbox) + .waitToClick(selectors.clientPayMethod.saveButton) + .waitForLastSnackbar(); - expect(snackbarMessage).toEqual('That payment method requires an IBAN'); - }); + expect(snackbarMessage).toEqual('That payment method requires an IBAN'); + }); - 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') - .waitToClick(selectors.clientPayMethod.saveButton) - .waitForLastSnackbar(); + 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') + .waitToClick(selectors.clientPayMethod.saveButton) + .waitForLastSnackbar(); - expect(snackbarMessage).toEqual('That payment method requires a BIC'); - }); + expect(snackbarMessage).toEqual('That payment method requires a BIC'); + }); - it(`should create a new BIC code`, async () => { - const newcode = await nightmare - .click(selectors.clientPayMethod.newBankEntityButton) - .type(selectors.clientPayMethod.newBankEntityName, 'Gotham City Banks') - .type(selectors.clientPayMethod.newBankEntityBIC, 'GTHMCT') - .click(selectors.clientPayMethod.acceptBankEntityButton) - .getInputValue(selectors.clientPayMethod.swiftBicInput); + it(`should create a new BIC code`, async () => { + const newcode = await nightmare + .click(selectors.clientPayMethod.newBankEntityButton) + .type(selectors.clientPayMethod.newBankEntityName, 'Gotham City Banks') + .type(selectors.clientPayMethod.newBankEntityBIC, 'GTHMCT') + .click(selectors.clientPayMethod.acceptBankEntityButton) + .getInputValue(selectors.clientPayMethod.swiftBicInput); - expect(newcode).toEqual(''); - }); + expect(newcode).toEqual(''); + }); - it(`should confirm the IBAN pay method is sucessfully saved`, async () => { - const payMethod = await nightmare - .getInputValue(selectors.clientPayMethod.payMethodInput); + it(`should confirm the IBAN pay method is sucessfully saved`, async () => { + const payMethod = await nightmare + .getInputValue(selectors.clientPayMethod.payMethodInput); - expect(payMethod).toEqual('PayMethod with IBAN'); - }); + expect(payMethod).toEqual('PayMethod with IBAN'); + }); - it('should confirm the due day have been edited', async () => { - const dueDate = await nightmare - .getInputValue(selectors.clientPayMethod.dueDayInput); + it('should confirm the due day have been edited', async () => { + const dueDate = await nightmare + .getInputValue(selectors.clientPayMethod.dueDayInput); - expect(dueDate).toEqual('60'); - }); + expect(dueDate).toEqual('60'); + }); - it('should confirm the IBAN was saved', async () => { - const IBAN = await nightmare - .waitProperty(selectors.clientPayMethod.IBANInput, 'value') - .getProperty(selectors.clientPayMethod.IBANInput, 'value'); + it('should confirm the IBAN was saved', async () => { + const IBAN = await nightmare + .waitProperty(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 () => { - const code = await nightmare - .waitProperty(selectors.clientPayMethod.swiftBicInput, 'value') - .getProperty(selectors.clientPayMethod.swiftBicInput, 'value'); + it('should confirm the swift / BIC code was saved', async () => { + const code = await nightmare + .waitProperty(selectors.clientPayMethod.swiftBicInput, 'value') + .getProperty(selectors.clientPayMethod.swiftBicInput, 'value'); - expect(code).toEqual('GTHMCT'); - }); + expect(code).toEqual('GTHMCT Gotham City Banks'); + }); - it('should confirm Received LCR checkbox is checked', async () => { - const checkedBox = await nightmare - .evaluate((selector) => { - return document.querySelector(selector).checked; - }, selectors.clientPayMethod.receivedCoreLCRCheckbox); + it('should confirm Received LCR checkbox is checked', async () => { + const checkedBox = await nightmare + .evaluate((selector) => { + return document.querySelector(selector).checked; + }, selectors.clientPayMethod.receivedCoreLCRCheckbox); - expect(checkedBox).toBeTruthy(); - }); + expect(checkedBox).toBeTruthy(); + }); - it('should confirm Received core VNL checkbox is unchecked', async () => { - const checkedBox = await nightmare - .evaluate((selector) => { - return document.querySelector(selector).checked; - }, selectors.clientPayMethod.receivedCoreVNLCheckbox); + it('should confirm Received core VNL checkbox is unchecked', async () => { + const checkedBox = await nightmare + .evaluate((selector) => { + return document.querySelector(selector).checked; + }, selectors.clientPayMethod.receivedCoreVNLCheckbox); - expect(checkedBox).toBeFalsy(); - }); + expect(checkedBox).toBeFalsy(); + }); - it('should confirm Received B2B VNL checkbox is unchecked', async () => { - const checkedBox = await nightmare - .evaluate((selector) => { - return document.querySelector(selector).checked; - }, selectors.clientPayMethod.receivedB2BVNLCheckbox); + it('should confirm Received B2B VNL checkbox is unchecked', async () => { + const checkedBox = await nightmare + .evaluate((selector) => { + return document.querySelector(selector).checked; + }, selectors.clientPayMethod.receivedB2BVNLCheckbox); - expect(checkedBox).toBeFalsy(); - }); + expect(checkedBox).toBeFalsy(); }); }); 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 ecd5c9502..967a54d7d 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 @@ -84,9 +84,10 @@ describe('Item', () => { it(`should confirm the item intrastad was edited`, async () => { const result = await nightmare - .getInputValue(selectors.itemBasicData.intrastatSelect); + .waitProperty(selectors.itemBasicData.intrastatSelect, 'value') + .getProperty(selectors.itemBasicData.intrastatSelect, 'value'); - expect(result).toEqual('Coral y materiales similares'); + expect(result).toEqual('5080000 Coral y materiales similares'); }); it(`should confirm the item relevancy was edited`, async () => { 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 1bfa239ff..42b77d15d 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 @@ -1,165 +1,145 @@ import selectors from '../../helpers/selectors.js'; import createNightmare from '../../helpers/nightmare'; -describe('Item', () => { +describe('Item Create path', () => { const nightmare = createNightmare(); describe('Create path', () => { beforeAll(() => { return nightmare - .waitForLogin('buyer'); + .waitForLogin('buyer'); }); - it('should access to the items index by clicking the items button', done => { - return nightmare - .click(selectors.moduleAccessView.itemsSectionButton) - .wait(selectors.itemsIndex.createItemButton) - .parsedUrl() - .then(url => { - expect(url.hash).toEqual('#!/item/index'); - done(); - }).catch(done.fail); + it('should access to the items index by clicking the items button', async () => { + const url = await nightmare + .click(selectors.moduleAccessView.itemsSectionButton) + .wait(selectors.itemsIndex.createItemButton) + .parsedUrl(); + + expect(url.hash).toEqual('#!/item/index'); }); - it(`should search for the item Infinity Gauntlet to confirm it isn't created yet`, done => { - return nightmare - .wait(selectors.itemsIndex.searchResult) - .type(selectors.itemsIndex.searchItemInput, 'Infinity Gauntlet') - .click(selectors.itemsIndex.searchButton) - .waitForNumberOfElements(selectors.itemsIndex.searchResult, 0) - .countElement(selectors.itemsIndex.searchResult) - .then(result => { - expect(result).toEqual(0); - done(); - }).catch(done.fail); + it(`should search for the item Infinity Gauntlet to confirm it isn't created yet`, async () => { + const result = await nightmare + .wait(selectors.itemsIndex.searchResult) + .type(selectors.itemsIndex.searchItemInput, 'Infinity Gauntlet') + .click(selectors.itemsIndex.searchButton) + .waitForNumberOfElements(selectors.itemsIndex.searchResult, 0) + .countElement(selectors.itemsIndex.searchResult); + + expect(result).toEqual(0); }); - it('should access to the create item view by clicking the create floating button', done => { - return nightmare - .click(selectors.itemsIndex.createItemButton) - .wait(selectors.itemCreateView.createButton) - .parsedUrl() - .then(url => { - expect(url.hash).toEqual('#!/item/create'); - done(); - }).catch(done.fail); + it('should access to the create item view by clicking the create floating button', async () => { + const url = await nightmare + .click(selectors.itemsIndex.createItemButton) + .wait(selectors.itemCreateView.createButton) + .parsedUrl(); + + expect(url.hash).toEqual('#!/item/create'); }); - it('should return to the item index by clickig the cancel button', done => { - return nightmare - .click(selectors.itemCreateView.cancelButton) - .wait(selectors.itemsIndex.createItemButton) - .parsedUrl() - .then(url => { - expect(url.hash).toEqual('#!/item/index'); - done(); - }).catch(done.fail); + it('should return to the item index by clickig the cancel button', async () => { + const url = await nightmare + .click(selectors.itemCreateView.cancelButton) + .wait(selectors.itemsIndex.createItemButton) + .parsedUrl(); + + expect(url.hash).toEqual('#!/item/index'); }); - it('should now access to the create item view by clicking the create floating button', done => { - return nightmare - .click(selectors.itemsIndex.createItemButton) - .wait(selectors.itemCreateView.createButton) - .parsedUrl() - .then(url => { - expect(url.hash).toEqual('#!/item/create'); - done(); - }).catch(done.fail); + it('should now access to the create item view by clicking the create floating button', async () => { + const url = await nightmare + .click(selectors.itemsIndex.createItemButton) + .wait(selectors.itemCreateView.createButton) + .parsedUrl(); + + expect(url.hash).toEqual('#!/item/create'); }); - it('should create the Infinity Gauntlet item', done => { - return nightmare - .type(selectors.itemCreateView.name, 'Infinity Gauntlet') - .waitToClick(selectors.itemCreateView.typeSelect) - .waitToClick(selectors.itemCreateView.typeSelectOptionThree) - .waitToClick(selectors.itemCreateView.intrastatSelect) - .waitToClick(selectors.itemCreateView.intrastatSelectOptionOne) - .waitToClick(selectors.itemCreateView.originSelect) - .waitToClick(selectors.itemCreateView.originSelectOptionOne) - .click(selectors.itemCreateView.createButton) - .waitForLastSnackbar() - .then(result => { - expect(result).toEqual('Data saved!'); - done(); - }).catch(done.fail); + it('should create the Infinity Gauntlet item', async () => { + const result = await nightmare + .type(selectors.itemCreateView.name, 'Infinity Gauntlet') + .waitToClick(selectors.itemCreateView.typeSelect) + .waitToClick(selectors.itemCreateView.typeSelectOptionThree) + .waitToClick(selectors.itemCreateView.intrastatSelect) + .waitToClick(selectors.itemCreateView.intrastatSelectOptionOne) + .waitToClick(selectors.itemCreateView.originSelect) + .waitToClick(selectors.itemCreateView.originSelectOptionOne) + .click(selectors.itemCreateView.createButton) + .waitForLastSnackbar(); + + expect(result).toEqual('Data saved!'); }); - it('should confirm Infinity Gauntlet item was created', done => { - return nightmare - .wait(selectors.itemBasicData.nameInput) - .getInputValue(selectors.itemBasicData.nameInput) - .then(result => { - expect(result).toBe('Infinity Gauntlet'); - return nightmare + it('should confirm Infinity Gauntlet item was created', async () => { + let result = await nightmare + .wait(selectors.itemBasicData.nameInput) + .getInputValue(selectors.itemBasicData.nameInput); + + expect(result).toEqual('Infinity Gauntlet'); + + + result = await nightmare .getInputValue(selectors.itemBasicData.typeSelect); - }) - .then(result => { - expect(result).toBe('Crisantemo'); - return nightmare - .getInputValue(selectors.itemBasicData.intrastatSelect); - }) - .then(result => { - expect(result).toBe('Plantas vivas: Esqueje/injerto, Vid'); - return nightmare + + expect(result).toEqual('Crisantemo'); + + result = await nightmare + .waitProperty(selectors.itemBasicData.intrastatSelect, 'value') + .getProperty(selectors.itemBasicData.intrastatSelect, 'value'); + + expect(result).toEqual('6021010 Plantas vivas: Esqueje/injerto, Vid'); + + result = await nightmare .getInputValue(selectors.itemBasicData.originSelect); - }) - .then(result => { - expect(result).toBe('Spain'); - done(); - }).catch(done.fail); + + expect(result).toEqual('Spain'); }); }); describe('Clone path', () => { - it('should return to the items index by clicking the return to items button', done => { - return nightmare - .click(selectors.itemBasicData.goToItemIndexButton) - .wait(selectors.itemsIndex.createItemButton) - .waitForURL('#!/item/index') - .parsedUrl() - .then(url => { - expect(url.hash).toContain('#!/item/index'); - done(); - }).catch(done.fail); + it('should return to the items index by clicking the return to items button', async () => { + const url = await nightmare + .click(selectors.itemBasicData.goToItemIndexButton) + .wait(selectors.itemsIndex.createItemButton) + .waitForURL('#!/item/index') + .parsedUrl(); + + expect(url.hash).toContain('#!/item/index'); }); - it(`should search for the item Infinity Gauntlet`, done => { - return nightmare - .wait(selectors.itemsIndex.searchResult) - .type(selectors.itemsIndex.searchItemInput, 'Infinity Gauntlet') - .click(selectors.itemsIndex.searchButton) - .waitForNumberOfElements(selectors.itemsIndex.searchResult, 1) - .countElement(selectors.itemsIndex.searchResult) - .then(result => { - expect(result).toEqual(1); - done(); - }).catch(done.fail); + it(`should search for the item Infinity Gauntlet`, async () => { + const result = await nightmare + .wait(selectors.itemsIndex.searchResult) + .type(selectors.itemsIndex.searchItemInput, 'Infinity Gauntlet') + .click(selectors.itemsIndex.searchButton) + .waitForNumberOfElements(selectors.itemsIndex.searchResult, 1) + .countElement(selectors.itemsIndex.searchResult); + + expect(result).toEqual(1); }); - it(`should clone the Infinity Gauntlet`, done => { - return nightmare - .waitForTextInElement(selectors.itemsIndex.searchResult, 'Infinity Gauntlet') - .click(selectors.itemsIndex.searchResultCloneButton) - .waitToClick(selectors.itemsIndex.acceptClonationAlertButton) - .waitForURL('tags') - .parsedUrl() - .then(url => { - expect(url.hash).toContain('tags'); - done(); - }).catch(done.fail); + it(`should clone the Infinity Gauntlet`, async () => { + const url = await nightmare + .waitForTextInElement(selectors.itemsIndex.searchResult, 'Infinity Gauntlet') + .click(selectors.itemsIndex.searchResultCloneButton) + .waitToClick(selectors.itemsIndex.acceptClonationAlertButton) + .waitForURL('tags') + .parsedUrl(); + + expect(url.hash).toContain('tags'); }); - it('should search for the item Infinity Gauntlet and find two', done => { - return nightmare - .waitToClick(selectors.itemTags.goToItemIndexButton) - .wait(selectors.itemsIndex.searchResult) - .type(selectors.itemsIndex.searchItemInput, 'Infinity Gauntlet') - .click(selectors.itemsIndex.searchButton) - .waitForNumberOfElements(selectors.itemsIndex.searchResult, 2) - .countElement(selectors.itemsIndex.searchResult) - .then(result => { - expect(result).toEqual(2); - done(); - }).catch(done.fail); + it('should search for the item Infinity Gauntlet and find two', async () => { + const result = await nightmare + .waitToClick(selectors.itemTags.goToItemIndexButton) + .wait(selectors.itemsIndex.searchResult) + .type(selectors.itemsIndex.searchItemInput, 'Infinity Gauntlet') + .click(selectors.itemsIndex.searchButton) + .waitForNumberOfElements(selectors.itemsIndex.searchResult, 2) + .countElement(selectors.itemsIndex.searchResult); + + expect(result).toEqual(2); }); }); }); diff --git a/e2e/paths/ticket-module/04_create_ticket_packages.spec.js b/e2e/paths/ticket-module/04_create_ticket_packages.spec.js index a5a266489..18ada323d 100644 --- a/e2e/paths/ticket-module/04_create_ticket_packages.spec.js +++ b/e2e/paths/ticket-module/04_create_ticket_packages.spec.js @@ -10,7 +10,7 @@ describe('Ticket Create packages path', () => { }); it('should click on the Tickets button of the top bar menu', async () => { - let url = await nightmare + const url = await nightmare .waitToClick(selectors.globalItems.applicationsMenuButton) .wait(selectors.globalItems.applicationsMenuVisible) .waitToClick(selectors.globalItems.ticketsButton) @@ -21,7 +21,7 @@ describe('Ticket Create packages path', () => { }); it('should search for the ticket 1', async () => { - let result = await nightmare + const result = await nightmare .wait(selectors.ticketsIndex.searchResult) .type(selectors.ticketsIndex.searchTicketInput, 'id:1') .click(selectors.ticketsIndex.searchButton) @@ -32,7 +32,7 @@ describe('Ticket Create packages path', () => { }); it(`should click on the search result to access to the ticket packages`, async () => { - let url = await nightmare + const url = await nightmare .waitForTextInElement(selectors.ticketsIndex.searchResultAddress, 'address 21') .waitToClick(selectors.ticketsIndex.searchResult) .waitToClick(selectors.ticketPackages.packagesButton) @@ -43,7 +43,7 @@ describe('Ticket Create packages path', () => { }); it(`should delete the first package and receive and error to save a new one with blank quantity`, async () => { - let result = await nightmare + const result = await nightmare .waitToClick(selectors.ticketPackages.firstRemovePackageButton) .waitToClick(selectors.ticketPackages.addPackageButton) .waitToClick(selectors.ticketPackages.firstPackageSelect) @@ -55,7 +55,7 @@ describe('Ticket Create packages path', () => { }); it(`should attempt create a new package but receive an error if quantity is a string`, async () => { - let result = await nightmare + const result = await nightmare .type(selectors.ticketPackages.firstQuantityInput, 'ninety 9') .click(selectors.ticketPackages.savePackagesButton) .waitForLastSnackbar(); @@ -64,7 +64,7 @@ describe('Ticket Create packages path', () => { }); it(`should attempt create a new package but receive an error if quantity is 0`, async () => { - let result = await nightmare + const result = await nightmare .clearInput(selectors.ticketPackages.firstQuantityInput) .type(selectors.ticketPackages.firstQuantityInput, 0) .click(selectors.ticketPackages.savePackagesButton) @@ -74,7 +74,7 @@ describe('Ticket Create packages path', () => { }); it(`should attempt create a new package but receive an error if package is blank`, async () => { - let result = await nightmare + const result = await nightmare .clearInput(selectors.ticketPackages.firstQuantityInput) .type(selectors.ticketPackages.firstQuantityInput, 99) .click(selectors.ticketPackages.clearPackageSelectButton) @@ -85,7 +85,7 @@ describe('Ticket Create packages path', () => { }); it(`should create a new package with correct data`, async () => { - let result = await nightmare + const result = await nightmare .waitToClick(selectors.ticketPackages.firstPackageSelect) .waitToClick(selectors.ticketPackages.firstPackageSelectOptionTwo) .waitForTextInInput(selectors.ticketPackages.firstPackageSelect, 'Legendary Box') @@ -96,18 +96,18 @@ describe('Ticket Create packages path', () => { }); it(`should confirm the first select is the expected one`, async () => { - let result = await nightmare + const result = await nightmare .click(selectors.ticketSales.saleButton) .wait(selectors.ticketSales.firstPackageSelect) .click(selectors.ticketPackages.packagesButton) .waitForTextInInput(selectors.ticketPackages.firstPackageSelect, 'Legendary Box') .getInputValue(selectors.ticketPackages.firstPackageSelect); - expect(result).toEqual('Legendary Box'); + expect(result).toEqual('7 : Legendary Box'); }); it(`should confirm the first quantity is the expected one`, async () => { - let result = await nightmare + const result = await nightmare .waitForTextInInput(selectors.ticketPackages.firstQuantityInput, '99') .getInputValue(selectors.ticketPackages.firstQuantityInput);