#623 Autocomplete deberia ser capaz de mostrar dos campos

This commit is contained in:
Carlos Jimenez 2018-10-31 11:58:10 +01:00
parent 9364594a57
commit 2ced497638
8 changed files with 272 additions and 287 deletions

View File

@ -15,9 +15,10 @@ import './style.scss';
* @event change Thrown when value is changed * @event change Thrown when value is changed
*/ */
export default class Autocomplete extends Input { export default class Autocomplete extends Input {
constructor($element, $scope, $http, $transclude, $translate) { constructor($element, $scope, $http, $transclude, $translate, $interpolate) {
super($element, $scope); super($element, $scope);
this.$http = $http; this.$http = $http;
this.$interpolate = $interpolate;
this.$transclude = $transclude; this.$transclude = $transclude;
this.$translate = $translate; this.$translate = $translate;
this._field = undefined; this._field = undefined;
@ -167,35 +168,39 @@ export default class Autocomplete extends Input {
} }
onSelectionRequest(data) { onSelectionRequest(data) {
if (data && data.length > 0) { if (data && data.length > 0)
if (this.multiple) if (this.multiple)
this.selection = data; this.selection = data;
else else
this.selection = data[0]; this.selection = data[0];
} else else
this.selection = null; this.selection = null;
} }
refreshDisplayed() { refreshDisplayed() {
let display = ''; 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)) { if (this.multiple && Array.isArray(this._selection)) {
for (var item of this._selection) { for (let item of this._selection) {
if (display.length > 0) display += ', '; if (display.length > 0) display += ', ';
display += item[this.showField]; display += item[this.showField];
} }
} else { } else {
display = this._selection[this.showField]; display = this._selection[this.showField];
if (hasTemplate) {
let template = this.$transclude(() => {}, null, 'tplItem').text();
display = this.$interpolate(template)(this._selection);
}
} }
}
this.input.value = display; this.input.value = display;
if (this.translateFields) { if (this.translateFields)
if (this.translateFields.indexOf(this.showField) > -1) if (this.translateFields.indexOf(this.showField) > -1)
this.input.value = this.$translate.instant(display); this.input.value = this.$translate.instant(display);
}
this.mdlUpdate(); this.mdlUpdate();
} }
@ -275,7 +280,7 @@ export default class Autocomplete extends Input {
this.$.dropDown.show(this.input, search); this.$.dropDown.show(this.input, search);
} }
} }
Autocomplete.$inject = ['$element', '$scope', '$http', '$transclude', '$translate']; Autocomplete.$inject = ['$element', '$scope', '$http', '$transclude', '$translate', '$interpolate'];
ngModule.component('vnAutocomplete', { ngModule.component('vnAutocomplete', {
template: require('./autocomplete.html'), template: require('./autocomplete.html'),

View File

@ -26,7 +26,7 @@ export default class DropDown extends Component {
this.showLoadMore = true; this.showLoadMore = true;
this.showFilter = true; this.showFilter = true;
this.docKeyDownHandler = e => this.onDocKeyDown(e); this.docKeyDownHandler = (e) => this.onDocKeyDown(e);
} }
$postLink() { $postLink() {
@ -34,7 +34,7 @@ export default class DropDown extends Component {
this.input = this.element.querySelector('.search input'); this.input = this.element.querySelector('.search input');
this.ul = this.element.querySelector('ul'); this.ul = this.element.querySelector('ul');
this.list = this.element.querySelector('.list'); this.list = this.element.querySelector('.list');
this.list.addEventListener('scroll', e => this.onScroll(e)); this.list.addEventListener('scroll', (e) => this.onScroll(e));
} }
get shown() { get shown() {
@ -310,9 +310,10 @@ export default class DropDown extends Component {
destroyList() { destroyList() {
this.ul.innerHTML = ''; this.ul.innerHTML = '';
if (this.scopes) if (this.scopes) {
for (let scope of this.scopes) for (let scope of this.scopes)
scope.$destroy(); scope.$destroy();
}
this.scopes = []; this.scopes = [];
} }
@ -322,9 +323,10 @@ export default class DropDown extends Component {
fields.push(this.valueField); fields.push(this.valueField);
fields.push(this.showField); fields.push(this.showField);
if (this.fields) if (this.fields) {
for (let field of this.fields) for (let field of this.fields)
fields.push(field); fields.push(field);
}
return fields; return fields;
} }
@ -440,9 +442,10 @@ function getPosition(parent, event) {
while (target.parentNode !== parent) while (target.parentNode !== parent)
target = target.parentNode; target = target.parentNode;
for (let i = 0; i < children.length; i++) for (let i = 0; i < children.length; i++) {
if (children[i] === target) if (children[i] === target)
return i; return i;
}
return -1; return -1;
} }

View File

@ -21,9 +21,9 @@ Nightmare.action('changeLanguageToEnglish', function(done) {
return document.querySelector(selector).title; return document.querySelector(selector).title;
}, '#lang') }, '#lang')
.then((title) => { .then((title) => {
if (title === 'Change language') { if (title === 'Change language')
this.then(done); this.then(done);
} else { else {
this.click('#lang') this.click('#lang')
.click('vn-main-menu [vn-id="langs-menu"] ul > li[name="en"]') .click('vn-main-menu [vn-id="langs-menu"] ul > li[name="en"]')
.then(done); .then(done);
@ -48,7 +48,7 @@ Nightmare.action('parsedUrl', function(done) {
Nightmare.action('getProperty', function(selector, property, done) { Nightmare.action('getProperty', function(selector, property, done) {
this.evaluate_now((selector, property) => { this.evaluate_now((selector, property) => {
return document.querySelector(selector)[property]; return document.querySelector(selector)[property].replace(/\s+/g, ' ').trim();
}, done, selector, property); }, done, selector, property);
}); });
@ -86,9 +86,9 @@ Nightmare.action('getInputValue', function(selector, done) {
Nightmare.action('clearInput', function(selector, done) { Nightmare.action('clearInput', function(selector, done) {
const backSpaces = []; const backSpaces = [];
for (let i = 0; i < 50; i += 1) { for (let i = 0; i < 50; i += 1)
backSpaces.push('\u0008'); backSpaces.push('\u0008');
}
this.wait(selector) this.wait(selector)
.type(selector, backSpaces.join('')) .type(selector, backSpaces.join(''))
.then(done); .then(done);
@ -111,9 +111,9 @@ Nightmare.action('isVisible', function(selector, done) {
.evaluate_now((elementSelector) => { .evaluate_now((elementSelector) => {
const selectorMatches = document.querySelectorAll(elementSelector); const selectorMatches = document.querySelectorAll(elementSelector);
const element = selectorMatches[0]; const element = selectorMatches[0];
if (selectorMatches.length > 1) { if (selectorMatches.length > 1)
throw new Error(`multiple matches of ${elementSelector} found`); throw new Error(`multiple matches of ${elementSelector} found`);
}
let isVisible = false; let isVisible = false;
if (element) { if (element) {
const eventHandler = (event) => { const eventHandler = (event) => {
@ -132,15 +132,15 @@ Nightmare.action('isVisible', function(selector, done) {
bubbles: true, bubbles: true,
cancelable: true, cancelable: true,
}); });
if (elementInCenter) { if (elementInCenter)
elementInCenter.dispatchEvent(e); elementInCenter.dispatchEvent(e);
}
if (elementInTopLeft) { if (elementInTopLeft)
elementInTopLeft.dispatchEvent(e); elementInTopLeft.dispatchEvent(e);
}
if (elementInBottomRight) { if (elementInBottomRight)
elementInBottomRight.dispatchEvent(e); elementInBottomRight.dispatchEvent(e);
}
element.removeEventListener('mouseover', eventHandler); element.removeEventListener('mouseover', eventHandler);
} }
return isVisible; return isVisible;
@ -176,9 +176,8 @@ Nightmare.action('waitForNumberOfElements', function(selector, count, done) {
Nightmare.action('waitForClassNotPresent', function(selector, className, done) { Nightmare.action('waitForClassNotPresent', function(selector, className, done) {
this.wait(selector) this.wait(selector)
.wait((resultSelector, targetClass) => { .wait((resultSelector, targetClass) => {
if (!document.querySelector(resultSelector).classList.contains(targetClass)) { if (!document.querySelector(resultSelector).classList.contains(targetClass))
return true; return true;
}
}, selector, className) }, selector, className)
.then(done); .then(done);
}); });
@ -186,9 +185,8 @@ Nightmare.action('waitForClassNotPresent', function(selector, className, done) {
Nightmare.action('waitForClassPresent', function(selector, className, done) { Nightmare.action('waitForClassPresent', function(selector, className, done) {
this.wait(selector) this.wait(selector)
.wait((resultSelector, targetClass) => { .wait((resultSelector, targetClass) => {
if (document.querySelector(resultSelector).classList.contains(targetClass)) { if (document.querySelector(resultSelector).classList.contains(targetClass))
return true; return true;
}
}, selector, className) }, selector, className)
.then(done); .then(done);
}); });
@ -240,9 +238,9 @@ Nightmare.action('waitForShapes', function(selector, done) {
const shapes = document.querySelectorAll(selector); const shapes = document.querySelectorAll(selector);
const shapesList = []; const shapesList = [];
for (const shape of shapes) { for (const shape of shapes)
shapesList.push(shape.innerText); shapesList.push(shape.innerText);
}
return shapesList; return shapesList;
}, done, selector); }, done, selector);

View File

@ -234,7 +234,7 @@ describe('Client Edit basicData path', () => {
const result = await nightmare const result = await nightmare
.getInputValue(selectors.clientBasicData.salesPersonInput); .getInputValue(selectors.clientBasicData.salesPersonInput);
expect(result).toEqual('accessory'); expect(result).toEqual('accessory accessory');
}); });
it('should now confirm the channel have been selected', async () => { it('should now confirm the channel have been selected', async () => {

View File

@ -1,142 +1,140 @@
import selectors from '../../helpers/selectors.js'; import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare'; import createNightmare from '../../helpers/nightmare';
describe('Client', () => { describe('Client Edit pay method path', () => {
describe('Edit pay method path', () => { const nightmare = createNightmare();
const nightmare = createNightmare();
beforeAll(() => { beforeAll(() => {
nightmare nightmare
.waitForLogin('administrative'); .waitForLogin('administrative');
}); });
it('should click on the Clients button of the top bar menu', async () => { it('should click on the Clients button of the top bar menu', async () => {
const url = await nightmare const url = await nightmare
.waitToClick(selectors.globalItems.applicationsMenuButton) .waitToClick(selectors.globalItems.applicationsMenuButton)
.wait(selectors.globalItems.applicationsMenuVisible) .wait(selectors.globalItems.applicationsMenuVisible)
.waitToClick(selectors.globalItems.clientsButton) .waitToClick(selectors.globalItems.clientsButton)
.wait(selectors.clientsIndex.createClientButton) .wait(selectors.clientsIndex.createClientButton)
.parsedUrl(); .parsedUrl();
expect(url.hash).toEqual('#!/client/index'); expect(url.hash).toEqual('#!/client/index');
}); });
it('should search for the user Bruce Banner', async () => { it('should search for the user Bruce Banner', async () => {
const resultCount = await nightmare const resultCount = await nightmare
.wait(selectors.clientsIndex.searchResult) .wait(selectors.clientsIndex.searchResult)
.type(selectors.clientsIndex.searchClientInput, 'Bruce Banner') .type(selectors.clientsIndex.searchClientInput, 'Bruce Banner')
.click(selectors.clientsIndex.searchButton) .click(selectors.clientsIndex.searchButton)
.waitForNumberOfElements(selectors.clientsIndex.searchResult, 1) .waitForNumberOfElements(selectors.clientsIndex.searchResult, 1)
.countElement(selectors.clientsIndex.searchResult); .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 () => { it(`should click on the search result to access to the client's pay method`, async () => {
const url = await nightmare const url = await nightmare
.waitForTextInElement(selectors.clientsIndex.searchResult, 'Bruce Banner') .waitForTextInElement(selectors.clientsIndex.searchResult, 'Bruce Banner')
.waitToClick(selectors.clientsIndex.searchResult) .waitToClick(selectors.clientsIndex.searchResult)
.waitToClick(selectors.clientPayMethod.payMethodButton) .waitToClick(selectors.clientPayMethod.payMethodButton)
.waitForURL('billing-data') .waitForURL('billing-data')
.url(); .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 () => { it(`should attempt to edit the Pay method without an IBAN but fail`, async () => {
const snackbarMessage = await nightmare const snackbarMessage = await nightmare
.waitToClick(selectors.clientPayMethod.payMethodInput) .waitToClick(selectors.clientPayMethod.payMethodInput)
.waitToClick(selectors.clientPayMethod.payMethodIBANOption) .waitToClick(selectors.clientPayMethod.payMethodIBANOption)
.waitForTextInInput(selectors.clientPayMethod.payMethodInput, 'PayMethod with IBAN') .waitForTextInInput(selectors.clientPayMethod.payMethodInput, 'PayMethod with IBAN')
.clearInput(selectors.clientPayMethod.dueDayInput) .clearInput(selectors.clientPayMethod.dueDayInput)
.type(selectors.clientPayMethod.dueDayInput, '60') .type(selectors.clientPayMethod.dueDayInput, '60')
.waitForTextInInput(selectors.clientPayMethod.dueDayInput, '60') .waitForTextInInput(selectors.clientPayMethod.dueDayInput, '60')
.waitToClick(selectors.clientPayMethod.receivedCoreLCRCheckbox) .waitToClick(selectors.clientPayMethod.receivedCoreLCRCheckbox)
.waitToClick(selectors.clientPayMethod.receivedCoreVNLCheckbox) .waitToClick(selectors.clientPayMethod.receivedCoreVNLCheckbox)
.waitToClick(selectors.clientPayMethod.receivedB2BVNLCheckbox) .waitToClick(selectors.clientPayMethod.receivedB2BVNLCheckbox)
.waitToClick(selectors.clientPayMethod.saveButton) .waitToClick(selectors.clientPayMethod.saveButton)
.waitForLastSnackbar(); .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 () => { 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, 'ES91 2100 0418 4502 0005 1332')
.waitForTextInInput(selectors.clientPayMethod.IBANInput, 'ES91 2100 0418 4502 0005 1332') .waitForTextInInput(selectors.clientPayMethod.IBANInput, 'ES91 2100 0418 4502 0005 1332')
.waitToClick(selectors.clientPayMethod.saveButton) .waitToClick(selectors.clientPayMethod.saveButton)
.waitForLastSnackbar(); .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 () => { it(`should create a new BIC code`, async () => {
const newcode = await nightmare const newcode = await nightmare
.click(selectors.clientPayMethod.newBankEntityButton) .click(selectors.clientPayMethod.newBankEntityButton)
.type(selectors.clientPayMethod.newBankEntityName, 'Gotham City Banks') .type(selectors.clientPayMethod.newBankEntityName, 'Gotham City Banks')
.type(selectors.clientPayMethod.newBankEntityBIC, 'GTHMCT') .type(selectors.clientPayMethod.newBankEntityBIC, 'GTHMCT')
.click(selectors.clientPayMethod.acceptBankEntityButton) .click(selectors.clientPayMethod.acceptBankEntityButton)
.getInputValue(selectors.clientPayMethod.swiftBicInput); .getInputValue(selectors.clientPayMethod.swiftBicInput);
expect(newcode).toEqual(''); expect(newcode).toEqual('');
}); });
it(`should confirm the IBAN pay method is sucessfully saved`, async () => { it(`should confirm the IBAN pay method is sucessfully saved`, async () => {
const payMethod = await nightmare const payMethod = await nightmare
.getInputValue(selectors.clientPayMethod.payMethodInput); .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 () => { it('should confirm the due day have been edited', async () => {
const dueDate = await nightmare const dueDate = await nightmare
.getInputValue(selectors.clientPayMethod.dueDayInput); .getInputValue(selectors.clientPayMethod.dueDayInput);
expect(dueDate).toEqual('60'); expect(dueDate).toEqual('60');
}); });
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') .waitProperty(selectors.clientPayMethod.IBANInput, 'value')
.getProperty(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') .waitProperty(selectors.clientPayMethod.swiftBicInput, 'value')
.getProperty(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 () => { it('should confirm Received LCR checkbox is checked', async () => {
const checkedBox = await nightmare const checkedBox = await nightmare
.evaluate((selector) => { .evaluate((selector) => {
return document.querySelector(selector).checked; return document.querySelector(selector).checked;
}, selectors.clientPayMethod.receivedCoreLCRCheckbox); }, selectors.clientPayMethod.receivedCoreLCRCheckbox);
expect(checkedBox).toBeTruthy(); expect(checkedBox).toBeTruthy();
}); });
it('should confirm Received core VNL checkbox is unchecked', async () => { it('should confirm Received core VNL checkbox is unchecked', async () => {
const checkedBox = await nightmare const checkedBox = await nightmare
.evaluate((selector) => { .evaluate((selector) => {
return document.querySelector(selector).checked; return document.querySelector(selector).checked;
}, selectors.clientPayMethod.receivedCoreVNLCheckbox); }, selectors.clientPayMethod.receivedCoreVNLCheckbox);
expect(checkedBox).toBeFalsy(); expect(checkedBox).toBeFalsy();
}); });
it('should confirm Received B2B VNL checkbox is unchecked', async () => { it('should confirm Received B2B VNL checkbox is unchecked', async () => {
const checkedBox = await nightmare const checkedBox = await nightmare
.evaluate((selector) => { .evaluate((selector) => {
return document.querySelector(selector).checked; return document.querySelector(selector).checked;
}, selectors.clientPayMethod.receivedB2BVNLCheckbox); }, selectors.clientPayMethod.receivedB2BVNLCheckbox);
expect(checkedBox).toBeFalsy(); expect(checkedBox).toBeFalsy();
});
}); });
}); });

View File

@ -84,9 +84,10 @@ describe('Item', () => {
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
.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 () => { it(`should confirm the item relevancy was edited`, async () => {

View File

@ -1,165 +1,145 @@
import selectors from '../../helpers/selectors.js'; import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare'; import createNightmare from '../../helpers/nightmare';
describe('Item', () => { describe('Item Create path', () => {
const nightmare = createNightmare(); const nightmare = createNightmare();
describe('Create path', () => { describe('Create path', () => {
beforeAll(() => { beforeAll(() => {
return nightmare return nightmare
.waitForLogin('buyer'); .waitForLogin('buyer');
}); });
it('should access to the items index by clicking the items button', done => { it('should access to the items index by clicking the items button', async () => {
return nightmare const url = await nightmare
.click(selectors.moduleAccessView.itemsSectionButton) .click(selectors.moduleAccessView.itemsSectionButton)
.wait(selectors.itemsIndex.createItemButton) .wait(selectors.itemsIndex.createItemButton)
.parsedUrl() .parsedUrl();
.then(url => {
expect(url.hash).toEqual('#!/item/index'); expect(url.hash).toEqual('#!/item/index');
done();
}).catch(done.fail);
}); });
it(`should search for the item Infinity Gauntlet to confirm it isn't created yet`, done => { it(`should search for the item Infinity Gauntlet to confirm it isn't created yet`, async () => {
return nightmare const result = await nightmare
.wait(selectors.itemsIndex.searchResult) .wait(selectors.itemsIndex.searchResult)
.type(selectors.itemsIndex.searchItemInput, 'Infinity Gauntlet') .type(selectors.itemsIndex.searchItemInput, 'Infinity Gauntlet')
.click(selectors.itemsIndex.searchButton) .click(selectors.itemsIndex.searchButton)
.waitForNumberOfElements(selectors.itemsIndex.searchResult, 0) .waitForNumberOfElements(selectors.itemsIndex.searchResult, 0)
.countElement(selectors.itemsIndex.searchResult) .countElement(selectors.itemsIndex.searchResult);
.then(result => {
expect(result).toEqual(0); expect(result).toEqual(0);
done();
}).catch(done.fail);
}); });
it('should access to the create item view by clicking the create floating button', done => { it('should access to the create item view by clicking the create floating button', async () => {
return nightmare const url = await nightmare
.click(selectors.itemsIndex.createItemButton) .click(selectors.itemsIndex.createItemButton)
.wait(selectors.itemCreateView.createButton) .wait(selectors.itemCreateView.createButton)
.parsedUrl() .parsedUrl();
.then(url => {
expect(url.hash).toEqual('#!/item/create'); expect(url.hash).toEqual('#!/item/create');
done();
}).catch(done.fail);
}); });
it('should return to the item index by clickig the cancel button', done => { it('should return to the item index by clickig the cancel button', async () => {
return nightmare const url = await nightmare
.click(selectors.itemCreateView.cancelButton) .click(selectors.itemCreateView.cancelButton)
.wait(selectors.itemsIndex.createItemButton) .wait(selectors.itemsIndex.createItemButton)
.parsedUrl() .parsedUrl();
.then(url => {
expect(url.hash).toEqual('#!/item/index'); expect(url.hash).toEqual('#!/item/index');
done();
}).catch(done.fail);
}); });
it('should now access to the create item view by clicking the create floating button', done => { it('should now access to the create item view by clicking the create floating button', async () => {
return nightmare const url = await nightmare
.click(selectors.itemsIndex.createItemButton) .click(selectors.itemsIndex.createItemButton)
.wait(selectors.itemCreateView.createButton) .wait(selectors.itemCreateView.createButton)
.parsedUrl() .parsedUrl();
.then(url => {
expect(url.hash).toEqual('#!/item/create'); expect(url.hash).toEqual('#!/item/create');
done();
}).catch(done.fail);
}); });
it('should create the Infinity Gauntlet item', done => { it('should create the Infinity Gauntlet item', async () => {
return nightmare const result = await nightmare
.type(selectors.itemCreateView.name, 'Infinity Gauntlet') .type(selectors.itemCreateView.name, 'Infinity Gauntlet')
.waitToClick(selectors.itemCreateView.typeSelect) .waitToClick(selectors.itemCreateView.typeSelect)
.waitToClick(selectors.itemCreateView.typeSelectOptionThree) .waitToClick(selectors.itemCreateView.typeSelectOptionThree)
.waitToClick(selectors.itemCreateView.intrastatSelect) .waitToClick(selectors.itemCreateView.intrastatSelect)
.waitToClick(selectors.itemCreateView.intrastatSelectOptionOne) .waitToClick(selectors.itemCreateView.intrastatSelectOptionOne)
.waitToClick(selectors.itemCreateView.originSelect) .waitToClick(selectors.itemCreateView.originSelect)
.waitToClick(selectors.itemCreateView.originSelectOptionOne) .waitToClick(selectors.itemCreateView.originSelectOptionOne)
.click(selectors.itemCreateView.createButton) .click(selectors.itemCreateView.createButton)
.waitForLastSnackbar() .waitForLastSnackbar();
.then(result => {
expect(result).toEqual('Data saved!'); expect(result).toEqual('Data saved!');
done();
}).catch(done.fail);
}); });
it('should confirm Infinity Gauntlet item was created', done => { it('should confirm Infinity Gauntlet item was created', async () => {
return nightmare let result = await nightmare
.wait(selectors.itemBasicData.nameInput) .wait(selectors.itemBasicData.nameInput)
.getInputValue(selectors.itemBasicData.nameInput) .getInputValue(selectors.itemBasicData.nameInput);
.then(result => {
expect(result).toBe('Infinity Gauntlet'); expect(result).toEqual('Infinity Gauntlet');
return nightmare
result = await nightmare
.getInputValue(selectors.itemBasicData.typeSelect); .getInputValue(selectors.itemBasicData.typeSelect);
})
.then(result => { expect(result).toEqual('Crisantemo');
expect(result).toBe('Crisantemo');
return nightmare result = await nightmare
.getInputValue(selectors.itemBasicData.intrastatSelect); .waitProperty(selectors.itemBasicData.intrastatSelect, 'value')
}) .getProperty(selectors.itemBasicData.intrastatSelect, 'value');
.then(result => {
expect(result).toBe('Plantas vivas: Esqueje/injerto, Vid'); expect(result).toEqual('6021010 Plantas vivas: Esqueje/injerto, Vid');
return nightmare
result = await nightmare
.getInputValue(selectors.itemBasicData.originSelect); .getInputValue(selectors.itemBasicData.originSelect);
})
.then(result => { expect(result).toEqual('Spain');
expect(result).toBe('Spain');
done();
}).catch(done.fail);
}); });
}); });
describe('Clone path', () => { describe('Clone path', () => {
it('should return to the items index by clicking the return to items button', done => { it('should return to the items index by clicking the return to items button', async () => {
return nightmare const url = await nightmare
.click(selectors.itemBasicData.goToItemIndexButton) .click(selectors.itemBasicData.goToItemIndexButton)
.wait(selectors.itemsIndex.createItemButton) .wait(selectors.itemsIndex.createItemButton)
.waitForURL('#!/item/index') .waitForURL('#!/item/index')
.parsedUrl() .parsedUrl();
.then(url => {
expect(url.hash).toContain('#!/item/index'); expect(url.hash).toContain('#!/item/index');
done();
}).catch(done.fail);
}); });
it(`should search for the item Infinity Gauntlet`, done => { it(`should search for the item Infinity Gauntlet`, async () => {
return nightmare const result = await nightmare
.wait(selectors.itemsIndex.searchResult) .wait(selectors.itemsIndex.searchResult)
.type(selectors.itemsIndex.searchItemInput, 'Infinity Gauntlet') .type(selectors.itemsIndex.searchItemInput, 'Infinity Gauntlet')
.click(selectors.itemsIndex.searchButton) .click(selectors.itemsIndex.searchButton)
.waitForNumberOfElements(selectors.itemsIndex.searchResult, 1) .waitForNumberOfElements(selectors.itemsIndex.searchResult, 1)
.countElement(selectors.itemsIndex.searchResult) .countElement(selectors.itemsIndex.searchResult);
.then(result => {
expect(result).toEqual(1); expect(result).toEqual(1);
done();
}).catch(done.fail);
}); });
it(`should clone the Infinity Gauntlet`, done => { it(`should clone the Infinity Gauntlet`, async () => {
return nightmare const url = await nightmare
.waitForTextInElement(selectors.itemsIndex.searchResult, 'Infinity Gauntlet') .waitForTextInElement(selectors.itemsIndex.searchResult, 'Infinity Gauntlet')
.click(selectors.itemsIndex.searchResultCloneButton) .click(selectors.itemsIndex.searchResultCloneButton)
.waitToClick(selectors.itemsIndex.acceptClonationAlertButton) .waitToClick(selectors.itemsIndex.acceptClonationAlertButton)
.waitForURL('tags') .waitForURL('tags')
.parsedUrl() .parsedUrl();
.then(url => {
expect(url.hash).toContain('tags'); expect(url.hash).toContain('tags');
done();
}).catch(done.fail);
}); });
it('should search for the item Infinity Gauntlet and find two', done => { it('should search for the item Infinity Gauntlet and find two', async () => {
return nightmare const result = await nightmare
.waitToClick(selectors.itemTags.goToItemIndexButton) .waitToClick(selectors.itemTags.goToItemIndexButton)
.wait(selectors.itemsIndex.searchResult) .wait(selectors.itemsIndex.searchResult)
.type(selectors.itemsIndex.searchItemInput, 'Infinity Gauntlet') .type(selectors.itemsIndex.searchItemInput, 'Infinity Gauntlet')
.click(selectors.itemsIndex.searchButton) .click(selectors.itemsIndex.searchButton)
.waitForNumberOfElements(selectors.itemsIndex.searchResult, 2) .waitForNumberOfElements(selectors.itemsIndex.searchResult, 2)
.countElement(selectors.itemsIndex.searchResult) .countElement(selectors.itemsIndex.searchResult);
.then(result => {
expect(result).toEqual(2); expect(result).toEqual(2);
done();
}).catch(done.fail);
}); });
}); });
}); });

View File

@ -10,7 +10,7 @@ describe('Ticket Create packages path', () => {
}); });
it('should click on the Tickets button of the top bar menu', async () => { 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) .waitToClick(selectors.globalItems.applicationsMenuButton)
.wait(selectors.globalItems.applicationsMenuVisible) .wait(selectors.globalItems.applicationsMenuVisible)
.waitToClick(selectors.globalItems.ticketsButton) .waitToClick(selectors.globalItems.ticketsButton)
@ -21,7 +21,7 @@ describe('Ticket Create packages path', () => {
}); });
it('should search for the ticket 1', async () => { it('should search for the ticket 1', async () => {
let result = await nightmare const result = await nightmare
.wait(selectors.ticketsIndex.searchResult) .wait(selectors.ticketsIndex.searchResult)
.type(selectors.ticketsIndex.searchTicketInput, 'id:1') .type(selectors.ticketsIndex.searchTicketInput, 'id:1')
.click(selectors.ticketsIndex.searchButton) .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 () => { 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') .waitForTextInElement(selectors.ticketsIndex.searchResultAddress, 'address 21')
.waitToClick(selectors.ticketsIndex.searchResult) .waitToClick(selectors.ticketsIndex.searchResult)
.waitToClick(selectors.ticketPackages.packagesButton) .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 () => { 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.firstRemovePackageButton)
.waitToClick(selectors.ticketPackages.addPackageButton) .waitToClick(selectors.ticketPackages.addPackageButton)
.waitToClick(selectors.ticketPackages.firstPackageSelect) .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 () => { 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') .type(selectors.ticketPackages.firstQuantityInput, 'ninety 9')
.click(selectors.ticketPackages.savePackagesButton) .click(selectors.ticketPackages.savePackagesButton)
.waitForLastSnackbar(); .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 () => { 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) .clearInput(selectors.ticketPackages.firstQuantityInput)
.type(selectors.ticketPackages.firstQuantityInput, 0) .type(selectors.ticketPackages.firstQuantityInput, 0)
.click(selectors.ticketPackages.savePackagesButton) .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 () => { 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) .clearInput(selectors.ticketPackages.firstQuantityInput)
.type(selectors.ticketPackages.firstQuantityInput, 99) .type(selectors.ticketPackages.firstQuantityInput, 99)
.click(selectors.ticketPackages.clearPackageSelectButton) .click(selectors.ticketPackages.clearPackageSelectButton)
@ -85,7 +85,7 @@ describe('Ticket Create packages path', () => {
}); });
it(`should create a new package with correct data`, async () => { 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.firstPackageSelect)
.waitToClick(selectors.ticketPackages.firstPackageSelectOptionTwo) .waitToClick(selectors.ticketPackages.firstPackageSelectOptionTwo)
.waitForTextInInput(selectors.ticketPackages.firstPackageSelect, 'Legendary Box') .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 () => { it(`should confirm the first select is the expected one`, async () => {
let result = await nightmare const result = await nightmare
.click(selectors.ticketSales.saleButton) .click(selectors.ticketSales.saleButton)
.wait(selectors.ticketSales.firstPackageSelect) .wait(selectors.ticketSales.firstPackageSelect)
.click(selectors.ticketPackages.packagesButton) .click(selectors.ticketPackages.packagesButton)
.waitForTextInInput(selectors.ticketPackages.firstPackageSelect, 'Legendary Box') .waitForTextInInput(selectors.ticketPackages.firstPackageSelect, 'Legendary Box')
.getInputValue(selectors.ticketPackages.firstPackageSelect); .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 () => { it(`should confirm the first quantity is the expected one`, async () => {
let result = await nightmare const result = await nightmare
.waitForTextInInput(selectors.ticketPackages.firstQuantityInput, '99') .waitForTextInInput(selectors.ticketPackages.firstQuantityInput, '99')
.getInputValue(selectors.ticketPackages.firstQuantityInput); .getInputValue(selectors.ticketPackages.firstQuantityInput);