mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-24 17:31:52 +00:00
[ACS-8398] unit tests part 3 (#4163)
* ACS-8398 Unit tests for search ai effects * ACS-8398 Unit tests for canDisplayKnowledgeRetrievalButton rule * ACS-8398 Unit tests for changes in document base page * ACS-8398 Added unit tests for changes in recent files component * ACS-8398 Unit tests for changes in lists pages * ACS-8398 Moved variable to inside of describe * ACS-8398 Moved repeated code to function * ACS-8398 Reverted one change * ACS-8398 Fix after rebase * ACS-8398 Fix issue with repeated code * ACS-8398 Fix issue with repeated code * ACS-8398 Fixed unit tests * ACS-8398 Fixed unit tests * ACS-8398 Trigger job
This commit is contained in:
@@ -26,6 +26,7 @@ import * as app from './app.rules';
|
||||
import { TestRuleContext } from './test-rule-context';
|
||||
import { NodeEntry, RepositoryInfo, StatusInfo } from '@alfresco/js-api';
|
||||
import { getFileExtension } from './app.rules';
|
||||
import { AppConfigService } from '@alfresco/adf-core';
|
||||
|
||||
describe('app.evaluators', () => {
|
||||
let context: TestRuleContext;
|
||||
@@ -540,44 +541,117 @@ describe('app.evaluators', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('isKnowledgeRetrievalEnabled', () => {
|
||||
it('should call context.appConfig.get with correct parameters', () => {
|
||||
context.appConfig = { get: jasmine.createSpy() } as any;
|
||||
describe('canDisplayKnowledgeRetrievalButton', () => {
|
||||
const testCanDisplayKnowledgeRetrievalButton = (testTitle: string, url: string, knowledgeRetrievalEnabled: boolean, expected: boolean) => {
|
||||
it(testTitle, () => {
|
||||
context.appConfig = jasmine.createSpyObj<AppConfigService>({
|
||||
get: knowledgeRetrievalEnabled
|
||||
});
|
||||
context.navigation.url = url;
|
||||
expect(app.canDisplayKnowledgeRetrievalButton(context)).toBe(expected);
|
||||
});
|
||||
};
|
||||
|
||||
[
|
||||
{
|
||||
pageName: 'personal files',
|
||||
pageUrl: '/personal-files'
|
||||
},
|
||||
{
|
||||
pageName: 'shared files',
|
||||
pageUrl: '/shared'
|
||||
},
|
||||
{
|
||||
pageName: 'recent files',
|
||||
pageUrl: '/recent-files'
|
||||
},
|
||||
{
|
||||
pageName: 'favorites',
|
||||
pageUrl: '/favorites'
|
||||
},
|
||||
{
|
||||
pageName: 'library content',
|
||||
pageUrl: '/libraries/some-id'
|
||||
}
|
||||
].forEach((testCase) => {
|
||||
testCanDisplayKnowledgeRetrievalButton(
|
||||
`should return false if get from appConfig returns false and navigation is ${testCase.pageName}`,
|
||||
testCase.pageUrl,
|
||||
false,
|
||||
false
|
||||
);
|
||||
|
||||
testCanDisplayKnowledgeRetrievalButton(
|
||||
`should return true if get from appConfig returns true and navigation is ${testCase.pageName}`,
|
||||
testCase.pageUrl,
|
||||
true,
|
||||
true
|
||||
);
|
||||
});
|
||||
|
||||
testCanDisplayKnowledgeRetrievalButton(
|
||||
'should return false if get from appConfig returns false and navigation is search results but not for libraries',
|
||||
'/search',
|
||||
false,
|
||||
false
|
||||
);
|
||||
|
||||
testCanDisplayKnowledgeRetrievalButton(
|
||||
'should return true if get from appConfig returns true and navigation is search results but not for libraries',
|
||||
'/search',
|
||||
true,
|
||||
true
|
||||
);
|
||||
|
||||
testCanDisplayKnowledgeRetrievalButton(
|
||||
'should return false if get from appConfig returns false and navigation is search results for libraries',
|
||||
'/search/libraries',
|
||||
false,
|
||||
false
|
||||
);
|
||||
|
||||
testCanDisplayKnowledgeRetrievalButton(
|
||||
'should return false if get from appConfig returns true and navigation is search results for libraries',
|
||||
'/search/libraries',
|
||||
true,
|
||||
false
|
||||
);
|
||||
|
||||
testCanDisplayKnowledgeRetrievalButton(
|
||||
'should return false if get from appConfig returns false and navigation is libraries',
|
||||
'/libraries',
|
||||
false,
|
||||
false
|
||||
);
|
||||
|
||||
testCanDisplayKnowledgeRetrievalButton(
|
||||
'should return false if get from appConfig returns true and navigation is libraries',
|
||||
'/libraries',
|
||||
true,
|
||||
false
|
||||
);
|
||||
|
||||
testCanDisplayKnowledgeRetrievalButton(
|
||||
'should return false if get from appConfig returns false and navigation is incorrect',
|
||||
'/my-special-files',
|
||||
false,
|
||||
false
|
||||
);
|
||||
|
||||
testCanDisplayKnowledgeRetrievalButton(
|
||||
'should return false if get from appConfig returns true but navigation is incorrect',
|
||||
'/my-special-files',
|
||||
true,
|
||||
false
|
||||
);
|
||||
|
||||
it('should call get on context.appConfig with correct parameters', () => {
|
||||
context.appConfig = jasmine.createSpyObj<AppConfigService>({
|
||||
get: false
|
||||
});
|
||||
|
||||
app.canDisplayKnowledgeRetrievalButton(context);
|
||||
expect(context.appConfig.get).toHaveBeenCalledWith('plugins.knowledgeRetrievalEnabled', true);
|
||||
});
|
||||
|
||||
it('should return false if get from appConfig returns false', () => {
|
||||
expect(
|
||||
app.canDisplayKnowledgeRetrievalButton({
|
||||
appConfig: {
|
||||
get: () => false
|
||||
}
|
||||
} as any)
|
||||
).toBeFalse();
|
||||
});
|
||||
|
||||
it('should return true if get from appConfig returns true and navigation is correct', () => {
|
||||
expect(
|
||||
app.canDisplayKnowledgeRetrievalButton({
|
||||
navigation: { url: '/personal-files' },
|
||||
appConfig: {
|
||||
get: () => true
|
||||
}
|
||||
} as any)
|
||||
).toBeTrue();
|
||||
});
|
||||
|
||||
it('should return false if get from appConfig returns true, but navigation is not correct', () => {
|
||||
expect(
|
||||
app.canDisplayKnowledgeRetrievalButton({
|
||||
navigation: { url: '/my-special-files' },
|
||||
appConfig: {
|
||||
get: () => true
|
||||
}
|
||||
} as any)
|
||||
).toBeFalse();
|
||||
expect(context.appConfig.get).toHaveBeenCalledWith('plugins.knowledgeRetrievalEnabled', false);
|
||||
});
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user