368 lines
15 KiB
JavaScript
368 lines
15 KiB
JavaScript
/**
|
|
* Created by mkumar1 on 20-03-2018.
|
|
*/
|
|
|
|
describe('Test ticket console model', function () {
|
|
|
|
var $httpBackend, scope;
|
|
beforeEach(module('myitsmApp'));
|
|
|
|
beforeEach(inject(function ($rootScope, $injector, consoleService, userModel, ticketConsoleModel, metadataModel, consoleColumnsModel) {
|
|
scope = $rootScope.$new();
|
|
this.consoleService = consoleService;
|
|
this.userModel = userModel;
|
|
this.metadataModel = metadataModel;
|
|
this.ticketConsoleModel = ticketConsoleModel;
|
|
this.consoleColumnsModel = consoleColumnsModel;
|
|
|
|
$httpBackend = $injector.get('$httpBackend');
|
|
|
|
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);
|
|
$httpBackend.when('POST', '/smartit/rest/v2/person/workitems/get').respond(200);
|
|
|
|
$rootScope = $injector.get('$rootScope');
|
|
}));
|
|
|
|
beforeEach(inject(function ($q) {
|
|
var deferred = $q.defer(), data = [{
|
|
"id": "9b456fc7-aabe-42d2-827d-3314584099b5",
|
|
"tenantId": "000000000000001",
|
|
"name": "columns",
|
|
"value": "{\"priority\":{\"order\":1,\"visible\":true,\"type\":\"system\"},\"actualEndDate\":{\"order\":2,\"visible\":true,\"type\":\"system\"},\"actualStartDate\":{\"order\":3,\"visible\":true,\"type\":\"system\"},\"submitDate\":{\"order\":4,\"visible\":true,\"type\":\"system\"},\"completedDate\":{\"order\":5,\"visible\":true,\"type\":\"system\"},\"deploymentEndDate\":{\"order\":6,\"visible\":true,\"type\":\"system\"},\"deploymentStartDate\":{\"order\":7,\"visible\":true,\"type\":\"system\"},\"scheduledEndDate\":{\"order\":8,\"visible\":true,\"type\":\"system\"},\"lastModifiedDate\":{\"order\":9,\"visible\":true,\"type\":\"system\"},\"reqResolvedDate\":{\"order\":10,\"visible\":true,\"type\":\"system\"},\"scheduledStartDate\":{\"order\":11,\"visible\":true,\"type\":\"system\"},\"requestedAvailabilityDate\":{\"order\":12,\"visible\":true,\"type\":\"system\"},\"respondedDate\":{\"order\":13,\"visible\":true,\"type\":\"system\"},\"resolvedDate\":{\"order\":14,\"visible\":true,\"type\":\"system\"},\"id\":{\"order\":15,\"visible\":true,\"type\":\"system\"},\"assigneeGroup\":{\"order\":16,\"visible\":true,\"type\":\"system\"},\"targetDate\":{\"order\":17,\"visible\":true,\"type\":\"system\"},\"slaStatus\":{\"order\":18,\"visible\":true,\"type\":\"system\"},\"customerName\":{\"order\":19,\"visible\":true,\"type\":\"system\"},\"assignee\":{\"order\":20,\"visible\":true,\"type\":\"system\"},\"summary\":{\"order\":21,\"visible\":true,\"type\":\"system\"},\"status\":{\"order\":22,\"visible\":true,\"type\":\"system\"}}",
|
|
"defaultpreset": false,
|
|
"systemgenerated": false,
|
|
"createDate": 1516861450070,
|
|
"modifiedDate": 1521208758293
|
|
}, {
|
|
"id": "dummyId",
|
|
"tenantId": null,
|
|
"name": "defaultConsoleColumns",
|
|
"value": {
|
|
"priority": {
|
|
"order": 1,
|
|
"visible": true
|
|
},
|
|
"id": {
|
|
"order": 2,
|
|
"visible": true
|
|
},
|
|
"targetDate": {
|
|
"order": 3,
|
|
"visible": true
|
|
},
|
|
"slaStatus": {
|
|
"order": 4,
|
|
"visible": true
|
|
},
|
|
"customerName": {
|
|
"order": 5,
|
|
"visible": true
|
|
},
|
|
"assignee": {
|
|
"order": 6,
|
|
"visible": true
|
|
},
|
|
"summary": {
|
|
"order": 7,
|
|
"visible": true
|
|
},
|
|
"status": {
|
|
"order": 8,
|
|
"visible": true
|
|
},
|
|
"lastModifiedDate": {
|
|
"order": 9,
|
|
"visible": true
|
|
}
|
|
},
|
|
"defaultpreset": false,
|
|
"systemgenerated": false,
|
|
"createDate": null,
|
|
"modifiedDate": null
|
|
}], metadataArr = [], colList = {};
|
|
|
|
spyOn(this.metadataModel, 'getMetadataByTypes').and.callFake(function () {
|
|
deferred.resolve(metadataArr);
|
|
return deferred.promise;
|
|
});
|
|
|
|
spyOn(this.consoleColumnsModel, 'getTicketAvailableColumnsList').and.callFake(function () {
|
|
deferred.resolve(colList);
|
|
return deferred.promise;
|
|
});
|
|
|
|
spyOn(this.userModel, 'getUserPreferences').and.callFake(function () {
|
|
deferred.resolve(data);
|
|
return deferred.promise;
|
|
});
|
|
|
|
|
|
}));
|
|
|
|
it(' should return ticket console column preference ', function () {
|
|
|
|
this.myResult = this.userModel.getUserPreferences('TicketConsoleColumns');
|
|
scope.$apply();
|
|
|
|
this.result2 = this.metadataModel.getMetadataByTypes([
|
|
"incident",
|
|
"workorder",
|
|
"task",
|
|
"request",
|
|
"change",
|
|
"problem",
|
|
"knownerror",
|
|
"release"
|
|
]);
|
|
scope.$apply();
|
|
|
|
this.result3 = this.consoleColumnsModel.getTicketAvailableColumnsList();
|
|
scope.$apply();
|
|
|
|
expect(this.myResult.$$state.value[0].id).toEqual('9b456fc7-aabe-42d2-827d-3314584099b5');
|
|
expect(this.myResult.$$state.value[0].tenantId).toEqual('000000000000001');
|
|
expect(this.myResult.$$state.value[0].name).toEqual('columns');
|
|
|
|
});
|
|
|
|
it(' should check if columnsConf is not null', function () {
|
|
this.ticketConsoleModel.currentColumnsConfig = null;
|
|
this.ticketConsoleModel.populateMetadataAndColumns();
|
|
scope.$apply();
|
|
expect(this.ticketConsoleModel.currentColumnsConfig).not.toBeNull();
|
|
});
|
|
|
|
beforeEach(inject(function ($q) {
|
|
var deferred = $q.defer();
|
|
var personData = [{
|
|
"items": [{
|
|
"objects": [{
|
|
"id": "AGGAA5V0FGXB9API4K9NPH7V01VC5M",
|
|
"customFields": {
|
|
"status_reason_new": null
|
|
},
|
|
"type": "task",
|
|
"displayId": "TAS118",
|
|
"summary": "Verify task automatically against compliance status",
|
|
"customer": {
|
|
"customFields": {},
|
|
"lastName": "Allbrook",
|
|
"fullName": "Allen Allbrook",
|
|
"company": {
|
|
"name": "Calbro Services"
|
|
},
|
|
"site": {}
|
|
},
|
|
"contact": {
|
|
"customFields": {}
|
|
},
|
|
"assignee": {
|
|
"customFields": {},
|
|
"fullName": "Allen Allbrook",
|
|
"company": {
|
|
"name": "Calbro Services"
|
|
},
|
|
"loginId": "Allen"
|
|
},
|
|
"priority": "Medium",
|
|
"status": {
|
|
"value": "Staged"
|
|
},
|
|
"owner": {
|
|
"customFields": {}
|
|
},
|
|
"changeManagerGroup": {
|
|
"name": " "
|
|
},
|
|
"changeManager": {
|
|
"customFields": {},
|
|
"fullName": " ",
|
|
"company": {
|
|
"name": " "
|
|
}
|
|
},
|
|
"taskType": "Automatic",
|
|
"processFlowName": " ",
|
|
"processFlowInstanceId": " ",
|
|
"serviceTargets": [{}, {}],
|
|
"impactedService": {
|
|
"customFields": {},
|
|
"needsReconciliation": false,
|
|
"verified": false
|
|
},
|
|
"categorizations": [{
|
|
"name": "operational",
|
|
"tiers": {}
|
|
}, {
|
|
"name": "product",
|
|
"tiers": {}
|
|
}, {
|
|
"name": "resolution",
|
|
"tiers": {
|
|
"resCategory1": " ",
|
|
"resCategory2": " ",
|
|
"resCategory3": " "
|
|
}
|
|
}, {
|
|
"name": "resolutionProduct",
|
|
"tiers": {
|
|
"resProdCategory1": " ",
|
|
"resProdCategory2": " ",
|
|
"resProdCategory3": " ",
|
|
"resProductName": " ",
|
|
"resProductModelVersion": " ",
|
|
"resProductManufacturer": " "
|
|
}
|
|
}],
|
|
"problemCoordinator": {
|
|
"customFields": {},
|
|
"fullName": " "
|
|
},
|
|
"problemCoordinatorGroup": {
|
|
"id": " ",
|
|
"name": " "
|
|
},
|
|
"validateCompany": true,
|
|
"company": {
|
|
"name": " "
|
|
},
|
|
"resolutionNote": " ",
|
|
"releaseCoordinatorGroup": {
|
|
"name": " "
|
|
},
|
|
"escalated": false,
|
|
"automatic": true,
|
|
"modifiedDate": 1525771139000,
|
|
"isEscalated": false,
|
|
"isAutomatic": true
|
|
},
|
|
{
|
|
"id": "IDGAA5V0FGXB9API45N5PH7Q4DURIO",
|
|
"customFields": {
|
|
"status_reason_new": 46000
|
|
},
|
|
"type": "incident",
|
|
"displayId": "INC22",
|
|
"summary": "Test",
|
|
"customer": {
|
|
"customFields": {},
|
|
"lastName": "Allbrook",
|
|
"fullName": "Allen Allbrook",
|
|
"company": {
|
|
"name": "Calbro Services"
|
|
},
|
|
"site": {}
|
|
},
|
|
"contact": {
|
|
"customFields": {}
|
|
},
|
|
"assignee": {
|
|
"customFields": {},
|
|
"fullName": "Allen Allbrook",
|
|
"company": {
|
|
"name": "Calbro Services"
|
|
},
|
|
"loginId": "Allen"
|
|
},
|
|
"priority": "Low",
|
|
"status": {
|
|
"value": "Pending",
|
|
"reason": "Infrastructure Change"
|
|
},
|
|
"owner": {
|
|
"customFields": {}
|
|
},
|
|
"changeManagerGroup": {
|
|
"name": " "
|
|
},
|
|
"changeManager": {
|
|
"customFields": {},
|
|
"fullName": " ",
|
|
"company": {
|
|
"name": " "
|
|
}
|
|
},
|
|
"processFlowName": " ",
|
|
"processFlowInstanceId": " ",
|
|
"serviceTargets": [{}, {}],
|
|
"impactedService": {
|
|
"customFields": {},
|
|
"needsReconciliation": false,
|
|
"verified": false
|
|
},
|
|
"accessMappings": [{
|
|
"id": "action-copy",
|
|
"permission": "write",
|
|
"type": 3
|
|
}, {
|
|
"id": "action-duplicate",
|
|
"permission": "write",
|
|
"type": 3
|
|
}, {
|
|
"id": "action-reopen",
|
|
"permission": "none",
|
|
"type": 3
|
|
}],
|
|
"categorizations": [{
|
|
"name": "operational",
|
|
"tiers": {}
|
|
}, {
|
|
"name": "product",
|
|
"tiers": {}
|
|
}, {
|
|
"name": "resolution",
|
|
"tiers": {}
|
|
}, {
|
|
"name": "resolutionProduct",
|
|
"tiers": {}
|
|
}],
|
|
"problemCoordinator": {
|
|
"customFields": {},
|
|
"fullName": " "
|
|
},
|
|
"problemCoordinatorGroup": {
|
|
"id": " ",
|
|
"name": " "
|
|
},
|
|
"validateCompany": true,
|
|
"company": {
|
|
"name": "Calbro Services"
|
|
},
|
|
"resolutionNote": "",
|
|
"releaseCoordinatorGroup": {
|
|
"name": " "
|
|
},
|
|
"escalated": false,
|
|
"automatic": false,
|
|
"modifiedDate": 1525768042000,
|
|
"isEscalated": false,
|
|
"isAutomatic": false
|
|
}
|
|
],
|
|
"totalMatches": 2
|
|
}],
|
|
"syncTime": 1525865487248,
|
|
"dataSourceName": "Person"
|
|
}];
|
|
spyOn(this.consoleService, 'getTicketList').and.callFake(function () {
|
|
deferred.resolve(personData);
|
|
return deferred.promise;
|
|
});
|
|
}));
|
|
|
|
it(' should get list of items', function () {
|
|
this.ticketConsoleModel.itemList = null;
|
|
this.ticketConsoleModel.getItemList();
|
|
scope.$apply();
|
|
expect(this.consoleService.getTicketList).toHaveBeenCalled();
|
|
expect(this.ticketConsoleModel.itemList).not.toBeNull();
|
|
});
|
|
|
|
}); |