Commit 7166c2aa authored by Evren Kutar's avatar Evren Kutar

Merge branch 'feature/issue-5102' into develop

parents 5d6abef9 46d0277c
......@@ -6,7 +6,7 @@
* (GPLv3). See LICENSE.txt for details.
*/
'use strict';
'use strict';
describe('dashboard controller module', function () {
......@@ -30,12 +30,13 @@ describe('dashboard controller module', function () {
expect('ulakbus.dashboard.DashCtrl').toBeDefined();
}));
// todo: complete dashboard tests
it('should execute DashCtrl functions', inject(function ($rootScope, RESTURL) {
$httpBackend.expectGET(RESTURL.url + 'ara/personel/123')
.respond(200, {});
var $scope = $rootScope.$new();
var controller = $controller('DashCtrl', { $scope: $scope });
var controller = $controller('DashCtrl', {$scope: $scope});
$scope.student_kw = "123";
$scope.staff_kw = "123";
......
......@@ -18,7 +18,8 @@
<!--Hepsini Seç-->
<!--</label>-->
</th>
<th ng-repeat="(key,value) in node.items[0] track by $index" ng-if="key!=='idx'">
<th ng-repeat="(key,value) in node.items[0] track by $index"
ng-if="key!=='idx' && node.schema.properties[key]">
<span ng-if="value.verbose_name">{{ value.verbose_name }}</span>
<span ng-if="!value.verbose_name">{{key}}</span>
</th>
......@@ -42,16 +43,21 @@
</td>
</tr>
<tr ng-repeat="listnodemodel in node.items track by $index" ng-init="outerIndex=$index" ng-if="node.schema.formType=='ListNode'">
<tr ng-repeat="listnodemodel in node.items track by $index"
ng-init="outerIndex=$index"
ng-if="node.schema.formType=='ListNode'">
<td width="60">
<!--<label>-->
<!--<input type="checkbox" style="zoom:1.5; margin:5px 0 0 8px;">-->
<!--</label>-->
</td>
<th scope="row" style="text-align:center">{{$index+1}}</th>
<td ng-repeat="(k, v) in listnodemodel track by $index" ng-init="innerIndex=$index" ng-if="k!=='idx'">
<td ng-repeat="(k, v) in listnodemodel track by $index"
ng-init="innerIndex=$index"
ng-if="k!=='idx' && node.schema.properties[k]">
<span ng-if="!node.schema.inline_edit || node.schema.inline_edit.indexOf(k) < 0">{{ v.unicode || v }}</span>
<input type="node.schema.formType" ng-if="node.schema.inline_edit.indexOf(k) > -1"
<input type="node.schema.formType"
ng-if="node.schema.inline_edit.indexOf(k) > -1"
ng-model="node.model[outerIndex][k]"
ng-change="nodeModelChange(this)">
</td>
......
......@@ -805,41 +805,42 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
}
});
};
/**
* @memberof ulakbus.formService
* @ngdoc function
* @name isValidEmail
* @description checks if given value is a valid email address.
* @param email
* @returns {boolean}
*/
generator.isValidEmail = function (email) {
var re = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
return re.test(email);
};
/**
* @memberof ulakbus.formService
* @ngdoc function
* @name isValidTCNo
* @description checks if given value is a valid identity number for Turkey.
* @param tcno
* @returns {boolean}
*/
generator.isValidTCNo = function (tcno) {
var re = /^([1-9]{1}[0-9]{9}[0,2,4,6,8]{1})$/i;
return re.test(tcno);
};
/**
* @memberof ulakbus.formService
* @ngdoc function
* @name isValidDate
* @description checks if given value can be parsed as Date object
* @param dateValue
* @returns {boolean}
*/
generator.isValidDate = function (dateValue) {
return !isNaN(Date.parse(dateValue));
};
///**
// * @memberof ulakbus.formService
// * @ngdoc function
// * @name isValidEmail
// * @description checks if given value is a valid email address.
// * @param email
// * @returns {boolean}
// */
//generator.isValidEmail = function (email) {
// var re = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
// return re.test(email);
//};
///**
// * @memberof ulakbus.formService
// * @ngdoc function
// * @name isValidTCNo
// * @description checks if given value is a valid identity number for Turkey.
// * @param tcno
// * @returns {boolean}
// */
//generator.isValidTCNo = function (tcno) {
// var re = /^([1-9]{1}[0-9]{9}[0,2,4,6,8]{1})$/i;
// return re.test(tcno);
//};
///**
// * @memberof ulakbus.formService
// * @ngdoc function
// * @name isValidDate
// * @description checks if given value can be parsed as Date object
// * @param dateValue
// * @returns {boolean}
// */
//generator.isValidDate = function (dateValue) {
// //return !isNaN(Date.parse(dateValue));
// return moment(dateValue)._d.toString() !== 'Invalid Date'
//};
/**
* @memberof ulakbus.formService
......
......@@ -301,82 +301,83 @@ describe('form service module', function () {
})
);
it('should validate email',
inject(function (Generator) {
var validEmails = [
'test@test.com',
'test@test.co.uk',
'test734ltylytkliytkryety9ef@jb-fe.com'
];
var invalidEmails = [
'test@testcom',
'test@ test.co.uk',
'ghgf@fe.com.co.',
'tes@t@test.com',
''
];
for (var i in validEmails) {
var valid = Generator.isValidEmail(validEmails[i]);
expect(valid).toBeTruthy();
}
for (var i in invalidEmails) {
var valid = Generator.isValidEmail(invalidEmails[i]);
expect(valid).toBeFalsy();
}
})
);
it('should validate tcNo',
inject(function (Generator) {
var validTCNos = [
'12345678902',
'18307990654'
];
var invalidTCNos = [
'00000000000',
'00000000002',
'12345678901',
'1234567892',
''
];
for (var i in validTCNos) {
var valid = Generator.isValidTCNo(validTCNos[i]);
expect(valid).toBeTruthy();
}
for (var i in invalidTCNos) {
var valid = Generator.isValidTCNo(invalidTCNos[i]);
expect(valid).toBeFalsy();
}
})
);
it('should validate date',
inject(function (Generator) {
var validDates = [
'12/12/2012'
];
var invalidDates = [
'dsad',
'0.0.0',
'12.15.2012',
''
];
for (var i in validDates) {
var valid = Generator.isValidDate(validDates[i]);
expect(valid).toBeTruthy();
}
for (var i in invalidDates) {
var valid = Generator.isValidDate(invalidDates[i]);
expect(valid).toBeFalsy();
}
})
);
//it('should validate email',
// inject(function (Generator) {
// var validEmails = [
// 'test@test.com',
// 'test@test.co.uk',
// 'test734ltylytkliytkryety9ef@jb-fe.com'
// ];
//
// var invalidEmails = [
// 'test@testcom',
// 'test@ test.co.uk',
// 'ghgf@fe.com.co.',
// 'tes@t@test.com',
// ''
// ];
//
// for (var i in validEmails) {
// var valid = Generator.isValidEmail(validEmails[i]);
// expect(valid).toBeTruthy();
// }
// for (var i in invalidEmails) {
// var valid = Generator.isValidEmail(invalidEmails[i]);
// expect(valid).toBeFalsy();
// }
// })
//);
//
//it('should validate tcNo',
// inject(function (Generator) {
// var validTCNos = [
// '12345678902',
// '18307990654'
// ];
//
// var invalidTCNos = [
// '00000000000',
// '00000000002',
// '12345678901',
// '1234567892',
// ''
// ];
//
// for (var i in validTCNos) {
// var valid = Generator.isValidTCNo(validTCNos[i]);
// expect(valid).toBeTruthy();
// }
// for (var i in invalidTCNos) {
// var valid = Generator.isValidTCNo(invalidTCNos[i]);
// expect(valid).toBeFalsy();
// }
// })
//);
//
//it('should validate date',
// inject(function (Generator) {
// var validDates = [
// '12.12.2012'
// ];
//
// var invalidDates = [
// 'dsad',
// '0.0.0',
// '15/12/2012',
// ''
// ];
//
// for (var i in validDates) {
// var valid = Generator.isValidDate(validDates[i]);
//
// expect(valid).toBeTruthy();
// }
// for (var j in invalidDates) {
// var notValid = Generator.isValidDate(invalidDates[j]);
// expect(notValid).toBeFalsy();
// }
// })
//);
it('should get wf and redirect according to client_cmd',
inject(function (Generator, $httpBackend, RESTURL) {
......
......@@ -55,13 +55,10 @@ angular.module('ulakbus')
}
}
// if (response.data.client_cmd) {
//$location.path(response.data.screen);
// }
return response;
},
'responseError': function (rejection) {
var errorInModal = ('error' in rejection.data);
var errorModal = function () {
if ($rootScope.loginAttempt === 0) {
$log.debug('not logged in, no alert message triggered');
......@@ -81,7 +78,7 @@ angular.module('ulakbus')
'<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span' +
' aria-hidden="true">&times;</span></button>' +
'<h4 class="modal-title" id="exampleModalLabel">' +
rejection.status + rejection.data.title +
"Error Status: " + rejection.status + "<br>Error Title: " + rejection.data.title +
'</h4>' +
'</div>' +
'<div class="modal-body">' +
......@@ -108,45 +105,54 @@ angular.module('ulakbus')
}
};
if (rejection.status === -1) {
rejection.status = 'Sunucu hatası'
rejection.data = {
title: "", description: 'Sunucu bağlantısında bir hata oluştu.' +
'Lütfen yetkili personelle iletişime geçiniz.'
};
$rootScope.$broadcast('alertBox', {
title: rejection.status,
msg: rejection.data.description,
type: 'error'
});
}
if (rejection.status === 400) {
$location.reload();
}
if (rejection.status === 401) {
$location.path('/login');
if ($location.path() === "/login") {
$log.debug("show errors on login form");
var errorInAlertBox = function (alertContent) {
if (errorInModal) {
errorModal();
} else {
$rootScope.$broadcast('alertBox', alertContent);
}
}
if (rejection.status === 403) {
if (rejection.data.is_login === true) {
$rootScope.loggedInUser = true;
};
var errorForAlertBox = {
title: rejection.status,
msg: rejection.data.description,
type: 'error'
};
var errorDispatch = {
"-1" : function () {
rejection.status = 'Sunucu hatası';
rejection.data.title = rejection.data.title || "Sunucu Hatası";
rejection.data.description = rejection.data.description || 'Sunucu bağlantısında bir hata oluştu. Lütfen yetkili personelle iletişime geçiniz.';
errorInAlertBox(errorForAlertBox);
},
"400": function () {
$location.reload();
},
"401": function () {
$location.path('/login');
if ($location.path() === "/login") {
$location.path("/dashboard");
$log.debug("show errors on login form");
}
},
"403": function () {
if (rejection.data.is_login === true) {
$rootScope.loggedInUser = true;
if ($location.path() === "/login") {
$location.path("/dashboard");
}
}
},
"404": function () {
errorInAlertBox(errorForAlertBox);
},
"500": function () {
errorInAlertBox(errorForAlertBox);
}
//errorModal();
}
$rootScope.$broadcast('show_notifications', rejection.data);
};
errorDispatch[rejection.status]();
if (rejection.status === 404) {
errorModal();
}
if (rejection.status === 500) {
errorModal();
}
return $q.reject(rejection);
}
};
......
/**
* @license Ulakbus-UI
* Copyright (C) 2015 ZetaOps Inc.
*
* This file is licensed under the GNU General Public License v3
* (GPLv3). See LICENSE.txt for details.
*/
//'use strict';
describe('interceptor module', function () {
beforeEach(module('ulakbus'));
var $httpBackend, $rootScope;
beforeEach(inject(function ($injector) {
$httpBackend = $injector.get('$httpBackend');
$rootScope = $injector.get('$rootScope');
}));
describe('http interceptor', function () {
it('should handle errors properly', inject(function ($http, $rootScope, RESTURL) {
this.statuses = [-1, 404, 500];
angular.forEach(this.statuses, function (value, key) {
var resp = {data: {title: 'test', description: 'test', is_login: true}};
//if (modal) { resp.data.error = 'some error'; }
$httpBackend.expectGET(RESTURL.url + 'testforerror').respond(value, resp);
var listener = jasmine.createSpy('listener');
$rootScope.$on('alertBox', listener);
$http.get(RESTURL.url + 'testforerror').error(function (data) {
expect(listener).toHaveBeenCalled();
});
$httpBackend.flush();
});
var resp2 = {data: {title: 'test', description: 'test', is_login: true, error: 'test error'}};
$httpBackend.expectGET(RESTURL.url + 'testforerror2').respond(500, resp2);
var listener2 = jasmine.createSpy('listener2');
$rootScope.$on('alertBox', listener2);
$http.get(RESTURL.url + 'testforerror2').error(function (data) {
expect(listener2).toHaveBeenCalled();
});
$httpBackend.flush();
var resp3 = {is_login: true, _debug_queries: [{query: ''}]};
$httpBackend.expectGET(RESTURL.url + 'testforerror3').respond(200, resp3);
$http.get(RESTURL.url + 'testforerror3').success(function (data) {
expect($rootScope.debug_queries[0].queries).toEqual([{query: ''}]);
});
$httpBackend.flush();
}));
});
});
\ No newline at end of file
......@@ -37,7 +37,7 @@ module.exports = function (config) {
frameworks: ['jasmine'],
browsers: ['PhantomJS'],
browsers: ['PhantomJS', 'Chrome', 'Firefox', 'Safari'],
customLaunchers: {
'PhantomJS_custom': {
......@@ -46,7 +46,7 @@ module.exports = function (config) {
windowName: 'my-window',
settings: {
webSecurityEnabled: false
},
}
},
flags: ['--load-images=true'],
debug: true
......@@ -60,6 +60,9 @@ module.exports = function (config) {
plugins: [
'karma-phantomjs-launcher',
'karma-chrome-launcher',
'karma-firefox-launcher',
'karma-safari-launcher',
'karma-jasmine',
'karma-junit-reporter',
'karma-coverage'
......@@ -90,8 +93,7 @@ module.exports = function (config) {
functions: 60,
lines: 60,
excludes: [
'app/components/uitemplates/*.js',
//'app/zetalib/interceptors.js'
'app/components/uitemplates/*.js'
]
}
},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment