213 lines
7.7 KiB
JavaScript
213 lines
7.7 KiB
JavaScript
describe('Testing feed service', function () {
|
|
'use strict';
|
|
|
|
var $httpBackend, feedService;
|
|
|
|
beforeEach(module('myitsmApp'));
|
|
beforeEach(inject(function (_$httpBackend_, _feedService_) {
|
|
$httpBackend = _$httpBackend_;
|
|
feedService = _feedService_;
|
|
|
|
var getLocale = function () {
|
|
return readJSON('scripts/app/i18n/resources-locale_en.json');
|
|
};
|
|
|
|
$httpBackend.whenGET(/^scripts\/app\/i18n\/resources-locale_en.*$/).respond(getLocale());
|
|
$httpBackend.whenGET('/smartit/rest/serverstates').respond(200);
|
|
$httpBackend.whenGET('/smartit/rest/sessionstatus?getLicenseKey=true').respond(200);
|
|
$httpBackend.whenGET('views/dashboard/index.html').respond(200);
|
|
}));
|
|
|
|
it('should exist', function () {
|
|
expect(feedService).toBeDefined();
|
|
});
|
|
|
|
it('should add activity feed work note', function () {
|
|
var entity = {
|
|
"type": "incident",
|
|
"id": "IDGAA5V0HG8PDAP3DCBOP2GGSCCI8C",
|
|
"poiId": null
|
|
}, params = {
|
|
"worknote": "test\n",
|
|
"access": true,
|
|
"workInfoType": 8000
|
|
}, result;
|
|
|
|
result = feedService.addActivityFeedWorknote(entity, params);
|
|
expect(result.$$state.status).toEqual(0);
|
|
});
|
|
|
|
it('should add activity feed work note in bulk', function () {
|
|
var request = {
|
|
"type": "incident",
|
|
"id": "IDGAA5V0HG8PDAP3DCBOP2GGSCCI8C",
|
|
"poiId": null,
|
|
"ticketList": [{
|
|
workNoteType: 'test'
|
|
}]
|
|
}, result;
|
|
|
|
result = feedService.addActivityFeedWorknoteBulk(request);
|
|
expect(result.$$state.status).toEqual(0);
|
|
});
|
|
|
|
it('should add activity feed work note with flag', function () {
|
|
var entity = {
|
|
"type": "knowledge",
|
|
"id": "KBGAA5V0HG8PDAN5NG8FKMHG5K0PQH",
|
|
"poiId": null
|
|
}, params = {
|
|
"flagNote": "test\n",
|
|
"flagged": true
|
|
}, result;
|
|
|
|
result = feedService.addActivityFeedWorknoteWithFlag(entity, params);
|
|
expect(result.$$state.status).toEqual(0);
|
|
});
|
|
|
|
it('should unpin feed item', function () {
|
|
var entity = {
|
|
"type": "system",
|
|
"id": "000000000000152"
|
|
}, result;
|
|
|
|
result = feedService.unpinFeedItem(entity);
|
|
expect(result.$$state.status).toEqual(0);
|
|
});
|
|
|
|
it('should fetch update feed items', function () {
|
|
var params = {
|
|
followCount: true,
|
|
limit: 20,
|
|
poiId: null
|
|
}, response = [{
|
|
"items": [
|
|
{
|
|
"id": "IDGAA5V0HG8PDAP3GMPPP2JR6CEK8Z",
|
|
"author": {},
|
|
"replies": [
|
|
{
|
|
"id": "KnGAA5V0HG8PDAP3GONMP2JT4AEMIY",
|
|
"type": "comment",
|
|
"note": {
|
|
"message": "test",
|
|
},
|
|
"event": {},
|
|
"eventType": "ka-unflagged"
|
|
}
|
|
],
|
|
"priority": 0,
|
|
"isSystemGenerated": false,
|
|
"createDate": 1533798781000,
|
|
"type": "comment",
|
|
"note": {
|
|
"repliesCount": "1",
|
|
"attachmentCount": 1,
|
|
"attachments": [
|
|
{
|
|
"fileSize": 23170,
|
|
"id": "AGGAA5V0HG8PDAP3GNC6P2JRSUELCO",
|
|
"thumbnail": "data:image/png;base64,iVB",
|
|
"fileName": "user.png",
|
|
"attachmentReference": {
|
|
"dataSource": "HPD:WorkLog",
|
|
"attachmentId": "1000000351",
|
|
"dataSourceId": "AGGAA5V0HG8PDAP3GNC6P2JRSUELCO"
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"event": {
|
|
"eventType": "ka-flagged"
|
|
}
|
|
}
|
|
],
|
|
"followCount": 20,
|
|
"syncTime": 1533801299386,
|
|
"dataSourceName": "UpdateFeed"
|
|
}], result;
|
|
|
|
$httpBackend.expectGET('/smartit/rest/v2/following/stream?followCount=true&limit=20').respond(response);
|
|
result = feedService.getUpdateFeedItems(params);
|
|
$httpBackend.flush();
|
|
expect(result.$$state.value.followCount).toBe(20);
|
|
expect(result.$$state.value.syncTime).toBe(1533801299386);
|
|
expect(result.$$state.value.items[0].note.repliesCount).toBe('1');
|
|
expect(result.$$state.value.items[0].note.multipleReplies).toBeFalsy();
|
|
expect(result.$$state.value.items[0].threadUnflagged).toBeTruthy();
|
|
});
|
|
|
|
it('should fetch activity feed items', function () {
|
|
var params = {
|
|
limit: 20,
|
|
poiId: null
|
|
}, response = [{
|
|
"items": [
|
|
{
|
|
"id": "IDGAA5V0HG8PDAP3GMPPP2JR6CEK8Z",
|
|
"author": {},
|
|
"replies": [
|
|
{
|
|
"id": "KnGAA5V0HG8PDAP3GONMP2JT4AEMIY",
|
|
"type": "comment",
|
|
"note": {
|
|
"message": "test",
|
|
},
|
|
"event": {},
|
|
"eventType": "ka-unflagged"
|
|
}
|
|
],
|
|
"priority": 0,
|
|
"isSystemGenerated": false,
|
|
"createDate": 1533798781000,
|
|
"type": "comment",
|
|
"note": {
|
|
"repliesCount": "1",
|
|
"attachmentCount": 1,
|
|
"attachments": [
|
|
{
|
|
"fileSize": 23170,
|
|
"id": "AGGAA5V0HG8PDAP3GNC6P2JRSUELCO",
|
|
"thumbnail": "data:image/png;base64,iVB",
|
|
"fileName": "user.png",
|
|
"attachmentReference": {
|
|
"dataSource": "HPD:WorkLog",
|
|
"attachmentId": "1000000351",
|
|
"dataSourceId": "AGGAA5V0HG8PDAP3GNC6P2JRSUELCO"
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"event": {
|
|
"eventType": "ka-flagged"
|
|
}
|
|
}
|
|
],
|
|
"numMatch": 20,
|
|
"syncTime": 1533801299386,
|
|
"dataSourceName": "KnowledgeTimeLine"
|
|
}], result;
|
|
|
|
$httpBackend.expectGET('/smartit/rest/timeline?limit=20').respond(response);
|
|
result = feedService.getActivityFeedItems(params);
|
|
$httpBackend.flush();
|
|
expect(result.$$state.value[0].note.repliesCount).toBe('1');
|
|
expect(result.$$state.value[0].note.multipleReplies).toBeFalsy();
|
|
expect(result.$$state.value[0].threadUnflagged).toBeTruthy();
|
|
});
|
|
|
|
it('should receive not authorized if user is not authorized', function () {
|
|
var params = {
|
|
limit: 20,
|
|
poiId: null
|
|
}, response = [{
|
|
timeline: 'UNAUTHORIZED'
|
|
}], result;
|
|
|
|
$httpBackend.expectGET('/smartit/rest/timeline?limit=20').respond(response);
|
|
result = feedService.getActivityFeedItems(params);
|
|
$httpBackend.flush();
|
|
expect(result.$$state.value.isNotAuthorized).toBeTruthy();
|
|
});
|
|
});
|