This commit is contained in:
Carlos Jimenez Ruiz 2019-05-03 17:49:38 +02:00
parent b60ee825ba
commit a578c84dba
5 changed files with 30 additions and 32 deletions

View File

@ -6,24 +6,25 @@ import config from './config.js';
let currentUser; let currentUser;
Nightmare.asyncAction = function(name, func) {
Nightmare.action(name, function(...args) {
let done = args[arguments.length - 1];
func.apply(this, args)
.then(result => done(null, result))
.catch(done);
});
};
Nightmare.asyncAction('clearInput', async function(selector) {
const backSpaces = [];
for (let i = 0; i < 50; i += 1)
backSpaces.push('\u0008');
await this.write(selector, backSpaces.join(''));
});
let actions = { let actions = {
clearTextarea: function(selector, done) {
this.wait(selector)
.evaluate(inputSelector => {
return document.querySelector(inputSelector).value = '';
}, selector)
.then(done)
.catch(done);
},
clearInput: function(selector, done) {
this.wait(selector)
.evaluate(inputSelector => {
return document.querySelector(inputSelector).closest('*[model], *[field], *[value]').$ctrl.value = '';
}, selector)
.then(done)
.catch(done);
},
login: function(userName, done) { login: function(userName, done) {
if (currentUser) if (currentUser)
this.waitToClick('#logout'); this.waitToClick('#logout');
@ -334,7 +335,6 @@ let actions = {
return shapesList; return shapesList;
}, done, selector); }, done, selector);
}, },
waitForSnackbar: function(done) { waitForSnackbar: function(done) {
this.wait(500).waitForShapes('vn-snackbar .shape .text') this.wait(500).waitForShapes('vn-snackbar .shape .text')
.then(shapes => { .then(shapes => {
@ -359,8 +359,9 @@ let actions = {
}, },
accessToSearchResult: function(searchValue, done) { accessToSearchResult: function(searchValue, done) {
this.write(`vn-searchbar input`, searchValue) this.clearInput('vn-searchbar input')
.click(`vn-searchbar vn-icon[icon="search"]`) .write('vn-searchbar input', searchValue)
.click('vn-searchbar vn-icon[icon="search"]')
.wait(100) .wait(100)
.waitForNumberOfElements('.searchResult', 1) .waitForNumberOfElements('.searchResult', 1)
.evaluate(() => { .evaluate(() => {

View File

@ -45,12 +45,11 @@ export default {
}, },
clientBasicData: { clientBasicData: {
basicDataButton: 'vn-left-menu a[ui-sref="client.card.basicData"]', basicDataButton: 'vn-left-menu a[ui-sref="client.card.basicData"]',
nameInput: `${components.vnTextfield}[name="name"]`, nameInput: 'vn-textfield[field="$ctrl.client.name"] input',
contactInput: `${components.vnTextfield}[name="contact"]`, contactInput: 'vn-textfield[field="$ctrl.client.contact"] input',
phoneInput: `${components.vnTextfield}[name="phone"]`, phoneInput: 'vn-textfield[field="$ctrl.client.phone"] input',
mobileInput: `${components.vnTextfield}[name="mobile"]`, mobileInput: 'vn-textfield[field="$ctrl.client.mobile"] input',
faxInput: `${components.vnTextfield}[name="fax"]`, emailInput: 'vn-textfield[field="$ctrl.client.email"] input',
emailInput: `${components.vnTextfield}[name="email"]`,
salesPersonAutocomplete: 'vn-autocomplete[field="$ctrl.client.salesPersonFk"]', salesPersonAutocomplete: 'vn-autocomplete[field="$ctrl.client.salesPersonFk"]',
channelAutocomplete: 'vn-autocomplete[field="$ctrl.client.contactChannelFk"]', channelAutocomplete: 'vn-autocomplete[field="$ctrl.client.contactChannelFk"]',
saveButton: `${components.vnSubmit}` saveButton: `${components.vnSubmit}`
@ -473,7 +472,7 @@ export default {
claimStateAutocomplete: 'vn-claim-basic-data vn-autocomplete[field="$ctrl.claim.claimStateFk"]', claimStateAutocomplete: 'vn-claim-basic-data vn-autocomplete[field="$ctrl.claim.claimStateFk"]',
isPaidWithManaCheckbox: 'vn-check[field="$ctrl.claim.isChargedToMana"] md-checkbox', isPaidWithManaCheckbox: 'vn-check[field="$ctrl.claim.isChargedToMana"] md-checkbox',
responsabilityInputRange: 'vn-input-range', responsabilityInputRange: 'vn-input-range',
observationInput: 'vn-textarea[label="Observation"] textarea', observationInput: 'vn-textarea[field="$ctrl.claim.observation"] textarea',
saveButton: `${components.vnSubmit}` saveButton: `${components.vnSubmit}`
}, },
claimDetail: { claimDetail: {

View File

@ -30,7 +30,6 @@ describe('Item index path', () => {
.waitToClick(selectors.itemsIndex.originCheckbox) .waitToClick(selectors.itemsIndex.originCheckbox)
.waitToClick(selectors.itemsIndex.buyerCheckbox) .waitToClick(selectors.itemsIndex.buyerCheckbox)
.waitToClick(selectors.itemsIndex.destinyCheckbox) .waitToClick(selectors.itemsIndex.destinyCheckbox)
// .waitToClick(selectors.itemsIndex.taxClassCheckbox)
.waitToClick(selectors.itemsIndex.saveFieldsButton) .waitToClick(selectors.itemsIndex.saveFieldsButton)
.waitForLastSnackbar(); .waitForLastSnackbar();
@ -68,7 +67,6 @@ describe('Item index path', () => {
.waitToClick(selectors.itemsIndex.originCheckbox) .waitToClick(selectors.itemsIndex.originCheckbox)
.waitToClick(selectors.itemsIndex.buyerCheckbox) .waitToClick(selectors.itemsIndex.buyerCheckbox)
.waitToClick(selectors.itemsIndex.destinyCheckbox) .waitToClick(selectors.itemsIndex.destinyCheckbox)
// .waitToClick(selectors.itemsIndex.taxClassCheckbox)
.waitToClick(selectors.itemsIndex.saveFieldsButton) .waitToClick(selectors.itemsIndex.saveFieldsButton)
.waitForLastSnackbar(); .waitForLastSnackbar();

View File

@ -15,7 +15,7 @@ describe('Claim edit basic data path', () => {
const result = await nightmare const result = await nightmare
.autocompleteSearch(selectors.claimBasicData.claimStateAutocomplete, 'Gestionado') .autocompleteSearch(selectors.claimBasicData.claimStateAutocomplete, 'Gestionado')
.waitToClick(selectors.claimBasicData.isPaidWithManaCheckbox) .waitToClick(selectors.claimBasicData.isPaidWithManaCheckbox)
.clearInput(selectors.claimBasicData.observationInput) .clearTextarea(selectors.claimBasicData.observationInput)
.write(selectors.claimBasicData.observationInput, 'edited observation') .write(selectors.claimBasicData.observationInput, 'edited observation')
.waitToClick(selectors.claimBasicData.saveButton) .waitToClick(selectors.claimBasicData.saveButton)
.waitForSnackbar(); .waitForSnackbar();
@ -58,7 +58,7 @@ describe('Claim edit basic data path', () => {
const result = await nightmare const result = await nightmare
.autocompleteSearch(selectors.claimBasicData.claimStateAutocomplete, 'Pendiente') .autocompleteSearch(selectors.claimBasicData.claimStateAutocomplete, 'Pendiente')
.waitToClick(selectors.claimBasicData.isPaidWithManaCheckbox) .waitToClick(selectors.claimBasicData.isPaidWithManaCheckbox)
.clearInput(selectors.claimBasicData.observationInput) .clearTextarea(selectors.claimBasicData.observationInput)
.write(selectors.claimBasicData.observationInput, 'Observation one') .write(selectors.claimBasicData.observationInput, 'Observation one')
.waitToClick(selectors.claimBasicData.saveButton) .waitToClick(selectors.claimBasicData.saveButton)
.waitForSnackbar(); .waitForSnackbar();

View File

@ -65,7 +65,7 @@ describe('Order edit basic data path', () => {
.autocompleteSearch(selectors.orderBasicData.clientAutocomplete, 'Tony Stark') .autocompleteSearch(selectors.orderBasicData.clientAutocomplete, 'Tony Stark')
.autocompleteSearch(selectors.orderBasicData.addressAutocomplete, 'Tony Stark') .autocompleteSearch(selectors.orderBasicData.addressAutocomplete, 'Tony Stark')
.autocompleteSearch(selectors.orderBasicData.agencyAutocomplete, 'Silla247') .autocompleteSearch(selectors.orderBasicData.agencyAutocomplete, 'Silla247')
.clearInput(selectors.orderBasicData.observationInput) .clearTextarea(selectors.orderBasicData.observationInput)
.write(selectors.orderBasicData.observationInput, 'Observation modified') .write(selectors.orderBasicData.observationInput, 'Observation modified')
.waitToClick(selectors.orderBasicData.saveButton) .waitToClick(selectors.orderBasicData.saveButton)
.waitForLastSnackbar(); .waitForLastSnackbar();