330 lines
14 KiB
JavaScript
330 lines
14 KiB
JavaScript
/**
|
|
* Created by vdhakre on 23-04-2018.
|
|
*/
|
|
|
|
describe('Test change tasks directive', function () {
|
|
var compile, scope, $httpBackend, event, modal, modalResult;
|
|
|
|
beforeEach(module('myitsmApp', 'templates'));
|
|
beforeEach(function () {
|
|
inject(function($compile, $rootScope, $injector, events, $modal, $q) {
|
|
$httpBackend = $injector.get('$httpBackend');
|
|
modal = $modal;
|
|
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/v2/metadata?type=incident').respond(new MetadataVO());
|
|
$httpBackend.whenGET('/smartit/rest/relations/incident/IDGAA5V0GEVRLAPFZMEXPFDAEA6ZWV').respond(200);
|
|
$httpBackend.whenGET('/smartit/rest/serverstates').respond(200);
|
|
$httpBackend.whenGET('/smartit/rest/sessionstatus?getLicenseKey=true').respond('');
|
|
$httpBackend.whenGET('views/dashboard/index.html').respond(200);
|
|
$httpBackend.whenGET('/smartit/rest/v2/metadata?type=task').respond(200);
|
|
$httpBackend.whenGET('/smartit/rest/task/draft').respond(200);
|
|
$httpBackend.whenGET('/smartit/rest/v2/customization/screenlayout?screen=createTaskScreen').respond(200);
|
|
$httpBackend.whenGET('/smartit/rest/v2/customization/application/search?name=Galileo&phase=2&screen=createTaskScreen').respond(200);
|
|
$httpBackend.whenGET('/smartit/rest/v2/metadata?type=global').respond(200);
|
|
$httpBackend.whenGET('/smartit/restapi/person/supportgroupperson').respond(200);
|
|
compile = $compile;
|
|
scope = $rootScope.$new();
|
|
event = events;
|
|
modalResult = {
|
|
result: $q.when([])
|
|
};
|
|
});
|
|
|
|
this.basicData = {
|
|
"type": "incident",
|
|
"resolvedDate": null,
|
|
"impact": "4-Minor/Localized",
|
|
"urgency": "4-Low",
|
|
"resolution": null,
|
|
"templateId": "",
|
|
"serviceType": "User Service Restoration",
|
|
"brokerVendorName": "",
|
|
"id": "IDGAA5V0GEVRLAPFZMEXPFDAEA6ZWV",
|
|
"createDate": 1521714148000,
|
|
"displayId": "INC000000000104",
|
|
"modifiedDate": 1521714148000,
|
|
"summary": "Sdfdsfsdfsd",
|
|
"priority": "Low",
|
|
"desc": "",
|
|
"numAttachments": 0,
|
|
"status": {
|
|
"value": "Assigned"
|
|
},
|
|
"assignee": {
|
|
"fullName": "Bob Baxter",
|
|
"loginId": "Bob",
|
|
"customFields": {},
|
|
"id": "Bob"
|
|
},
|
|
"customFields": {},
|
|
"accessMappings": {
|
|
"fieldMappings": {
|
|
"locationCompany": "write",
|
|
"company": "write",
|
|
"assigneeLoginId": "write",
|
|
"impactedService": "write",
|
|
"assignee": "write",
|
|
"department": "write",
|
|
"site": "write",
|
|
"region": "write",
|
|
"siteGroup": "write",
|
|
"timeZone": "write",
|
|
"zipPostalCode": "write",
|
|
"street": "write",
|
|
"mailStation": "write",
|
|
"deskLocation": "write",
|
|
"city": "write",
|
|
"state": "write",
|
|
"country": "write",
|
|
"internetEmail": "write",
|
|
"phoneNumber": "write",
|
|
"organization": "write",
|
|
"contactFirstName": "write",
|
|
"contactLastName": "write",
|
|
"contactCompany": "write",
|
|
"contactRegion": "write",
|
|
"contactSiteGroup": "write",
|
|
"contactSite": "write",
|
|
"contactStreet": "write",
|
|
"contactCity": "write",
|
|
"contactState": "write",
|
|
"contactCountry": "write",
|
|
"contactZip": "write",
|
|
"contactEmail": "write",
|
|
"contactPhoneNumber": "write",
|
|
"contactOrganization": "write",
|
|
"contactDepartment": "write",
|
|
"desc": "write",
|
|
"statusReason": "write",
|
|
"serviceCIReconId": "write",
|
|
"CI_reconid": "write",
|
|
"causalCI": "write",
|
|
"targetDate": "write",
|
|
"id": "read",
|
|
"lastName": "write",
|
|
"firstName": "write",
|
|
"serviceType": "write",
|
|
"impact": "write",
|
|
"urgency": "write",
|
|
"reportedSource": "write",
|
|
"summary": "write",
|
|
"action": "write",
|
|
"operationCategoryTier1": "write",
|
|
"operationCategoryTier2": "write"
|
|
},
|
|
"priorityEditAllowed": true,
|
|
"statusEditAllowed": true,
|
|
"detailsEditAllowed": true,
|
|
"timelineEditAllowed": true,
|
|
"relationsEditAllowed": true,
|
|
"tasksEditAllowed": true,
|
|
"assigneeSelfAssignmentAllowed": true,
|
|
"incidentTypeEditAllowed": true,
|
|
"requestedforEditAllowed": true,
|
|
"resolutionNoteEditAllowed": true
|
|
},
|
|
"locationCompany": {
|
|
"name": "Calbro Services"
|
|
},
|
|
"ownerGroup": {
|
|
"company": {
|
|
"name": "Calbro Services"
|
|
},
|
|
"id": "SGP000000000011"
|
|
},
|
|
"dynamicFields": [],
|
|
"company": {
|
|
"name": "Calbro Services"
|
|
},
|
|
"SLA": {
|
|
"slaTextValid": true,
|
|
"divClassType": "partial",
|
|
"reachTime": "Ticket created on Mar 22, 2018 3:52 PM"
|
|
},
|
|
"syncTime": 1521714230591,
|
|
"attachments": [],
|
|
"hasImpactAnalysis": false,
|
|
"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"
|
|
]
|
|
},
|
|
{
|
|
"name": "product",
|
|
"label": "Product Category",
|
|
"listOfTiers": [
|
|
{
|
|
"name": "productCategoryTier1",
|
|
"label": "Product Categorization Tier 1"
|
|
},
|
|
{
|
|
"name": "productCategoryTier2",
|
|
"label": "Product Categorization Tier 2",
|
|
"dependAttribute": "productCategoryTier1"
|
|
},
|
|
{
|
|
"name": "productCategoryTier3",
|
|
"label": "Product Categorization Tier 3",
|
|
"dependAttribute": "productCategoryTier2"
|
|
},
|
|
{
|
|
"name": "productName",
|
|
"label": "Product Name+",
|
|
"dependAttribute": "productCategoryTier3"
|
|
},
|
|
{
|
|
"name": "productModelVersion",
|
|
"label": "Model/Version",
|
|
"dependAttribute": "productName"
|
|
}
|
|
],
|
|
"listOfTiersToShow": [
|
|
"productName",
|
|
"productCategoryTier3",
|
|
"productCategoryTier2",
|
|
"productCategoryTier1"
|
|
]
|
|
},
|
|
{
|
|
"name": "resolution",
|
|
"label": "Resolution Category",
|
|
"dependAttributes": [
|
|
"operationCategoryTier1",
|
|
"operationCategoryTier2",
|
|
"operationCategoryTier3",
|
|
"resProductCategoryTier1",
|
|
"resProductCategoryTier2",
|
|
"resProductCategoryTier3",
|
|
"resProductName",
|
|
"resProductManufacturer"
|
|
],
|
|
"listOfTiers": [
|
|
{
|
|
"name": "resOperationCategoryTier1",
|
|
"label": "Resolution Categorization Tier 1"
|
|
},
|
|
{
|
|
"name": "resOperationCategoryTier2",
|
|
"label": "Resolution Categorization Tier 2",
|
|
"dependAttribute": "resOperationCategoryTier1"
|
|
},
|
|
{
|
|
"name": "resOperationCategoryTier3",
|
|
"label": "Resolution Categorization Tier 3",
|
|
"dependAttribute": "resOperationCategoryTier2"
|
|
}
|
|
],
|
|
"listOfTiersToShow": [
|
|
"resOperationCategoryTier3",
|
|
"resOperationCategoryTier2",
|
|
"resOperationCategoryTier1"
|
|
]
|
|
},
|
|
{
|
|
"name": "resolutionProduct",
|
|
"label": "Resolution Product Category",
|
|
"listOfTiers": [
|
|
{
|
|
"name": "resProductCategoryTier1",
|
|
"label": "Resolution Product Categorization Tier 1"
|
|
},
|
|
{
|
|
"name": "resProductCategoryTier2",
|
|
"label": "Resolution Product Categorization Tier 2",
|
|
"dependAttribute": "resProductCategoryTier1"
|
|
},
|
|
{
|
|
"name": "resProductCategoryTier3",
|
|
"label": "Resolution Product Categorization Tier 3",
|
|
"dependAttribute": "resProductCategoryTier2"
|
|
},
|
|
{
|
|
"name": "resProductName",
|
|
"label": "Product Name (R)+",
|
|
"dependAttribute": "resProductCategoryTier3"
|
|
},
|
|
{
|
|
"name": "resProductModelVersion",
|
|
"label": "Model/Version (R)",
|
|
"dependAttribute": "resProductName"
|
|
}
|
|
],
|
|
"listOfTiersToShow": [
|
|
"resProductName",
|
|
"resProductCategoryTier3",
|
|
"resProductCategoryTier2",
|
|
"resProductCategoryTier1"
|
|
]
|
|
}
|
|
],
|
|
"noCategories": 0,
|
|
"ticketType": "incident"
|
|
};
|
|
this.relationCounter = {
|
|
"tickets": 0,
|
|
"linkedItems": 0,
|
|
"tasks": 0,
|
|
"CIs": 0
|
|
};
|
|
|
|
this.relations = {
|
|
"IDGAA5V0GEVRLAPFZMEXPFDAEA6ZWV": []
|
|
};
|
|
});
|
|
|
|
function getCompiledElement(){
|
|
var element = angular.element('<change-tasks ticket="basicData" relation-counters="relationCounters"></change-tasks>');
|
|
var compiledElement = compile(element)(scope);
|
|
scope.$digest();
|
|
return compiledElement;
|
|
}
|
|
|
|
it('should compile', function () {
|
|
scope.basicData = new IncidentVO().build(this.basicData);
|
|
scope.relationCounters = this.relationCounter;
|
|
scope.relations = this.relations;
|
|
|
|
var directiveElem = getCompiledElement();
|
|
var divElem = directiveElem[0];
|
|
expect(divElem).toBeDefined();
|
|
});
|
|
|
|
it('should broadcast RELATIONS_UPDATE_COMPLETE event after task creation', function () {
|
|
scope.basicData = new IncidentVO().build(this.basicData);
|
|
scope.relationCounters = this.relationCounter;
|
|
scope.relations = this.relations;
|
|
|
|
spyOn(modal, 'open').and.returnValue(modalResult);
|
|
|
|
var ele = getCompiledElement(), isoScope = ele.isolateScope();
|
|
spyOn(isoScope, '$emit');
|
|
isoScope.createBlankTask();
|
|
isoScope.$digest();
|
|
expect(isoScope.$emit).toHaveBeenCalledWith(event.RELATIONS_UPDATE_COMPLETE, true);
|
|
});
|
|
});
|