132 lines
4.5 KiB
JavaScript
132 lines
4.5 KiB
JavaScript
describe('Test mcsm-details-directive', function () {
|
|
var element, scope, compile, rootScope, $httpBackend, elementScope, noteData, events;
|
|
|
|
beforeEach(module('myitsmApp', 'templates'));
|
|
beforeEach(function () {
|
|
inject(function ($compile, $rootScope, $injector, _events_) {
|
|
$httpBackend = $injector.get('$httpBackend');
|
|
|
|
var getLocale = function () {
|
|
return readJSON('scripts/app/i18n/resources-locale_en.json');
|
|
},
|
|
getMcsmVendorList = function () {
|
|
return readJSON('mocks/mcsm-vendorList.json');
|
|
},
|
|
getMcsmDevops = function (type) {
|
|
var vendorTicketList = readJSON('mocks/' + type + '-mcsm.json');
|
|
// simulate adding of one new ticket
|
|
vendorTicketList.tickets.push({
|
|
description: 'test desc',
|
|
id: 'JIRA_567811',
|
|
title: 'test title'
|
|
});
|
|
return vendorTicketList;
|
|
},
|
|
deleteMcsmTicket = function (type) {
|
|
var vendorTicketList = readJSON('mocks/' + type + '-mcsm.json');
|
|
// simulate removal of one ticket
|
|
vendorTicketList.tickets.splice(0, 1);
|
|
return vendorTicketList;
|
|
};
|
|
|
|
$httpBackend.whenGET(/^scripts\/app\/i18n\/resources-locale_en.*$/).respond(getLocale());
|
|
$httpBackend.whenGET('/smartit/rest/sessionstatus?getLicenseKey=true').respond('');
|
|
$httpBackend.whenGET('/smartit/rest/serverstates').respond('');
|
|
|
|
$httpBackend.whenGET("/smartit/rest/mcsm/vendordevops?type=change").respond(200, getMcsmVendorList());
|
|
$httpBackend.whenGET("/smartit/rest/mcsm/devops/change/CRQ713/vendor/AGGADG0HG1B1ZAOW6WPPOVKNBUYYJK").respond(200, getMcsmDevops(EntityVO.TYPE_CHANGE));
|
|
$httpBackend.whenDELETE("/smartit/rest/mcsm/devops/change/CRQ713/vendorticketid/JIRA_1234?vendorId=AGGADG0HG1B1ZAOW6WPPOVKNBUYYJK").respond(200, deleteMcsmTicket(EntityVO.TYPE_CHANGE));
|
|
|
|
compile = $compile;
|
|
rootScope = $rootScope;
|
|
scope = $rootScope.$new();
|
|
events = _events_;
|
|
});
|
|
});
|
|
|
|
function getCompiledElement(type) {
|
|
element = angular.element('<mcsm-details ' +
|
|
'ticket="parentContext" ' +
|
|
'></mcsm-details>');
|
|
|
|
switch (type) {
|
|
case EntityVO.TYPE_INCIDENT:
|
|
scope.parentContext = new IncidentVO();
|
|
break;
|
|
case EntityVO.TYPE_CHANGE:
|
|
scope.parentContext = new ChangeVO();
|
|
scope.parentContext.displayId = 'CRQ713';
|
|
break;
|
|
}
|
|
scope.parentContext.vendorInfo = readJSON('mocks/' + type + '-mcsm.json').tickets;
|
|
scope.parentContext.accessMappings.relationsEditAllowed = true;
|
|
|
|
scope.parentContext.id = 'IDGAA5V0GEXKMAOU28QBFDNOLEIUCE';
|
|
|
|
var directiveElem = compile(element)(scope);
|
|
|
|
scope.$digest();
|
|
$('body').append(element);
|
|
|
|
$httpBackend.flush();
|
|
scope.$digest();
|
|
|
|
elementScope = element.isolateScope();
|
|
|
|
return directiveElem;
|
|
}
|
|
|
|
it('should compile', function () {
|
|
var directiveElem = getCompiledElement(EntityVO.TYPE_CHANGE);
|
|
var divElem = directiveElem[0];
|
|
expect(divElem).toBeDefined();
|
|
});
|
|
|
|
it('should process and display the correct MultiCloud tickets', function () {
|
|
var directiveElem = getCompiledElement(EntityVO.TYPE_CHANGE);
|
|
scope.$digest();
|
|
|
|
var mcsmTicketElements = directiveElem.find('.panel-default');
|
|
expect(mcsmTicketElements.length).toEqual(2);
|
|
});
|
|
|
|
it('should process and display the correct MultiCloud tickets after the manual association button is pressed', function () {
|
|
var directiveElem = getCompiledElement(EntityVO.TYPE_CHANGE);
|
|
scope.$digest();
|
|
|
|
var manualAssociationButton = directiveElem.find('button[ng-click*="startManualAssociation"]');
|
|
expect(manualAssociationButton.length).toEqual(1);
|
|
|
|
manualAssociationButton.click();
|
|
$httpBackend.flush();
|
|
scope.$digest();
|
|
mcsmTicketElements = directiveElem.find('.panel-default');
|
|
expect(mcsmTicketElements.length).toEqual(3);
|
|
});
|
|
|
|
it('should process and display the correct MultiCloud tickets after a ticket is removed', function () {
|
|
var directiveElem = getCompiledElement(EntityVO.TYPE_CHANGE);
|
|
scope.$digest();
|
|
|
|
var mcsmTicketElements = directiveElem.find('.panel-default');
|
|
expect(mcsmTicketElements.length).toEqual(2);
|
|
|
|
var removeAssociationButton = directiveElem.find('i[ng-click*="removeAssociation"]');
|
|
expect(removeAssociationButton.length).toEqual(2);
|
|
|
|
removeAssociationButton[0].click();
|
|
scope.$digest();
|
|
|
|
var modalDialog = $('body').find('div[window-class="bmc-system-alert-modal"]');
|
|
var confirmationButton = modalDialog.find('button[ng-click*="close"]');
|
|
expect(confirmationButton.length).toEqual(2); // yes and no buttons
|
|
|
|
confirmationButton[0].click();
|
|
|
|
$httpBackend.flush();
|
|
scope.$digest();
|
|
mcsmTicketElements = directiveElem.find('.panel-default');
|
|
expect(mcsmTicketElements.length).toEqual(1);
|
|
});
|
|
});
|