This commit is contained in:
Vicente Falco 2017-11-09 09:41:32 +01:00
commit 81f108fb9a
6 changed files with 81 additions and 18 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
.DS_Store
node_modules
build
npm-debug.log

View File

@ -53,6 +53,7 @@ export default {
invoiceByMailCheckboxLabel: `${components.vnCheck}[label='Invoice by mail'] > label`,
invoiceByMailCheckboxInput: `${components.vnCheck}[label='Invoice by mail'] > label > label > input`,
addressInput: `${components.vnTextfield}[name="street"]`,
cityInput: `${components.vnTextfield}[name="city"]`,
saveButton: 'body > vn-app > vn-vertical > vn-vertical > vn-client-card > vn-horizontal > vn-auto > vn-vertical > vn-client-fiscal-data > form > vn-button-bar > vn-submit > input'
}
};

View File

@ -132,4 +132,64 @@ describe('Edit fiscalData path', () => {
})
.catch(catchErrors(done));
});
it(`should edit the address`, done => {
nightmare
.wait(selectors.fiscalData.addressInput)
.clearInput(selectors.fiscalData.addressInput)
.type(selectors.fiscalData.addressInput, 'Alpha Flight Low-Orbit')
.click(selectors.fiscalData.saveButton)
.wait(selectors.globalItems.snackbarIsActive)
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => {
expect(result).toEqual(`¡Datos guardados!`);
done();
})
.catch(catchErrors(done));
});
it(`should confirm the address have been edited`, done => {
nightmare
.waitForSnackbarReset()
.click(selectors.basicData.basicDataButton)
.wait(selectors.basicData.nameInput)
.click(selectors.fiscalData.fiscalDataButton)
.wait(selectors.fiscalData.addressInput)
.getInputValue(selectors.fiscalData.addressInput)
.then(result => {
expect(result).toEqual(`Alpha Flight Low-Orbit`);
done();
})
.catch(catchErrors(done));
});
it(`should edit the city`, done => {
nightmare
.wait(selectors.fiscalData.cityInput)
.clearInput(selectors.fiscalData.cityInput)
.type(selectors.fiscalData.cityInput, 'N/A')
.click(selectors.fiscalData.saveButton)
.wait(selectors.globalItems.snackbarIsActive)
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => {
expect(result).toEqual(`¡Datos guardados!`);
done();
})
.catch(catchErrors(done));
});
it(`should confirm the city have been edited`, done => {
nightmare
.waitForSnackbarReset()
.click(selectors.basicData.basicDataButton)
.wait(selectors.basicData.nameInput)
.click(selectors.fiscalData.fiscalDataButton)
.wait(selectors.fiscalData.cityInput)
.getInputValue(selectors.fiscalData.cityInput)
.then(result => {
expect(result).toEqual(`N/A`);
done();
})
.catch(catchErrors(done));
});
});

View File

@ -45,18 +45,20 @@ module.exports = function(Self) {
});
this.list = function(ctx, clientFilter, cb) {
var clientFields = (clientFilter && clientFilter.fields) ? clientFilter.fields : [];
var serverFields = (serverFilter && serverFilter.fields) ? serverFilter.fields : [];
var fields = clientFields.filter(itemC => {
let clientFields = (clientFilter && clientFilter.fields) ? clientFilter.fields : [];
let serverFields = (serverFilter && serverFilter.fields) ? serverFilter.fields : [];
let fields = clientFields.filter(itemC => {
return serverFields.some(itemS => itemS === itemC);
});
let and = [];
let order;
let limit;
let filter = {order: order, limit: limit};
var and = [];
(clientFilter && clientFilter.where) && and.push(clientFilter.where);
(serverFilter && serverFilter.where) && and.push(serverFilter.where);
var order;
var limit;
if (clientFilter && clientFilter.where)
and.push(clientFilter.where);
if (serverFilter && serverFilter.where)
and.push(serverFilter.where);
if (clientFilter && clientFilter.order)
order = clientFilter.order;
@ -68,12 +70,14 @@ module.exports = function(Self) {
else if (clientFilter && clientFilter.limit)
limit = clientFilter.limit;
var filter = {order: order, limit: limit};
filter.where = (and.length > 0) && {and: and};
filter.fields = fields;
this.find(filter, function(err, states) {
(err) ? cb(err, null) : cb(null, states);
if (err)
cb(err, null);
else
cb(null, states);
});
};
};
@ -198,8 +202,8 @@ function removeEmpty(o) {
let array = [];
for (let item of o) {
let i = removeEmpty(item);
if (!isEmpty(item))
array.push(item);
if (!isEmpty(i))
array.push(i);
}
if (array.length > 0)
return array;

View File

@ -2,9 +2,6 @@ module.exports = function(Self) {
Self.defineScope();
Self.list = function(ctx, filter, callback) {
var page = filter.page - 1;
var limit = filter.limit * page;
var offset = (page + 1) * filter.limit;
let daysTickets = 0;
let warehouseFk = filter.where.warehouseFk;
delete filter.limit;
@ -80,7 +77,7 @@ module.exports = function(Self) {
}, this);
obj.m3 = obj.m3.toFixed(2);
obj.total = tickets.length;
obj.tickets = tickets.slice(limit, offset);
obj.tickets = tickets;
return obj;
}
};