1180 lines
44 KiB
JavaScript
1180 lines
44 KiB
JavaScript
describe('Test ticket template directive', function () {
|
|
var compile, scope, $httpBackend, createTicketModel, ticketModel, objectValueMapperService, fieldValidationModel, $modal, $q, permissionModel,
|
|
field,
|
|
templateData,
|
|
resolutionCategoryField,
|
|
updatedPriority,
|
|
metadata,
|
|
priorityWidget;
|
|
|
|
beforeEach(module('myitsmApp', 'templates'));
|
|
beforeEach(function () {
|
|
inject(function (_$q_, $compile, $rootScope, $injector, _ticketModel_, _objectValueMapperService_, _createTicketModel_, _fieldValidationModel_, _$modal_, _permissionModel_) {
|
|
$httpBackend = $injector.get('$httpBackend');
|
|
var getLocale = function () {
|
|
return readJSON('scripts/app/i18n/resources-locale_en.json');
|
|
},
|
|
deferred;
|
|
$httpBackend.whenGET(/^scripts\/app\/i18n\/resources-locale_en.*$/).respond(getLocale());
|
|
$httpBackend.whenGET('/smartit/rest/v2/metadata?type=incident').respond(new MetadataVO());
|
|
$httpBackend.whenGET('/smartit/rest/serverstates').respond(200);
|
|
$httpBackend.whenGET('/smartit/rest/sessionstatus?getLicenseKey=true').respond(200);
|
|
compile = $compile;
|
|
scope = $rootScope.$new();
|
|
createTicketModel = _createTicketModel_;
|
|
fieldValidationModel = _fieldValidationModel_;
|
|
$modal = _$modal_;
|
|
$q = _$q_;
|
|
deferred = $q.defer();
|
|
permissionModel = _permissionModel_;
|
|
|
|
ticketModel = _ticketModel_;
|
|
objectValueMapperService = _objectValueMapperService_;
|
|
|
|
spyOn(ticketModel, 'getDraft').and.callFake(function () {
|
|
deferred.resolve(templateData);
|
|
return deferred.promise;
|
|
});
|
|
|
|
spyOn(ticketModel, 'getPriority').and.callFake(function () {
|
|
deferred.resolve(updatedPriority);
|
|
return deferred.promise;
|
|
});
|
|
|
|
spyOn(objectValueMapperService, 'getExactValueByFieldName').and.callFake(function () {
|
|
return {};
|
|
});
|
|
|
|
resolutionCategoryField = {
|
|
name: 'resolutionOperational',
|
|
type: 'category',
|
|
value: {
|
|
'name': 'resolution',
|
|
'label': 'Resolution Category',
|
|
'dependAttributes': ['operationCategoryTier1', 'operationCategoryTier2', 'operationCategoryTier3', 'resProductCategoryTier1', 'resProductCategoryTier2', 'resProductCategoryTier3', 'resProductName', 'resProductManufacturer'],
|
|
'listOfTiers': [{
|
|
'name': 'resOperationCategoryTier1',
|
|
'label': 'Resolution Categorization Tier 1',
|
|
'selectedValue': '',
|
|
'index': 0,
|
|
'$$hashKey': 'object:666'
|
|
}, {
|
|
'name': 'resOperationCategoryTier2',
|
|
'label': 'Resolution Categorization Tier 2',
|
|
'dependAttribute': 'resOperationCategoryTier1',
|
|
'selectedValue': '',
|
|
'index': 1,
|
|
'$$hashKey': 'object:667',
|
|
'disabled': true
|
|
}, {
|
|
'name': 'resOperationCategoryTier3',
|
|
'label': 'Resolution Categorization Tier 3',
|
|
'dependAttribute': 'resOperationCategoryTier2',
|
|
'selectedValue': '',
|
|
'index': 2,
|
|
'$$hashKey': 'object:668',
|
|
'disabled': true
|
|
}],
|
|
'listOfTiersToShow': ['resOperationCategoryTier3', 'resOperationCategoryTier2', 'resOperationCategoryTier1'],
|
|
'serializedValue': '',
|
|
'exceedsChunkSize': false,
|
|
'dirty': true
|
|
}
|
|
};
|
|
|
|
});
|
|
});
|
|
|
|
beforeEach(function () {
|
|
var ticket = {
|
|
type: EntityVO.TYPE_INCIDENT,
|
|
company: {name: 'Test Company'}
|
|
};
|
|
|
|
field = {
|
|
"name": "incidentTemplate",
|
|
"label": "Incident Template",
|
|
"arFieldName": "",
|
|
"type": "ticketTemplate",
|
|
"dataType": "widget",
|
|
"valueField": null,
|
|
"members": [
|
|
{
|
|
"name": "templateId",
|
|
"label": "",
|
|
"arFieldName": "",
|
|
"type": "",
|
|
"parentId": "AGGAA5V0HGR55AOUVV3ROTZNQRTASK"
|
|
}
|
|
],
|
|
"options": [],
|
|
"groupMember": false,
|
|
"rowCount": 0,
|
|
"expanded": false,
|
|
"sealed": false,
|
|
"hasValue": true,
|
|
"isDynamic": false,
|
|
"widgetMember": false,
|
|
"value": {
|
|
"templateId": "GTP000000000002"
|
|
},
|
|
"id": "AGGAA5V0HGR55AOUVV3ROTZNQRTASK"
|
|
};
|
|
templateData = {
|
|
'id': 'INC_TEMPLATE_008',
|
|
'templateId': 'GGP000000000013ASLDKLASD',
|
|
'customFields': '0013ASL',
|
|
'displayId': 'INC123',
|
|
'summary': 'summaryAdded',
|
|
'title': 'Frequent Blue Screen to heaven is preventing work',
|
|
'createDate': 1392122014941,
|
|
'type': 'incident',
|
|
'desc': 'Priority, Product Categorization',
|
|
'status': {
|
|
"value": "In Progress",
|
|
"reason": "reasonOfStatus"
|
|
},
|
|
'serviceType': 'application',
|
|
'resolution': 'added resolution',
|
|
'impactedService': {'name': 'Email',
|
|
'reconciliationId': 'JDJDSPMCQODJNEO123NKDN3FN'},
|
|
'causalCI': {'name': 'Email',
|
|
'reconciliationId': 'JDJDSPMCQODJNEO123NKDN3FN'},
|
|
'assignee': {
|
|
'fullName': 'Bobby Hill',
|
|
'loginId': 'bhill',
|
|
'customFields': {},
|
|
'id': 'bhill'
|
|
},
|
|
'supportGroup': {
|
|
'name': 'LA Support 1',
|
|
'company': {
|
|
'name': 'Petramco'
|
|
},
|
|
'organization': 'Latin America Support',
|
|
'id': 'GGP000000000013'
|
|
},
|
|
'categorizations': [
|
|
{
|
|
"name": "operational",
|
|
"tiers": {
|
|
"operationCategoryTier1": "Applications",
|
|
"operationCategoryTier2": "Social",
|
|
"operationCategoryTier3": "Communities"
|
|
}
|
|
},
|
|
{
|
|
"name": "product",
|
|
"tiers": {
|
|
"productCategoryTier1": "Software",
|
|
"productCategoryTier2": "Applications",
|
|
"productCategoryTier3": "Office Apps"
|
|
}
|
|
}
|
|
],
|
|
'resCategorizations': [{
|
|
'name': 'resolutionProduct',
|
|
'tiers': {
|
|
'resProductCategoryTier1': 'Hardware',
|
|
'resProductCategoryTier2': 'Application System',
|
|
'resProductCategoryTier3': 'Other Type of Application System'
|
|
}
|
|
}, {
|
|
'name': 'resolution',
|
|
'tiers': {
|
|
'resOperationCategoryTier1': 'Failure',
|
|
'resOperationCategoryTier2': 'Availability',
|
|
'resOperationCategoryTier3': 'Add'
|
|
}
|
|
}]
|
|
};
|
|
updatedPriority = {
|
|
"id": "INC_TEMPLATE_008",
|
|
"title": "Frequent Blue Screen to heaven is preventing work",
|
|
"createDate": 1392122014941,
|
|
"name": "High",
|
|
"type": "incident",
|
|
"desc": "Priority, Product Categorization",
|
|
"status": {},
|
|
"assignee": {
|
|
"fullName": "Bobby Hill",
|
|
"loginId": "bhill",
|
|
"customFields": {},
|
|
"id": "bhill"
|
|
},
|
|
"supportGroup": {
|
|
"name": "LA Support 1",
|
|
"company": {
|
|
"name": "Petramco"
|
|
},
|
|
"organization": "Latin America Support",
|
|
"id": "GGP000000000013",
|
|
"supportGroups": "LA Support 1"
|
|
},
|
|
"resCategorizations": [
|
|
{
|
|
"name": "resolutionProduct",
|
|
"tiers": {
|
|
"resProductCategoryTier1": "Hardware",
|
|
"resProductCategoryTier2": "Application System",
|
|
"resProductCategoryTier3": "Other Type of Application System"
|
|
}
|
|
},
|
|
{
|
|
"name": "resolution",
|
|
"tiers": {
|
|
"resOperationCategoryTier1": "Failure",
|
|
"resOperationCategoryTier2": "Availability",
|
|
"resOperationCategoryTier3": "Add"
|
|
}
|
|
}
|
|
]
|
|
};
|
|
metadata = {
|
|
"impacts": [
|
|
{
|
|
"index": 1000,
|
|
"name": "1-Extensive/Widespread",
|
|
"label": "1-Extensive/Widespread"
|
|
},
|
|
{
|
|
"index": 2000,
|
|
"name": "2-Significant/Large",
|
|
"label": "2-Significant/Large"
|
|
},
|
|
{
|
|
"index": 3000,
|
|
"name": "3-Moderate/Limited",
|
|
"label": "3-Moderate/Limited"
|
|
},
|
|
{
|
|
"index": 4000,
|
|
"name": "4-Minor/Localized",
|
|
"label": "4-Minor/Localized"
|
|
}
|
|
],
|
|
"priorities": [
|
|
{
|
|
"index": 0,
|
|
"name": "Critical",
|
|
"label": "Critical"
|
|
},
|
|
{
|
|
"index": 1,
|
|
"name": "High",
|
|
"label": "High"
|
|
},
|
|
{
|
|
"index": 2,
|
|
"name": "Medium",
|
|
"label": "Medium"
|
|
},
|
|
{
|
|
"index": 3,
|
|
"name": "Low",
|
|
"label": "Low"
|
|
}
|
|
],
|
|
"urgencies": [
|
|
{
|
|
"index": 1000,
|
|
"name": "1-Critical",
|
|
"label": "1-Critical"
|
|
},
|
|
{
|
|
"index": 2000,
|
|
"name": "2-High",
|
|
"label": "2-High"
|
|
},
|
|
{
|
|
"index": 3000,
|
|
"name": "3-Medium",
|
|
"label": "3-Medium"
|
|
},
|
|
{
|
|
"index": 4000,
|
|
"name": "4-Low",
|
|
"label": "4-Low"
|
|
}
|
|
],
|
|
"metadatatype": "incident",
|
|
"statuses": [
|
|
{
|
|
"isValidForCreate": true,
|
|
"index": 0,
|
|
"name": "New",
|
|
"label": "New",
|
|
"ticketTypes": [
|
|
"incident"
|
|
]
|
|
},
|
|
{
|
|
"invalidStatusTransitions": [
|
|
"New"
|
|
],
|
|
"isValidForCreate": true,
|
|
"index": 1,
|
|
"name": "Assigned",
|
|
"label": "Assigned",
|
|
"ticketTypes": [
|
|
"incident",
|
|
"workorder",
|
|
"task",
|
|
"problem",
|
|
"knownerror"
|
|
]
|
|
},
|
|
{
|
|
"invalidStatusTransitions": [
|
|
"New"
|
|
],
|
|
"isValidForCreate": true,
|
|
"index": 2,
|
|
"name": "In Progress",
|
|
"label": "In Progress",
|
|
"ticketTypes": [
|
|
"incident",
|
|
"workorder",
|
|
"request",
|
|
"release"
|
|
],
|
|
"statusReasons": [{
|
|
"name": 'reason'
|
|
}]
|
|
},
|
|
{
|
|
"statusReasons": [
|
|
{
|
|
"displayOrder": 0,
|
|
"index": 19000,
|
|
"name": "Automated Resolution Reported",
|
|
"label": "Automated Resolution Reported"
|
|
},
|
|
{
|
|
"displayOrder": 0,
|
|
"index": 8000,
|
|
"name": "Client Action Required",
|
|
"label": "Client Action Required"
|
|
},
|
|
{
|
|
"displayOrder": 0,
|
|
"index": 13000,
|
|
"name": "Client Hold",
|
|
"label": "Client Hold"
|
|
},
|
|
{
|
|
"displayOrder": 0,
|
|
"index": 11000,
|
|
"name": "Future Enhancement",
|
|
"label": "Future Enhancement"
|
|
},
|
|
{
|
|
"displayOrder": 0,
|
|
"index": 9000,
|
|
"name": "Infrastructure Change",
|
|
"label": "Infrastructure Change"
|
|
},
|
|
{
|
|
"displayOrder": 0,
|
|
"index": 2000,
|
|
"name": "Local Site Action Required",
|
|
"label": "Local Site Action Required"
|
|
},
|
|
{
|
|
"displayOrder": 0,
|
|
"index": 14000,
|
|
"name": "Monitoring Incident",
|
|
"label": "Monitoring Incident"
|
|
},
|
|
{
|
|
"displayOrder": 0,
|
|
"index": 3000,
|
|
"name": "Purchase Order Approval",
|
|
"label": "Purchase Order Approval"
|
|
},
|
|
{
|
|
"displayOrder": 0,
|
|
"index": 4000,
|
|
"name": "Registration Approval",
|
|
"label": "Registration Approval"
|
|
},
|
|
{
|
|
"displayOrder": 0,
|
|
"index": 10000,
|
|
"name": "Request",
|
|
"label": "Request"
|
|
},
|
|
{
|
|
"displayOrder": 0,
|
|
"index": 5000,
|
|
"name": "Supplier Delivery",
|
|
"label": "Supplier Delivery"
|
|
},
|
|
{
|
|
"displayOrder": 0,
|
|
"index": 6000,
|
|
"name": "Support Contact Hold",
|
|
"label": "Support Contact Hold"
|
|
},
|
|
{
|
|
"displayOrder": 0,
|
|
"index": 7000,
|
|
"name": "Third Party Vendor Action Reqd",
|
|
"label": "Third Party Vendor Action Reqd"
|
|
}
|
|
],
|
|
"invalidStatusTransitions": [
|
|
"New"
|
|
],
|
|
"isValidForCreate": true,
|
|
"index": 3,
|
|
"name": "Pending",
|
|
"label": "Pending"
|
|
},
|
|
{
|
|
"statusReasons": [
|
|
{
|
|
"displayOrder": 0,
|
|
"index": 19000,
|
|
"name": "Automated Resolution Reported",
|
|
"label": "Automated Resolution Reported"
|
|
},
|
|
{
|
|
"displayOrder": 0,
|
|
"index": 15000,
|
|
"name": "Customer Follow-Up Required",
|
|
"label": "Customer Follow-Up Required"
|
|
},
|
|
{
|
|
"displayOrder": 0,
|
|
"index": 11000,
|
|
"name": "Future Enhancement",
|
|
"label": "Future Enhancement"
|
|
},
|
|
{
|
|
"displayOrder": 0,
|
|
"index": 14000,
|
|
"name": "Monitoring Incident",
|
|
"label": "Monitoring Incident"
|
|
},
|
|
{
|
|
"displayOrder": 0,
|
|
"index": 17000,
|
|
"name": "No Further Action Required",
|
|
"label": "No Further Action Required"
|
|
},
|
|
{
|
|
"displayOrder": 0,
|
|
"index": 16000,
|
|
"name": "Temporary Corrective Action",
|
|
"label": "Temporary Corrective Action"
|
|
}
|
|
],
|
|
"invalidStatusTransitions": [
|
|
"New"
|
|
],
|
|
"isValidForCreate": true,
|
|
"index": 4,
|
|
"name": "Resolved",
|
|
"label": "Resolved",
|
|
"ticketTypes": [
|
|
"incident"
|
|
]
|
|
},
|
|
{
|
|
"statusReasons": [
|
|
{
|
|
"displayOrder": 0,
|
|
"index": 19000,
|
|
"name": "Automated Resolution Reported",
|
|
"label": "Automated Resolution Reported"
|
|
},
|
|
{
|
|
"displayOrder": 0,
|
|
"index": 1000,
|
|
"name": "Infrastructure Change Created",
|
|
"label": "Infrastructure Change Created"
|
|
}
|
|
],
|
|
"invalidStatusTransitions": [
|
|
"New",
|
|
"Assigned",
|
|
"In Progress",
|
|
"Pending",
|
|
"Resolved",
|
|
"Cancelled"
|
|
],
|
|
"isValidForCreate": true,
|
|
"index": 5,
|
|
"name": "Closed",
|
|
"label": "Closed"
|
|
},
|
|
{
|
|
"statusReasons": [
|
|
{
|
|
"displayOrder": 0,
|
|
"index": 20000,
|
|
"name": "No longer a Causal CI",
|
|
"label": "No longer a Causal CI"
|
|
}
|
|
],
|
|
"invalidStatusTransitions": [
|
|
"New",
|
|
"Assigned",
|
|
"In Progress",
|
|
"Pending",
|
|
"Resolved",
|
|
"Closed"
|
|
],
|
|
"isValidForCreate": true,
|
|
"index": 6,
|
|
"name": "Cancelled",
|
|
"label": "Cancelled"
|
|
}
|
|
]
|
|
};
|
|
priorityWidget = {
|
|
"name": "priority",
|
|
"label": "Priority",
|
|
"members": [
|
|
{
|
|
"name": "priority",
|
|
"label": "Priority",
|
|
"arFieldName": "Priority",
|
|
"setValue": function () {
|
|
return true;
|
|
},
|
|
"options": [
|
|
{
|
|
"index": 0,
|
|
"name": "Critical",
|
|
"label": "Critical"
|
|
},
|
|
{
|
|
"index": 1,
|
|
"name": "High",
|
|
"label": "High"
|
|
},
|
|
{
|
|
"index": 2,
|
|
"name": "Medium",
|
|
"label": "Medium"
|
|
},
|
|
{
|
|
"index": 3,
|
|
"name": "Low",
|
|
"label": "Low"
|
|
}
|
|
],
|
|
"value": {
|
|
"name": "Low",
|
|
"label": "Low"
|
|
}
|
|
},
|
|
{
|
|
"name": "impact",
|
|
"label": "Impact",
|
|
"arFieldName": "Impact",
|
|
"setValue": function () {
|
|
return true;
|
|
},
|
|
"options": [
|
|
{
|
|
"index": 1000,
|
|
"name": "1-Extensive/Widespread",
|
|
"label": "1-Extensive/Widespread"
|
|
},
|
|
{
|
|
"index": 2000,
|
|
"name": "2-Significant/Large",
|
|
"label": "2-Significant/Large"
|
|
},
|
|
{
|
|
"index": 3000,
|
|
"name": "3-Moderate/Limited",
|
|
"label": "3-Moderate/Limited"
|
|
},
|
|
{
|
|
"index": 4000,
|
|
"name": "4-Minor/Localized",
|
|
"label": "4-Minor/Localized"
|
|
}
|
|
],
|
|
"value": {
|
|
"name": "4-Minor/Localized",
|
|
"label": "4-Minor/Localized"
|
|
}
|
|
},
|
|
{
|
|
"name": "urgency",
|
|
"label": "Urgency",
|
|
"arFieldName": "Urgency",
|
|
"setValue": function () {
|
|
return true;
|
|
},
|
|
"options": [
|
|
{
|
|
"index": 1000,
|
|
"name": "1-Critical",
|
|
"label": "1-Critical"
|
|
},
|
|
{
|
|
"index": 2000,
|
|
"name": "2-High",
|
|
"label": "2-High"
|
|
},
|
|
{
|
|
"index": 3000,
|
|
"name": "3-Medium",
|
|
"label": "3-Medium"
|
|
},
|
|
{
|
|
"index": 4000,
|
|
"name": "4-Low",
|
|
"label": "4-Low"
|
|
}
|
|
],
|
|
"value": {
|
|
"name": "4-Low",
|
|
"label": "4-Low"
|
|
}
|
|
}
|
|
],
|
|
"value": {
|
|
"impact": {
|
|
"index": 4000,
|
|
"name": "4-Minor/Localized",
|
|
"label": "4-Minor/Localized",
|
|
"$$hashKey": "object:6320"
|
|
},
|
|
"urgency": {
|
|
"index": 4000,
|
|
"name": "4-Low",
|
|
"label": "4-Low",
|
|
"$$hashKey": "object:6328"
|
|
},
|
|
"priority": {
|
|
"index": 3,
|
|
"name": "Low",
|
|
"label": "Low"
|
|
}
|
|
}
|
|
};
|
|
scope.field = new FieldVO().build(field);
|
|
scope.ticket = ticket;
|
|
scope.metadata = new MetadataVO().build(metadata);
|
|
});
|
|
|
|
function getCompiledElement() {
|
|
var element = angular.element('<ticket-template data="field" context="ticket" metadata="metadata" is-editable="true"></ticket-template>');
|
|
var compiledElement = compile(element)(scope);
|
|
scope.$digest();
|
|
return compiledElement;
|
|
}
|
|
|
|
it('should compile', function() {
|
|
var directiveElem = getCompiledElement();
|
|
var divElem = directiveElem[0];
|
|
expect(divElem).toBeDefined();
|
|
});
|
|
|
|
it('should load fields from template on template selection', function () {
|
|
spyOn(objectValueMapperService, 'getFieldByName').and.callFake(function () {
|
|
return {value: {}};
|
|
});
|
|
|
|
var directiveElem = getCompiledElement(),
|
|
divElem = directiveElem[0];
|
|
expect(divElem).toBeDefined();
|
|
|
|
scope.ticket.selectedTemplate = {
|
|
id: 123
|
|
};
|
|
scope.ticket.status = {};
|
|
scope.ticket.selectedImpact = {};
|
|
scope.ticket.selectedUrgency = {};
|
|
scope.metadata = metadata;
|
|
scope.metadata.impacts = [{ name: 'Minor' }];
|
|
scope.metadata.urgencies = [{ name: 'Low' }];
|
|
scope.$apply();
|
|
expect(scope.ticket.locationCompany).toEqual({});
|
|
expect(scope.ticket.selectedGroup.supportGroups).toEqual('LA Support 1');
|
|
});
|
|
|
|
it('should load fields from template on template selection for task', function () {
|
|
spyOn(objectValueMapperService, 'getFieldByName').and.callFake(function () {
|
|
return {value: {}};
|
|
});
|
|
|
|
var directiveElem = getCompiledElement(),
|
|
divElem = directiveElem[0];
|
|
expect(divElem).toBeDefined();
|
|
scope.ticket.selectedTemplate = {
|
|
id: 123
|
|
};
|
|
scope.ticket.status = {};
|
|
scope.ticket.selectedImpact = {};
|
|
scope.ticket.selectedUrgency = {};
|
|
scope.metadata = metadata;
|
|
scope.metadata.impacts = [{ name: 'Minor' }];
|
|
scope.metadata.urgencies = [{ name: 'Low' }];
|
|
scope.$apply();
|
|
expect(objectValueMapperService.getFieldByName).toHaveBeenCalled();
|
|
});
|
|
|
|
it('should load fields from template and populate resolution category', function () {
|
|
spyOn(objectValueMapperService, 'getFieldByName').and.callFake(function () {
|
|
return {value: {}};
|
|
});
|
|
|
|
var directiveElem = getCompiledElement(),
|
|
divElem = directiveElem[0];
|
|
expect(divElem).toBeDefined();
|
|
|
|
spyOn(objectValueMapperService, 'getFieldsByType').and.callFake(function () {
|
|
if (arguments[0] === 'category') {
|
|
return [resolutionCategoryField];
|
|
}
|
|
return [];
|
|
});
|
|
spyOn(objectValueMapperService, 'getValueByFieldName').and.callFake(function () {
|
|
if (arguments[0] === 'resolutionOperational') {
|
|
return resolutionCategoryField.value;
|
|
}
|
|
return {};
|
|
});
|
|
|
|
scope.ticket.selectedTemplate = {
|
|
id: 123
|
|
};
|
|
scope.ticket.status = {};
|
|
scope.ticket.selectedImpact = {};
|
|
scope.ticket.selectedUrgency = {};
|
|
scope.ticket.allCategories = [{
|
|
'name': 'resolution',
|
|
'label': 'Resolution Category',
|
|
'dependAttributes': ['operationCategoryTier1', 'operationCategoryTier2', 'operationCategoryTier3', 'resProductCategoryTier1', 'resProductCategoryTier2', 'resProductCategoryTier3', 'resProductName', 'resProductManufacturer'],
|
|
'listOfTiers': [{
|
|
'name': 'resOperationCategoryTier1',
|
|
'label': 'Resolution Categorization Tier 1',
|
|
'disabled': false
|
|
}, {
|
|
'name': 'resOperationCategoryTier2',
|
|
'label': 'Resolution Categorization Tier 2',
|
|
'dependAttribute': 'resOperationCategoryTier1',
|
|
'disabled': false
|
|
}, {
|
|
'name': 'resOperationCategoryTier3',
|
|
'label': 'Resolution Categorization Tier 3',
|
|
'dependAttribute': 'resOperationCategoryTier2',
|
|
'disabled': false
|
|
}],
|
|
'listOfTiersToShow': ['resOperationCategoryTier3', 'resOperationCategoryTier2', 'resOperationCategoryTier1'],
|
|
'serializedValue': '',
|
|
'dirty': true
|
|
}];
|
|
scope.metadata = metadata;
|
|
scope.metadata.impacts = [{ name: 'Minor' }];
|
|
scope.metadata.urgencies = [{ name: 'Low' }];
|
|
scope.$apply();
|
|
expect(scope.ticket.allCategories[0].listOfTiers[0].selectedValue).toEqual('Failure');
|
|
});
|
|
|
|
it('should update priority for customer update', function(){
|
|
var ticket = {
|
|
type: EntityVO.TYPE_INCIDENT,
|
|
company: {name: 'Test Company'},
|
|
customer: {company: 'some company'},
|
|
selectedCompany: 'Calbro',
|
|
selectedImpact: {name: 'impacted'},
|
|
selectedUrgency: {name: 'urgent'},
|
|
calculatedPriority: 'critical',
|
|
allCategories: [
|
|
{
|
|
"name": "operational",
|
|
"label": "Operational Category",
|
|
"listOfTiers": [
|
|
{
|
|
"name": "operationCategoryTier1",
|
|
"label": "Operational Categorization Tier 1+"
|
|
},
|
|
{
|
|
"name": "operationCategoryTier2",
|
|
"label": "Operational Categorization Tier 2",
|
|
"dependAttribute": "operationCategoryTier1"
|
|
},
|
|
{
|
|
"name": "operationCategoryTier3",
|
|
"label": "Operational Categorization Tier 3",
|
|
"dependAttribute": "operationCategoryTier2"
|
|
}
|
|
],
|
|
"listOfTiersToShow": [
|
|
"operationCategoryTier3",
|
|
"operationCategoryTier2",
|
|
"operationCategoryTier1"
|
|
]
|
|
}
|
|
]
|
|
};
|
|
scope.ticket = ticket;
|
|
spyOn(objectValueMapperService, 'getFieldByName').and.callFake(function () {
|
|
return priorityWidget;
|
|
});
|
|
var directiveElem = getCompiledElement();
|
|
var isoScope = directiveElem.isolateScope();
|
|
scope.$digest();
|
|
expect(isoScope.calculatedPriority).toBeUndefined();
|
|
});
|
|
|
|
describe('should watch context.selectedTemplate', function () {
|
|
var directiveElemment, isolateScope, selectedTemplate, storedcontext, fieldNameData, dynamicSelectionField;
|
|
beforeEach(function () {
|
|
directiveElemment = getCompiledElement();
|
|
isolateScope = directiveElemment.isolateScope();
|
|
selectedTemplate = {
|
|
"name": "New patch for Incident Management.",
|
|
"company": {
|
|
"name": "Petramco"
|
|
}
|
|
};
|
|
storedcontext = {
|
|
"id": "IDGAA5V0HHE9CAP0MGAHPJP3WSGM5J",
|
|
"displayId": "WO0000000000008",
|
|
"status": {
|
|
"value": "Assigned",
|
|
"reason": "Any Reason"
|
|
},
|
|
"categorizations": [],
|
|
"resCategorizations": [],
|
|
"customFields": {},
|
|
"customerCompany": "Calbro Services",
|
|
"templateId": "IDGAA5V0HI5R3ANAK2FRLPA344PC4W",
|
|
"templateName": "New patch for Incident Management.",
|
|
"priority": "Low",
|
|
"locationCompany": {
|
|
"name": "Calbro Services"
|
|
},
|
|
"supportGroup": {
|
|
"supportGroups": ""
|
|
},
|
|
"managerGroup": {
|
|
"supportGroups": "Mary Mann"
|
|
},
|
|
"impact": "4-Minor/Localized",
|
|
"urgency": "4-Low",
|
|
"serviceType": "User Service Restoration"
|
|
};
|
|
|
|
dynamicSelectionField = [
|
|
{
|
|
"name": "resOperationCategoryTier1",
|
|
"tiers": {
|
|
"operationCategoryTier1": "Applications",
|
|
"operationCategoryTier2": "Social",
|
|
"operationCategoryTier3": "Communities"
|
|
},
|
|
'listOfTiers': [{
|
|
'name': 'resOperationCategoryTier1',
|
|
'label': 'Resolution Categorization Tier 1',
|
|
'disabled': false
|
|
}]
|
|
}
|
|
];
|
|
|
|
fieldNameData = {
|
|
value: {}
|
|
};
|
|
isolateScope.context.selectedTemplate = selectedTemplate;
|
|
|
|
spyOn(objectValueMapperService, 'getFieldByName').and.callFake(function (fieldName) {
|
|
return fieldName !== FieldVO.prototype.STATUS_REASON ? fieldNameData : {};
|
|
});
|
|
spyOn(createTicketModel, 'collectTicketChanges').and.returnValue(storedcontext);
|
|
spyOn(objectValueMapperService, 'getFieldsByType').and.returnValue(dynamicSelectionField);
|
|
spyOn(objectValueMapperService, 'getValueByFieldName').and.returnValue({});
|
|
});
|
|
|
|
it('and set the value of selectedStatusReason if template status reason is empty and context.selectedStatus.statusReasons does not reason value', function () {
|
|
isolateScope.context.selectedStatusReason = { name: 'reason' };
|
|
templateData.status.reason = '';
|
|
|
|
isolateScope.$digest();
|
|
|
|
expect(isolateScope.context.selectedStatusReason.name).toBeUndefined();
|
|
expect()
|
|
});
|
|
|
|
it('and set the value of selectedStatusReason if template status reason is empty and context.selectedStatus.statusReasons has reason value', function () {
|
|
spyOn(fieldValidationModel, 'isFieldRequired').and.returnValue(true);
|
|
templateData.status.reason = '';
|
|
isolateScope.$digest();
|
|
|
|
expect(isolateScope.context.selectedStatusReason.name).toBe('reason');
|
|
});
|
|
|
|
it('and set the value of selectedStatus if template status value is empty and context.metadata.statuses has reason value', function () {
|
|
templateData.status.value = '';
|
|
isolateScope.context.status = {
|
|
value: 'New'
|
|
};
|
|
isolateScope.$digest();
|
|
|
|
expect(isolateScope.context.selectedStatus.name).toBe('New');
|
|
});
|
|
|
|
it('and set the value of selectedGroup to empty string if supportGroup is empty', function () {
|
|
templateData.status.value = 'New';
|
|
templateData.supportGroup.name = '';
|
|
isolateScope.$digest();
|
|
|
|
expect(isolateScope.context.selectedGroup.supportGroups).toBe('');
|
|
});
|
|
|
|
it('and set the value of selectedManagerGroup to managerGroup if managerGroup has some values', function () {
|
|
templateData.managerGroup = {
|
|
name: 'Allen'
|
|
};
|
|
templateData.manager = {
|
|
loginId: '12345'
|
|
};
|
|
isolateScope.context.type = 'workorder';
|
|
isolateScope.$digest();
|
|
|
|
expect(isolateScope.context.selectedManagerGroup.name).toBe('Allen');
|
|
expect(isolateScope.context.selectedManager.loginId).toBe('12345');
|
|
});
|
|
|
|
it('and set the value of selectedManagerGroup to empty string if managerGroup is empty', function () {
|
|
templateData.managerGroup = '';
|
|
isolateScope.context.type = 'workorder';
|
|
isolateScope.$digest();
|
|
|
|
expect(isolateScope.context.selectedManagerGroup.supportGroups).toBe('');
|
|
});
|
|
|
|
it('and set the value of locationCompany', function () {
|
|
templateData.locationCompany = {
|
|
name: 'Calbro'
|
|
};
|
|
isolateScope.context.allCategories = [
|
|
{
|
|
"name": "operational",
|
|
"tiers": {
|
|
"operationCategoryTier1": "Applications",
|
|
"operationCategoryTier2": "Social",
|
|
"operationCategoryTier3": "Communities"
|
|
},
|
|
'listOfTiers': [{
|
|
'name': 'resOperationCategoryTier1',
|
|
'label': 'Resolution Categorization Tier 1',
|
|
'disabled': false
|
|
}]
|
|
}
|
|
];
|
|
isolateScope.context.resCategories = [{
|
|
'name': 'resolutionProduct',
|
|
'tiers': {
|
|
'resProductCategoryTier1': 'Hardware',
|
|
'resProductCategoryTier2': 'Application System',
|
|
'resProductCategoryTier3': 'Other Type of Application System'
|
|
},
|
|
'listOfTiers': [{
|
|
'name': 'resOperationCategoryTier1',
|
|
'label': 'Resolution Categorization Tier 1',
|
|
'disabled': false
|
|
}]
|
|
}];
|
|
isolateScope.$digest();
|
|
|
|
expect(isolateScope.context.locationCompany).toBe('Calbro');
|
|
});
|
|
|
|
it('and should successfully update priority in case of task', function () {
|
|
fieldNameData = {
|
|
members: [
|
|
{
|
|
name: 'priority',
|
|
setValue: function () {}
|
|
}
|
|
],
|
|
value: {
|
|
priority: {}
|
|
}
|
|
};
|
|
templateData.dynamicFields = [];
|
|
templateData.customFields = null;
|
|
templateData.priority = 'Medium';
|
|
isolateScope.context.type = 'task';
|
|
isolateScope.$digest();
|
|
|
|
expect(fieldNameData.value.priority.name).toBe('Medium');
|
|
});
|
|
|
|
it('and should clear selected template for incident', function () {
|
|
isolateScope.context.type = 'incident';
|
|
isolateScope.context.allCategories = [
|
|
{
|
|
"name": "operational",
|
|
"tiers": {
|
|
"operationCategoryTier1": "Applications",
|
|
"operationCategoryTier2": "Social",
|
|
"operationCategoryTier3": "Communities"
|
|
},
|
|
'listOfTiers': [{
|
|
'name': 'resOperationCategoryTier1',
|
|
'label': 'Resolution Categorization Tier 1',
|
|
'disabled': false
|
|
}]
|
|
}
|
|
];
|
|
isolateScope.context.dynamicFields = [];
|
|
isolateScope.$digest();
|
|
isolateScope.clearSelectedTemplate();
|
|
isolateScope.$digest();
|
|
|
|
expect(isolateScope.context.selectedTemplate).toBe('');
|
|
expect(ticketModel.getPriority).toHaveBeenCalled();
|
|
});
|
|
|
|
it('and should clear selected template for task', function () {
|
|
storedcontext.status.reason = '';
|
|
isolateScope.$digest();
|
|
isolateScope.context.type = 'task';
|
|
isolateScope.clearSelectedTemplate();
|
|
|
|
expect(isolateScope.context.selectedTemplate).toBe('');
|
|
expect(fieldNameData.value.priority.name).toBe('Low');
|
|
});
|
|
|
|
it('and should clear selected template for work order', function () {
|
|
isolateScope.$digest();
|
|
isolateScope.context.type = 'workorder';
|
|
isolateScope.clearSelectedTemplate();
|
|
|
|
expect(isolateScope.context.selectedTemplate).toBe('');
|
|
expect(isolateScope.context.managerGroup.supportGroups).toBe('Mary Mann');
|
|
});
|
|
});
|
|
|
|
it('should browse the template if user click on Browse All templates button', function () {
|
|
var directiveElem = getCompiledElement(),
|
|
isolateScope = directiveElem.isolateScope();
|
|
|
|
$httpBackend.whenGET('/smartit/rest/category/incidentTemplate/template/templateCategoryTier1?criteria=%7B%7D').respond(200);
|
|
$httpBackend.whenGET('/smartit/rest/task/template/metadata').respond(200);
|
|
|
|
isolateScope.browseTemplate();
|
|
isolateScope.$digest();
|
|
|
|
isolateScope.context.type = 'task';
|
|
|
|
isolateScope.browseTemplate();
|
|
isolateScope.$digest();
|
|
});
|
|
|
|
it('should store the value of template', function () {
|
|
var defer = $q.defer(),
|
|
template = {
|
|
name: 'New Template'
|
|
},
|
|
data,
|
|
fieldNameData = {
|
|
value: {}
|
|
},
|
|
directiveElem = getCompiledElement(),
|
|
isolateScope = directiveElem.isolateScope();
|
|
|
|
defer.resolve(template);
|
|
data = {
|
|
result: defer.promise
|
|
};
|
|
|
|
spyOn(objectValueMapperService, 'getFieldByName').and.callFake(function () {
|
|
return fieldNameData;
|
|
});
|
|
spyOn($modal, 'open').and.returnValue(data);
|
|
isolateScope.browseTemplate();
|
|
isolateScope.$digest();
|
|
|
|
expect(isolateScope.context.selectedTemplate.name).toBe('New Template');
|
|
});
|
|
|
|
it('should watch the value of data.setValueFlag', function () {
|
|
var directiveElem = getCompiledElement(),
|
|
isolateScope = directiveElem.isolateScope();
|
|
|
|
isolateScope.data.setValueFlag = 'test';
|
|
isolateScope.$digest();
|
|
|
|
expect(isolateScope.data.setValueFlag).toBe('#$#');
|
|
});
|
|
|
|
it('should get the list of person', function () {
|
|
var directiveElem = getCompiledElement(),
|
|
isolateScope = directiveElem.isolateScope(),
|
|
data = [
|
|
{
|
|
name: 'person1'
|
|
}
|
|
];
|
|
spyOn(permissionModel, 'hasRole').and.returnValue(true);
|
|
spyOn(createTicketModel, 'getList').and.callFake(function () {
|
|
var defer = $q.defer();
|
|
defer.resolve({ exceedsChunkSize: true, list: data });
|
|
return defer.promise;
|
|
});
|
|
isolateScope.getList('person').then(function (response) {
|
|
expect(response[1].name).toBe('person1');
|
|
expect(response[0].isEmptyResult).toBeTruthy();
|
|
});
|
|
isolateScope.$digest();
|
|
});
|
|
|
|
describe(' Should test the template notes to be appended after user description in new line', function() {
|
|
var isolateScope;
|
|
beforeEach(function () {
|
|
var collectData = {
|
|
"status": {},
|
|
"categorizations": [],
|
|
"resCategorizations": [],
|
|
"customFields": {},
|
|
"desc": 'Test Desc'
|
|
};
|
|
spyOn(createTicketModel, 'collectTicketChanges').and.returnValue(collectData);
|
|
spyOn(objectValueMapperService, 'getFieldByName').and.callFake(function () {
|
|
return {value: {}};
|
|
});
|
|
var ticket = {
|
|
type: EntityVO.TYPE_INCIDENT,
|
|
company: { name: 'Test Company' }
|
|
};
|
|
scope.field = new FieldVO().build(field);
|
|
scope.ticket = ticket;
|
|
|
|
var directiveElem = getCompiledElement();
|
|
isolateScope = directiveElem.isolateScope();
|
|
|
|
scope.ticket.selectedTemplate = {
|
|
id: 123
|
|
};
|
|
scope.ticket.status = {};
|
|
scope.ticket.selectedImpact = {};
|
|
scope.ticket.selectedUrgency = {};
|
|
scope.metadata = metadata;
|
|
scope.metadata.impacts = [{ name: 'Minor' }];
|
|
scope.metadata.urgencies = [{ name: 'Low' }];
|
|
});
|
|
it(' if user has some input already as Test Desc', function () {
|
|
scope.$digest();
|
|
expect(isolateScope.context.desc).toBe('Test Desc' + '\n' + 'Priority, Product Categorization ');
|
|
});
|
|
|
|
it(' if user doesnt have any input already', function () {
|
|
templateData.desc = '';
|
|
scope.$digest();
|
|
expect(isolateScope.context.desc).toBe('Test Desc');
|
|
});
|
|
});
|
|
});
|