this.noChanges(reject)
);
}
- let changedData = getModifiedData(this.data, this.orgData);
+ let changedData = (this.$attrs.save && this.$attrs.save.toLowerCase() === 'post') ? this.copyInNewObject(this.data) : getModifiedData(this.data, this.orgData);
if (this.save) {
- this.save.model = this.copyInNewObject(changedData);
+ this.save.model = changedData; // this.copyInNewObject(changedData);
return new Promise((resolve, reject) => {
this.save.accept().then(
json => this.writeData({data: json}, resolve),
@@ -180,6 +181,7 @@ export default class Watcher extends Component {
}
dataChanged() {
+ if (this.form && !this.form.$dirty) return false;
let newData = this.copyInNewObject(this.data);
return !isEqual(newData, this.orgData);
}
@@ -194,7 +196,7 @@ export default class Watcher extends Component {
}
}
-Watcher.$inject = ['$element', '$scope', '$state', '$transitions', '$http', 'vnApp', '$translate'];
+Watcher.$inject = ['$element', '$scope', '$state', '$transitions', '$http', 'vnApp', '$translate', '$attrs'];
module.component('vnWatcher', {
template: require('./watcher.html'),
diff --git a/client/core/src/watcher/watcher.spec.js b/client/core/src/watcher/watcher.spec.js
index 5faba7934..e27efc9f0 100644
--- a/client/core/src/watcher/watcher.spec.js
+++ b/client/core/src/watcher/watcher.spec.js
@@ -11,6 +11,7 @@ describe('Component vnWatcher', () => {
let vnApp;
let $translate;
let controller;
+ let $attrs;
beforeEach(() => {
angular.mock.module('client');
@@ -25,7 +26,10 @@ describe('Component vnWatcher', () => {
$transitions = _$transitions_;
$httpBackend = _$httpBackend_;
$translate = _$translate_;
- controller = $componentController('vnWatcher', {$scope, $element, $state, vnApp, $transitions, $httpBackend, $translate});
+ $attrs = {
+ save: "patch"
+ };
+ controller = $componentController('vnWatcher', {$scope, $element, $state, vnApp, $transitions, $httpBackend, $translate, $attrs});
}));
describe('$onInit()', () => {
diff --git a/client/item/routes.json b/client/item/routes.json
index e703ed1de..d871114d6 100644
--- a/client/item/routes.json
+++ b/client/item/routes.json
@@ -2,6 +2,7 @@
"module": "item",
"name": "Items",
"icon": "/static/images/icon_item.png",
+ "validations" : true,
"routes": [
{
"url": "/item",
diff --git a/client/item/src/create/item-create.html b/client/item/src/create/item-create.html
index 9e8b35e35..1a489057d 100644
--- a/client/item/src/create/item-create.html
+++ b/client/item/src/create/item-create.html
@@ -9,16 +9,9 @@
- Create item
-
-
-
-
-
-
-
-
+ New item
+
-
-
-
-
+
+
+ {{$parent.$parent.item.description}}
+
+
+
+
+
-
-
-
-
+ >
+
+
diff --git a/client/item/src/create/item-create.js b/client/item/src/create/item-create.js
index 7723370e1..415e67c4f 100644
--- a/client/item/src/create/item-create.js
+++ b/client/item/src/create/item-create.js
@@ -1,16 +1,21 @@
import ngModule from '../module';
class ItemCreate {
- constructor() {
- this.item = {};
+ constructor($scope, $state) {
+ this.$ = $scope;
+ this.$state = $state;
+ this.item = {
+ relevancy: 0
+ };
}
onSubmit() {
this.$.watcher.submit().then(
- json => this.$state.go('item.card.basic', {id: json.data.id})
+ json => this.$state.go('item.card.data', {id: json.data.id})
);
}
}
+ItemCreate.$inject = ['$scope', '$state'];
ngModule.component('vnItemCreate', {
template: require('./item-create.html'),
diff --git a/client/item/src/locale/es.json b/client/item/src/locale/es.json
index e51c46008..29c254448 100644
--- a/client/item/src/locale/es.json
+++ b/client/item/src/locale/es.json
@@ -4,5 +4,8 @@
"Category": "Categoría",
"Description": "Descripción",
"Size": "Tamaño",
- "Type": "Tipo"
+ "Type": "Tipo",
+ "Name": "Nombre",
+ "Relevancy": "Relevancia",
+ "New item": "Nuevo artículo"
}
\ No newline at end of file
diff --git a/e2e/helpers/nightmare.js b/e2e/helpers/nightmare.js
index d9847a3ec..8bc84526d 100644
--- a/e2e/helpers/nightmare.js
+++ b/e2e/helpers/nightmare.js
@@ -1,14 +1,14 @@
/* eslint no-console: 0 */
import Nightmare from 'nightmare';
-export default function createNightmare(width = 1100, height = 600) {
- const nightmare = new Nightmare({show: true, typeInterval: 10}).viewport(width, height);
+export default function createNightmare(width = 1280, height = 720) {
+ const nightmare = new Nightmare({show: true, typeInterval: 10, x: 0, y: 0}).viewport(width, height);
- nightmare.on('page', function(type, message, error) {
+ nightmare.on('page', (type, message, error) => {
fail(error);
});
- nightmare.on('console', function(type, message) {
+ nightmare.on('console', (type, message) => {
if (type === 'error') {
fail(message);
}
diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js
index 80a41a954..ea076f76a 100644
--- a/e2e/helpers/selectors.js
+++ b/e2e/helpers/selectors.js
@@ -78,6 +78,9 @@ export default {
IBANInput: `${components.vnTextfield}[name="iban"]`,
dueDayInput: `${components.vnTextfield}[name="dueDay"]`,
cancelNotificationButton: 'body > vn-app > vn-vertical > vn-vertical > vn-client-card > vn-main-block > vn-horizontal > vn-one > vn-vertical > vn-client-billing-data > vn-dialog > div > form > div.button-bar > tpl-buttons > button:nth-child(1)',
+ receivedCoreVNHCheckbox: `${components.vnCheck}[label='Received core VNH'] > label > input`,
+ receivedCoreVNLCheckbox: `${components.vnCheck}[label='Received core VNL'] > label > input`,
+ receivedB2BVNLCheckbox: `${components.vnCheck}[label='Received B2B VNL'] > label > input`,
saveButton: `${components.vnSubmit}`
},
addresses: {
@@ -121,5 +124,19 @@ export default {
creditInput: `${components.vnTextfield}[name="credit"]`,
saveButton: `${components.vnSubmit}`,
firstCreditText: 'body > vn-app > vn-vertical > vn-vertical > vn-client-card > vn-main-block > vn-horizontal > vn-one > vn-vertical > ui-view > vn-client-credit-list > vn-card > div > vn-vertical > vn-one > vn-horizontal:nth-child(1) > vn-one'
+ },
+ greuge: {
+ greugeButton: `${components.vnMenuItem}[ui-sref="clientCard.greuge.list"]`,
+ addGreugeFloatButton: `${components.vnFloatButton}`,
+ amountInput: `${components.vnTextfield}[name="amount"]`,
+ descriptionInput: `${components.vnTextfield}[name="description"]`,
+ typeInput: `${components.vnAutocomplete}[field="$ctrl.greuge.greugeTypeFk"] > vn-vertical > ${components.vnTextfield}`,
+ typeSecondOption: `${components.vnAutocomplete}[field="$ctrl.greuge.greugeTypeFk"] > vn-vertical > vn-drop-down > vn-vertical > vn-auto:nth-child(2) > ul > li`,
+ saveButton: `${components.vnSubmit}`,
+ firstGreugeText: 'body > vn-app > vn-vertical > vn-vertical > vn-client-card > vn-main-block > vn-horizontal > vn-one > vn-vertical > ui-view > vn-client-greuge-list > vn-card > div > vn-vertical > vn-one > vn-horizontal'
+ },
+ mandate: {
+ mandateButton: `${components.vnMenuItem}[ui-sref="clientCard.mandate"]`,
+ firstMandateText: 'body > vn-app > vn-vertical > vn-vertical > vn-client-card > vn-main-block > vn-horizontal > vn-one > vn-vertical > vn-client-mandate > vn-card > div > vn-vertical > vn-one > vn-horizontal'
}
};
diff --git a/e2e/paths/01_create_client_path.spec.js b/e2e/paths/01_create_client_path.spec.js
index 75828ba4b..b235dc818 100644
--- a/e2e/paths/01_create_client_path.spec.js
+++ b/e2e/paths/01_create_client_path.spec.js
@@ -86,7 +86,7 @@ describe('create client path', () => {
.wait(selectors.globalItems.snackbarIsActive)
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => {
- expect(result).toEqual('No changes to save');
+ expect(result).toEqual('Some fields are invalid');
done();
})
.catch(catchErrors(done));
@@ -100,7 +100,7 @@ describe('create client path', () => {
.wait(selectors.globalItems.snackbarIsActive)
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => {
- expect(result).toContain('Error');
+ expect(result).toContain('Some fields are invalid');
done();
})
.catch(catchErrors(done));
@@ -115,7 +115,7 @@ describe('create client path', () => {
.wait(selectors.globalItems.snackbarIsActive)
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => {
- expect(result).toContain('Error');
+ expect(result).toContain('Some fields are invalid');
done();
})
.catch(catchErrors(done));
@@ -130,7 +130,7 @@ describe('create client path', () => {
.wait(selectors.globalItems.snackbarIsActive)
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => {
- expect(result).toContain('Error');
+ expect(result).toContain('Some fields are invalid');
done();
})
.catch(catchErrors(done));
@@ -145,7 +145,7 @@ describe('create client path', () => {
.wait(selectors.globalItems.snackbarIsActive)
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => {
- expect(result).toContain('Error');
+ expect(result).toContain('Some fields are invalid');
done();
})
.catch(catchErrors(done));
@@ -175,7 +175,7 @@ describe('create client path', () => {
.wait(selectors.globalItems.snackbarIsActive)
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => {
- expect(result).toContain('Error');
+ expect(result).toContain('Some fields are invalid');
done();
})
.catch(catchErrors(done));
@@ -190,7 +190,7 @@ describe('create client path', () => {
.wait(selectors.globalItems.snackbarIsActive)
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => {
- expect(result).toContain('Error');
+ expect(result).toContain('Some fields are invalid');
done();
})
.catch(catchErrors(done));
diff --git a/e2e/paths/03_edit_fiscal_data.spec.js b/e2e/paths/03_edit_fiscal_data.spec.js
index b5c2bcf5c..00449578f 100644
--- a/e2e/paths/03_edit_fiscal_data.spec.js
+++ b/e2e/paths/03_edit_fiscal_data.spec.js
@@ -131,62 +131,62 @@ describe('Edit fiscalData path', () => {
it('should edit the social name', done => {
nightmare
- .wait(selectors.fiscalData.socialNameInput)
- .clearInput(selectors.fiscalData.socialNameInput)
- .type(selectors.fiscalData.socialNameInput, 'Hulk edited')
- .click(selectors.fiscalData.saveButton)
- .wait(selectors.globalItems.snackbarIsActive)
- .getInnerText(selectors.globalItems.snackbarIsActive)
- .then(result => {
- expect(result).toEqual('Data saved!');
- done();
- })
- .catch(catchErrors(done));
+ .wait(selectors.fiscalData.socialNameInput)
+ .clearInput(selectors.fiscalData.socialNameInput)
+ .type(selectors.fiscalData.socialNameInput, 'Hulk edited')
+ .click(selectors.fiscalData.saveButton)
+ .wait(selectors.globalItems.snackbarIsActive)
+ .getInnerText(selectors.globalItems.snackbarIsActive)
+ .then(result => {
+ expect(result).toEqual('Data saved!');
+ done();
+ })
+ .catch(catchErrors(done));
});
it('should confirm the social name have been edited', done => {
nightmare
- .waitForSnackbarReset()
- .waitToClick(selectors.basicData.basicDataButton)
- .wait(selectors.basicData.nameInput)
- .waitToClick(selectors.fiscalData.fiscalDataButton)
- .wait(selectors.fiscalData.socialNameInput)
- .getInputValue(selectors.fiscalData.socialNameInput)
- .then(result => {
- expect(result).toEqual('Hulk edited');
- done();
- })
- .catch(catchErrors(done));
+ .waitForSnackbarReset()
+ .waitToClick(selectors.basicData.basicDataButton)
+ .wait(selectors.basicData.nameInput)
+ .waitToClick(selectors.fiscalData.fiscalDataButton)
+ .wait(selectors.fiscalData.socialNameInput)
+ .getInputValue(selectors.fiscalData.socialNameInput)
+ .then(result => {
+ expect(result).toEqual('Hulk edited');
+ done();
+ })
+ .catch(catchErrors(done));
});
it('should edit the fiscal id', done => {
nightmare
- .wait(selectors.fiscalData.fiscalIdInput)
- .clearInput(selectors.fiscalData.fiscalIdInput)
- .type(selectors.fiscalData.fiscalIdInput, '94980061C')
- .click(selectors.fiscalData.saveButton)
- .wait(selectors.globalItems.snackbarIsActive)
- .getInnerText(selectors.globalItems.snackbarIsActive)
- .then(result => {
- expect(result).toEqual('Data saved!');
- done();
- })
- .catch(catchErrors(done));
+ .wait(selectors.fiscalData.fiscalIdInput)
+ .clearInput(selectors.fiscalData.fiscalIdInput)
+ .type(selectors.fiscalData.fiscalIdInput, '94980061C')
+ .click(selectors.fiscalData.saveButton)
+ .wait(selectors.globalItems.snackbarIsActive)
+ .getInnerText(selectors.globalItems.snackbarIsActive)
+ .then(result => {
+ expect(result).toEqual('Data saved!');
+ done();
+ })
+ .catch(catchErrors(done));
});
it('should confirm the fiscal id have been edited', done => {
nightmare
- .waitForSnackbarReset()
- .waitToClick(selectors.basicData.basicDataButton)
- .wait(selectors.basicData.nameInput)
- .waitToClick(selectors.fiscalData.fiscalDataButton)
- .wait(selectors.fiscalData.fiscalIdInput)
- .getInputValue(selectors.fiscalData.fiscalIdInput)
- .then(result => {
- expect(result).toEqual('94980061C');
- done();
- })
- .catch(catchErrors(done));
+ .waitForSnackbarReset()
+ .waitToClick(selectors.basicData.basicDataButton)
+ .wait(selectors.basicData.nameInput)
+ .waitToClick(selectors.fiscalData.fiscalDataButton)
+ .wait(selectors.fiscalData.fiscalIdInput)
+ .getInputValue(selectors.fiscalData.fiscalIdInput)
+ .then(result => {
+ expect(result).toEqual('94980061C');
+ done();
+ })
+ .catch(catchErrors(done));
});
it('should uncheck the Equalization tax checkbox', done => {
@@ -216,19 +216,19 @@ describe('Edit fiscalData path', () => {
it('should confirm Equalization tax checkbox is unchecked', done => {
nightmare
- .waitForSnackbarReset()
- .waitToClick(selectors.basicData.basicDataButton)
- .wait(selectors.basicData.nameInput)
- .waitToClick(selectors.fiscalData.fiscalDataButton)
- .wait(selectors.fiscalData.equalizationTaxCheckboxLabel)
- .evaluate(selector => {
- return document.querySelector(selector).checked;
- }, selectors.fiscalData.equalizationTaxCheckboxLabel)
- .then(value => {
- expect(value).toBeFalsy();
- done();
- })
- .catch(catchErrors(done));
+ .waitForSnackbarReset()
+ .waitToClick(selectors.basicData.basicDataButton)
+ .wait(selectors.basicData.nameInput)
+ .waitToClick(selectors.fiscalData.fiscalDataButton)
+ .wait(selectors.fiscalData.equalizationTaxCheckboxLabel)
+ .evaluate(selector => {
+ return document.querySelector(selector).checked;
+ }, selectors.fiscalData.equalizationTaxCheckboxLabel)
+ .then(value => {
+ expect(value).toBeFalsy();
+ done();
+ })
+ .catch(catchErrors(done));
});
describe('Confirm all addresses havent got EQtax as uncheck was propagated', () => {
@@ -412,168 +412,168 @@ describe('Edit fiscalData path', () => {
it('should confirm active checkbox is unchecked', done => {
nightmare
- .waitForSnackbarReset()
- .waitToClick(selectors.basicData.basicDataButton)
- .wait(selectors.basicData.nameInput)
- .waitToClick(selectors.fiscalData.fiscalDataButton)
- .wait(selectors.fiscalData.activeCheckboxLabel)
- .evaluate(selector => {
- return document.querySelector(selector).checked;
- }, selectors.fiscalData.activeCheckboxLabel)
- .then(value => {
- expect(value).toBeFalsy();
- done();
- })
- .catch(catchErrors(done));
+ .waitForSnackbarReset()
+ .waitToClick(selectors.basicData.basicDataButton)
+ .wait(selectors.basicData.nameInput)
+ .waitToClick(selectors.fiscalData.fiscalDataButton)
+ .wait(selectors.fiscalData.activeCheckboxLabel)
+ .evaluate(selector => {
+ return document.querySelector(selector).checked;
+ }, selectors.fiscalData.activeCheckboxLabel)
+ .then(value => {
+ expect(value).toBeFalsy();
+ done();
+ })
+ .catch(catchErrors(done));
});
- it('should check the invoice by address checkbox', done => {
+ it('should uncheck the invoice by address checkbox', done => {
nightmare
- .waitToClick(selectors.fiscalData.invoiceByAddressCheckboxInput)
- .waitToClick(selectors.fiscalData.saveButton)
- .wait(selectors.globalItems.snackbarIsActive)
- .getInnerText(selectors.globalItems.snackbarIsActive)
- .then(result => {
- expect(result).toEqual('Data saved!');
- done();
- })
- .catch(catchErrors(done));
+ .waitToClick(selectors.fiscalData.invoiceByAddressCheckboxInput)
+ .waitToClick(selectors.fiscalData.saveButton)
+ .wait(selectors.globalItems.snackbarIsActive)
+ .getInnerText(selectors.globalItems.snackbarIsActive)
+ .then(result => {
+ expect(result).toEqual('Data saved!');
+ done();
+ })
+ .catch(catchErrors(done));
});
- it('should confirm invoice by address checkbox is checked', done => {
+ it('should confirm invoice by address checkbox is unchecked', done => {
nightmare
- .waitForSnackbarReset()
- .waitToClick(selectors.basicData.basicDataButton)
- .wait(selectors.basicData.nameInput)
- .waitToClick(selectors.fiscalData.fiscalDataButton)
- .wait(selectors.fiscalData.invoiceByAddressCheckboxInput)
- .evaluate(selector => {
- return document.querySelector(selector).checked;
- }, selectors.fiscalData.invoiceByAddressCheckboxInput)
- .then(value => {
- expect(value).toBeTruthy();
- done();
- })
- .catch(catchErrors(done));
+ .waitForSnackbarReset()
+ .waitToClick(selectors.basicData.basicDataButton)
+ .wait(selectors.basicData.nameInput)
+ .waitToClick(selectors.fiscalData.fiscalDataButton)
+ .wait(selectors.fiscalData.invoiceByAddressCheckboxInput)
+ .evaluate(selector => {
+ return document.querySelector(selector).checked;
+ }, selectors.fiscalData.invoiceByAddressCheckboxInput)
+ .then(value => {
+ expect(value).toBeFalsy();
+ done();
+ })
+ .catch(catchErrors(done));
});
it('should check the Verified data checkbox', done => {
nightmare
- .waitToClick(selectors.fiscalData.verifiedDataCheckboxInput)
- .waitToClick(selectors.fiscalData.saveButton)
- .wait(selectors.globalItems.snackbarIsActive)
- .getInnerText(selectors.globalItems.snackbarIsActive)
- .then(result => {
- expect(result).toEqual('Data saved!');
- done();
- })
- .catch(catchErrors(done));
+ .waitToClick(selectors.fiscalData.verifiedDataCheckboxInput)
+ .waitToClick(selectors.fiscalData.saveButton)
+ .wait(selectors.globalItems.snackbarIsActive)
+ .getInnerText(selectors.globalItems.snackbarIsActive)
+ .then(result => {
+ expect(result).toEqual('Data saved!');
+ done();
+ })
+ .catch(catchErrors(done));
});
- it('should confirm Verified data checkbox is checked', done => {
+ it('should confirm Verified data checkbox is unchecked', done => {
nightmare
- .waitForSnackbarReset()
- .waitToClick(selectors.basicData.basicDataButton)
- .wait(selectors.basicData.nameInput)
- .waitToClick(selectors.fiscalData.fiscalDataButton)
- .wait(selectors.fiscalData.verifiedDataCheckboxInput)
- .evaluate(selector => {
- return document.querySelector(selector).checked;
- }, selectors.fiscalData.verifiedDataCheckboxInput)
- .then(value => {
- expect(value).toBeTruthy();
- done();
- })
- .catch(catchErrors(done));
+ .waitForSnackbarReset()
+ .waitToClick(selectors.basicData.basicDataButton)
+ .wait(selectors.basicData.nameInput)
+ .waitToClick(selectors.fiscalData.fiscalDataButton)
+ .wait(selectors.fiscalData.verifiedDataCheckboxInput)
+ .evaluate(selector => {
+ return document.querySelector(selector).checked;
+ }, selectors.fiscalData.verifiedDataCheckboxInput)
+ .then(value => {
+ expect(value).toBeFalsy();
+ done();
+ })
+ .catch(catchErrors(done));
});
it('should uncheck the Has to invoice checkbox', done => {
nightmare
- .waitToClick(selectors.fiscalData.hasToInvoiceCheckboxLabel)
- .waitToClick(selectors.fiscalData.saveButton)
- .wait(selectors.globalItems.snackbarIsActive)
- .getInnerText(selectors.globalItems.snackbarIsActive)
- .then(result => {
- expect(result).toEqual('Data saved!');
- done();
- })
- .catch(catchErrors(done));
+ .waitToClick(selectors.fiscalData.hasToInvoiceCheckboxLabel)
+ .waitToClick(selectors.fiscalData.saveButton)
+ .wait(selectors.globalItems.snackbarIsActive)
+ .getInnerText(selectors.globalItems.snackbarIsActive)
+ .then(result => {
+ expect(result).toEqual('Data saved!');
+ done();
+ })
+ .catch(catchErrors(done));
});
it('should confirm Has to invoice checkbox is unchecked', done => {
nightmare
- .waitForSnackbarReset()
- .waitToClick(selectors.basicData.basicDataButton)
- .wait(selectors.basicData.nameInput)
- .waitToClick(selectors.fiscalData.fiscalDataButton)
- .wait(selectors.fiscalData.hasToInvoiceCheckboxLabel)
- .evaluate(selector => {
- return document.querySelector(selector).checked;
- }, selectors.fiscalData.hasToInvoiceCheckboxLabel)
- .then(value => {
- expect(value).toBeFalsy();
- done();
- })
- .catch(catchErrors(done));
+ .waitForSnackbarReset()
+ .waitToClick(selectors.basicData.basicDataButton)
+ .wait(selectors.basicData.nameInput)
+ .waitToClick(selectors.fiscalData.fiscalDataButton)
+ .wait(selectors.fiscalData.hasToInvoiceCheckboxLabel)
+ .evaluate(selector => {
+ return document.querySelector(selector).checked;
+ }, selectors.fiscalData.hasToInvoiceCheckboxLabel)
+ .then(value => {
+ expect(value).toBeFalsy();
+ done();
+ })
+ .catch(catchErrors(done));
});
it('should uncheck the Invoice by mail checkbox', done => {
nightmare
- .waitToClick(selectors.fiscalData.invoiceByMailCheckboxLabel)
- .waitToClick(selectors.fiscalData.saveButton)
- .wait(selectors.globalItems.snackbarIsActive)
- .getInnerText(selectors.globalItems.snackbarIsActive)
- .then(result => {
- expect(result).toEqual('Data saved!');
- done();
- })
- .catch(catchErrors(done));
+ .waitToClick(selectors.fiscalData.invoiceByMailCheckboxLabel)
+ .waitToClick(selectors.fiscalData.saveButton)
+ .wait(selectors.globalItems.snackbarIsActive)
+ .getInnerText(selectors.globalItems.snackbarIsActive)
+ .then(result => {
+ expect(result).toEqual('Data saved!');
+ done();
+ })
+ .catch(catchErrors(done));
});
it('should confirm Invoice by mail checkbox is unchecked', done => {
nightmare
- .waitForSnackbarReset()
- .waitToClick(selectors.basicData.basicDataButton)
- .wait(selectors.basicData.nameInput)
- .waitToClick(selectors.fiscalData.fiscalDataButton)
- .wait(selectors.fiscalData.invoiceByMailCheckboxLabel)
- .evaluate(selector => {
- return document.querySelector(selector).checked;
- }, selectors.fiscalData.invoiceByMailCheckboxLabel)
- .then(value => {
- expect(value).toBeFalsy();
- done();
- })
- .catch(catchErrors(done));
+ .waitForSnackbarReset()
+ .waitToClick(selectors.basicData.basicDataButton)
+ .wait(selectors.basicData.nameInput)
+ .waitToClick(selectors.fiscalData.fiscalDataButton)
+ .wait(selectors.fiscalData.invoiceByMailCheckboxLabel)
+ .evaluate(selector => {
+ return document.querySelector(selector).checked;
+ }, selectors.fiscalData.invoiceByMailCheckboxLabel)
+ .then(value => {
+ expect(value).toBeFalsy();
+ done();
+ })
+ .catch(catchErrors(done));
});
it('should check the Vies checkbox', done => {
nightmare
- .waitToClick(selectors.fiscalData.viesCheckboxInput)
- .waitToClick(selectors.fiscalData.saveButton)
- .wait(selectors.globalItems.snackbarIsActive)
- .getInnerText(selectors.globalItems.snackbarIsActive)
- .then(result => {
- expect(result).toEqual('Data saved!');
- done();
- })
- .catch(catchErrors(done));
+ .waitToClick(selectors.fiscalData.viesCheckboxInput)
+ .waitToClick(selectors.fiscalData.saveButton)
+ .wait(selectors.globalItems.snackbarIsActive)
+ .getInnerText(selectors.globalItems.snackbarIsActive)
+ .then(result => {
+ expect(result).toEqual('Data saved!');
+ done();
+ })
+ .catch(catchErrors(done));
});
it('should confirm Vies checkbox is checked', done => {
nightmare
- .waitForSnackbarReset()
- .waitToClick(selectors.basicData.basicDataButton)
- .wait(selectors.basicData.nameInput)
- .waitToClick(selectors.fiscalData.fiscalDataButton)
- .wait(selectors.fiscalData.viesCheckboxInput)
- .evaluate(selector => {
- return document.querySelector(selector).checked;
- }, selectors.fiscalData.viesCheckboxInput)
- .then(value => {
- expect(value).toBeTruthy();
- done();
- })
- .catch(catchErrors(done));
+ .waitForSnackbarReset()
+ .waitToClick(selectors.basicData.basicDataButton)
+ .wait(selectors.basicData.nameInput)
+ .waitToClick(selectors.fiscalData.fiscalDataButton)
+ .wait(selectors.fiscalData.viesCheckboxInput)
+ .evaluate(selector => {
+ return document.querySelector(selector).checked;
+ }, selectors.fiscalData.viesCheckboxInput)
+ .then(value => {
+ expect(value).toBeTruthy();
+ done();
+ })
+ .catch(catchErrors(done));
});
});
diff --git a/e2e/paths/04_edit_pay_method.spec.js b/e2e/paths/04_edit_pay_method.spec.js
index 1b12710ad..88e186ad2 100644
--- a/e2e/paths/04_edit_pay_method.spec.js
+++ b/e2e/paths/04_edit_pay_method.spec.js
@@ -160,35 +160,123 @@ describe('Edit pay method path', () => {
.catch(catchErrors(done));
});
- // BUG IBAN validation seems to break down whenever the due day is edited plus due day shouldnt accep values above 31.
+ it(`should edit the due day`, done => {
+ nightmare
+ .clearInput(selectors.payMethod.dueDayInput)
+ .type(selectors.payMethod.dueDayInput, '60')
+ .waitToClick(selectors.payMethod.saveButton)
+ .waitToClick(selectors.payMethod.cancelNotificationButton)
+ .wait(selectors.globalItems.snackbarIsActive)
+ .getInnerText(selectors.globalItems.snackbarIsActive)
+ .then(result => {
+ expect(result).toEqual('Data saved!');
+ done();
+ })
+ .catch(catchErrors(done));
+ });
- // it(`should edit the due day`, done => {
- // nightmare
- // .clearInput(selectors.payMethod.dueDayInput)
- // .type(selectors.payMethod.dueDayInput, '25')
- // .waitToClick(selectors.payMethod.saveButton)
- // .waitToClick(selectors.payMethod.cancelNotificationButton)
- // .wait(selectors.globalItems.snackbarIsActive)
- // .getInnerText(selectors.globalItems.snackbarIsActive)
- // .then(result => {
- // expect(result).toEqual('Data saved!');
- // done();
- // })
- // .catch(catchErrors(done));
- // });
+ it('should confirm the due day have been edited', done => {
+ nightmare
+ .waitForSnackbarReset()
+ .waitToClick(selectors.basicData.basicDataButton)
+ .wait(selectors.basicData.nameInput)
+ .waitToClick(selectors.payMethod.payMethodButton)
+ .wait(selectors.payMethod.dueDayInput)
+ .getInputValue(selectors.payMethod.dueDayInput)
+ .then(result => {
+ expect(result).toEqual('60');
+ done();
+ })
+ .catch(catchErrors(done));
+ });
- // it('should confirm the due day have been edited', done => {
- // nightmare
- // .waitForSnackbarReset()
- // .waitToClick(selectors.basicData.basicDataButton)
- // .wait(selectors.basicData.nameInput)
- // .waitToClick(selectors.payMethod.payMethodButton)
- // .wait(selectors.payMethod.dueDayInput)
- // .getInputValue(selectors.payMethod.dueDayInput)
- // .then(result => {
- // expect(result).toEqual('25');
- // done();
- // })
- // .catch(catchErrors(done));
- // });
+ it('should uncheck the Received core VNH checkbox', done => {
+ nightmare
+ .waitToClick(selectors.payMethod.receivedCoreVNHCheckbox)
+ .waitToClick(selectors.payMethod.saveButton)
+ .wait(selectors.globalItems.snackbarIsActive)
+ .getInnerText(selectors.globalItems.snackbarIsActive)
+ .then(result => {
+ expect(result).toEqual('Data saved!');
+ done();
+ })
+ .catch(catchErrors(done));
+ });
+
+ it('should confirm Received core VNH checkbox is unchecked', done => {
+ nightmare
+ .waitForSnackbarReset()
+ .waitToClick(selectors.basicData.basicDataButton)
+ .wait(selectors.basicData.nameInput)
+ .waitToClick(selectors.payMethod.payMethodButton)
+ .wait(selectors.payMethod.receivedCoreVNHCheckbox)
+ .evaluate(selector => {
+ return document.querySelector(selector).checked;
+ }, selectors.payMethod.receivedCoreVNHCheckbox)
+ .then(value => {
+ expect(value).toBeFalsy();
+ done();
+ })
+ .catch(catchErrors(done));
+ });
+
+ it('should uncheck the Received core VNL checkbox', done => {
+ nightmare
+ .waitToClick(selectors.payMethod.receivedCoreVNLCheckbox)
+ .waitToClick(selectors.payMethod.saveButton)
+ .wait(selectors.globalItems.snackbarIsActive)
+ .getInnerText(selectors.globalItems.snackbarIsActive)
+ .then(result => {
+ expect(result).toEqual('Data saved!');
+ done();
+ })
+ .catch(catchErrors(done));
+ });
+
+ it('should confirm Received core VNL checkbox is unchecked', done => {
+ nightmare
+ .waitForSnackbarReset()
+ .waitToClick(selectors.basicData.basicDataButton)
+ .wait(selectors.basicData.nameInput)
+ .waitToClick(selectors.payMethod.payMethodButton)
+ .wait(selectors.payMethod.receivedCoreVNLCheckbox)
+ .evaluate(selector => {
+ return document.querySelector(selector).checked;
+ }, selectors.payMethod.receivedCoreVNLCheckbox)
+ .then(value => {
+ expect(value).toBeFalsy();
+ done();
+ })
+ .catch(catchErrors(done));
+ });
+
+ it('should uncheck the Received B2B VNL checkbox', done => {
+ nightmare
+ .waitToClick(selectors.payMethod.receivedB2BVNLCheckbox)
+ .waitToClick(selectors.payMethod.saveButton)
+ .wait(selectors.globalItems.snackbarIsActive)
+ .getInnerText(selectors.globalItems.snackbarIsActive)
+ .then(result => {
+ expect(result).toEqual('Data saved!');
+ done();
+ })
+ .catch(catchErrors(done));
+ });
+
+ it('should confirm Received B2B VNL checkbox is unchecked', done => {
+ nightmare
+ .waitForSnackbarReset()
+ .waitToClick(selectors.basicData.basicDataButton)
+ .wait(selectors.basicData.nameInput)
+ .waitToClick(selectors.payMethod.payMethodButton)
+ .wait(selectors.payMethod.receivedB2BVNLCheckbox)
+ .evaluate(selector => {
+ return document.querySelector(selector).checked;
+ }, selectors.payMethod.receivedB2BVNLCheckbox)
+ .then(value => {
+ expect(value).toBeFalsy();
+ done();
+ })
+ .catch(catchErrors(done));
+ });
});
diff --git a/e2e/paths/05_edit_addresses.spec.js b/e2e/paths/05_edit_addresses.spec.js
index 631affcd7..b87ba7fd4 100644
--- a/e2e/paths/05_edit_addresses.spec.js
+++ b/e2e/paths/05_edit_addresses.spec.js
@@ -98,15 +98,15 @@ describe('Edit addresses path', () => {
it('should check the default checkbox then receive an error after clicking save button as the form is empty', done => {
nightmare
- .waitToClick(selectors.addresses.defaultCheckboxInput)
- .waitToClick(selectors.fiscalData.saveButton)
- .wait(selectors.globalItems.snackbarIsActive)
- .getInnerText(selectors.globalItems.snackbarIsActive)
- .then(result => {
- expect(result).toContain('Error');
- done();
- })
- .catch(catchErrors(done));
+ .waitToClick(selectors.addresses.defaultCheckboxInput)
+ .waitToClick(selectors.fiscalData.saveButton)
+ .wait(selectors.globalItems.snackbarIsActive)
+ .getInnerText(selectors.globalItems.snackbarIsActive)
+ .then(result => {
+ expect(result).toContain('Some fields are invalid');
+ done();
+ })
+ .catch(catchErrors(done));
});
it('should receive an error when clicking the save button having all the form fields empty but consignee', done => {
@@ -117,7 +117,7 @@ describe('Edit addresses path', () => {
.wait(selectors.globalItems.snackbarIsActive)
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => {
- expect(result).toContain('Error');
+ expect(result).toContain('Some fields are invalid');
done();
})
.catch(catchErrors(done));
@@ -132,7 +132,7 @@ describe('Edit addresses path', () => {
.wait(selectors.globalItems.snackbarIsActive)
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => {
- expect(result).toContain('Error');
+ expect(result).toContain('Some fields are invalid');
done();
})
.catch(catchErrors(done));
@@ -147,7 +147,7 @@ describe('Edit addresses path', () => {
.wait(selectors.globalItems.snackbarIsActive)
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => {
- expect(result).toContain('Error');
+ expect(result).toContain('Some fields are invalid');
done();
})
.catch(catchErrors(done));
@@ -162,7 +162,7 @@ describe('Edit addresses path', () => {
.wait(selectors.globalItems.snackbarIsActive)
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => {
- expect(result).toContain('Error');
+ expect(result).toContain('Some fields are invalid');
done();
})
.catch(catchErrors(done));
@@ -178,7 +178,7 @@ describe('Edit addresses path', () => {
.wait(selectors.globalItems.snackbarIsActive)
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => {
- expect(result).toContain('Error');
+ expect(result).toContain('Some fields are invalid');
done();
})
.catch(catchErrors(done));
@@ -193,7 +193,7 @@ describe('Edit addresses path', () => {
.wait(selectors.globalItems.snackbarIsActive)
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => {
- expect(result).toContain('Error');
+ expect(result).toContain('Some fields are invalid');
done();
})
.catch(catchErrors(done));
@@ -207,7 +207,7 @@ describe('Edit addresses path', () => {
.wait(selectors.globalItems.snackbarIsActive)
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => {
- expect(result).toContain('Error');
+ expect(result).toContain('Some fields are invalid');
done();
})
.catch(catchErrors(done));
@@ -222,7 +222,7 @@ describe('Edit addresses path', () => {
.wait(selectors.globalItems.snackbarIsActive)
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => {
- expect(result).toContain('Error');
+ expect(result).toContain('Some fields are invalid');
done();
})
.catch(catchErrors(done));
diff --git a/e2e/paths/06_edit_web_access.spec.js b/e2e/paths/06_edit_web_access.spec.js
index 3748dbb9c..e42e46561 100644
--- a/e2e/paths/06_edit_web_access.spec.js
+++ b/e2e/paths/06_edit_web_access.spec.js
@@ -86,32 +86,32 @@ describe('Edit web access path', () => {
it(`should click on the Enable web access checkbox to uncheck it`, done => {
nightmare
- .waitToClick(selectors.webAccess.enableWebAccessCheckbox)
- .waitToClick(selectors.fiscalData.saveButton)
- .wait(selectors.globalItems.snackbarIsActive)
- .getInnerText(selectors.globalItems.snackbarIsActive)
- .then(result => {
- expect(result).toContain(`Data saved!`);
- done();
- })
- .catch(catchErrors(done));
+ .waitToClick(selectors.webAccess.enableWebAccessCheckbox)
+ .waitToClick(selectors.fiscalData.saveButton)
+ .wait(selectors.globalItems.snackbarIsActive)
+ .getInnerText(selectors.globalItems.snackbarIsActive)
+ .then(result => {
+ expect(result).toContain(`Data saved!`);
+ done();
+ })
+ .catch(catchErrors(done));
});
it('should confirm Enable web access checkbox is unchecked', done => {
nightmare
- .waitForSnackbarReset()
- .waitToClick(selectors.basicData.basicDataButton)
- .wait(selectors.basicData.nameInput)
- .waitToClick(selectors.webAccess.webAccessButton)
- .wait(selectors.webAccess.enableWebAccessCheckbox)
- .evaluate(selector => {
- return document.querySelector(selector).checked;
- }, selectors.webAccess.enableWebAccessCheckbox)
- .then(value => {
- expect(value).toBeFalsy();
- done();
- })
- .catch(catchErrors(done));
+ .waitForSnackbarReset()
+ .waitToClick(selectors.basicData.basicDataButton)
+ .wait(selectors.basicData.nameInput)
+ .waitToClick(selectors.webAccess.webAccessButton)
+ .wait(selectors.webAccess.enableWebAccessCheckbox)
+ .evaluate(selector => {
+ return document.querySelector(selector).checked;
+ }, selectors.webAccess.enableWebAccessCheckbox)
+ .then(value => {
+ expect(value).toBeFalsy();
+ done();
+ })
+ .catch(catchErrors(done));
});
it('should edit the User name', done => {
diff --git a/e2e/paths/08_add_credit.spec.js b/e2e/paths/08_add_credit.spec.js
index d540fbe61..d3a218327 100644
--- a/e2e/paths/08_add_credit.spec.js
+++ b/e2e/paths/08_add_credit.spec.js
@@ -2,13 +2,12 @@ import config from '../helpers/config.js';
import createNightmare from '../helpers/nightmare';
import selectors from '../helpers/selectors.js';
import {catchErrors} from '../../services/utils/jasmineHelpers';
-import { fail } from 'assert';
const nightmare = createNightmare();
const moduleAccessViewHashURL = '#!/';
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
-fdescribe('Add credit path', () => {
+describe('Add credit path', () => {
describe('warm up', () => {
it('should warm up login and fixtures', done => {
nightmare
@@ -104,7 +103,7 @@ fdescribe('Add credit path', () => {
.wait(selectors.globalItems.snackbarIsActive)
.getInnerText(selectors.globalItems.snackbarIsActive)
.then(result => {
- expect(result).toEqual('Data saved');
+ expect(result).toEqual('Data saved!');
done();
})
.catch(catchErrors(done));
diff --git a/e2e/paths/09_add_greuge.spec.js b/e2e/paths/09_add_greuge.spec.js
new file mode 100644
index 000000000..4dd6990cf
--- /dev/null
+++ b/e2e/paths/09_add_greuge.spec.js
@@ -0,0 +1,180 @@
+import config from '../helpers/config.js';
+import createNightmare from '../helpers/nightmare';
+import selectors from '../helpers/selectors.js';
+import {catchErrors} from '../../services/utils/jasmineHelpers';
+const nightmare = createNightmare();
+const moduleAccessViewHashURL = '#!/';
+
+jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
+
+describe('Add greuge path', () => {
+ describe('warm up', () => {
+ it('should warm up login and fixtures', done => {
+ nightmare
+ .login()
+ .waitForURL(moduleAccessViewHashURL)
+ .waitToClick(selectors.globalItems.logOutButton)
+ .then(() => {
+ done();
+ })
+ .catch(catchErrors(done));
+ });
+ });
+
+ it('should log in', done => {
+ nightmare
+ .login()
+ .waitForURL(moduleAccessViewHashURL)
+ .url()
+ .then(url => {
+ expect(url).toEqual(config.url + moduleAccessViewHashURL);
+ done();
+ })
+ .catch(catchErrors(done));
+ });
+
+ it('should make sure the language is English', done => {
+ nightmare
+ .changeLanguageToEnglish()
+ .then(() => {
+ done();
+ })
+ .catch(catchErrors(done));
+ });
+
+ it('should click on the Clients button of the top bar menu', done => {
+ nightmare
+ .waitToClick(selectors.globalItems.applicationsMenuButton)
+ .wait(selectors.globalItems.applicationsMenuVisible)
+ .waitToClick(selectors.globalItems.clientsButton)
+ .wait(selectors.clientsIndex.createClientButton)
+ .url()
+ .then(url => {
+ expect(url).toEqual(config.url + '#!/clients');
+ done();
+ })
+ .catch(catchErrors(done));
+ });
+
+ it('should search for the user Petter Parker', done => {
+ nightmare
+ .wait(selectors.clientsIndex.searchResult)
+ .type(selectors.clientsIndex.searchClientInput, 'Petter Parker')
+ .click(selectors.clientsIndex.searchButton)
+ .waitForNumberOfElements(selectors.clientsIndex.searchResult, 1)
+ .countSearchResults(selectors.clientsIndex.searchResult)
+ .then(result => {
+ expect(result).toEqual(1);
+ done();
+ })
+ .catch(catchErrors(done));
+ });
+
+ it(`should click on the search result to access to the client's greuge`, done => {
+ nightmare
+ .waitForTextInElement(selectors.clientsIndex.searchResult, 'Petter Parker')
+ .waitToClick(selectors.clientsIndex.searchResult)
+ .waitToClick(selectors.greuge.greugeButton)
+ .waitForURL('greuge/list')
+ .url()
+ .then(url => {
+ expect(url).toContain('greuge/list');
+ done();
+ })
+ .catch(catchErrors(done));
+ });
+
+ it(`should click on the add greuge button`, done => {
+ nightmare
+ .waitToClick(selectors.greuge.addGreugeFloatButton)
+ .waitForURL('greuge/create')
+ .url()
+ .then(url => {
+ expect(url).toContain('greuge/create');
+ done();
+ })
+ .catch(catchErrors(done));
+ });
+
+ it(`should receive an error if all fields are empty but date on submit`, done => {
+ nightmare
+ .click(selectors.credit.saveButton)
+ .wait(selectors.globalItems.snackbarIsActive)
+ .getInnerText(selectors.globalItems.snackbarIsActive)
+ .then(result => {
+ expect(result).toContain('Some fields are invalid');
+ done();
+ })
+ .catch(catchErrors(done));
+ });
+
+ it(`should receive an error if all fields are empty but date and amount on submit`, done => {
+ nightmare
+ .type(selectors.greuge.amountInput, 999)
+ .click(selectors.greuge.saveButton)
+ .wait(selectors.globalItems.snackbarIsActive)
+ .getInnerText(selectors.globalItems.snackbarIsActive)
+ .then(result => {
+ expect(result).toContain('Some fields are invalid');
+ done();
+ })
+ .catch(catchErrors(done));
+ });
+
+ it(`should receive an error if all fields are empty but date and description on submit`, done => {
+ nightmare
+ .clearInput(selectors.greuge.amountInput)
+ .type(selectors.greuge.descriptionInput, 'new armor for Batman!')
+ .click(selectors.greuge.saveButton)
+ .wait(selectors.globalItems.snackbarIsActive)
+ .getInnerText(selectors.globalItems.snackbarIsActive)
+ .then(result => {
+ expect(result).toContain('Some fields are invalid');
+ done();
+ })
+ .catch(catchErrors(done));
+ });
+
+ it(`should receive an error if all fields are empty but date and type on submit`, done => {
+ nightmare
+ .clearInput(selectors.greuge.descriptionInput)
+ .waitToClick(selectors.greuge.typeInput)
+ .waitToClick(selectors.greuge.typeSecondOption)
+ .click(selectors.greuge.saveButton)
+ .wait(selectors.globalItems.snackbarIsActive)
+ .getInnerText(selectors.globalItems.snackbarIsActive)
+ .then(result => {
+ expect(result).toContain('Some fields are invalid');
+ done();
+ })
+ .catch(catchErrors(done));
+ });
+
+ it(`should create a new greuge with all its data`, done => {
+ nightmare
+ .type(selectors.greuge.amountInput, 999)
+ .type(selectors.greuge.descriptionInput, 'new armor for Batman!')
+ .click(selectors.greuge.saveButton)
+ .wait(selectors.globalItems.snackbarIsActive)
+ .getInnerText(selectors.globalItems.snackbarIsActive)
+ .then(result => {
+ expect(result).toContain('Data saved!');
+ done();
+ })
+ .catch(catchErrors(done));
+ });
+
+ it('should confirm the greuge was added to the list', done => {
+ nightmare
+ .waitForSnackbarReset()
+ .wait(selectors.greuge.firstGreugeText)
+ .getInnerText(selectors.greuge.firstGreugeText)
+ .then(value => {
+ expect(value).toContain(999);
+ expect(value).toContain('new armor for Batman!');
+ expect(value).toContain('Diff');
+ done();
+ })
+ .catch(catchErrors(done));
+ });
+});
diff --git a/e2e/paths/10_mandate.spec.js b/e2e/paths/10_mandate.spec.js
new file mode 100644
index 000000000..ab7847ee7
--- /dev/null
+++ b/e2e/paths/10_mandate.spec.js
@@ -0,0 +1,99 @@
+import config from '../helpers/config.js';
+import createNightmare from '../helpers/nightmare';
+import selectors from '../helpers/selectors.js';
+import {catchErrors} from '../../services/utils/jasmineHelpers';
+const nightmare = createNightmare();
+const moduleAccessViewHashURL = '#!/';
+
+jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
+
+describe('mandate path', () => {
+ describe('warm up', () => {
+ it('should warm up login and fixtures', done => {
+ nightmare
+ .login()
+ .waitForURL(moduleAccessViewHashURL)
+ .waitToClick(selectors.globalItems.logOutButton)
+ .then(() => {
+ done();
+ })
+ .catch(catchErrors(done));
+ });
+ });
+
+ it('should log in', done => {
+ nightmare
+ .login()
+ .waitForURL(moduleAccessViewHashURL)
+ .url()
+ .then(url => {
+ expect(url).toEqual(config.url + moduleAccessViewHashURL);
+ done();
+ })
+ .catch(catchErrors(done));
+ });
+
+ it('should make sure the language is English', done => {
+ nightmare
+ .changeLanguageToEnglish()
+ .then(() => {
+ done();
+ })
+ .catch(catchErrors(done));
+ });
+
+ it('should click on the Clients button of the top bar menu', done => {
+ nightmare
+ .waitToClick(selectors.globalItems.applicationsMenuButton)
+ .wait(selectors.globalItems.applicationsMenuVisible)
+ .waitToClick(selectors.globalItems.clientsButton)
+ .wait(selectors.clientsIndex.createClientButton)
+ .url()
+ .then(url => {
+ expect(url).toEqual(config.url + '#!/clients');
+ done();
+ })
+ .catch(catchErrors(done));
+ });
+
+ it('should search for the user Petter Parker', done => {
+ nightmare
+ .wait(selectors.clientsIndex.searchResult)
+ .type(selectors.clientsIndex.searchClientInput, 'Petter Parker')
+ .click(selectors.clientsIndex.searchButton)
+ .waitForNumberOfElements(selectors.clientsIndex.searchResult, 1)
+ .countSearchResults(selectors.clientsIndex.searchResult)
+ .then(result => {
+ expect(result).toEqual(1);
+ done();
+ })
+ .catch(catchErrors(done));
+ });
+
+ it(`should click on the search result to access to the client's mandate`, done => {
+ nightmare
+ .waitForTextInElement(selectors.clientsIndex.searchResult, 'Petter')
+ .waitToClick(selectors.clientsIndex.searchResult)
+ .waitToClick(selectors.mandate.mandateButton)
+ .waitForURL('mandate')
+ .url()
+ .then(url => {
+ expect(url).toContain('mandate');
+ done();
+ })
+ .catch(catchErrors(done));
+ });
+
+ it('should confirm the client has a mandate of the CORE type', done => {
+ nightmare
+ .wait(selectors.mandate.firstMandateText)
+ .getInnerText(selectors.mandate.firstMandateText)
+ .then(value => {
+ expect(value).toContain('1');
+ expect(value).toContain('WAY');
+ expect(value).toContain('CORE');
+ done();
+ })
+ .catch(catchErrors(done));
+ });
+});
diff --git a/e2e_tests.js b/e2e_tests.js
index 495cc7495..dd1d7a079 100644
--- a/e2e_tests.js
+++ b/e2e_tests.js
@@ -18,8 +18,8 @@ var SpecReporter = require('jasmine-spec-reporter').SpecReporter;
jasmine.loadConfig({
spec_files: [
- './e2e/helpers/extensions.js',
- './e2e/**/*[sS]pec.js'
+ './e2e/**/*[sS]pec.js',
+ './e2e/helpers/extensions.js'
],
helpers: [
'/services/utils/jasmineHelpers.js'
diff --git a/gulpfile.js b/gulpfile.js
index 2bb1f85b1..656b81308 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -1,4 +1,5 @@
var gulp = require('gulp');
+const jasmine = require('gulp-jasmine');
var gutil = require('gulp-util');
var wrap = require('gulp-wrap');
var concat = require('gulp-concat');
@@ -37,6 +38,15 @@ gulp.task('client', ['clean'], function() {
return gulp.start('watch', 'routes', 'locales', 'webpack-dev-server');
});
+gulp.task('nginxRestart', callback => {
+ let isWindows = /^win/.test(process.platform);
+ let command = isWindows ? '.\\dev.cmd' : './dev.sh';
+ exec(command, (err, stdout, stderr) => {
+ console.log(stdout);
+ callback(err);
+ });
+});
+
gulp.task('services', () => {
process.env.NODE_ENV = gutil.env.env || 'development';
const pathServices = './services/';
@@ -49,6 +59,25 @@ gulp.task('services', () => {
});
});
+gulp.task('clientDev', callback => {
+ runSequence('nginxRestart', 'client', callback);
+});
+
+gulp.task('servicesDev', callback => {
+ let isWindows = /^win/.test(process.platform);
+ let command = isWindows ? 'docker inspect dblocal | findstr Status' : 'docker inspect dblocal | grep Status';
+ gutil.env.env = 'test';
+ exec(command, (err, stdout, stderr) => {
+ let isNotRunning = !stdout.includes('running');
+ if (isNotRunning) {
+ runSequence('docker', 'waitForMySQL', 'services');
+ } else {
+ runSequence('services');
+ }
+ callback(err);
+ });
+});
+
gulp.task('clean', function() {
return del([`${buildDir}/*`, `!${buildDir}/templates`, `!${buildDir}/images`], {force: true});
});
@@ -154,34 +183,33 @@ gulp.task('test', callback => {
// e2e tests
gulp.task('e2e', callback => {
- runSequence('docker', 'runDockerLogs', 'endToEndTests', callback);
+ runSequence('docker', 'waitForMySQL', 'endToEndTests', callback);
});
-gulp.task('runDockerLogs', callback => {
+gulp.task('waitForMySQL', callback => {
+ let maxInterval = 30000;
+ let interval = 1000;
let timer = 0;
console.log('Waiting for MySQL init process...');
let waitForLocaldb = setInterval(() => {
- if (timer < 15000) {
- timer += 1000;
+ if (timer < maxInterval) {
+ timer += interval;
exec('docker logs --tail 4 dblocal', (err, stdout, stderr) => {
if (stdout.includes('MySQL init process done. Ready for start up.')) {
- console.log('MySQL init process done.');
clearInterval(waitForLocaldb);
callback(err);
}
});
} else {
- console.log('MySQL connection not established whithin 15 secs!');
+ console.log(`MySQL connection not established whithin ${maxInterval / 1000} secs!`);
clearInterval(waitForLocaldb);
}
- }, 1000);
+ }, interval);
});
gulp.task('endToEndTests', callback => {
- exec('npm run e2e', (err, stdout, stderr) => {
- console.log(stdout);
- callback(err);
- });
+ gulp.src('./e2e_tests.js')
+ .pipe(jasmine({reporter: 'none'}));
});
// docker dblocal
diff --git a/package.json b/package.json
index c89c08933..b981b7b4a 100644
--- a/package.json
+++ b/package.json
@@ -44,6 +44,7 @@
"gulp-concat": "^2.6.0",
"gulp-extend": "^0.2.0",
"gulp-install": "^1.1.0",
+ "gulp-jasmine": "^3.0.0",
"gulp-print": "^2.0.1",
"gulp-util": "^3.0.7",
"gulp-wrap": "^0.13.0",
@@ -57,7 +58,9 @@
"karma-jasmine": "^1.1.0",
"karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "^2.0.4",
+ "md5": "^2.2.1",
"merge-stream": "^1.0.1",
+ "mysql": "^2.15.0",
"nightmare": "^2.10.0",
"node-sass": "^3.11.0",
"raw-loader": "*",
@@ -71,8 +74,7 @@
"build": "webpack --progress --colors",
"dev": "webpack-dev-server --progress --colors",
"lint": "eslint ./ --cache --ignore-pattern .gitignore",
- "test": "node services_tests",
- "testWatcher": "nodemon -q services_tests.js -w services",
+ "test": "nodemon -q services_tests.js -w services",
"e2e": "node e2e_tests"
}
}
diff --git a/services/auth/package.json b/services/auth/package.json
index f959ddc95..2b78464c7 100644
--- a/services/auth/package.json
+++ b/services/auth/package.json
@@ -8,7 +8,6 @@
"posttest": "npm run lint && nsp check"
},
"dependencies": {
- "md5": "^2.2.1"
},
"repository": {
"type": "git",
diff --git a/services/client/common/methods/client/create.js b/services/client/common/methods/client/create.js
index fcf85c0bc..643bdf3b3 100644
--- a/services/client/common/methods/client/create.js
+++ b/services/client/common/methods/client/create.js
@@ -1,4 +1,5 @@
-var app = require('../../../server/server');
+let app = require('../../../server/server');
+let md5 = require('md5');
module.exports = function(Client) {
Client.remoteMethod('createUserProfile', {
@@ -23,7 +24,7 @@ module.exports = function(Client) {
let user = {
name: data.userName,
email: firstEmail,
- password: parseInt(Math.random() * 100000000000000)
+ password: md5(parseInt(Math.random() * 100000000000000))
};
app.models.Account.beginTransaction('READ COMMITTED', (error, transaction) => {
diff --git a/services/client/common/methods/client/specs/create.spec.js b/services/client/common/methods/client/specs/create.spec.js
index a19ef074c..f199ccdc4 100644
--- a/services/client/common/methods/client/specs/create.spec.js
+++ b/services/client/common/methods/client/specs/create.spec.js
@@ -1,31 +1,77 @@
+import app from '../../../../server/server';
import {catchErrors} from '../../../../../../services/utils/jasmineHelpers';
-let app = require('../../../../server/server');
+import {restoreFixtures} from '../../../../../../services/db/testing_fixtures';
+
+jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
describe('Client Create()', () => {
- let data = {
- name: 'MaxEisenhardt',
- userName: 'Magneto',
- email: 'magneto@marvel.com',
- fi: 'X-tax number',
- socialName: 'The X-Men'
+ beforeEach(() => {
+ restoreFixtures();
+ });
+
+ let newAccountData = {
+ name: 'Wade',
+ userName: 'Deadpool',
+ email: 'Deadpool@marvel.com',
+ fi: 'DP',
+ socialName: 'Deadpool Marvel'
};
- it('should createa new account', done => {
- app.models.Client.createUserProfile(data, () => {
- app.models.Account.findOne({where: {name: data.userName}})
- .then(account => {
- expect(account.name).toEqual(data.userName);
- app.models.Client.findOne({where: {name: data.name}})
- .then(client => {
- expect(client.id).toEqual(account.id);
- expect(client.name).toEqual(data.name);
- expect(client.email).toEqual(data.email);
- expect(client.fi).toEqual(data.fi);
- expect(client.socialName).toEqual(data.socialName);
- done();
- });
- })
+ it('should find Charles Xavier', done => {
+ app.models.Account.findOne({where: {name: 'CharlesXavier'}})
+ .then(account => {
+ expect(account.name).toEqual('CharlesXavier');
+ done();
+ })
.catch(catchErrors(done));
+ });
+
+ it("should not find Deadpool as he's not created yet", done => {
+ app.models.Account.findOne({where: {name: newAccountData.userName}})
+ .then(account => {
+ expect(account).toEqual(null);
+ app.models.Client.findOne({where: {name: newAccountData.name}})
+ .then(client => {
+ expect(client).toEqual(null);
+ done();
+ });
+ })
+ .catch(catchErrors(done));
+ });
+
+ it('should not be able to create a user if exists', done => {
+ app.models.Client.findOne({where: {name: 'Charles Xavier'}})
+ .then(client => {
+ let formerAccountData = {
+ name: client.name,
+ userName: client.userName,
+ email: client.email,
+ fi: client.fi,
+ socialName: client.socialName
+ };
+
+ expect(app.models.Client.createUserProfile(formerAccountData)).toBeFalsy();
+ done();
});
});
+
+ // awaiting for fixtures
+ // it('should create a new account', done => {
+ // app.models.Client.createUserProfile(data => {
+ // app.models.Account.findOne({where: {name: data.userName}})
+ // .then(account => {
+ // expect(account.name).toEqual(data.userName);
+ // app.models.Client.findOne({where: {name: data.name}})
+ // .then(client => {
+ // expect(client.id).toEqual(account.id);
+ // expect(client.name).toEqual(data.name);
+ // expect(client.email).toEqual(data.email);
+ // expect(client.fi).toEqual(data.fi);
+ // expect(client.socialName).toEqual(data.socialName);
+ // done();
+ // });
+ // })
+ // .catch(catchErrors(done));
+ // });
+ // });
});
diff --git a/services/client/common/models/client-observation.js b/services/client/common/models/client-observation.js
index cd1cba2a8..8b0e4a3ef 100644
--- a/services/client/common/models/client-observation.js
+++ b/services/client/common/models/client-observation.js
@@ -8,9 +8,9 @@ module.exports = function(Self) {
ctx.instance.created = Date();
let token = ctx.options.accessToken;
let userId = token && token.userId;
- let app = require('../../server/server');
+ let app = require('../../server/server');
let Employee = app.models.Employee;
- Employee.findOne({where: {userFk: userId}}, function (err, user){
+ Employee.findOne({where: {userFk: userId}}, (err, user) => {
if (user) {
ctx.instance.employeeFk = user.id;
next();
diff --git a/services/client/common/models/client.js b/services/client/common/models/client.js
index 0340042d3..85a24496e 100644
--- a/services/client/common/models/client.js
+++ b/services/client/common/models/client.js
@@ -18,15 +18,9 @@ module.exports = function(Self) {
// Validations
- Self.validatesUniquenessOf('name', {
- message: 'El nombre debe ser único'
- });
Self.validatesUniquenessOf('fi', {
message: 'El NIF/CIF debe ser único'
});
- Self.validatesPresenceOf('socialName', {
- message: 'Debe especificarse la razón social'
- });
Self.validatesUniquenessOf('socialName', {
message: 'La razón social debe ser única'
});
diff --git a/services/client/common/models/client.json b/services/client/common/models/client.json
index 223d6ef8f..e2600e0b4 100644
--- a/services/client/common/models/client.json
+++ b/services/client/common/models/client.json
@@ -22,7 +22,8 @@
"description": "Fiscal indentifier"
},
"socialName": {
- "type": "string"
+ "type": "string",
+ "required": true
},
"contact": {
"type": "string"
diff --git a/services/client/common/models/greuge.js b/services/client/common/models/greuge.js
index 7bacecc4e..9cf127d41 100644
--- a/services/client/common/models/greuge.js
+++ b/services/client/common/models/greuge.js
@@ -1,4 +1,9 @@
module.exports = function(Self) {
require('../methods/greuge/filter.js')(Self);
require('../methods/greuge/totalGreuge.js')(Self);
+
+ Self.validatesLengthOf('description', {
+ max: 45,
+ message: 'La description debe tener maximo 45 caracteres'
+ });
};
diff --git a/services/client/common/models/greuge.json b/services/client/common/models/greuge.json
index 37c2c000a..c7a407341 100644
--- a/services/client/common/models/greuge.json
+++ b/services/client/common/models/greuge.json
@@ -14,10 +14,12 @@
"description": "Identifier"
},
"description": {
- "type": "String"
+ "type": "String",
+ "required": true
},
"amount": {
- "type": "Number"
+ "type": "Number",
+ "required": true
},
"shipped": {
"type": "date"
@@ -35,7 +37,8 @@
"greugeType": {
"type": "belongsTo",
"model": "GreugeType",
- "foreignKey": "greugeTypeFk"
+ "foreignKey": "greugeTypeFk",
+ "required": true
}
}
}
\ No newline at end of file
diff --git a/services/db/Dockerfile b/services/db/Dockerfile
index ba6c150b1..075a63b51 100644
--- a/services/db/Dockerfile
+++ b/services/db/Dockerfile
@@ -1,6 +1,7 @@
FROM mysql:5.6.37
ENV MYSQL_ALLOW_EMPTY_PASSWORD yes
+ENV TZ GMT-1
COPY localDB01StructureAccount.sql /docker-entrypoint-initdb.d
COPY localDB02StructureVn2008.sql /docker-entrypoint-initdb.d
diff --git a/services/db/localDB09Inserts.sql b/services/db/localDB09Inserts.sql
index a59dcfa78..da5599ff4 100644
--- a/services/db/localDB09Inserts.sql
+++ b/services/db/localDB09Inserts.sql
@@ -459,7 +459,7 @@ INSERT INTO `vn2008`.`empresa_grupo`(`empresa_grupo_id`, `grupo`)
INSERT INTO `vn2008`.`empresa`(`id`, `abbreviation`, `registro`, `gerente_id`, `alta`, `baja`, `logo`, `oficial`, `cyc`, `rgb`, `mail`, `cuno`, `ODBC_DATE`, `Id_Cliente`, `digito_factura`, `Id_Proveedores_account`, `morosidad`, `empresa_grupo`)
VALUES
- ('442', 'WAY', 'Wayne Industries, Inc. operates as a warehouse for steel products. Wayne Industries, Inc. was founded in 1989 and is based in Wayne, Michigan.', '2', '1989-11-19', NULL, NULL, '1', '1', '00FF00', 'BruceWayne@verdnatura.es', NULL, '1989-08-11 12:31:22', '10', '1', NULL, '1', '1');
+ (442, 'WAY', 'Wayne Industries, Inc. operates as a warehouse for steel products. Wayne Industries, Inc. was founded in 1989 and is based in Wayne, Michigan.', '2', '1989-11-19', NULL, NULL, '1', '1', '00FF00', 'BruceWayne@verdnatura.es', NULL, '1989-08-11 12:31:22', '10', '1', NULL, '1', '1');
INSERT INTO `salix`.`Ticket`(`id`, `agencyFk`, `employeeFk`, `date`, `hour`, `clientFk`, `addressFk`)
VALUES
@@ -525,5 +525,5 @@ INSERT INTO `vn`.`mandateType`(`id`, `name`)
INSERT INTO `vn`.`mandate`(`id`, `clientFk`, `companyFk`, `code`, `created`, `mandateTypeFk`)
VALUES
- (1, 1, 442, '1-1', CURDATE(), 2);
+ (1, 2, 442, '1-1', CURDATE(), 2);
diff --git a/services/db/testing_fixtures.js b/services/db/testing_fixtures.js
new file mode 100644
index 000000000..11df46eb6
--- /dev/null
+++ b/services/db/testing_fixtures.js
@@ -0,0 +1,16 @@
+let mysql = require('mysql');
+
+let connection = mysql.createConnection({
+ multipleStatements: false,
+ host: 'localhost',
+ user: 'root',
+ password: '',
+ database: 'salix'
+});
+
+export function restoreFixtures() {
+ // connection.connect();
+ // connection.query('CALL truncateDatabase');
+ // connection.disconect();
+ // console.log('fixtures restored');
+}
diff --git a/services/item/common/models/intrastat.json b/services/item/common/models/intrastat.json
index 615c16a1e..0ef5c5876 100644
--- a/services/item/common/models/intrastat.json
+++ b/services/item/common/models/intrastat.json
@@ -18,10 +18,10 @@
}
},
"relations": {
- "taxGroup": {
+ "taxClass": {
"type": "belongsTo",
- "model": "TaxGroup",
- "foreignKey": "taxGroupFk"
+ "model": "TaxClass",
+ "foreignKey": "taxClassFk"
},
"taxCode": {
"type": "belongsTo",
diff --git a/services/item/common/models/item.js b/services/item/common/models/item.js
index 4c8019af3..2c193b587 100644
--- a/services/item/common/models/item.js
+++ b/services/item/common/models/item.js
@@ -1,3 +1,6 @@
module.exports = function(Self) {
require('../methods/item/filter.js')(Self);
+
+ Self.validatesPresenceOf('name', {message: 'Cannot be blank'});
+ Self.validatesPresenceOf('originFk', {message: 'Cannot be blank'});
};
diff --git a/services/item/common/models/item.json b/services/item/common/models/item.json
index 0e396c0bf..070157c7e 100644
--- a/services/item/common/models/item.json
+++ b/services/item/common/models/item.json
@@ -14,7 +14,8 @@
"description": "Identifier"
},
"name": {
- "type": "String"
+ "type": "String",
+ "required": true
},
"size": {
"type": "Number"
diff --git a/services/item/common/models/tax-group.json b/services/item/common/models/tax-class.json
similarity index 86%
rename from services/item/common/models/tax-group.json
rename to services/item/common/models/tax-class.json
index e2fdd5a3b..c107f3391 100644
--- a/services/item/common/models/tax-group.json
+++ b/services/item/common/models/tax-class.json
@@ -1,9 +1,9 @@
{
- "name": "TaxGroup",
+ "name": "TaxClass",
"base": "VnModel",
"options": {
"mysql": {
- "table": "taxGroup",
+ "table": "taxClass",
"database": "vn"
}
},
diff --git a/services/item/server/model-config.json b/services/item/server/model-config.json
index 9258f7f1c..43c9a80fe 100644
--- a/services/item/server/model-config.json
+++ b/services/item/server/model-config.json
@@ -42,7 +42,7 @@
"Intrastat": {
"dataSource": "vn"
},
- "TaxGroup": {
+ "TaxClass": {
"dataSource": "vn"
},
"TaxCode": {
diff --git a/services/loopback/server/boot/validations.js b/services/loopback/server/boot/validations.js
index 06a8a8c0b..fe5e5d365 100644
--- a/services/loopback/server/boot/validations.js
+++ b/services/loopback/server/boot/validations.js
@@ -36,7 +36,7 @@ module.exports = function(app) {
for (let validation of validations[fieldName]) {
let options = validation.options;
- if ((options && options.async) ||
+ if ((options && options.async) ||
(validation.validation == 'custom' && !validation.isExportable))
continue;
diff --git a/services/loopback/server/datasources.test.json b/services/loopback/server/datasources.test.json
index 5f988ebf1..49407698d 100644
--- a/services/loopback/server/datasources.test.json
+++ b/services/loopback/server/datasources.test.json
@@ -23,5 +23,4 @@
"connectTimeout": 20000,
"acquireTimeout": 20000
}
-}
-
+}
\ No newline at end of file
diff --git a/services/mailer/application/mail.js b/services/mailer/application/mail.js
index 2d3a2c626..2cc8c7465 100644
--- a/services/mailer/application/mail.js
+++ b/services/mailer/application/mail.js
@@ -63,7 +63,7 @@ module.exports = {
console.log('Mail sent ' + info.messageId + ' [' + info.response + ']');
cb();
- } catch(e) {
+ } catch (e) {
throw e;
}
});
@@ -85,7 +85,7 @@ module.exports = {
params.attachments.forEach(function(attachment) {
result.attachments.push(attachment);
});
-
+
this.send(result.recipient, result.subject, result.body, result.attachments, params, error => {
if (error)
return cb(error);
diff --git a/services/print/application/config.js b/services/print/application/config.js
index c46f236f8..53a157937 100644
--- a/services/print/application/config.js
+++ b/services/print/application/config.js
@@ -7,7 +7,7 @@ function getFile(fileName) {
try {
let envFile = 'datasources.development.json';
-
+
if (process.env.NODE_ENV === 'test')
envFile = 'datasources.test.json';
diff --git a/services/production/common/models/ticket-state.js b/services/production/common/models/ticket-state.js
index 4c320c203..2580d98db 100644
--- a/services/production/common/models/ticket-state.js
+++ b/services/production/common/models/ticket-state.js
@@ -1,4 +1,4 @@
module.exports = function(Self) {
require('../methods/ticket-state/change-state.js')(Self);
-};
\ No newline at end of file
+};
diff --git a/services_tests.js b/services_tests.js
index 9a282490f..1fb70fdb5 100644
--- a/services_tests.js
+++ b/services_tests.js
@@ -1,5 +1,7 @@
require('babel-core/register')({presets: ['es2015']});
+process.env.NODE_ENV = 'test';
+
process.on('warning', warning => {
console.log(warning.name);
console.log(warning.message);
@@ -17,13 +19,12 @@ var jasmine = new Jasmine();
var SpecReporter = require('jasmine-spec-reporter').SpecReporter;
jasmine.loadConfig({
- spec_dir: 'services/',
+ spec_dir: 'services',
spec_files: [
- '**/specs/*[sS]pec.js'
+ 'client/common/**/*[sS]pec.js'
],
helpers: [
- // to implement
- // '/api/utils/jasmineHelpers.js'
+ '/services/utils/jasmineHelpers.js'
]
});
@@ -36,6 +37,5 @@ jasmine.addReporter(new SpecReporter({
}
}));
-exports.start = () => {
- jasmine.execute();
-};
+jasmine.execute();
+