810 lines
31 KiB
JavaScript
810 lines
31 KiB
JavaScript
/**
|
||
* Created by npatil2
|
||
*/
|
||
describe('service: knowledgeConsoleModel', function () {
|
||
var $httpBackend, $rootScope, scope, myResult;
|
||
|
||
beforeEach(module('myitsmApp'));
|
||
beforeEach(inject(function ($injector, consoleService, authService, configurationModel, metadataModel, userModel, knowledgeArticleModel, $rootScope, $q, $filter, roles) {
|
||
scope = $rootScope.$new();
|
||
$httpBackend = $injector.get('$httpBackend');
|
||
$httpBackend.whenGET('scripts/app/i18n/resources-locale_en-US.json').respond(200);
|
||
$httpBackend.whenGET('/smartit/rest/serverstates').respond(200);
|
||
$httpBackend.whenGET('/smartit/rest/v2/metadata?type=global').respond(200);
|
||
$httpBackend.whenGET('/smartit/restapi/person/supportgroupperson').respond(200);
|
||
$httpBackend.whenGET('/smartit/rest/sessionstatus?getLicenseKey=true').respond(200);
|
||
$httpBackend.whenGET('views/dashboard/index.html').respond(200);
|
||
$httpBackend.whenGET('/smartit/rest/v2/preference/details/search?clientType=UC&preferenceGroup=knowledgeConsoleColumns').respond(200);
|
||
$httpBackend.whenGET('/smartit/rest/v2/preference/details/search?clientType=UC&preferenceGroup=knowledgeConsoleFilter').respond(200);
|
||
|
||
$rootScope = $injector.get('$rootScope');
|
||
this.knowledgeConsoleModel = $injector.get('knowledgeConsoleModel');
|
||
this.consoleService = consoleService;
|
||
this.authService = authService;
|
||
this.configurationModel = configurationModel;
|
||
this.metadataModel = metadataModel;
|
||
this.userModel = userModel;
|
||
this.knowledgeArticleModel = knowledgeArticleModel;
|
||
this.$q = $q;
|
||
this.$filter = $filter;
|
||
this.roles = roles;
|
||
}));
|
||
|
||
beforeEach(inject(function ($q) {
|
||
|
||
var deferred = $q.defer(),
|
||
result =[
|
||
{
|
||
accessRestrictions: [
|
||
{
|
||
name: 'Calbro Services'
|
||
}
|
||
],
|
||
available: 'OFFLINE',
|
||
company: {
|
||
name: 'Calbro Services'
|
||
},
|
||
displayId: 'PPL000000000013',
|
||
email: 'A.Allbrook@calbroservices.com',
|
||
firstName: 'Allen',
|
||
fullName: 'Allen Allbrook',
|
||
id: 'Allen',
|
||
lastName: 'Allbrook',
|
||
loginId: 'Allen',
|
||
openTickets: 147,
|
||
organization: 'Information Technology',
|
||
personId: 'PPL000000000013'
|
||
},
|
||
{
|
||
impacts: [],
|
||
metadatatype: 'knowledge',
|
||
statuses: [
|
||
{
|
||
validKnowledgeTransitions: [
|
||
{
|
||
validStatus: 'Work In Progress',
|
||
requiredKnowledgeAdmin: false
|
||
}
|
||
],
|
||
isValidForCreate: true,
|
||
index: 0,
|
||
name: 'Work In Progress',
|
||
label: 'In Progress'
|
||
}
|
||
]
|
||
},
|
||
[
|
||
{
|
||
name: 'Known Error',
|
||
type: 'knowledgeTemplate',
|
||
desc: 'The Known Error template enables you to create knowledge articles to provide root cause information and workarounds for a known issue.',
|
||
templateObject: {
|
||
isAssigneeGroupFieldPresent: true,
|
||
sections: [
|
||
{
|
||
name: 'Error',
|
||
label: 'Error',
|
||
embeddedImageLimit: 15,
|
||
order: 1
|
||
}
|
||
],
|
||
styles: [
|
||
{
|
||
text: '20px, Black',
|
||
type: 'Header 1',
|
||
element: 'h1',
|
||
styles: 'color:black;font-size:20px',
|
||
userStyle: false
|
||
}
|
||
],
|
||
label: 'Known Error'
|
||
},
|
||
id: 'ID005056A6052ByY7VSwVOpSAQS5MB'
|
||
},
|
||
{
|
||
name: 'KCS Template',
|
||
type: 'knowledgeTemplate',
|
||
desc: 'The KCS template enables you to create knowledge articles which identify the problem, environment, and root cause for the issue, and to document its resolution. This template aligns to a format suggested by the KCS Practices Guide.',
|
||
templateObject: {
|
||
isAssigneeGroupFieldPresent: true,
|
||
sections: [
|
||
{
|
||
name: 'Problem',
|
||
label: 'Problem',
|
||
embeddedImageLimit: 15,
|
||
order: 1
|
||
}
|
||
],
|
||
styles: [
|
||
{
|
||
text: '12px, Black',
|
||
type: 'Paragraph',
|
||
element: 'p',
|
||
styles: 'font-size: 12px; color: darkgrey',
|
||
userStyle: false
|
||
}
|
||
],
|
||
label: 'KCS Template'
|
||
},
|
||
id: 'AGGAA5V0GQF7XANRCBLUAAV3FTLWGB',
|
||
label: 'KCS Template'
|
||
}
|
||
]
|
||
];
|
||
spyOn(this.userModel, 'getFullCurrentUserData').and.callFake(function () {
|
||
deferred.resolve(result[0]);
|
||
return deferred.promise;
|
||
});
|
||
}));
|
||
|
||
beforeEach(inject(function ($q) {
|
||
|
||
var deferred = $q.defer(),
|
||
result =[
|
||
{
|
||
accessRestrictions: [
|
||
{
|
||
name: 'Calbro Services'
|
||
}
|
||
],
|
||
available: 'OFFLINE',
|
||
company: {
|
||
name: 'Calbro Services'
|
||
},
|
||
displayId: 'PPL000000000013',
|
||
email: 'A.Allbrook@calbroservices.com',
|
||
firstName: 'Allen',
|
||
fullName: 'Allen Allbrook',
|
||
id: 'Allen',
|
||
lastName: 'Allbrook',
|
||
loginId: 'Allen',
|
||
openTickets: 147,
|
||
organization: 'Information Technology',
|
||
personId: 'PPL000000000013'
|
||
},
|
||
{
|
||
impacts: [],
|
||
metadatatype: 'knowledge',
|
||
statuses: [
|
||
{
|
||
validKnowledgeTransitions: [
|
||
{
|
||
validStatus: 'Work In Progress',
|
||
requiredKnowledgeAdmin: false
|
||
}
|
||
],
|
||
isValidForCreate: true,
|
||
index: 0,
|
||
name: 'Work In Progress',
|
||
label: 'In Progress'
|
||
}
|
||
]
|
||
},
|
||
[
|
||
{
|
||
name: 'Known Error',
|
||
type: 'knowledgeTemplate',
|
||
desc: 'The Known Error template enables you to create knowledge articles to provide root cause information and workarounds for a known issue.',
|
||
templateObject: {
|
||
isAssigneeGroupFieldPresent: true,
|
||
sections: [
|
||
{
|
||
name: 'Error',
|
||
label: 'Error',
|
||
embeddedImageLimit: 15,
|
||
order: 1
|
||
}
|
||
],
|
||
styles: [
|
||
{
|
||
text: '20px, Black',
|
||
type: 'Header 1',
|
||
element: 'h1',
|
||
styles: 'color:black;font-size:20px',
|
||
userStyle: false
|
||
}
|
||
],
|
||
label: 'Known Error'
|
||
},
|
||
id: 'ID005056A6052ByY7VSwVOpSAQS5MB'
|
||
},
|
||
{
|
||
name: 'KCS Template',
|
||
type: 'knowledgeTemplate',
|
||
desc: 'The KCS template enables you to create knowledge articles which identify the problem, environment, and root cause for the issue, and to document its resolution. This template aligns to a format suggested by the KCS Practices Guide.',
|
||
templateObject: {
|
||
isAssigneeGroupFieldPresent: true,
|
||
sections: [
|
||
{
|
||
name: 'Problem',
|
||
label: 'Problem',
|
||
embeddedImageLimit: 15,
|
||
order: 1
|
||
}
|
||
],
|
||
styles: [
|
||
{
|
||
text: '12px, Black',
|
||
type: 'Paragraph',
|
||
element: 'p',
|
||
styles: 'font-size: 12px; color: darkgrey',
|
||
userStyle: false
|
||
}
|
||
],
|
||
label: 'KCS Template'
|
||
},
|
||
id: 'AGGAA5V0GQF7XANRCBLUAAV3FTLWGB',
|
||
label: 'KCS Template'
|
||
}
|
||
]
|
||
];
|
||
spyOn(this.metadataModel, 'getMetadataByType').and.callFake(function () {
|
||
deferred.resolve(result[1]);
|
||
return deferred.promise;
|
||
});
|
||
|
||
}));
|
||
|
||
beforeEach(inject(function ($q) {
|
||
|
||
var deferred = $q.defer(), result =[
|
||
{
|
||
accessRestrictions: [
|
||
{
|
||
name: 'Calbro Services'
|
||
}
|
||
],
|
||
available: 'OFFLINE',
|
||
company: {
|
||
name: 'Calbro Services'
|
||
},
|
||
displayId: 'PPL000000000013',
|
||
email: 'A.Allbrook@calbroservices.com',
|
||
firstName: 'Allen',
|
||
fullName: 'Allen Allbrook',
|
||
id: 'Allen',
|
||
lastName: 'Allbrook',
|
||
loginId: 'Allen',
|
||
openTickets: 147,
|
||
organization: 'Information Technology',
|
||
personId: 'PPL000000000013'
|
||
},
|
||
{
|
||
impacts: [],
|
||
metadatatype: 'knowledge',
|
||
statuses: [
|
||
{
|
||
validKnowledgeTransitions: [
|
||
{
|
||
validStatus: 'Work In Progress',
|
||
requiredKnowledgeAdmin: false
|
||
}
|
||
],
|
||
isValidForCreate: true,
|
||
index: 0,
|
||
name: 'Work In Progress',
|
||
label: 'In Progress'
|
||
}
|
||
]
|
||
},
|
||
[
|
||
{
|
||
name: 'Known Error',
|
||
type: 'knowledgeTemplate',
|
||
desc: 'The Known Error template enables you to create knowledge articles to provide root cause information and workarounds for a known issue.',
|
||
templateObject: {
|
||
isAssigneeGroupFieldPresent: true,
|
||
sections: [
|
||
{
|
||
name: 'Error',
|
||
label: 'Error',
|
||
embeddedImageLimit: 15,
|
||
order: 1
|
||
}
|
||
],
|
||
styles: [
|
||
{
|
||
text: '20px, Black',
|
||
type: 'Header 1',
|
||
element: 'h1',
|
||
styles: 'color:black;font-size:20px',
|
||
userStyle: false
|
||
}
|
||
],
|
||
label: 'Known Error'
|
||
},
|
||
id: 'ID005056A6052ByY7VSwVOpSAQS5MB'
|
||
},
|
||
{
|
||
name: 'KCS Template',
|
||
type: 'knowledgeTemplate',
|
||
desc: 'The KCS template enables you to create knowledge articles which identify the problem, environment, and root cause for the issue, and to document its resolution. This template aligns to a format suggested by the KCS Practices Guide.',
|
||
templateObject: {
|
||
isAssigneeGroupFieldPresent: true,
|
||
sections: [
|
||
{
|
||
name: 'Problem',
|
||
label: 'Problem',
|
||
embeddedImageLimit: 15,
|
||
order: 1
|
||
}
|
||
],
|
||
styles: [
|
||
{
|
||
text: '12px, Black',
|
||
type: 'Paragraph',
|
||
element: 'p',
|
||
styles: 'font-size: 12px; color: darkgrey',
|
||
userStyle: false
|
||
}
|
||
],
|
||
label: 'KCS Template'
|
||
},
|
||
id: 'AGGAA5V0GQF7XANRCBLUAAV3FTLWGB',
|
||
label: 'KCS Template'
|
||
}
|
||
]
|
||
];
|
||
|
||
spyOn(this.knowledgeArticleModel, 'getKnowledgeArticleTemplates').and.callFake(function () {
|
||
deferred.resolve(result[2]);
|
||
return deferred.promise;
|
||
});
|
||
}));
|
||
|
||
beforeEach(inject(function ($q) {
|
||
|
||
var deferred = $q.defer(),
|
||
result = [
|
||
{
|
||
accessRestrictions: [
|
||
{
|
||
name: 'Calbro Services'
|
||
}
|
||
],
|
||
available: 'OFFLINE',
|
||
company: {
|
||
name: 'Calbro Services'
|
||
},
|
||
displayId: 'PPL000000000013',
|
||
email: 'A.Allbrook@calbroservices.com',
|
||
firstName: 'Allen',
|
||
fullName: 'Allen Allbrook',
|
||
id: 'Allen',
|
||
lastName: 'Allbrook',
|
||
loginId: 'Allen',
|
||
openTickets: 147,
|
||
organization: 'Information Technology',
|
||
personId: 'PPL000000000013'
|
||
},
|
||
{
|
||
impacts: [],
|
||
metadatatype: 'knowledge',
|
||
statuses: [
|
||
{
|
||
validKnowledgeTransitions: [
|
||
{
|
||
validStatus: 'Work In Progress',
|
||
requiredKnowledgeAdmin: false
|
||
}
|
||
],
|
||
isValidForCreate: true,
|
||
index: 0,
|
||
name: 'Work In Progress',
|
||
label: 'In Progress'
|
||
}
|
||
]
|
||
},
|
||
[
|
||
{
|
||
name: 'Known Error',
|
||
type: 'knowledgeTemplate',
|
||
desc: 'The Known Error template enables you to create knowledge articles to provide root cause information and workarounds for a known issue.',
|
||
templateObject: {
|
||
isAssigneeGroupFieldPresent: true,
|
||
sections: [
|
||
{
|
||
name: 'Error',
|
||
label: 'Error',
|
||
embeddedImageLimit: 15,
|
||
order: 1
|
||
}
|
||
],
|
||
styles: [
|
||
{
|
||
text: '20px, Black',
|
||
type: 'Header 1',
|
||
element: 'h1',
|
||
styles: 'color:black;font-size:20px',
|
||
userStyle: false
|
||
}
|
||
],
|
||
label: 'Known Error'
|
||
},
|
||
id: 'ID005056A6052ByY7VSwVOpSAQS5MB'
|
||
},
|
||
{
|
||
name: 'KCS Template',
|
||
type: 'knowledgeTemplate',
|
||
desc: 'The KCS template enables you to create knowledge articles which identify the problem, environment, and root cause for the issue, and to document its resolution. This template aligns to a format suggested by the KCS Practices Guide.',
|
||
templateObject: {
|
||
isAssigneeGroupFieldPresent: true,
|
||
sections: [
|
||
{
|
||
name: 'Problem',
|
||
label: 'Problem',
|
||
embeddedImageLimit: 15,
|
||
order: 1
|
||
}
|
||
],
|
||
styles: [
|
||
{
|
||
text: '12px, Black',
|
||
type: 'Paragraph',
|
||
element: 'p',
|
||
styles: 'font-size: 12px; color: darkgrey',
|
||
userStyle: false
|
||
}
|
||
],
|
||
label: 'KCS Template'
|
||
},
|
||
id: 'AGGAA5V0GQF7XANRCBLUAAV3FTLWGB',
|
||
label: 'KCS Template'
|
||
}
|
||
]
|
||
], knowledgeList = {
|
||
itemList: [
|
||
{
|
||
articleId: 'KBA00000054',
|
||
title: 'dff',
|
||
type: 'knowledge',
|
||
version: 0,
|
||
assignee: {
|
||
'customFields': {},
|
||
fullName: 'Allen Allbrook',
|
||
loginId: 'Allen'
|
||
},
|
||
owner: {
|
||
customFields: {}
|
||
},
|
||
company: {
|
||
name: 'All'
|
||
},
|
||
author: {
|
||
customFields: {},
|
||
company: {
|
||
name: 'Calbro Services'
|
||
}
|
||
},
|
||
statusValue: {
|
||
value: 'Draft'
|
||
},
|
||
id: 'AGGAA5V0HGOHVAOYUES9OXXRZAI8FA'
|
||
}
|
||
],
|
||
totalCount: 4
|
||
};
|
||
|
||
spyOn(this.userModel, 'getUserPreferences').and.callFake(function () {
|
||
deferred.resolve(result);
|
||
return deferred.promise;
|
||
});
|
||
|
||
spyOn(this.consoleService, 'getKnowledgeStats').and.callFake(function () {
|
||
deferred.resolve(result);
|
||
return deferred.promise;
|
||
});
|
||
|
||
spyOn(this.consoleService, 'getKnowledgeList').and.callFake(function () {
|
||
deferred.resolve(knowledgeList);
|
||
return deferred.promise;
|
||
});
|
||
|
||
spyOn(this.userModel, 'updateUserPreferences').and.callFake(function () {
|
||
deferred.resolve(knowledgeList);
|
||
return deferred.promise;
|
||
});
|
||
|
||
spyOn(this.consoleService, 'saveKnowledgeFilterConfiguration').and.callFake(function () {
|
||
deferred.resolve(knowledgeList);
|
||
return deferred.promise;
|
||
});
|
||
|
||
spyOn(this.userModel, 'removeUserPreferences').and.callFake(function () {
|
||
deferred.resolve('sucess');
|
||
return deferred.promise;
|
||
});
|
||
|
||
spyOn(this.consoleService, 'removeFilterConfiguration').and.callFake(function () {
|
||
deferred.resolve('sucess');
|
||
return deferred.promise;
|
||
});
|
||
|
||
}));
|
||
|
||
it('should defined ', function () {
|
||
expect(this.knowledgeConsoleModel).toBeDefined();
|
||
});
|
||
|
||
it('should populate Filters ', function () {
|
||
this.knowledgeConsoleModel.areFiltersPopulated = true;
|
||
this.myResult = this.knowledgeConsoleModel.populateFilters();
|
||
expect(this.myResult.$$state.value).toEqual(1);
|
||
this.knowledgeConsoleModel.areFiltersPopulated = false;
|
||
this.knowledgeConsoleModel.filterDict.statusMappings = {
|
||
options: []
|
||
|
||
};
|
||
|
||
this.myResult = this.knowledgeConsoleModel.populateFilters();
|
||
scope.$apply();
|
||
expect(this.knowledgeConsoleModel.filterDict.templateNames.options).toBeTruthy();
|
||
expect(this.knowledgeConsoleModel.filterDict.templateNames.options[0].name).toEqual('Known Error');
|
||
expect(this.knowledgeConsoleModel.filterDict.templateNames.options[0].type).toEqual('dynamic');
|
||
|
||
});
|
||
|
||
it('should run populateConfiguration ()', function () {
|
||
this.knowledgeConsoleModel.columnsConfig = 'test columns config';
|
||
this.knowledgeConsoleModel.populateConfiguration().then(function (data) {
|
||
myResult = data;
|
||
});
|
||
|
||
scope.$apply();
|
||
expect(myResult).toEqual(1);
|
||
this.knowledgeConsoleModel.columnsConfig = null;
|
||
this.knowledgeConsoleModel.populateConfiguration();
|
||
scope.$apply();
|
||
expect(this.knowledgeConsoleModel.userSavedColumnPresets).toBeTruthy();
|
||
expect(this.knowledgeConsoleModel.userSavedColumnPresets[0].id).toEqual('myAllOpenKnowledge');
|
||
expect(this.knowledgeConsoleModel.userSavedColumnPresets[0].fixed).toBe(true);
|
||
expect(this.knowledgeConsoleModel.userSavedColumnPresets[0].name).toEqual('My Assigned Articles');
|
||
expect(this.knowledgeConsoleModel.userSavedFilterPresets).toBeTruthy();
|
||
expect(this.knowledgeConsoleModel.currentColumnsConfig).toBeTruthy();
|
||
expect(this.knowledgeConsoleModel.userSavedPresets).toBeTruthy();
|
||
expect(this.knowledgeConsoleModel.criteria.attributeNames).toBeTruthy();
|
||
expect(this.knowledgeConsoleModel.criteria.attributeNames[0]).toEqual('assignee');
|
||
});
|
||
|
||
it('should run populateAttributeNames ()', function () {
|
||
this.myResult=this.knowledgeConsoleModel.populateAttributeNames();
|
||
expect(this.knowledgeConsoleModel.criteria.attributeNames).toBeDefined();
|
||
});
|
||
|
||
it('should drop Criteria Start Index', function () {
|
||
this.knowledgeConsoleModel.dropCriteriaStartIndex();
|
||
expect(this.knowledgeConsoleModel.criteria.chunkInfo.startIndex).toEqual(0);
|
||
});
|
||
|
||
it('should Ticket Console Metric ', function () {
|
||
this.knowledgeConsoleModel.getTicketConsoleMetric();
|
||
scope.$apply();
|
||
expect(this.knowledgeConsoleModel.statsConfig).toBeTruthy();
|
||
expect(this.knowledgeConsoleModel.statsConfig[0].name).toEqual('myArticles');
|
||
});
|
||
|
||
it('should return Item List', function () {
|
||
this.knowledgeConsoleModel.getItemList().then(function (data) {
|
||
myResult = data;
|
||
});
|
||
|
||
scope.$apply();
|
||
expect(myResult).toEqual(4);
|
||
expect(this.knowledgeConsoleModel.itemList).toBeTruthy();
|
||
expect(this.knowledgeConsoleModel.itemList[0].articleId).toEqual('KBA00000054');
|
||
expect(this.knowledgeConsoleModel.itemList[0].type).toEqual('knowledge');
|
||
});
|
||
|
||
it('should apply Filter Set', function () {
|
||
this.filterOption = [
|
||
{
|
||
filter: 'assignees',
|
||
option: 'me'
|
||
},
|
||
{
|
||
filter: 'organizations',
|
||
option: 'myOrganization'
|
||
},
|
||
{
|
||
filter: 'modifiedDateRanges',
|
||
option: 'modifiedDatePast24'
|
||
}
|
||
];
|
||
|
||
|
||
this.knowledgeConsoleModel.applyFilterSet(this.filterOption);
|
||
expect(this.knowledgeConsoleModel.filterDict).toBeTruthy();
|
||
|
||
});
|
||
|
||
it('should remove open filter when published metric is clicked', function () {
|
||
this.knowledgeConsoleModel.selectedFilters = [
|
||
{
|
||
name: 'allOpen',
|
||
label: 'allOpen',
|
||
type: 'constant',
|
||
filterName: 'statusMappings',
|
||
criteria: {
|
||
name: 'statusMappings',
|
||
value: [
|
||
'open'
|
||
]
|
||
},
|
||
active: true
|
||
},
|
||
{
|
||
name: 'me',
|
||
label: 'me',
|
||
type: 'constant',
|
||
criteria: {
|
||
name: 'assignees',
|
||
value: [
|
||
{
|
||
loginId: 'Allen'
|
||
}
|
||
]
|
||
},
|
||
subLabel: 'Allen Allbrook',
|
||
active: true,
|
||
filterName: 'assignees',
|
||
filterLabel: 'assignee'
|
||
}
|
||
];
|
||
|
||
this.filterOptions = [
|
||
{
|
||
"filter": "statusMappings",
|
||
"option": "Published"
|
||
}
|
||
];
|
||
|
||
this.knowledgeConsoleModel.filterDict = {
|
||
"statusMappings": {
|
||
"name": "statusMappings",
|
||
"label": "status",
|
||
"options": [
|
||
{
|
||
"name": "Publish Approval",
|
||
"type": "dynamic",
|
||
"filterName": "statusMappings",
|
||
"criteria": {
|
||
"name": "statusMappings",
|
||
"value": [
|
||
"Publish Approval"
|
||
]
|
||
},
|
||
"$$hashKey": "object:1490"
|
||
},
|
||
{
|
||
"name": "Published",
|
||
"type": "dynamic",
|
||
"filterName": "statusMappings",
|
||
"criteria": {
|
||
"name": "statusMappings",
|
||
"value": [
|
||
"Published"
|
||
]
|
||
},
|
||
"$$hashKey": "object:1491"
|
||
},
|
||
{
|
||
"name": "Not Published",
|
||
"type": "dynamic",
|
||
"filterName": "statusMappings",
|
||
"criteria": {
|
||
"name": "statusMappings",
|
||
"value": [
|
||
"Not Published"
|
||
]
|
||
},
|
||
"$$hashKey": "object:1488"
|
||
}
|
||
],
|
||
"onDisplay": true,
|
||
"$$hashKey": "object:1150"
|
||
}
|
||
};
|
||
|
||
this.knowledgeConsoleModel.applyFilterSet(this.filterOptions, true);
|
||
var allOpenFilter = _.find(this.knowledgeConsoleModel.selectedFilters, {name: 'allOpen'});
|
||
expect(allOpenFilter).toBeUndefined();
|
||
|
||
});
|
||
|
||
|
||
it('should save Filter Preset', function () {
|
||
this.name = 'test';
|
||
this.knowledgeConsoleModel.selectedFilters = [
|
||
{
|
||
name: 'allOpen',
|
||
label: 'allOpen',
|
||
type: 'constant',
|
||
filterName: 'statusMappings',
|
||
criteria: {
|
||
name: 'statusMappings',
|
||
value: [
|
||
'open'
|
||
]
|
||
},
|
||
active: true
|
||
},
|
||
{
|
||
name: 'me',
|
||
label: 'me',
|
||
type: 'constant',
|
||
criteria: {
|
||
name: 'assignees',
|
||
value: [
|
||
{
|
||
loginId: 'Allen'
|
||
}
|
||
]
|
||
},
|
||
subLabel: 'Allen Allbrook',
|
||
active: true,
|
||
filterName: 'assignees',
|
||
filterLabel: 'assignee'
|
||
}
|
||
];
|
||
this.knowledgeConsoleModel.saveFilterPreset(this.name).then(function (data) {
|
||
myResult = data;
|
||
});
|
||
|
||
scope.$apply();
|
||
expect(myResult[0].itemList).toBeTruthy();
|
||
expect(myResult[0].itemList[0].articleId).toEqual('KBA00000054');
|
||
expect(myResult[0].itemList[0].type).toEqual('knowledge');
|
||
});
|
||
|
||
it('should enable Assessment', function () {
|
||
myResult = this.knowledgeConsoleModel.enableAssessment();
|
||
expect(myResult).toBe(false);
|
||
});
|
||
|
||
it('should enable Kcs Filters', function () {
|
||
myResult = this.knowledgeConsoleModel.enableKcsFilters();
|
||
expect(myResult).toBe(false);
|
||
});
|
||
|
||
it('should enable Kcs Filters', function () {
|
||
this.knowledgeConsoleModel.saveColumnPreset().then(function (data) {
|
||
myResult = data;
|
||
});
|
||
|
||
scope.$apply();
|
||
expect(myResult.itemList).toBeTruthy();
|
||
expect(myResult.itemList[0].articleId).toEqual('KBA00000054');
|
||
expect(myResult.itemList[0].type).toEqual('knowledge');
|
||
});
|
||
|
||
it('should Search Enabled', function () {
|
||
this.knowledgeConsoleModel.selectedFilters = ['test', 'test1', 'test2', 'test3'];
|
||
myResult = this.knowledgeConsoleModel.isSearchEnabled();
|
||
expect(myResult).toBe(true);
|
||
});
|
||
|
||
it('should update Column Config', function () {
|
||
this.columnsConfig = 'test';
|
||
this.name = 'My Assigned Articles';
|
||
this.id = 'myAllOpenKnowledge';
|
||
this.knowledgeConsoleModel.currentColumnsConfig = {};
|
||
this.knowledgeConsoleModel.updateColumnConfig(this.columnsConfig, this.name, this.id).then(function (data) {
|
||
myResult = data;
|
||
});
|
||
|
||
scope.$apply();
|
||
expect(this.knowledgeConsoleModel.currentColumnsConfig).toBeDefined();
|
||
});
|
||
|
||
it('should remove User Filter Preset', function () {
|
||
this.userFilterPreset = {
|
||
id: 'myAllOpenKnowledge',
|
||
columnId: 'KBA00000054',
|
||
name: 'My Assigned Articles'
|
||
};
|
||
|
||
this.myResult=this.knowledgeConsoleModel.removeUserFilterPreset(this.userFilterPreset);
|
||
scope.$apply();
|
||
});
|
||
|
||
}); |