This commit is contained in:
Carlos 2017-11-09 14:52:16 +01:00
commit 7c37ded182
10 changed files with 172 additions and 91 deletions

18
Jenkinsfile vendored
View File

@ -3,22 +3,24 @@
def branchName = "${env.BRANCH_NAME}";
def branchProduction = "master"
def branchTest = "test";
def dockerHost = "${env.DOCKER_HOST}";
env.NODE_ENV = branchName;
env.BRANCH_NAME = branchName;
env.TAG = "${env.BUILD_NUMBER}";
if (branchName == "test")
env.NODE_ENV = "development";
if (branchName == branchProduction)
dockerHost = "tcp://172.16.255.29:2375";
switch (branchName){
case branchTest:
env.NODE_ENV = "development";
break;
case branchProduction:
env.DOCKER_HOST = "tcp://172.16.255.29:2375";
env.NODE_ENV = "production"
break;
}
node
{
stage ('Print environment variables'){
echo "Branch ${branchName}, Build ${env.TAG}, NODE_ENV ${env.NODE_ENV} en docker Host ${dockerHost}"
echo "Branch ${branchName}, Build ${env.TAG}, NODE_ENV ${env.NODE_ENV} en docker Host ${env.DOCKER_HOST}"
}
stage ('Checkout') {
checkout scm

View File

@ -18,18 +18,18 @@
</vn-one>
</vn-horizontal>
<vn-horizontal>
<vn-textfield vn-two label="Domicilio fiscal" field="$ctrl.client.street" vn-focus></vn-textfield>
<vn-textfield vn-one label="Municipio" field="$ctrl.client.city"></vn-textfield>
<vn-textfield vn-two label="Street" field="$ctrl.client.street" vn-focus></vn-textfield>
<vn-textfield vn-one label="City" field="$ctrl.client.city"></vn-textfield>
</vn-horizontal>
<vn-horizontal>
<vn-textfield vn-one label="Código postal" field="$ctrl.client.postcode"></vn-textfield>
<vn-textfield vn-one label="Postcode" field="$ctrl.client.postcode"></vn-textfield>
<vn-autocomplete vn-one
initial-data="$ctrl.client.province"
field="$ctrl.client.provinceFk"
url="/client/api/Provinces"
show-field="name"
value-field="id"
label="Provincia">
label="Province">
</vn-autocomplete>
<vn-autocomplete vn-one
initial-data="$ctrl.client.country"
@ -37,13 +37,13 @@
url="/client/api/Countries"
show-field="name"
value-field="id"
label="CountryFk">
label="Country">
</vn-autocomplete>
</vn-horizontal>
</vn-vertical>
</vn-card>
<vn-button-bar>
<vn-submit label="Guardar"></vn-submit>
<vn-submit label="Save"></vn-submit>
</vn-button-bar>
</form>

View File

@ -4,5 +4,10 @@
"Fiscal data": "Datos Fiscales",
"Has to invoice": "Factura",
"Invoice by mail": "Factura impresa",
"CountryFk": "País"
"Country": "País",
"Street": "Domicilio fiscal",
"City": "Municipio",
"Postcode": "Código postal",
"Province": "Provincia",
"Save": "Guardar"
}

View File

@ -11,8 +11,8 @@ function loader(moduleName, validations) {
return load;
}
config.$inject = ['$stateProvider', '$urlRouterProvider', 'aclServiceProvider'];
function config($stateProvider, $urlRouterProvider, aclServiceProvider) {
config.$inject = ['$stateProvider', '$urlRouterProvider', 'aclServiceProvider', 'modulesFactoryProvider'];
function config($stateProvider, $urlRouterProvider, aclServiceProvider, modulesFactory) {
splitingRegister.registerGraph(deps);
let aclService = aclServiceProvider.$get();
@ -41,21 +41,28 @@ function config($stateProvider, $urlRouterProvider, aclServiceProvider) {
let fileRoutes = window.routes[file].routes;
let moduleName = window.routes[file].module;
let validations = window.routes[file].validations || false;
fileRoutes.forEach(function(route) {
if (aclService.routeHasPermission(route)) {
$stateProvider.state(route.state, {
url: route.url,
abstract: route.abstract || false,
template: `<${route.component} ${getParams(route)}></${route.component}>`,
resolve: {
loader: loader(moduleName, validations)
},
data: {
routes: fileRoutes
}
});
let mainModule = modulesFactory.$get().getMainRoute(fileRoutes);
if (mainModule) {
let count = fileRoutes.length;
for (let i = 0; i < count; i++) {
let route = fileRoutes[i];
if (aclService.routeHasPermission(route)) {
$stateProvider.state(route.state, {
url: route.url,
abstract: route.abstract || false,
template: `<${route.component} ${getParams(route)}></${route.component}>`,
resolve: {
loader: loader(moduleName, validations)
},
data: {
routes: fileRoutes
}
});
} else if (route.state === mainModule.state) {
break;
}
}
});
}
}
}
ngModule.config(config);

View File

@ -1,7 +1,7 @@
import ngModule from './module';
function modulesFactory(aclService) {
function _getMainRoute(routeCollection) {
function getMainRoute(routeCollection) {
let cant = routeCollection.length;
for (let i = 0; i < cant; i++) {
if (!routeCollection[i].abstract) {
@ -18,7 +18,7 @@ function modulesFactory(aclService) {
name: routes[file].name || routes[file].module,
icon: routes[file].icon || ''
};
let mainRoute = _getMainRoute(window.routes[file].routes);
let mainRoute = getMainRoute(window.routes[file].routes);
if (mainRoute && aclService.routeHasPermission(mainRoute)) {
card.route = mainRoute;
modules.push(card);
@ -28,7 +28,8 @@ function modulesFactory(aclService) {
}
return {
getModules: getModules
getModules: getModules,
getMainRoute: getMainRoute
};
}
modulesFactory.$inject = ['aclService'];

View File

@ -54,6 +54,9 @@ export default {
invoiceByMailCheckboxInput: `${components.vnCheck}[label='Invoice by mail'] > label > label > input`,
addressInput: `${components.vnTextfield}[name="street"]`,
cityInput: `${components.vnTextfield}[name="city"]`,
postcodeInput: `${components.vnTextfield}[name="postcode"]`,
provinceInput: `${components.vnAutocomplete}[field="$ctrl.client.provinceFk"] > vn-vertical > ${components.vnTextfield}`,
provinceFifthOption: `${components.vnAutocomplete}[field="$ctrl.client.provinceFk"] > vn-vertical > vn-drop-down > vn-vertical > vn-one:nth-child(2) > ul > li:nth-child(5)`,
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

@ -45,7 +45,7 @@ describe('Edit basicData path', () => {
.catch(catchErrors(done));
});
it(`should search for the user Bruce Wayne`, done => {
it('should search for the user Bruce Wayne', done => {
nightmare
.wait(selectors.clientsIndex.searchResult)
.type(selectors.clientsIndex.searchClientInput, 'Bruce Wayne')
@ -59,7 +59,7 @@ describe('Edit basicData path', () => {
.catch(catchErrors(done));
});
it(`should click on the search result to access to the client's basic data`, done => {
it('should click on the search result to access to the clients basic data', done => {
nightmare
.waitForTextInElement(selectors.clientsIndex.searchResult, 'Bruce Wayne')
.waitToClick(selectors.clientsIndex.searchResult)
@ -72,7 +72,7 @@ describe('Edit basicData path', () => {
.catch(catchErrors(done));
});
it(`should edit the name`, done => {
it('should edit the name', done => {
nightmare
.wait(selectors.basicData.nameInput)
.clearInput(selectors.basicData.nameInput)
@ -81,13 +81,13 @@ describe('Edit basicData path', () => {
.wait(selectors.globalItems.snackbarIsActive)
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => {
expect(result).toEqual(`¡Datos guardados!`);
expect(result).toEqual('¡Datos guardados!');
done();
})
.catch(catchErrors(done));
});
it(`should confirm the name have been edited`, done => {
it('should confirm the name have been edited', done => {
nightmare
.waitForSnackbarReset()
.click(selectors.fiscalData.fiscalDataButton)
@ -96,13 +96,13 @@ describe('Edit basicData path', () => {
.wait(selectors.basicData.nameInput)
.getInputValue(selectors.basicData.nameInput)
.then(result => {
expect(result).toEqual(`Carol Danvers Edited`);
expect(result).toEqual('Carol Danvers Edited');
done();
})
.catch(catchErrors(done));
});
it(`should edit the tax number`, done => {
it('should edit the tax number', done => {
nightmare
.wait(selectors.basicData.taxNumberInput)
.clearInput(selectors.basicData.taxNumberInput)
@ -111,13 +111,13 @@ describe('Edit basicData path', () => {
.wait(selectors.globalItems.snackbarIsActive)
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => {
expect(result).toEqual(`¡Datos guardados!`);
expect(result).toEqual('¡Datos guardados!');
done();
})
.catch(catchErrors(done));
});
it(`should confirm the tax number have been edited`, done => {
it('should confirm the tax number have been edited', done => {
nightmare
.waitForSnackbarReset()
.click(selectors.fiscalData.fiscalDataButton)
@ -126,13 +126,13 @@ describe('Edit basicData path', () => {
.wait(selectors.basicData.taxNumberInput)
.getInputValue(selectors.basicData.taxNumberInput)
.then(result => {
expect(result).toEqual(`AVG tax Edited`);
expect(result).toEqual('AVG tax Edited');
done();
})
.catch(catchErrors(done));
});
it(`should edit the social name`, done => {
it('should edit the social name', done => {
nightmare
.wait(selectors.basicData.socialNameInput)
.clearInput(selectors.basicData.socialNameInput)
@ -141,13 +141,13 @@ describe('Edit basicData path', () => {
.wait(selectors.globalItems.snackbarIsActive)
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => {
expect(result).toEqual(`¡Datos guardados!`);
expect(result).toEqual('¡Datos guardados!');
done();
})
.catch(catchErrors(done));
});
it(`should confirm the social name have been edited`, done => {
it('should confirm the social name have been edited', done => {
nightmare
.waitForSnackbarReset()
.click(selectors.fiscalData.fiscalDataButton)
@ -156,13 +156,13 @@ describe('Edit basicData path', () => {
.wait(selectors.basicData.socialNameInput)
.getInputValue(selectors.basicData.socialNameInput)
.then(result => {
expect(result).toEqual(`Avengers Team Edited`);
expect(result).toEqual('Avengers Team Edited');
done();
})
.catch(catchErrors(done));
});
it(`should add the landline phone number`, done => {
it('should add the landline phone number', done => {
nightmare
.wait(selectors.basicData.phoneInput)
.clearInput(selectors.basicData.phoneInput)
@ -171,13 +171,13 @@ describe('Edit basicData path', () => {
.wait(selectors.globalItems.snackbarIsActive)
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => {
expect(result).toEqual(`¡Datos guardados!`);
expect(result).toEqual('¡Datos guardados!');
done();
})
.catch(catchErrors(done));
});
it(`should confirm the landline phone number have been added`, done => {
it('should confirm the landline phone number have been added', done => {
nightmare
.waitForSnackbarReset()
.click(selectors.fiscalData.fiscalDataButton)
@ -192,7 +192,7 @@ describe('Edit basicData path', () => {
.catch(catchErrors(done));
});
it(`should add the mobile phone number`, done => {
it('should add the mobile phone number', done => {
nightmare
.wait(selectors.basicData.mobileInput)
.clearInput(selectors.basicData.mobileInput)
@ -201,13 +201,13 @@ describe('Edit basicData path', () => {
.wait(selectors.globalItems.snackbarIsActive)
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => {
expect(result).toEqual(`¡Datos guardados!`);
expect(result).toEqual('¡Datos guardados!');
done();
})
.catch(catchErrors(done));
});
it(`should confirm the mobile phone number have been added`, done => {
it('should confirm the mobile phone number have been added', done => {
nightmare
.waitForSnackbarReset()
.click(selectors.fiscalData.fiscalDataButton)
@ -222,7 +222,7 @@ describe('Edit basicData path', () => {
.catch(catchErrors(done));
});
it(`should add the fax number`, done => {
it('should add the fax number', done => {
nightmare
.wait(selectors.basicData.faxInput)
.clearInput(selectors.basicData.faxInput)
@ -231,13 +231,13 @@ describe('Edit basicData path', () => {
.wait(selectors.globalItems.snackbarIsActive)
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => {
expect(result).toEqual(`¡Datos guardados!`);
expect(result).toEqual('¡Datos guardados!');
done();
})
.catch(catchErrors(done));
});
it(`should confirm the fax number have been added`, done => {
it('should confirm the fax number have been added', done => {
nightmare
.waitForSnackbarReset()
.click(selectors.fiscalData.fiscalDataButton)
@ -252,7 +252,7 @@ describe('Edit basicData path', () => {
.catch(catchErrors(done));
});
it(`should edit the email`, done => {
it('should edit the email', done => {
nightmare
.wait(selectors.basicData.emailInput)
.clearInput(selectors.basicData.emailInput)
@ -261,13 +261,13 @@ describe('Edit basicData path', () => {
.wait(selectors.globalItems.snackbarIsActive)
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => {
expect(result).toEqual(`¡Datos guardados!`);
expect(result).toEqual('¡Datos guardados!');
done();
})
.catch(catchErrors(done));
});
it(`should confirm the email have been edited`, done => {
it('should confirm the email have been edited', done => {
nightmare
.waitForSnackbarReset()
.click(selectors.fiscalData.fiscalDataButton)
@ -282,7 +282,7 @@ describe('Edit basicData path', () => {
.catch(catchErrors(done));
});
// it(`should select the sales person`, done => {
// it('should select the sales person', done => {
// nightmare
// .wait(selectors.basicData.salesPersonInput)
// .select(selectors.basicData.salesPersonInput, '') // not working quite yet
@ -290,13 +290,13 @@ describe('Edit basicData path', () => {
// .wait(selectors.globalItems.snackbarIsActive)
// .getInnerText(selectors.globalItems.snackbarIsActive)
// .then(result => {
// expect(result).toEqual(`¡Datos guardados!`);
// expect(result).toEqual('¡Datos guardados!');
// done();
// })
// .catch(catchErrors(done));
// });
it(`should select the channel`, done => {
it('should select the channel', done => {
nightmare
.waitToClick(selectors.basicData.channelInput)
.waitToClick(selectors.basicData.channelInput)
@ -305,13 +305,13 @@ describe('Edit basicData path', () => {
.wait(selectors.globalItems.snackbarIsActive)
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => {
expect(result).toEqual(`¡Datos guardados!`);
expect(result).toEqual('¡Datos guardados!');
done();
})
.catch(catchErrors(done));
});
it(`should confirm the channel have been selected`, done => {
it('should confirm the channel have been selected', done => {
nightmare
.waitForSnackbarReset()
.click(selectors.fiscalData.fiscalDataButton)

View File

@ -45,7 +45,7 @@ describe('Edit fiscalData path', () => {
.catch(catchErrors(done));
});
it(`should search for the user Bruce Banner`, done => {
it('should search for the user Bruce Banner', done => {
nightmare
.wait(selectors.clientsIndex.searchResult)
.type(selectors.clientsIndex.searchClientInput, 'Bruce Banner')
@ -73,7 +73,7 @@ describe('Edit fiscalData path', () => {
.catch(catchErrors(done));
});
it(`should uncheck the hasToInvoice checkbox`, done => {
it('should uncheck the hasToInvoice checkbox', done => {
nightmare
.waitToClick(selectors.fiscalData.hasToInvoiceCheckboxLabel)
.waitToClick(selectors.fiscalData.saveButton)
@ -86,7 +86,7 @@ describe('Edit fiscalData path', () => {
.catch(catchErrors(done));
});
it(`should confirm hasToInvoice checkbox is unchecked`, done => {
it('should confirm hasToInvoice checkbox is unchecked', done => {
nightmare
.waitForSnackbarReset()
.waitToClick(selectors.basicData.basicDataButton)
@ -103,7 +103,7 @@ describe('Edit fiscalData path', () => {
.catch(catchErrors(done));
});
it(`should uncheck the invoiceByMail checkbox`, done => {
it('should uncheck the invoiceByMail checkbox', done => {
nightmare
.waitToClick(selectors.fiscalData.invoiceByMailCheckboxLabel)
.waitToClick(selectors.fiscalData.saveButton)
@ -116,7 +116,7 @@ describe('Edit fiscalData path', () => {
.catch(catchErrors(done));
});
it(`should confirm invoiceByMail checkbox is unchecked`, done => {
it('should confirm invoiceByMail checkbox is unchecked', done => {
nightmare
.waitForSnackbarReset()
.waitToClick(selectors.basicData.basicDataButton)
@ -133,7 +133,7 @@ describe('Edit fiscalData path', () => {
.catch(catchErrors(done));
});
it(`should edit the address`, done => {
it('should edit the address', done => {
nightmare
.wait(selectors.fiscalData.addressInput)
.clearInput(selectors.fiscalData.addressInput)
@ -142,13 +142,13 @@ describe('Edit fiscalData path', () => {
.wait(selectors.globalItems.snackbarIsActive)
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => {
expect(result).toEqual(`¡Datos guardados!`);
expect(result).toEqual('¡Datos guardados!');
done();
})
.catch(catchErrors(done));
});
it(`should confirm the address have been edited`, done => {
it('should confirm the address have been edited', done => {
nightmare
.waitForSnackbarReset()
.click(selectors.basicData.basicDataButton)
@ -157,13 +157,13 @@ describe('Edit fiscalData path', () => {
.wait(selectors.fiscalData.addressInput)
.getInputValue(selectors.fiscalData.addressInput)
.then(result => {
expect(result).toEqual(`Alpha Flight Low-Orbit`);
expect(result).toEqual('Alpha Flight Low-Orbit');
done();
})
.catch(catchErrors(done));
});
it(`should edit the city`, done => {
it('should edit the city', done => {
nightmare
.wait(selectors.fiscalData.cityInput)
.clearInput(selectors.fiscalData.cityInput)
@ -172,13 +172,13 @@ describe('Edit fiscalData path', () => {
.wait(selectors.globalItems.snackbarIsActive)
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => {
expect(result).toEqual(`¡Datos guardados!`);
expect(result).toEqual('¡Datos guardados!');
done();
})
.catch(catchErrors(done));
});
it(`should confirm the city have been edited`, done => {
it('should confirm the city have been edited', done => {
nightmare
.waitForSnackbarReset()
.click(selectors.basicData.basicDataButton)
@ -187,9 +187,69 @@ describe('Edit fiscalData path', () => {
.wait(selectors.fiscalData.cityInput)
.getInputValue(selectors.fiscalData.cityInput)
.then(result => {
expect(result).toEqual(`N/A`);
expect(result).toEqual('N/A');
done();
})
.catch(catchErrors(done));
});
it('should edit the postcode', done => {
nightmare
.wait(selectors.fiscalData.postcodeInput)
.clearInput(selectors.fiscalData.postcodeInput)
.type(selectors.fiscalData.postcodeInput, '12345')
.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 postcode have been edited', done => {
nightmare
.waitForSnackbarReset()
.click(selectors.basicData.basicDataButton)
.wait(selectors.basicData.nameInput)
.click(selectors.fiscalData.fiscalDataButton)
.wait(selectors.fiscalData.postcodeInput)
.getInputValue(selectors.fiscalData.postcodeInput)
.then(result => {
expect(result).toEqual('12345');
done();
})
.catch(catchErrors(done));
});
// it(`should edit the province`, done => {
// nightmare
// .waitToClick(selectors.fiscalData.provinceInput)
// .waitToClick(selectors.fiscalData.provinceInput)
// .waitToClick(selectors.fiscalData.provinceMetropolisOption)
// .waitToClick(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 province have been selected`, done => {
// nightmare
// .waitForSnackbarReset()
// .click(selectors.fiscalData.fiscalDataButton)
// .wait(selectors.fiscalData.addressInput)
// .click(selectors.fiscalData.basicDataButton)
// .wait(100)
// .getInputValue(selectors.fiscalData.provinceInput)
// .then(result => {
// expect(result).toEqual('Province two');
// done();
// })
// .catch(catchErrors(done));
// });
});

View File

@ -11,7 +11,7 @@ module.exports = function(Self) {
function create(data, next) {
if (data.isDefaultAddress) {
removeAllDefault(data.client, next);
removeAllDefault(data, next);
} else {
next();
}
@ -25,10 +25,10 @@ module.exports = function(Self) {
Self.beforeRemote('findById', function(ctx, modelInstance, next) {
ctx.args.filter = {
"include": {
"relation": "province",
"scope": {
"fields": ["id", "name"]
include: {
relation: "province",
scope: {
fields: ["id", "name"]
}
}
};
@ -44,7 +44,7 @@ module.exports = function(Self) {
function callbackGetAddress(ctx, newData, oldData, next) {
if (newData.isDefaultAddress) {
removeAllDefault(oldData.client, next);
removeAllDefault(oldData, next);
} else if (oldData.isDefaultAddress && newData.hasOwnProperty('isDefaultAddress') && !newData.isDefaultAddress) {
next(generateErrorDefaultAddress());
} else
@ -52,7 +52,10 @@ module.exports = function(Self) {
}
function removeAllDefault(client, next) {
Self.updateAll({clientFk: client.id, isDefaultAddress: {neq: 0}}, {isDefaultAddress: false}, next);
if (client && client.clientFk)
Self.updateAll({clientFk: client.clientFk, isDefaultAddress: {neq: 0}}, {isDefaultAddress: false}, next);
else
next();
}
function generateErrorDefaultAddress() {

View File

@ -335,11 +335,11 @@ INSERT INTO `salix`.`Zone`(`id`, `name`, `printingOrder`)
INSERT INTO `salix`.`Province`(`id`, `name`, `countryFk`, `warehouseFk`, `zoneFk`)
VALUES
(1, 'Provicen one', 1, NULL, 1),
(2, 'Provicen two', 1, NULL, 2),
(3, 'Provicen three', 1, NULL, 3),
(4, 'Provicen four', 1, NULL, 2),
(5, 'Provicen five', 1, NULL, 1);
(1, 'Province one', 1, NULL, 1),
(2, 'Province two', 1, NULL, 2),
(3, 'Province three', 1, NULL, 3),
(4, 'Province four', 1, NULL, 2),
(5, 'Province five', 1, NULL, 1);
INSERT INTO `salix`.`ClientType`(`id`, `code`, `type`)
VALUES