Fontend tests fixed

This commit is contained in:
Juan Ferrer Toribio 2018-01-30 14:48:21 +01:00
parent 9d92b9def7
commit 7d7d179bdd
16 changed files with 152 additions and 85 deletions

View File

@ -41,9 +41,7 @@ export default class Controller {
returnDialog(response) {
if (response === 'ACCEPT') {
this.$http.post(`/mailer/notification/payment-update/${this.client.id}`).then(
() => {
this.vnApp.showMessage(this.translate.instant('Notification sent!'));
}
() => this.vnApp.showMessage(this.translate.instant('Notification sent!'))
);
}
}

View File

@ -14,6 +14,7 @@ describe('Client', () => {
beforeEach(angular.mock.inject((_$componentController_, $rootScope, _$httpBackend_) => {
$componentController = _$componentController_;
$httpBackend = _$httpBackend_;
$httpBackend.when('GET', /\/locale\/\w+\/[a-z]{2}\.json/).respond({});
$scope = $rootScope.$new();
let submit = jasmine.createSpy('submit').and.returnValue(Promise.resolve());
$scope.watcher = {submit};

View File

@ -15,7 +15,8 @@ describe('Client', () => {
$componentController = _$componentController_;
$state = _$state_;
$httpBackend = _$httpBackend_;
controller = $componentController('vnClientNotes', {$httpBackend: $httpBackend, $state: $state});
$httpBackend.when('GET', /\/locale\/\w+\/[a-z]{2}\.json/).respond({});
controller = $componentController('vnClientNotes', {$state: $state});
}));
describe('$onChanges()', () => {

View File

@ -15,6 +15,7 @@ describe('Component VnClientWebAccess', () => {
$componentController = _$componentController_;
$scope = $rootScope.$new();
$httpBackend = _$httpBackend_;
$httpBackend.when('GET', /\/locale\/\w+\/[a-z]{2}\.json/).respond({});
vnApp = _vnApp_;
spyOn(vnApp, 'showError');
controller = $componentController('vnClientWebAccess', {$scope: $scope});

View File

@ -16,6 +16,7 @@ describe('Component vnAutocomplete', () => {
$componentController = _$componentController_;
$scope = $rootScope.$new();
$httpBackend = _$httpBackend_;
$httpBackend.when('GET', /\/locale\/\w+\/[a-z]{2}\.json/).respond({});
$timeout = _$timeout_;
$element = angular.element('<div></div>');
controller = $componentController('vnAutocomplete', {$scope, $element, $httpBackend, $timeout});
@ -150,7 +151,7 @@ describe('Component vnAutocomplete', () => {
let controller = $componentController('vnAutocomplete', {$scope, $element, $httpBackend, $timeout});
controller.url = 'test.com';
let search = 'The Joker';
let json = JSON.stringify({where: {name: {regexp: search}}, order: controller.order});
let json = JSON.stringify({where: {name: {regexp: search}}, order: controller.getOrder()});
$httpBackend.whenGET(`${controller.url}?filter=${json}`).respond([{id: 3, name: 'The Joker'}]);
$httpBackend.expectGET(`${controller.url}?filter=${json}`);
controller.findItems(search);
@ -164,7 +165,7 @@ describe('Component vnAutocomplete', () => {
controller.url = 'test.com';
let search = 'The Joker';
controller.filterSearch = "{where: {name: {regexp: 'search'}}}";
let json = JSON.stringify({where: {name: {regexp: search}}, order: controller.order});
let json = JSON.stringify({where: {name: {regexp: search}}, order: controller.getOrder()});
$httpBackend.whenGET(`${controller.url}?filter=${json}`).respond([{id: 3, name: 'The Joker'}]);
$httpBackend.expectGET(`${controller.url}?filter=${json}`);
controller.findItems(search);
@ -177,7 +178,7 @@ describe('Component vnAutocomplete', () => {
controller.url = 'test.com';
let search = 'Joker';
controller.multiple = true;
let json = JSON.stringify({where: {name: {regexp: search}}, order: controller.order});
let json = JSON.stringify({where: {name: {regexp: search}}, order: controller.getOrder()});
$httpBackend.whenGET(`${controller.url}?filter=${json}`).respond([{id: 3, name: 'The Joker'}, {id: 4, name: 'Joker'}]);
$httpBackend.expectGET(`${controller.url}?filter=${json}`);
controller.findItems(search);

View File

@ -9,7 +9,8 @@ describe('Directive acl', () => {
});
compile = (hasPermissions, _element) => {
inject(($compile, $rootScope, aclService, _$timeout_) => {
inject(($compile, $rootScope, aclService, _$timeout_, _$httpBackend_) => {
_$httpBackend_.when('GET', /\/locale\/\w+\/[a-z]{2}\.json/).respond({});
spyOn(aclService, 'aclPermission').and.returnValue(hasPermissions);
scope = $rootScope.$new();
$timeout = _$timeout_;

View File

@ -20,8 +20,9 @@ describe('Directive dialog', () => {
});
};
beforeEach(angular.mock.inject(_$componentController_ => {
beforeEach(angular.mock.inject((_$componentController_, _$httpBackend_) => {
$componentController = _$componentController_;
_$httpBackend_.when('GET', /\/locale\/\w+\/[a-z]{2}\.json/).respond({});
$element = angular.element('<div></div>');
controller = $componentController('vnDialog', {$element});
}));

View File

@ -8,12 +8,13 @@ describe('Directive focus', () => {
});
compile = (_element, _childElement) => {
inject(($compile, $rootScope) => {
inject(($compile, $rootScope, _$httpBackend_) => {
$scope = $rootScope.$new();
_$httpBackend_.when('GET', /\/locale\/\w+\/[a-z]{2}\.json/).respond({});
$element = angular.element(_element);
if (_childElement) {
let childElement = angular.element(_childElement);
$element[0] < childElement;
$element[0] < childElement; // FIXME
$element[0].firstChild.focus = jasmine.createSpy(focus);
}
$element[0].focus = jasmine.createSpy('focus');

View File

@ -8,8 +8,9 @@ describe('Directive vnId', () => {
});
compile = _element => {
inject(($compile, $rootScope) => {
inject(($compile, $rootScope, _$httpBackend_) => {
$scope = $rootScope.$new();
_$httpBackend_.when('GET', /\/locale\/\w+\/[a-z]{2}\.json/).respond({});
$element = angular.element(_element);
$compile($element)($scope);
$scope.$digest();

View File

@ -8,8 +8,9 @@ describe('Directive validation', () => {
});
compile = (_element, validations, value) => {
inject(($compile, $rootScope, aclService, _$timeout_, $window) => {
inject(($compile, $rootScope, aclService, _$timeout_, $window, _$httpBackend_) => {
$window.validations = validations;
_$httpBackend_.when('GET', /\/locale\/\w+\/[a-z]{2}\.json/).respond({});
scope = $rootScope.$new();
scope.user = {name: value};
element = angular.element(_element);

View File

@ -11,7 +11,8 @@ describe('Component vnDropDown', () => {
angular.mock.module('client');
});
beforeEach(angular.mock.inject((_$componentController_, _$timeout_, _$filter_) => {
beforeEach(angular.mock.inject((_$componentController_, _$timeout_, _$filter_, _$httpBackend_) => {
_$httpBackend_.when('GET', /\/locale\/\w+\/[a-z]{2}\.json/).respond({});
$componentController = _$componentController_;
$element = angular.element('<div><ul><li></li></ul></div>');
$timeout = _$timeout_;

View File

@ -15,6 +15,7 @@ describe('Component vnIconMenu', () => {
beforeEach(angular.mock.inject((_$componentController_, $rootScope, _$httpBackend_, _$timeout_) => {
$componentController = _$componentController_;
$httpBackend = _$httpBackend_;
$httpBackend.when('GET', /\/locale\/\w+\/[a-z]{2}\.json/).respond({});
$timeout = _$timeout_;
$scope = $rootScope.$new();
$element = angular.element('<div></div>');

View File

@ -25,6 +25,7 @@ describe('Component vnWatcher', () => {
vnApp = _vnApp_;
$transitions = _$transitions_;
$httpBackend = _$httpBackend_;
$httpBackend.when('GET', /\/locale\/\w+\/[a-z]{2}\.json/).respond({});
$translate = _$translate_;
$attrs = {
save: "patch"

View File

@ -8,7 +8,7 @@ webpackConfig.plugins = [];
// Generated on Tue Aug 22 2017 13:37:43 GMT+0200 (CEST)
module.exports = function(config) {
config.set({
let myConfig = {
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',
@ -61,20 +61,7 @@ module.exports = function(config) {
// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['ChromeNoSandboxHeadless'],
customLaunchers: {
ChromeNoSandboxHeadless: {
base: 'Chrome',
flags: [
'--no-sandbox',
// See https://chromium.googlesource.com/chromium/src/+/lkgr/headless/README.md
'--headless',
'--disable-gpu',
// Without a remote debugging port, Google Chrome exits immediately.
' --remote-debugging-port=9222'
]
}
},
browsers: [],
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
@ -91,5 +78,41 @@ module.exports = function(config) {
'karma-firefox-launcher',
'karma-sourcemap-loader'
]
});
};
let browserConfig;
// TODO: Detect the browser
if (true) {
browserConfig = {
browsers: ['ChromeNoSandboxHeadless'],
customLaunchers: {
ChromeNoSandboxHeadless: {
base: 'Chrome',
flags: [
'--no-sandbox',
// See https://chromium.googlesource.com/chromium/src/+/lkgr/headless/README.md
'--headless',
'--disable-gpu',
// Without a remote debugging port, Google Chrome exits immediately.
' --remote-debugging-port=9222'
]
}
}
};
} else {
browserConfig = {
browsers: ['FirefoxHeadless'],
customLaunchers: {
FirefoxHeadless: {
base: 'Firefox',
flags: [
'--headless'
]
}
}
};
}
config.set(Object.assign(myConfig, browserConfig));
};

130
package-lock.json generated
View File

@ -110,9 +110,9 @@
"dev": true
},
"angular": {
"version": "1.6.4",
"resolved": "https://registry.npmjs.org/angular/-/angular-1.6.4.tgz",
"integrity": "sha1-A7exXAGggC1+LPWTJA5gQFTcd/s="
"version": "1.6.8",
"resolved": "https://registry.npmjs.org/angular/-/angular-1.6.8.tgz",
"integrity": "sha512-9WErZIOw1Cu1V5Yxdvxz/6YpND8ntdP71fdPpufPFJvZodZXqCjQBYrHqEoMZreO5i84O3D/Jw/vepoFt68Azw=="
},
"angular-cookies": {
"version": "1.6.4",
@ -135,7 +135,7 @@
"resolved": "https://registry.npmjs.org/angular-translate/-/angular-translate-2.13.1.tgz",
"integrity": "sha1-BWc+s3GYb8Ee3BUfWQKZ1+DEYig=",
"requires": {
"angular": "1.6.4"
"angular": "1.6.8"
}
},
"angular-translate-loader-partial": {
@ -1049,9 +1049,9 @@
}
},
"bluebird": {
"version": "3.5.0",
"resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.0.tgz",
"integrity": "sha1-eRQg1/VR7qKJdFOop3ZT+WYG1nw=",
"version": "3.5.1",
"resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.1.tgz",
"integrity": "sha512-MKiLiV+I1AA596t9w1sQJ8jkiSr5+ZKi0WKrYGUn6d1Fx+Ij4tIj+m2WMQSGczs5jZVxV339chE8iwk6F64wjA==",
"dev": true
},
"bn.js": {
@ -1069,7 +1069,7 @@
"bytes": "3.0.0",
"content-type": "1.0.4",
"debug": "2.6.9",
"depd": "1.1.1",
"depd": "1.1.2",
"http-errors": "1.6.2",
"iconv-lite": "0.4.19",
"on-finished": "2.3.0",
@ -1100,9 +1100,9 @@
}
},
"depd": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/depd/-/depd-1.1.1.tgz",
"integrity": "sha1-V4O04cRZ8G+lyif5kfPQbnoxA1k=",
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz",
"integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=",
"dev": true
},
"http-errors": {
@ -1115,6 +1115,14 @@
"inherits": "2.0.3",
"setprototypeof": "1.0.3",
"statuses": "1.3.1"
},
"dependencies": {
"depd": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/depd/-/depd-1.1.1.tgz",
"integrity": "sha1-V4O04cRZ8G+lyif5kfPQbnoxA1k=",
"dev": true
}
}
},
"mime-db": {
@ -9020,7 +9028,7 @@
"dev": true,
"requires": {
"arrify": "1.0.1",
"jasmine": "2.8.0",
"jasmine": "2.9.0",
"jasmine-terminal-reporter": "1.0.3",
"plugin-error": "0.1.2",
"through2": "2.0.1"
@ -10791,26 +10799,26 @@
"dev": true
},
"jasmine": {
"version": "2.8.0",
"resolved": "https://registry.npmjs.org/jasmine/-/jasmine-2.8.0.tgz",
"integrity": "sha1-awicChFXax8W3xG4AUbZHU6Lij4=",
"version": "2.9.0",
"resolved": "https://registry.npmjs.org/jasmine/-/jasmine-2.9.0.tgz",
"integrity": "sha1-dlcfklyHg0CefGFTVy5aY0HPk+s=",
"dev": true,
"requires": {
"exit": "0.1.2",
"glob": "7.1.1",
"jasmine-core": "2.8.0"
"jasmine-core": "2.9.1"
}
},
"jasmine-core": {
"version": "2.8.0",
"resolved": "https://registry.npmjs.org/jasmine-core/-/jasmine-core-2.8.0.tgz",
"integrity": "sha1-vMl5rh+f0FcB5F5S5l06XWPxok4=",
"version": "2.9.1",
"resolved": "https://registry.npmjs.org/jasmine-core/-/jasmine-core-2.9.1.tgz",
"integrity": "sha1-trvB2OZSUNVvWIhGFwXr7uuI8i8=",
"dev": true
},
"jasmine-spec-reporter": {
"version": "4.2.1",
"resolved": "https://registry.npmjs.org/jasmine-spec-reporter/-/jasmine-spec-reporter-4.2.1.tgz",
"integrity": "sha1-HWMq7ANBZwrTJPkrqEtLMrNeniI=",
"integrity": "sha512-FZBoZu7VE5nR7Nilzy+Np8KuVIOxF4oXDPDknehCYBDE080EnlPu0afdZNmpGDBRCUBv3mj5qgqCRmk6W/K8vg==",
"dev": true,
"requires": {
"colors": "1.1.2"
@ -10945,10 +10953,10 @@
"karma": {
"version": "1.7.1",
"resolved": "https://registry.npmjs.org/karma/-/karma-1.7.1.tgz",
"integrity": "sha1-hcwI6eCiLXzpzKN8ShvoJPaisa4=",
"integrity": "sha512-k5pBjHDhmkdaUccnC7gE3mBzZjcxyxYsYVaqiL2G5AqlfLyBO5nw2VdNK+O16cveEPd/gIOWULH7gkiYYwVNHg==",
"dev": true,
"requires": {
"bluebird": "3.5.0",
"bluebird": "3.5.1",
"body-parser": "1.18.2",
"chokidar": "1.6.1",
"colors": "1.1.2",
@ -10974,7 +10982,7 @@
"socket.io": "1.7.3",
"source-map": "0.5.6",
"tmp": "0.0.31",
"useragent": "2.2.1"
"useragent": "2.3.0"
},
"dependencies": {
"lodash": {
@ -10997,7 +11005,7 @@
"karma-chrome-launcher": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/karma-chrome-launcher/-/karma-chrome-launcher-2.2.0.tgz",
"integrity": "sha1-zxudBxNswY/iOTJ9JGVMPbw2is8=",
"integrity": "sha512-uf/ZVpAabDBPvdPdveyk1EPgbnloPvFFGgmRhYLTDH7gEB4nZdSBk8yTU47w1g/drLSx5uMOkjKk7IWKfWg/+w==",
"dev": true,
"requires": {
"fs-access": "1.0.1",
@ -11005,15 +11013,15 @@
}
},
"karma-firefox-launcher": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/karma-firefox-launcher/-/karma-firefox-launcher-1.0.1.tgz",
"integrity": "sha1-zlj0fCATqIFW1VpdYTN8CZz1u1E=",
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/karma-firefox-launcher/-/karma-firefox-launcher-1.1.0.tgz",
"integrity": "sha512-LbZ5/XlIXLeQ3cqnCbYLn+rOVhuMIK9aZwlP6eOLGzWdo1UVp7t6CN3DP4SafiRLjexKwHeKHDm0c38Mtd3VxA==",
"dev": true
},
"karma-jasmine": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/karma-jasmine/-/karma-jasmine-1.1.0.tgz",
"integrity": "sha1-IuTAa/mhguUpTR9wXjczgRuBCs8=",
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/karma-jasmine/-/karma-jasmine-1.1.1.tgz",
"integrity": "sha1-b+hA51oRYAydkehLM8RY4cRqNSk=",
"dev": true
},
"karma-sourcemap-loader": {
@ -11026,16 +11034,16 @@
}
},
"karma-webpack": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/karma-webpack/-/karma-webpack-2.0.4.tgz",
"integrity": "sha1-Pi1PSLqUqHjhxmu44a5hKJh6F1s=",
"version": "2.0.9",
"resolved": "https://registry.npmjs.org/karma-webpack/-/karma-webpack-2.0.9.tgz",
"integrity": "sha512-F1j3IG/XhiMzcunAXbWXH95uizjzr3WdTzmVWlta8xqxcCtAu9FByCb4sccIMxaVFAefpgnUW9KlCo0oLvIX6A==",
"dev": true,
"requires": {
"async": "0.9.2",
"loader-utils": "0.2.16",
"lodash": "3.10.1",
"source-map": "0.1.43",
"webpack-dev-middleware": "1.10.0"
"source-map": "0.5.6",
"webpack-dev-middleware": "1.12.2"
},
"dependencies": {
"async": {
@ -11050,13 +11058,29 @@
"integrity": "sha1-W/Rejkm6QYnhfUgnid/RW9FAt7Y=",
"dev": true
},
"source-map": {
"version": "0.1.43",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.1.43.tgz",
"integrity": "sha1-wkvBRspRfBRx9drL4lcbK3+eM0Y=",
"mime": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz",
"integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==",
"dev": true
},
"time-stamp": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/time-stamp/-/time-stamp-2.0.0.tgz",
"integrity": "sha1-lcakRTDhW6jW9KPsuMOj+sRto1c=",
"dev": true
},
"webpack-dev-middleware": {
"version": "1.12.2",
"resolved": "https://registry.npmjs.org/webpack-dev-middleware/-/webpack-dev-middleware-1.12.2.tgz",
"integrity": "sha512-FCrqPy1yy/sN6U/SaEZcHKRXGlqU0DUaEBL45jkUYoB8foVb6wCnbIJ1HKIx+qUFTW+3JpVcCJCxZ8VATL4e+A==",
"dev": true,
"requires": {
"amdefine": "1.0.1"
"memory-fs": "0.4.1",
"mime": "1.6.0",
"path-is-absolute": "1.0.1",
"range-parser": "1.2.0",
"time-stamp": "2.0.0"
}
}
}
@ -11603,7 +11627,7 @@
"resolved": "https://registry.npmjs.org/mg-crud/-/mg-crud-1.1.2.tgz",
"integrity": "sha1-p6AWGzWSPK7/8ZpIBpS2V1vDggw=",
"requires": {
"angular": "1.6.4"
"angular": "1.6.8"
}
},
"micromatch": {
@ -14271,19 +14295,29 @@
}
},
"useragent": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/useragent/-/useragent-2.2.1.tgz",
"integrity": "sha1-z1k+9PLRdYdei7ZY6pLhik/QbY4=",
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/useragent/-/useragent-2.3.0.tgz",
"integrity": "sha512-4AoH4pxuSvHCjqLO04sU6U/uE65BYza8l/KKBS0b0hnUPWi+cQ2BpeTEwejCSx9SPV5/U03nniDTrWx5NrmKdw==",
"dev": true,
"requires": {
"lru-cache": "2.2.4",
"lru-cache": "4.1.1",
"tmp": "0.0.31"
},
"dependencies": {
"lru-cache": {
"version": "2.2.4",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-2.2.4.tgz",
"integrity": "sha1-bGWGGb7PFAMdDQtZSxYELOTcBj0=",
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.1.tgz",
"integrity": "sha512-q4spe4KTfsAS1SUHLO0wz8Qiyf1+vMIAgpRYioFYDMNqKfHQbg+AVDH3i4fvpl71/P1L0dBl+fQi+P37UYf0ew==",
"dev": true,
"requires": {
"pseudomap": "1.0.2",
"yallist": "2.1.2"
}
},
"yallist": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz",
"integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=",
"dev": true
}
}

View File

@ -10,7 +10,7 @@
},
"dependencies": {
"@uirouter/angularjs": "^1.0.3",
"angular": "^1.6.4",
"angular": "^1.6.8",
"angular-cookies": "^1.6.4",
"angular-paging": "^2.2.2",
"angular-translate": "^2.13.1",
@ -23,7 +23,7 @@
"validator": "^6.2.1"
},
"devDependencies": {
"angular-mocks": "1.6.6",
"angular-mocks": "^1.6.6",
"babel": "^6.5.2",
"babel-core": "^6.22.1",
"babel-loader": "^6.4.1",
@ -50,14 +50,14 @@
"gulp-wrap": "^0.13.0",
"gulp-yaml": "^1.0.1",
"html-loader": "^0.4.4",
"jasmine": "^2.7.0",
"jasmine": "^2.9.0",
"jasmine-spec-reporter": "^4.2.1",
"karma": "^1.7.0",
"karma": "^1.7.1",
"karma-chrome-launcher": "^2.2.0",
"karma-firefox-launcher": "^1.0.1",
"karma-jasmine": "^1.1.0",
"karma-firefox-launcher": "^1.1.0",
"karma-jasmine": "^1.1.1",
"karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "^2.0.4",
"karma-webpack": "^2.0.9",
"md5": "^2.2.1",
"merge-stream": "^1.0.1",
"mysql": "^2.15.0",