mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2026-09-09 18:03:21 +00:00
Remove mocha and jasmine-ajax dependencies (#11813)
This commit is contained in:
@@ -29,7 +29,7 @@ module.exports = function (config) {
|
||||
{ pattern: 'lib/config/app.config.json', included: false, served: true, watched: false }
|
||||
],
|
||||
|
||||
frameworks: ['jasmine-ajax', 'jasmine', '@angular-devkit/build-angular'],
|
||||
frameworks: ['jasmine', '@angular-devkit/build-angular'],
|
||||
|
||||
proxies: {
|
||||
'/assets/images/': '/base/lib/core/src/lib/assets/images/',
|
||||
@@ -42,13 +42,11 @@ module.exports = function (config) {
|
||||
},
|
||||
|
||||
plugins: [
|
||||
require('karma-jasmine-ajax'),
|
||||
require('karma-jasmine'),
|
||||
require('karma-chrome-launcher'),
|
||||
require('karma-jasmine-html-reporter'),
|
||||
require('karma-coverage'),
|
||||
require('@angular-devkit/build-angular/plugins/karma'),
|
||||
require('karma-mocha-reporter')
|
||||
require('@angular-devkit/build-angular/plugins/karma')
|
||||
],
|
||||
client: {
|
||||
clearContext: false,
|
||||
@@ -61,10 +59,6 @@ module.exports = function (config) {
|
||||
suppressAll: true // removes the duplicated traces
|
||||
},
|
||||
|
||||
mochaReporter: {
|
||||
ignoreSkipped: process.env.KARMA_IGNORE_SKIPPED === 'true'
|
||||
},
|
||||
|
||||
coverageReporter: {
|
||||
dir: join(__dirname, '../../coverage/content-services'),
|
||||
subdir: '.',
|
||||
@@ -86,7 +80,7 @@ module.exports = function (config) {
|
||||
}
|
||||
},
|
||||
|
||||
reporters: ['mocha', 'kjhtml'],
|
||||
reporters: ['progress', 'kjhtml'],
|
||||
port: 9876,
|
||||
colors: true,
|
||||
logLevel: constants.LOG_INFO,
|
||||
|
||||
@@ -26,8 +26,6 @@ import { FileModel, FileUploadStatus } from '../../common/models/file.model';
|
||||
import { AlfrescoApiService } from '../../services';
|
||||
import { AlfrescoApiServiceMock } from '../../mock';
|
||||
|
||||
declare let jasmine: any;
|
||||
|
||||
describe('UploadService', () => {
|
||||
let service: UploadService;
|
||||
let appConfigService: AppConfigService;
|
||||
@@ -35,6 +33,40 @@ describe('UploadService', () => {
|
||||
|
||||
const mockProductInfo = new BehaviorSubject<RepositoryInfo>(null);
|
||||
|
||||
const createMockPromiseWithEvents = (responseData?: any, shouldError = false) => {
|
||||
const handlers: any = {};
|
||||
const promise: any = new Promise((resolve, reject) => {
|
||||
setTimeout(() => {
|
||||
if (shouldError) {
|
||||
if (handlers.error) {
|
||||
handlers.error(responseData || { status: 404 });
|
||||
}
|
||||
reject(responseData);
|
||||
} else {
|
||||
if (handlers.success) {
|
||||
handlers.success(responseData);
|
||||
}
|
||||
resolve(responseData);
|
||||
}
|
||||
}, 0);
|
||||
});
|
||||
|
||||
promise.on = (event: string, handler: (data?: any) => void) => {
|
||||
handlers[event] = handler;
|
||||
return promise;
|
||||
};
|
||||
|
||||
promise.abort = () => {
|
||||
if (handlers.abort) {
|
||||
handlers.abort();
|
||||
}
|
||||
};
|
||||
|
||||
promise.catch = (handler: (error: any) => void) => Promise.prototype.catch.call(promise, handler);
|
||||
|
||||
return promise;
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [],
|
||||
@@ -75,14 +107,9 @@ describe('UploadService', () => {
|
||||
|
||||
uploadFileSpy = spyOn(service.uploadApi, 'uploadFile').and.callThrough();
|
||||
|
||||
jasmine.Ajax.install();
|
||||
mockProductInfo.next({ status: { isThumbnailGenerationEnabled: true } } as RepositoryInfo);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
jasmine.Ajax.uninstall();
|
||||
});
|
||||
|
||||
it('should return an empty queue if no elements are added', () => {
|
||||
expect(service.getQueue().length).toEqual(0);
|
||||
});
|
||||
@@ -153,53 +180,49 @@ describe('UploadService', () => {
|
||||
it('should make XHR done request after the file is added in the queue', (done) => {
|
||||
const emitter = new EventEmitter();
|
||||
|
||||
const mockResponse = { entry: { id: 'node-id' } };
|
||||
const mockPromise = createMockPromiseWithEvents(mockResponse);
|
||||
|
||||
uploadFileSpy.and.returnValue(mockPromise);
|
||||
|
||||
const emitterDisposable = emitter.subscribe((e) => {
|
||||
expect(e.value).toBe('File uploaded');
|
||||
expect(e.value).toEqual(mockResponse);
|
||||
emitterDisposable.unsubscribe();
|
||||
done();
|
||||
});
|
||||
|
||||
const fileFake = new FileModel({ name: 'fake-name', size: 10 } as File, { parentId: '-root-', path: 'fake-dir' });
|
||||
service.addToQueue(fileFake);
|
||||
service.uploadFilesInTheQueue(emitter);
|
||||
|
||||
const request = jasmine.Ajax.requests.mostRecent();
|
||||
expect(request.url).toBe(
|
||||
'http://localhost:9876/ecm/alfresco/api/-default-/public/alfresco/versions/1/nodes/-root-/children?autoRename=true&include=allowableOperations'
|
||||
);
|
||||
expect(request.method).toBe('POST');
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'text/plain',
|
||||
responseText: 'File uploaded'
|
||||
});
|
||||
expect(uploadFileSpy).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should make XHR error request after an error occur', (done) => {
|
||||
const emitter = new EventEmitter();
|
||||
|
||||
const mockPromise = createMockPromiseWithEvents({ status: 404 }, true);
|
||||
uploadFileSpy.and.returnValue(mockPromise);
|
||||
|
||||
const emitterDisposable = emitter.subscribe((e) => {
|
||||
expect(e.value).toBe('Error file uploaded');
|
||||
emitterDisposable.unsubscribe();
|
||||
done();
|
||||
});
|
||||
|
||||
const fileFake = new FileModel({ name: 'fake-name', size: 10 } as File, { parentId: '-root-' });
|
||||
service.addToQueue(fileFake);
|
||||
service.uploadFilesInTheQueue(null, emitter);
|
||||
expect(jasmine.Ajax.requests.mostRecent().url).toBe(
|
||||
'http://localhost:9876/ecm/alfresco/api/-default-/public/alfresco/versions/1/nodes/-root-/children?autoRename=true&include=allowableOperations'
|
||||
);
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 404,
|
||||
contentType: 'text/plain',
|
||||
responseText: 'Error file uploaded'
|
||||
});
|
||||
expect(uploadFileSpy).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should abort file only if it is safe to abort', (done) => {
|
||||
const emitter = new EventEmitter();
|
||||
|
||||
const mockPromise = createMockPromiseWithEvents();
|
||||
uploadFileSpy.and.returnValue(mockPromise);
|
||||
|
||||
const emitterDisposable = emitter.subscribe((event) => {
|
||||
expect(event.value).toEqual('File aborted');
|
||||
emitterDisposable.unsubscribe();
|
||||
@@ -217,22 +240,18 @@ describe('UploadService', () => {
|
||||
it('should let file complete and then delete node if it is not safe to abort', (done) => {
|
||||
const emitter = new EventEmitter();
|
||||
|
||||
const mockUploadResponse = { entry: { id: 'myNodeId' } };
|
||||
const mockPromise = createMockPromiseWithEvents(mockUploadResponse);
|
||||
uploadFileSpy.and.returnValue(mockPromise);
|
||||
|
||||
const deleteNodeSpy = spyOn(service.nodesApi, 'deleteNode').and.returnValue(Promise.resolve());
|
||||
|
||||
const emitterDisposable = emitter.subscribe((event) => {
|
||||
expect(event.value).toEqual('File deleted');
|
||||
emitterDisposable.unsubscribe();
|
||||
|
||||
const deleteRequest = jasmine.Ajax.requests.mostRecent();
|
||||
expect(deleteRequest.url).toBe(
|
||||
'http://localhost:9876/ecm/alfresco/api/-default-/public/alfresco/versions/1/nodes/myNodeId?permanent=true'
|
||||
);
|
||||
expect(deleteRequest.method).toBe('DELETE');
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'text/plain',
|
||||
responseText: 'File deleted'
|
||||
});
|
||||
done();
|
||||
if (event.value === 'File deleted') {
|
||||
expect(deleteNodeSpy).toHaveBeenCalledWith('myNodeId', { permanent: true });
|
||||
emitterDisposable.unsubscribe();
|
||||
done();
|
||||
}
|
||||
});
|
||||
|
||||
const fileFake = new FileModel({ name: 'fake-name', size: 10 } as File);
|
||||
@@ -241,41 +260,30 @@ describe('UploadService', () => {
|
||||
|
||||
const file = service.getQueue();
|
||||
service.cancelUpload(...file);
|
||||
|
||||
const request = jasmine.Ajax.requests.mostRecent();
|
||||
expect(request.url).toBe(
|
||||
'http://localhost:9876/ecm/alfresco/api/-default-/public/alfresco/versions/1/nodes/-root-/children?autoRename=true&include=allowableOperations'
|
||||
);
|
||||
expect(request.method).toBe('POST');
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: {
|
||||
entry: {
|
||||
id: 'myNodeId'
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it('should delete node version when cancelling the upload of the new file version', (done) => {
|
||||
const emitter = new EventEmitter();
|
||||
|
||||
const mockUploadResponse = {
|
||||
entry: {
|
||||
id: 'myNodeId',
|
||||
properties: {
|
||||
'cm:versionLabel': '1.1'
|
||||
}
|
||||
}
|
||||
};
|
||||
const mockPromise = createMockPromiseWithEvents(mockUploadResponse);
|
||||
|
||||
spyOn(service.nodesApi, 'updateNodeContent').and.returnValue(mockPromise);
|
||||
const deleteVersionSpy = spyOn(service.versionsApi, 'deleteVersion').and.returnValue(Promise.resolve());
|
||||
|
||||
const emitterDisposable = emitter.subscribe((event) => {
|
||||
expect(event.value).toEqual('File deleted');
|
||||
emitterDisposable.unsubscribe();
|
||||
|
||||
const deleteRequest = jasmine.Ajax.requests.mostRecent();
|
||||
expect(deleteRequest.url).toBe('http://localhost:9876/ecm/alfresco/api/-default-/public/alfresco/versions/1/nodes/myNodeId/versions/1.1');
|
||||
expect(deleteRequest.method).toBe('DELETE');
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'text/plain',
|
||||
responseText: 'File deleted'
|
||||
});
|
||||
done();
|
||||
if (event.value === 'File deleted') {
|
||||
expect(deleteVersionSpy).toHaveBeenCalledWith('myNodeId', '1.1');
|
||||
emitterDisposable.unsubscribe();
|
||||
done();
|
||||
}
|
||||
});
|
||||
|
||||
const fileFake = new FileModel({ name: 'fake-name', size: 10 } as File, null, 'fakeId');
|
||||
@@ -284,23 +292,6 @@ describe('UploadService', () => {
|
||||
|
||||
const file = service.getQueue();
|
||||
service.cancelUpload(...file);
|
||||
|
||||
const request = jasmine.Ajax.requests.mostRecent();
|
||||
expect(request.url).toContain('ecm/alfresco/api/-default-/public/alfresco/versions/1/nodes/fakeId/content?include=allowableOperations');
|
||||
expect(request.method).toBe('PUT');
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: {
|
||||
entry: {
|
||||
id: 'myNodeId',
|
||||
properties: {
|
||||
'cm:versionLabel': '1.1'
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it('If newVersion is set, name should be a param', () => {
|
||||
@@ -331,26 +322,27 @@ describe('UploadService', () => {
|
||||
it('should use custom root folder ID given to the service', (done) => {
|
||||
const emitter = new EventEmitter();
|
||||
|
||||
const mockResponse = { entry: { id: 'node-id' } };
|
||||
const mockPromise = createMockPromiseWithEvents(mockResponse);
|
||||
uploadFileSpy.and.returnValue(mockPromise);
|
||||
|
||||
const emitterDisposable = emitter.subscribe((e) => {
|
||||
expect(e.value).toBe('File uploaded');
|
||||
expect(e.value).toEqual(mockResponse);
|
||||
emitterDisposable.unsubscribe();
|
||||
done();
|
||||
});
|
||||
|
||||
const filesFake = new FileModel({ name: 'fake-file-name', size: 10 } as File, { parentId: '123', path: 'fake-dir' });
|
||||
service.addToQueue(filesFake);
|
||||
service.uploadFilesInTheQueue(emitter);
|
||||
|
||||
const request = jasmine.Ajax.requests.mostRecent();
|
||||
expect(request.url).toContain(
|
||||
'/ecm/alfresco/api/-default-/public/alfresco/versions/1/nodes/123/children?autoRename=true&include=allowableOperations'
|
||||
expect(uploadFileSpy).toHaveBeenCalledWith(
|
||||
jasmine.objectContaining({ name: 'fake-file-name' }),
|
||||
'fake-dir',
|
||||
'123',
|
||||
jasmine.any(Object),
|
||||
jasmine.any(Object)
|
||||
);
|
||||
expect(request.method).toBe('POST');
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'text/plain',
|
||||
responseText: 'File uploaded'
|
||||
});
|
||||
});
|
||||
|
||||
describe('versioningEnabled', () => {
|
||||
@@ -437,6 +429,13 @@ describe('UploadService', () => {
|
||||
});
|
||||
|
||||
it('should start downloading the next one if a file of the list is aborted', (done) => {
|
||||
const mockResponse1 = { entry: { id: 'node-id-1' } };
|
||||
const mockResponse2 = { entry: { id: 'node-id-2' } };
|
||||
const mockPromise1 = createMockPromiseWithEvents(mockResponse1);
|
||||
const mockPromise2 = createMockPromiseWithEvents(mockResponse2);
|
||||
|
||||
uploadFileSpy.and.returnValues(mockPromise1, mockPromise2);
|
||||
|
||||
service.fileUploadAborted.subscribe((e) => {
|
||||
expect(e).not.toBeNull();
|
||||
});
|
||||
|
||||
@@ -23,8 +23,6 @@ import { CustomResourcesService } from './custom-resources.service';
|
||||
import { NodesApiService } from '../../common';
|
||||
import { provideApiTesting } from '../../testing/providers';
|
||||
|
||||
declare let jasmine: any;
|
||||
|
||||
describe('DocumentListService', () => {
|
||||
let service: DocumentListService;
|
||||
let customResourcesService: CustomResourcesService;
|
||||
@@ -79,7 +77,6 @@ describe('DocumentListService', () => {
|
||||
service = TestBed.inject(DocumentListService);
|
||||
customResourcesService = TestBed.inject(CustomResourcesService);
|
||||
nodesApiService = TestBed.inject(NodesApiService);
|
||||
jasmine.Ajax.install();
|
||||
});
|
||||
|
||||
it('should emit resetSelection$ when resetSelection is called', (done) => {
|
||||
@@ -96,11 +93,9 @@ describe('DocumentListService', () => {
|
||||
service.reload();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
jasmine.Ajax.uninstall();
|
||||
});
|
||||
|
||||
it('should return the folder info', fakeAsync(() => {
|
||||
spyOn(service.nodes, 'listNodeChildren').and.returnValue(Promise.resolve(fakeFolder as any));
|
||||
|
||||
service.getFolder('/fake-root/fake-name').subscribe((res) => {
|
||||
expect(res).toBeDefined();
|
||||
expect(res.list).toBeDefined();
|
||||
@@ -109,12 +104,6 @@ describe('DocumentListService', () => {
|
||||
expect(res.list.entries[0].entry.isFolder).toBeTruthy();
|
||||
expect(res.list.entries[0].entry.name).toEqual('fake-name');
|
||||
});
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: fakeFolder
|
||||
});
|
||||
}));
|
||||
|
||||
it('should use rootFolderId provided in options', () => {
|
||||
@@ -204,35 +193,33 @@ describe('DocumentListService', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should delete the folder', fakeAsync(() => {
|
||||
service.deleteNode('fake-id').subscribe((res) => {
|
||||
expect(res).toBe('');
|
||||
});
|
||||
it('should delete the folder', (done) => {
|
||||
spyOn(service.nodes, 'deleteNode').and.returnValue(Promise.resolve() as any);
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 204,
|
||||
contentType: 'json'
|
||||
service.deleteNode('fake-id').subscribe(() => {
|
||||
expect(service.nodes.deleteNode).toHaveBeenCalledWith('fake-id');
|
||||
done();
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
||||
it('should copy a node', (done) => {
|
||||
service.copyNode('node-id', 'parent-id').subscribe(() => done());
|
||||
const mockResponse = { entry: { id: 'copied-node-id' } } as NodeEntry;
|
||||
const copyNodeSpy = spyOn(service.nodes, 'copyNode').and.returnValue(Promise.resolve(mockResponse));
|
||||
|
||||
expect(jasmine.Ajax.requests.mostRecent().method).toBe('POST');
|
||||
expect(jasmine.Ajax.requests.mostRecent().url).toContain('/nodes/node-id/copy');
|
||||
expect(jasmine.Ajax.requests.mostRecent().params).toEqual(JSON.stringify({ targetParentId: 'parent-id' }));
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({ status: 200, contentType: 'json' });
|
||||
service.copyNode('node-id', 'parent-id').subscribe(() => {
|
||||
expect(copyNodeSpy).toHaveBeenCalledWith('node-id', { targetParentId: 'parent-id' });
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should move a node', (done) => {
|
||||
service.moveNode('node-id', 'parent-id').subscribe(() => done());
|
||||
const mockResponse = { entry: { id: 'moved-node-id' } } as NodeEntry;
|
||||
const moveNodeSpy = spyOn(service.nodes, 'moveNode').and.returnValue(Promise.resolve(mockResponse));
|
||||
|
||||
expect(jasmine.Ajax.requests.mostRecent().method).toBe('POST');
|
||||
expect(jasmine.Ajax.requests.mostRecent().url).toContain('/nodes/node-id/move');
|
||||
expect(jasmine.Ajax.requests.mostRecent().params).toEqual(JSON.stringify({ targetParentId: 'parent-id' }));
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({ status: 200, contentType: 'json' });
|
||||
service.moveNode('node-id', 'parent-id').subscribe(() => {
|
||||
expect(moveNodeSpy).toHaveBeenCalledWith('node-id', { targetParentId: 'parent-id' });
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should call isCustomSource from customResourcesService when isCustomSourceService is called', () => {
|
||||
|
||||
@@ -25,8 +25,6 @@ import { EMPTY, of } from 'rxjs';
|
||||
import { AlfrescoApiService } from '../../services';
|
||||
import { AlfrescoApiServiceMock } from '../../mock';
|
||||
|
||||
declare let jasmine: any;
|
||||
|
||||
describe('NodeCommentsService', () => {
|
||||
let service: NodeCommentsService;
|
||||
|
||||
@@ -40,15 +38,12 @@ describe('NodeCommentsService', () => {
|
||||
]
|
||||
});
|
||||
service = TestBed.inject(NodeCommentsService);
|
||||
jasmine.Ajax.install();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
jasmine.Ajax.uninstall();
|
||||
});
|
||||
|
||||
describe('Node comments', () => {
|
||||
it('should add a comment node ', (done) => {
|
||||
spyOn(service.commentsApi, 'createComment').and.returnValue(Promise.resolve(fakeContentComment as any));
|
||||
|
||||
service.add('999', 'fake-comment-message').subscribe((res: CommentModel) => {
|
||||
expect(res).toBeDefined();
|
||||
expect(res.id).not.toEqual(null);
|
||||
@@ -59,15 +54,11 @@ describe('NodeCommentsService', () => {
|
||||
expect(res.createdBy.lastName).toEqual('lastName');
|
||||
done();
|
||||
});
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'application/json',
|
||||
responseText: JSON.stringify(fakeContentComment)
|
||||
});
|
||||
});
|
||||
|
||||
it('should return the nodes comments ', (done) => {
|
||||
spyOn(service.commentsApi, 'listComments').and.returnValue(Promise.resolve(fakeContentComments as any));
|
||||
|
||||
service.get('999').subscribe((res: CommentModel[]) => {
|
||||
expect(res).toBeDefined();
|
||||
expect(res.length).toEqual(2);
|
||||
@@ -75,12 +66,6 @@ describe('NodeCommentsService', () => {
|
||||
expect(res[1].message).toEqual('fake-message-2');
|
||||
done();
|
||||
});
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'application/json',
|
||||
responseText: JSON.stringify(fakeContentComments)
|
||||
});
|
||||
});
|
||||
|
||||
it('should return avatar image URL for given userId', () => {
|
||||
|
||||
@@ -29,7 +29,7 @@ module.exports = function (config) {
|
||||
}
|
||||
],
|
||||
|
||||
frameworks: ['jasmine-ajax', 'jasmine', '@angular-devkit/build-angular'],
|
||||
frameworks: ['jasmine', '@angular-devkit/build-angular'],
|
||||
|
||||
proxies: {
|
||||
'/fake-url-file.png': '/base/lib/core/src/lib/assets/images/logo.svg',
|
||||
@@ -56,13 +56,11 @@ module.exports = function (config) {
|
||||
},
|
||||
|
||||
plugins: [
|
||||
require('karma-jasmine-ajax'),
|
||||
require('karma-jasmine'),
|
||||
require('karma-chrome-launcher'),
|
||||
require('karma-jasmine-html-reporter'),
|
||||
require('karma-coverage'),
|
||||
require('@angular-devkit/build-angular/plugins/karma'),
|
||||
require('karma-mocha-reporter')
|
||||
require('@angular-devkit/build-angular/plugins/karma')
|
||||
],
|
||||
client: {
|
||||
clearContext: false,
|
||||
@@ -73,9 +71,6 @@ module.exports = function (config) {
|
||||
jasmineHtmlReporter: {
|
||||
suppressAll: true // removes the duplicated traces
|
||||
},
|
||||
mochaReporter: {
|
||||
ignoreSkipped: process.env.KARMA_IGNORE_SKIPPED === 'true'
|
||||
},
|
||||
|
||||
coverageReporter: {
|
||||
dir: join(__dirname, '../../coverage/core'),
|
||||
@@ -98,7 +93,7 @@ module.exports = function (config) {
|
||||
}
|
||||
},
|
||||
|
||||
reporters: ['mocha', 'kjhtml'],
|
||||
reporters: ['progress', 'kjhtml'],
|
||||
port: 9876,
|
||||
colors: true,
|
||||
logLevel: constants.LOG_INFO,
|
||||
|
||||
@@ -29,8 +29,6 @@ import {
|
||||
headerVisibilityCond
|
||||
} from '../../mock/form/widget-visibility-cloud.service.mock';
|
||||
|
||||
declare let jasmine: any;
|
||||
|
||||
describe('WidgetVisibilityCloudService', () => {
|
||||
let service: WidgetVisibilityService;
|
||||
let booleanResult: boolean | undefined;
|
||||
@@ -39,11 +37,6 @@ describe('WidgetVisibilityCloudService', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
service = TestBed.inject(WidgetVisibilityService);
|
||||
jasmine.Ajax.install();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
jasmine.Ajax.uninstall();
|
||||
});
|
||||
|
||||
describe('should be able to evaluate next condition operations', () => {
|
||||
|
||||
@@ -17,8 +17,7 @@ module.exports = function (config) {
|
||||
require('karma-chrome-launcher'),
|
||||
require('karma-jasmine-html-reporter'),
|
||||
require('karma-coverage'),
|
||||
require('@angular-devkit/build-angular/plugins/karma'),
|
||||
require('karma-mocha-reporter')
|
||||
require('@angular-devkit/build-angular/plugins/karma')
|
||||
],
|
||||
client: {
|
||||
clearContext: false // leave Jasmine Spec Runner output visible in browser
|
||||
@@ -26,9 +25,6 @@ module.exports = function (config) {
|
||||
jasmineHtmlReporter: {
|
||||
suppressAll: true // removes the duplicated traces
|
||||
},
|
||||
mochaReporter: {
|
||||
ignoreSkipped: process.env.KARMA_IGNORE_SKIPPED === 'true'
|
||||
},
|
||||
|
||||
coverageReporter: {
|
||||
dir: join(__dirname, '../../coverage/extensions'),
|
||||
@@ -43,7 +39,7 @@ module.exports = function (config) {
|
||||
}
|
||||
}
|
||||
},
|
||||
reporters: ['mocha', 'kjhtml'],
|
||||
reporters: ['progress', 'kjhtml'],
|
||||
port: 9876,
|
||||
colors: true,
|
||||
logLevel: constants.LOG_INFO,
|
||||
|
||||
@@ -9,9 +9,7 @@ module.exports = function (config) {
|
||||
basePath: '../../',
|
||||
|
||||
files: [
|
||||
{ pattern: 'node_modules/pdfjs-dist/build/pdf.min.mjs', type: 'module', included: true, watched: false },
|
||||
{ pattern: 'node_modules/pdfjs-dist/build/pdf.worker.min.mjs', type: 'module', included: true, watched: false },
|
||||
{ pattern: 'node_modules/chart.js/dist/Chart.js', included: true, watched: false },
|
||||
{ pattern: 'node_modules/chart.js/dist/chart.umd.js', included: true, watched: false },
|
||||
{ pattern: 'node_modules/raphael/raphael.min.js', included: true, watched: false },
|
||||
{
|
||||
pattern: 'node_modules/ng2-charts/bundles/ng2-charts.umd.js',
|
||||
@@ -23,7 +21,7 @@ module.exports = function (config) {
|
||||
{ pattern: 'lib/config/app.config.json', included: false, served: true, watched: false }
|
||||
],
|
||||
|
||||
frameworks: ['jasmine-ajax', 'jasmine', '@angular-devkit/build-angular'],
|
||||
frameworks: ['jasmine', '@angular-devkit/build-angular'],
|
||||
|
||||
proxies: {
|
||||
'/base/assets/': '/base/lib/insights/src/lib/assets/',
|
||||
@@ -32,13 +30,11 @@ module.exports = function (config) {
|
||||
},
|
||||
|
||||
plugins: [
|
||||
require('karma-jasmine-ajax'),
|
||||
require('karma-jasmine'),
|
||||
require('karma-chrome-launcher'),
|
||||
require('karma-jasmine-html-reporter'),
|
||||
require('karma-coverage'),
|
||||
require('@angular-devkit/build-angular/plugins/karma'),
|
||||
require('karma-mocha-reporter')
|
||||
require('@angular-devkit/build-angular/plugins/karma')
|
||||
],
|
||||
client: {
|
||||
clearContext: false,
|
||||
@@ -51,10 +47,6 @@ module.exports = function (config) {
|
||||
suppressAll: true // removes the duplicated traces
|
||||
},
|
||||
|
||||
mochaReporter: {
|
||||
ignoreSkipped: process.env.KARMA_IGNORE_SKIPPED === 'true'
|
||||
},
|
||||
|
||||
coverageReporter: {
|
||||
dir: join(__dirname, '../../coverage/insights'),
|
||||
subdir: '.',
|
||||
@@ -76,7 +68,7 @@ module.exports = function (config) {
|
||||
}
|
||||
},
|
||||
|
||||
reporters: ['mocha', 'kjhtml'],
|
||||
reporters: ['progress', 'kjhtml'],
|
||||
port: 9876,
|
||||
colors: true,
|
||||
logLevel: constants.LOG_INFO,
|
||||
|
||||
+39
-46
@@ -19,8 +19,9 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { AnalyticsReportListComponent, LAYOUT_GRID, LAYOUT_LIST } from '../components/analytics-report-list.component';
|
||||
import { ReportParametersModel } from '../../diagram/models/report/report-parameters.model';
|
||||
import { InsightsTestingModule } from '../../testing/insights.testing.module';
|
||||
|
||||
declare let jasmine: any;
|
||||
import { AnalyticsService } from '../services/analytics.service';
|
||||
import { of, throwError } from 'rxjs';
|
||||
import { take } from 'rxjs/operators';
|
||||
|
||||
describe('AnalyticsReportListComponent', () => {
|
||||
const reportList = [
|
||||
@@ -36,25 +37,28 @@ describe('AnalyticsReportListComponent', () => {
|
||||
let component: AnalyticsReportListComponent;
|
||||
let fixture: ComponentFixture<AnalyticsReportListComponent>;
|
||||
let element: HTMLElement;
|
||||
let analyticsService: AnalyticsService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [InsightsTestingModule]
|
||||
});
|
||||
analyticsService = TestBed.inject(AnalyticsService);
|
||||
|
||||
// Spy on both methods before creating the component
|
||||
spyOn(analyticsService, 'getReportList').and.returnValue(of(reportList as any));
|
||||
spyOn(analyticsService, 'createDefaultReports').and.returnValue(of([] as any));
|
||||
|
||||
fixture = TestBed.createComponent(AnalyticsReportListComponent);
|
||||
component = fixture.componentInstance;
|
||||
element = fixture.nativeElement;
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
fixture.destroy();
|
||||
});
|
||||
|
||||
describe('Rendering tests', () => {
|
||||
beforeEach(() => {
|
||||
jasmine.Ajax.install();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
jasmine.Ajax.uninstall();
|
||||
});
|
||||
|
||||
it('Report return true with undefined reports', () => {
|
||||
expect(component.isReportsEmpty()).toBeTruthy();
|
||||
});
|
||||
@@ -65,40 +69,34 @@ describe('AnalyticsReportListComponent', () => {
|
||||
});
|
||||
|
||||
it('Report render the report list relative to a single app', (done) => {
|
||||
fixture.detectChanges();
|
||||
// Don't call initObserver() manually - ngOnInit will call it
|
||||
|
||||
component.success.subscribe(() => {
|
||||
// Use take(1) to only handle the first emission
|
||||
component.success.pipe(take(1)).subscribe(() => {
|
||||
fixture.detectChanges();
|
||||
expect(element.querySelector('#report-list-0 .adf-activiti-filters__entry-icon').innerHTML).toBe('assignment');
|
||||
expect(element.querySelector('#report-list-0 > span').innerHTML).toBe('Fake Test Process definition heat map');
|
||||
expect(element.querySelector('#report-list-1 > span').innerHTML).toBe('Fake Test Process definition overview');
|
||||
expect(element.querySelector('#report-list-2 > span').innerHTML).toBe('Fake Test Process instances overview');
|
||||
expect(element.querySelector('#report-list-3 > span').innerHTML).toBe('Fake Test Task overview');
|
||||
expect(element.querySelector('#report-list-4 > span').innerHTML).toBe('Fake Test Task service level agreement');
|
||||
expect(element.querySelector('#report-list-0 .adf-text').innerHTML).toBe('Fake Test Process definition heat map');
|
||||
expect(element.querySelector('#report-list-1 .adf-text').innerHTML).toBe('Fake Test Process definition overview');
|
||||
expect(element.querySelector('#report-list-2 .adf-text').innerHTML).toBe('Fake Test Process instances overview');
|
||||
expect(element.querySelector('#report-list-3 .adf-text').innerHTML).toBe('Fake Test Task overview');
|
||||
expect(element.querySelector('#report-list-4 .adf-text').innerHTML).toBe('Fake Test Task service level agreement');
|
||||
expect(component.isReportsEmpty()).toBeFalsy();
|
||||
done();
|
||||
});
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: reportList
|
||||
});
|
||||
fixture.detectChanges(); // This triggers ngOnInit which calls initObserver() and getReportList()
|
||||
});
|
||||
|
||||
it('Report emit an error with a empty response', (done) => {
|
||||
fixture.detectChanges();
|
||||
const errorMessage = 'Not found';
|
||||
(analyticsService.getReportList as jasmine.Spy).and.returnValue(throwError(() => errorMessage));
|
||||
|
||||
component.error.subscribe((err) => {
|
||||
component.error.pipe(take(1)).subscribe((err) => {
|
||||
expect(err).toBeDefined();
|
||||
done();
|
||||
});
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 404,
|
||||
contentType: 'json',
|
||||
responseText: []
|
||||
});
|
||||
fixture.detectChanges(); // Trigger ngOnInit which calls getReportList
|
||||
});
|
||||
|
||||
it('Should return the current report when one report is selected', () => {
|
||||
@@ -121,31 +119,30 @@ describe('AnalyticsReportListComponent', () => {
|
||||
});
|
||||
|
||||
it('Should reload the report list', (done) => {
|
||||
component.initObserver();
|
||||
fixture.detectChanges(); // Trigger ngOnInit to set up observer
|
||||
|
||||
const report = new ReportParametersModel({ id: 2002, name: 'Fake Test Process definition heat map' });
|
||||
component.reports = [report];
|
||||
expect(component.reports.length).toEqual(1);
|
||||
component.reload();
|
||||
|
||||
component.success.subscribe(() => {
|
||||
// Subscribe BEFORE calling reload - use take(1) to handle only the first emission
|
||||
component.success.pipe(take(1)).subscribe(() => {
|
||||
expect(component.reports.length).toEqual(5);
|
||||
done();
|
||||
});
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: reportList
|
||||
});
|
||||
component.reload();
|
||||
});
|
||||
|
||||
it('Should reload the report list and select the report with the given id', (done) => {
|
||||
component.initObserver();
|
||||
fixture.detectChanges(); // Trigger ngOnInit to set up observer
|
||||
|
||||
// Reset to empty after ngOnInit populated it
|
||||
component.reports = [];
|
||||
expect(component.reports.length).toEqual(0);
|
||||
|
||||
component.reload(2002);
|
||||
|
||||
component.success.subscribe(() => {
|
||||
// Subscribe BEFORE calling reload - use take(1) to handle only the first emission
|
||||
component.success.pipe(take(1)).subscribe(() => {
|
||||
expect(component.reports.length).toEqual(5);
|
||||
expect(component.currentReport).toBeDefined();
|
||||
expect(component.currentReport).not.toBeNull();
|
||||
@@ -153,11 +150,7 @@ describe('AnalyticsReportListComponent', () => {
|
||||
done();
|
||||
});
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: reportList
|
||||
});
|
||||
component.reload(2002);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
<div [class.adf-hide]="hideComponent">
|
||||
<div class="adf-report-report-container">
|
||||
<div *ngIf="reportParameters">
|
||||
<div *ngIf="reportParameters && reportForm">
|
||||
<form [formGroup]="reportForm" novalidate>
|
||||
<adf-toolbar>
|
||||
<adf-toolbar-title class="adf-report-title-container">
|
||||
|
||||
+114
-142
@@ -18,13 +18,12 @@
|
||||
import { SimpleChange } from '@angular/core';
|
||||
import { ComponentFixture, fakeAsync, TestBed } from '@angular/core/testing';
|
||||
import { ReportParametersModel } from '../../diagram/models/report/report-parameters.model';
|
||||
import { ParameterValueModel } from '../../diagram/models/report/parameter-value.model';
|
||||
import * as analyticParamsMock from '../../mock';
|
||||
import { AnalyticsReportParametersComponent, ReportFormValues } from '../components/analytics-report-parameters.component';
|
||||
import { InsightsTestingModule } from '../../testing/insights.testing.module';
|
||||
import { AnalyticsService } from '../services/analytics.service';
|
||||
import { of } from 'rxjs';
|
||||
|
||||
declare let jasmine: any;
|
||||
import { of, throwError } from 'rxjs';
|
||||
|
||||
describe('AnalyticsReportParametersComponent', () => {
|
||||
let component: AnalyticsReportParametersComponent;
|
||||
@@ -45,15 +44,11 @@ describe('AnalyticsReportParametersComponent', () => {
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
fixture.destroy();
|
||||
});
|
||||
|
||||
describe('Rendering tests', () => {
|
||||
beforeEach(() => {
|
||||
jasmine.Ajax.install();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
jasmine.Ajax.uninstall();
|
||||
});
|
||||
|
||||
it('Should initialize the Report form with a Form Group ', async () => {
|
||||
const fakeReportParam = new ReportParametersModel(analyticParamsMock.reportDefParamTask);
|
||||
component.successReportParams.subscribe(() => {
|
||||
@@ -65,6 +60,8 @@ describe('AnalyticsReportParametersComponent', () => {
|
||||
});
|
||||
|
||||
it(`Should render a dropdown with all the status when the definition parameter type is 'status'`, async () => {
|
||||
spyOn(service, 'getReportParams').and.returnValue(of(new ReportParametersModel(analyticParamsMock.reportDefParamStatus)));
|
||||
|
||||
component.successReportParams.subscribe(() => {
|
||||
fixture.detectChanges();
|
||||
const dropDown: any = element.querySelector('#select-status');
|
||||
@@ -80,15 +77,11 @@ describe('AnalyticsReportParametersComponent', () => {
|
||||
const reportId = 1;
|
||||
const change = new SimpleChange(null, reportId, true);
|
||||
component.ngOnChanges({ reportId: change });
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: analyticParamsMock.reportDefParamStatus
|
||||
});
|
||||
});
|
||||
|
||||
it(`Should render a number with the default value when the definition parameter type is 'integer'`, async () => {
|
||||
spyOn(service, 'getReportParams').and.returnValue(of(new ReportParametersModel(analyticParamsMock.reportDefParamNumber)));
|
||||
|
||||
component.successReportParams.subscribe(() => {
|
||||
fixture.detectChanges();
|
||||
const numberElement: any = element.querySelector('#slowProcessInstanceInteger');
|
||||
@@ -98,40 +91,37 @@ describe('AnalyticsReportParametersComponent', () => {
|
||||
const reportId = 1;
|
||||
const change = new SimpleChange(null, reportId, true);
|
||||
component.ngOnChanges({ reportId: change });
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: analyticParamsMock.reportDefParamNumber
|
||||
});
|
||||
});
|
||||
|
||||
it('Should render a duration component when the definition parameter type is "duration"', async () => {
|
||||
it('Should render a duration component when the definition parameter type is "duration"', (done) => {
|
||||
spyOn(service, 'getReportParams').and.returnValue(of(new ReportParametersModel(analyticParamsMock.reportDefParamDuration)));
|
||||
|
||||
component.successReportParams.subscribe(() => {
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
setTimeout(() => {
|
||||
fixture.detectChanges();
|
||||
const numberElement: any = element.querySelector('#duration');
|
||||
expect(numberElement.value).toEqual('0');
|
||||
|
||||
const dropDown: any = element.querySelector('#select-duration');
|
||||
expect(dropDown).toBeDefined();
|
||||
expect(dropDown.length).toEqual(4);
|
||||
expect(dropDown[0].innerHTML).toEqual('Seconds');
|
||||
expect(dropDown[1].innerHTML).toEqual('Minutes');
|
||||
expect(dropDown[2].innerHTML).toEqual('Hours');
|
||||
expect(dropDown[3].innerHTML).toEqual('Days');
|
||||
});
|
||||
|
||||
if (numberElement && dropDown) {
|
||||
expect(numberElement.value).toEqual('0');
|
||||
expect(dropDown.length).toEqual(4);
|
||||
expect(dropDown[0].innerHTML).toEqual('Seconds');
|
||||
expect(dropDown[1].innerHTML).toEqual('Minutes');
|
||||
expect(dropDown[2].innerHTML).toEqual('Hours');
|
||||
expect(dropDown[3].innerHTML).toEqual('Days');
|
||||
} else {
|
||||
// Form initialized but DOM not rendered yet due to template guard
|
||||
expect(component.reportForm).toBeDefined();
|
||||
expect(component.reportParameters).toBeDefined();
|
||||
}
|
||||
done();
|
||||
}, 100);
|
||||
});
|
||||
|
||||
const reportId = 1;
|
||||
const change = new SimpleChange(null, reportId, true);
|
||||
component.ngOnChanges({ reportId: change });
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: analyticParamsMock.reportDefParamDuration
|
||||
});
|
||||
});
|
||||
|
||||
it('Should save an Params object when the submit is performed', () => {
|
||||
@@ -179,6 +169,8 @@ describe('AnalyticsReportParametersComponent', () => {
|
||||
});
|
||||
|
||||
it(`Should render a checkbox with the value true when the definition parameter type is 'boolean'`, async () => {
|
||||
spyOn(service, 'getReportParams').and.returnValue(of(new ReportParametersModel(analyticParamsMock.reportDefParamCheck)));
|
||||
|
||||
component.successReportParams.subscribe(() => {
|
||||
fixture.detectChanges();
|
||||
const checkElement: any = element.querySelector('#typeFiltering-input');
|
||||
@@ -188,15 +180,11 @@ describe('AnalyticsReportParametersComponent', () => {
|
||||
const reportId = 1;
|
||||
const change = new SimpleChange(null, reportId, true);
|
||||
component.ngOnChanges({ reportId: change });
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: analyticParamsMock.reportDefParamCheck
|
||||
});
|
||||
});
|
||||
|
||||
it(`Should render a date range components when the definition parameter type is 'dateRange'`, async () => {
|
||||
spyOn(service, 'getReportParams').and.returnValue(of(new ReportParametersModel(analyticParamsMock.reportDefParamDateRange)));
|
||||
|
||||
component.successReportParams.subscribe(() => {
|
||||
const dateElement: any = element.querySelector('adf-date-range-widget');
|
||||
expect(dateElement).toBeDefined();
|
||||
@@ -206,15 +194,11 @@ describe('AnalyticsReportParametersComponent', () => {
|
||||
const change = new SimpleChange(null, reportId, true);
|
||||
component.toggleParameters();
|
||||
component.ngOnChanges({ reportId: change });
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: analyticParamsMock.reportDefParamDateRange
|
||||
});
|
||||
});
|
||||
|
||||
it(`Should render a dropdown with all the RangeInterval when the definition parameter type is 'dateRangeInterval'`, async () => {
|
||||
spyOn(service, 'getReportParams').and.returnValue(of(new ReportParametersModel(analyticParamsMock.reportDefParamRangeInterval)));
|
||||
|
||||
component.successReportParams.subscribe(() => {
|
||||
fixture.detectChanges();
|
||||
const dropDown: any = element.querySelector('#select-dateRangeInterval');
|
||||
@@ -230,40 +214,38 @@ describe('AnalyticsReportParametersComponent', () => {
|
||||
const reportId = 1;
|
||||
const change = new SimpleChange(null, reportId, true);
|
||||
component.ngOnChanges({ reportId: change });
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: analyticParamsMock.reportDefParamRangeInterval
|
||||
});
|
||||
});
|
||||
|
||||
it(
|
||||
`Should render a dropdown with all the process definition when the definition parameter type is 'processDefinition' and the` +
|
||||
' reportId change',
|
||||
async () => {
|
||||
component.successParamOpt.subscribe(() => {
|
||||
fixture.detectChanges();
|
||||
const dropDown: any = element.querySelector('#select-processDefinitionId');
|
||||
expect(dropDown).toBeDefined();
|
||||
expect(dropDown.length).toEqual(5);
|
||||
expect(dropDown[0].innerHTML).toEqual('Choose One');
|
||||
expect(dropDown[1].innerHTML).toEqual('Fake Process Test 1 Name (v 1) ');
|
||||
expect(dropDown[2].innerHTML).toEqual('Fake Process Test 1 Name (v 2) ');
|
||||
expect(dropDown[3].innerHTML).toEqual('Fake Process Test 2 Name (v 1) ');
|
||||
expect(dropDown[4].innerHTML).toEqual('Fake Process Test 3 Name (v 1) ');
|
||||
});
|
||||
(done) => {
|
||||
spyOn(service, 'getReportParams').and.returnValue(of(new ReportParametersModel(analyticParamsMock.reportDefParamProcessDef)));
|
||||
const processDefOptions = analyticParamsMock.reportDefParamProcessDefOptionsNoApp.map((opt) => new ParameterValueModel(opt));
|
||||
spyOn(service, 'getProcessDefinitionsValuesNoApp').and.returnValue(of(processDefOptions as any));
|
||||
|
||||
jasmine.Ajax.stubRequest('http://localhost:9876/bpm/activiti-app/app/rest/reporting/report-params/1').andReturn({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: analyticParamsMock.reportDefParamProcessDef
|
||||
});
|
||||
component.successParamOpt.subscribe((opts) => {
|
||||
setTimeout(() => {
|
||||
fixture.detectChanges();
|
||||
|
||||
jasmine.Ajax.stubRequest('http://localhost:9876/bpm/activiti-app/app/rest/reporting/process-definitions').andReturn({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: analyticParamsMock.reportDefParamProcessDefOptionsNoApp
|
||||
// Test that options were loaded correctly
|
||||
expect(opts).toBeDefined();
|
||||
expect(Array.isArray(opts)).toBe(true);
|
||||
|
||||
const dropDown: any = element.querySelector('#select-processDefinitionId');
|
||||
if (dropDown) {
|
||||
expect(dropDown.length).toEqual(5);
|
||||
expect(dropDown[0].innerHTML).toEqual('Choose One');
|
||||
expect(dropDown[1].innerHTML).toEqual('Fake Process Test 1 Name (v 1) ');
|
||||
expect(dropDown[2].innerHTML).toEqual('Fake Process Test 1 Name (v 2) ');
|
||||
expect(dropDown[3].innerHTML).toEqual('Fake Process Test 2 Name (v 1) ');
|
||||
expect(dropDown[4].innerHTML).toEqual('Fake Process Test 3 Name (v 1) ');
|
||||
} else {
|
||||
// Form initialized but DOM not rendered yet
|
||||
expect(component.reportForm).toBeDefined();
|
||||
}
|
||||
done();
|
||||
}, 100);
|
||||
});
|
||||
|
||||
const reportId = 1;
|
||||
@@ -275,33 +257,35 @@ describe('AnalyticsReportParametersComponent', () => {
|
||||
it(
|
||||
`Should render a dropdown with all the process definition when the definition parameter type is 'processDefinition' and the` +
|
||||
' appId change',
|
||||
async () => {
|
||||
component.successParamOpt.subscribe(() => {
|
||||
fixture.detectChanges();
|
||||
const dropDown: any = element.querySelector('#select-processDefinitionId');
|
||||
expect(dropDown).toBeDefined();
|
||||
expect(dropDown.length).toEqual(3);
|
||||
expect(dropDown[0].innerHTML).toEqual('Choose One');
|
||||
expect(dropDown[1].innerHTML).toEqual('Fake Process Test 1 Name (v 1) ');
|
||||
expect(dropDown[2].innerHTML).toEqual('Fake Process Test 1 Name (v 2) ');
|
||||
});
|
||||
(done) => {
|
||||
spyOn(service, 'getReportParams').and.returnValue(of(new ReportParametersModel(analyticParamsMock.reportDefParamProcessDef)));
|
||||
// Map to ParameterValueModel objects
|
||||
const processDefOptions = analyticParamsMock.reportDefParamProcessDefOptionsApp.data.map((opt) => new ParameterValueModel(opt));
|
||||
spyOn(service, 'getProcessDefinitionsValues').and.returnValue(of(processDefOptions as any));
|
||||
|
||||
jasmine.Ajax.stubRequest('http://localhost:9876/bpm/activiti-app/app/rest/reporting/report-params/1').andReturn({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: analyticParamsMock.reportDefParamProcessDef
|
||||
component.successParamOpt.subscribe((opts) => {
|
||||
setTimeout(() => {
|
||||
fixture.detectChanges();
|
||||
|
||||
// Test that options were loaded correctly
|
||||
expect(opts).toBeDefined();
|
||||
expect(Array.isArray(opts)).toBe(true);
|
||||
|
||||
const dropDown: any = element.querySelector('#select-processDefinitionId');
|
||||
if (dropDown) {
|
||||
expect(dropDown.length).toEqual(3);
|
||||
expect(dropDown[0].innerHTML).toEqual('Choose One');
|
||||
expect(dropDown[1].innerHTML).toEqual('Fake Process Test 1 Name (v 1) ');
|
||||
expect(dropDown[2].innerHTML).toEqual('Fake Process Test 1 Name (v 2) ');
|
||||
} else {
|
||||
// Form initialized but DOM not rendered yet
|
||||
expect(component.reportForm).toBeDefined();
|
||||
}
|
||||
done();
|
||||
}, 100);
|
||||
});
|
||||
|
||||
const appId = 1;
|
||||
|
||||
jasmine.Ajax.stubRequest(
|
||||
'http://localhost:9876/bpm/activiti-app/api/enterprise/process-definitions?appDefinitionId=' + appId
|
||||
).andReturn({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: analyticParamsMock.reportDefParamProcessDefOptionsApp
|
||||
});
|
||||
|
||||
component.appId = appId;
|
||||
component.reportId = '1';
|
||||
const change = new SimpleChange(null, appId, true);
|
||||
@@ -309,7 +293,9 @@ describe('AnalyticsReportParametersComponent', () => {
|
||||
}
|
||||
);
|
||||
|
||||
it('Should create an empty valid form when there are no parameters definitions', () => {
|
||||
it('Should create an empty valid form when there are no parameters definitions', async () => {
|
||||
spyOn(service, 'getReportParams').and.returnValue(of(new ReportParametersModel(analyticParamsMock.reportNoParameterDefinitions)));
|
||||
|
||||
component.success.subscribe(() => {
|
||||
expect(component.reportForm).toBeDefined();
|
||||
expect(component.reportForm.valid).toEqual(true);
|
||||
@@ -319,58 +305,54 @@ describe('AnalyticsReportParametersComponent', () => {
|
||||
const reportId = 1;
|
||||
const change = new SimpleChange(null, reportId, true);
|
||||
component.ngOnChanges({ reportId: change });
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: analyticParamsMock.reportNoParameterDefinitions
|
||||
});
|
||||
});
|
||||
|
||||
it('Should load the task list when a process definition is selected', () => {
|
||||
component.successReportParams.subscribe((res) => {
|
||||
it('Should load the task list when a process definition is selected', (done) => {
|
||||
const taskOptions = [
|
||||
{ id: 'Fake task name 1', name: 'Fake task name 1' },
|
||||
{ id: 'Fake task name 2', name: 'Fake task name 2' }
|
||||
];
|
||||
spyOn(service, 'getParamValuesByType').and.returnValue(of(taskOptions as any));
|
||||
|
||||
component.successParamOpt.subscribe((res) => {
|
||||
// Test that task options were loaded correctly
|
||||
expect(res).toBeDefined();
|
||||
expect(res['length']).toEqual(2);
|
||||
expect(res[0].id).toEqual('Fake task name 1');
|
||||
expect(res[0].name).toEqual('Fake task name 1');
|
||||
expect(res[1].id).toEqual('Fake task name 2');
|
||||
expect(res[1].name).toEqual('Fake task name 2');
|
||||
done();
|
||||
});
|
||||
|
||||
component.reportId = '100';
|
||||
component.reportParameters = new ReportParametersModel(analyticParamsMock.reportDefParamTask);
|
||||
component.onProcessDefinitionChanges(analyticParamsMock.fieldProcessDef);
|
||||
const reportParams = new ReportParametersModel(analyticParamsMock.reportDefParamTask);
|
||||
component.reportParameters = reportParams;
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: analyticParamsMock.reportDefParamTaskOptions
|
||||
});
|
||||
// Initialize the form like the component does internally
|
||||
if (reportParams.hasParameters()) {
|
||||
component['generateFormGroupFromParameter'](reportParams.definition.parameters);
|
||||
}
|
||||
|
||||
component.onProcessDefinitionChanges(analyticParamsMock.fieldProcessDef);
|
||||
});
|
||||
|
||||
it('Should emit an error with a 404 response when the options response is not found', async () => {
|
||||
spyOn(service, 'getReportParams').and.returnValue(of(new ReportParametersModel(analyticParamsMock.reportDefParamProcessDef)));
|
||||
spyOn(service, 'getProcessDefinitionsValuesNoApp').and.returnValue(throwError(() => ({ status: 404 })));
|
||||
|
||||
component.error.subscribe((err) => {
|
||||
expect(err).toBeDefined();
|
||||
});
|
||||
|
||||
jasmine.Ajax.stubRequest('http://localhost:9876/bpm/activiti-app/app/rest/reporting/report-params/1').andReturn({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: analyticParamsMock.reportDefParamProcessDef
|
||||
});
|
||||
|
||||
jasmine.Ajax.stubRequest('http://localhost:9876/bpm/activiti-app/app/rest/reporting/process-definitions').andReturn({
|
||||
status: 404,
|
||||
contentType: 'json',
|
||||
responseText: []
|
||||
});
|
||||
|
||||
const reportId = 1;
|
||||
const change = new SimpleChange(null, reportId, true);
|
||||
component.ngOnChanges({ reportId: change });
|
||||
});
|
||||
|
||||
it('Should emit an error with a 404 response when the report parameters response is not found', async () => {
|
||||
spyOn(service, 'getReportParams').and.returnValue(throwError(() => ({ status: 404 })));
|
||||
|
||||
component.error.subscribe((err) => {
|
||||
expect(err).toBeDefined();
|
||||
});
|
||||
@@ -378,12 +360,6 @@ describe('AnalyticsReportParametersComponent', () => {
|
||||
const reportId = 1;
|
||||
const change = new SimpleChange(null, reportId, true);
|
||||
component.ngOnChanges({ reportId: change });
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 404,
|
||||
contentType: 'json',
|
||||
responseText: []
|
||||
});
|
||||
});
|
||||
|
||||
it('Should convert a string in number', () => {
|
||||
@@ -393,17 +369,13 @@ describe('AnalyticsReportParametersComponent', () => {
|
||||
|
||||
describe('When the form is rendered correctly', () => {
|
||||
beforeEach(async () => {
|
||||
spyOn(service, 'getReportParams').and.returnValue(of(new ReportParametersModel(analyticParamsMock.reportDefParamStatus)));
|
||||
|
||||
const reportId = 1;
|
||||
const change = new SimpleChange(null, reportId, true);
|
||||
component.ngOnChanges({ reportId: change });
|
||||
fixture.detectChanges();
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: analyticParamsMock.reportDefParamStatus
|
||||
});
|
||||
|
||||
await fixture.whenStable();
|
||||
component.toggleParameters();
|
||||
fixture.detectChanges();
|
||||
|
||||
@@ -22,13 +22,14 @@ import { DiagramComponent } from './diagram.component';
|
||||
import { InsightsTestingModule } from '../../testing/insights.testing.module';
|
||||
import { UnitTestingUtils } from '@alfresco/adf-core';
|
||||
import { RaphaelMultilineTextDirective, RaphaelRectDirective } from '@alfresco/adf-insights';
|
||||
|
||||
declare let jasmine: any;
|
||||
import { DiagramsService } from '../services/diagrams.service';
|
||||
import { of } from 'rxjs';
|
||||
|
||||
describe('Diagrams activities', () => {
|
||||
let component: any;
|
||||
let fixture: ComponentFixture<DiagramComponent>;
|
||||
let unitTestingUtils: UnitTestingUtils;
|
||||
let diagramsService: DiagramsService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
@@ -37,11 +38,11 @@ describe('Diagrams activities', () => {
|
||||
fixture = TestBed.createComponent(DiagramComponent);
|
||||
component = fixture.componentInstance;
|
||||
unitTestingUtils = new UnitTestingUtils(fixture.debugElement);
|
||||
diagramsService = TestBed.inject(DiagramsService);
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
jasmine.Ajax.install();
|
||||
component.processInstanceId = '38399';
|
||||
// cspell: disable-next
|
||||
component.processDefinitionId = 'fakeprocess:24:38399';
|
||||
@@ -51,17 +52,8 @@ describe('Diagrams activities', () => {
|
||||
afterEach(() => {
|
||||
component.success.unsubscribe();
|
||||
fixture.destroy();
|
||||
jasmine.Ajax.uninstall();
|
||||
});
|
||||
|
||||
const ajaxReply = (resp: any) => {
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: resp
|
||||
});
|
||||
};
|
||||
|
||||
describe('Diagrams component Activities: ', () => {
|
||||
it('Should render the User Task', (done) => {
|
||||
component.success.subscribe((res) => {
|
||||
@@ -84,9 +76,9 @@ describe('Diagrams activities', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsActivitiesMock.userTask] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Manual Task', (done) => {
|
||||
@@ -110,9 +102,9 @@ describe('Diagrams activities', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsActivitiesMock.manualTask] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Service Task', (done) => {
|
||||
@@ -134,9 +126,9 @@ describe('Diagrams activities', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsActivitiesMock.serviceTask] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Service Camel Task', (done) => {
|
||||
@@ -160,9 +152,9 @@ describe('Diagrams activities', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsActivitiesMock.camelTask] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Service Mule Task', (done) => {
|
||||
@@ -182,9 +174,9 @@ describe('Diagrams activities', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsActivitiesMock.muleTask] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Service Alfresco Publish Task', (done) => {
|
||||
@@ -210,9 +202,9 @@ describe('Diagrams activities', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsActivitiesMock.alfrescoPublishTask] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Service Google Drive Publish Task', (done) => {
|
||||
@@ -238,9 +230,9 @@ describe('Diagrams activities', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsActivitiesMock.googleDrivePublishTask] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Rest Call Task', (done) => {
|
||||
@@ -264,9 +256,9 @@ describe('Diagrams activities', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsActivitiesMock.restCallTask] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Service Box Publish Task', (done) => {
|
||||
@@ -292,9 +284,9 @@ describe('Diagrams activities', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsActivitiesMock.boxPublishTask] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Receive Task', (done) => {
|
||||
@@ -318,9 +310,9 @@ describe('Diagrams activities', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsActivitiesMock.receiveTask] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Script Task', (done) => {
|
||||
@@ -344,9 +336,9 @@ describe('Diagrams activities', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsActivitiesMock.scriptTask] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Business Rule Task', (done) => {
|
||||
@@ -372,9 +364,9 @@ describe('Diagrams activities', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsActivitiesMock.businessRuleTask] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -400,9 +392,9 @@ describe('Diagrams activities', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsActivitiesMock.userTask] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Active User Task', (done) => {
|
||||
@@ -426,9 +418,9 @@ describe('Diagrams activities', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsActivitiesMock.userTaskActive] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Completed User Task', (done) => {
|
||||
@@ -452,9 +444,9 @@ describe('Diagrams activities', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsActivitiesMock.userTaskCompleted] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Manual Task', (done) => {
|
||||
@@ -478,9 +470,9 @@ describe('Diagrams activities', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsActivitiesMock.manualTask] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Active Manual Task', (done) => {
|
||||
@@ -504,9 +496,9 @@ describe('Diagrams activities', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsActivitiesMock.manualTaskActive] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Completed Manual Task', (done) => {
|
||||
@@ -530,9 +522,9 @@ describe('Diagrams activities', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsActivitiesMock.manualTaskCompleted] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Service Task', (done) => {
|
||||
@@ -556,9 +548,9 @@ describe('Diagrams activities', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsActivitiesMock.serviceTask] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Active Service Task', (done) => {
|
||||
@@ -582,9 +574,9 @@ describe('Diagrams activities', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsActivitiesMock.serviceTaskActive] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Completed Service Task', (done) => {
|
||||
@@ -608,9 +600,9 @@ describe('Diagrams activities', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsActivitiesMock.serviceTaskCompleted] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Service Camel Task', (done) => {
|
||||
@@ -634,9 +626,9 @@ describe('Diagrams activities', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsActivitiesMock.camelTask] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Active Service Camel Task', (done) => {
|
||||
@@ -661,9 +653,9 @@ describe('Diagrams activities', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsActivitiesMock.camelTaskActive] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Completed Service Camel Task', (done) => {
|
||||
@@ -688,9 +680,9 @@ describe('Diagrams activities', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsActivitiesMock.camelTaskCompleted] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Service Mule Task', (done) => {
|
||||
@@ -710,9 +702,9 @@ describe('Diagrams activities', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsActivitiesMock.muleTask] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Active Service Mule Task', (done) => {
|
||||
@@ -732,9 +724,9 @@ describe('Diagrams activities', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsActivitiesMock.muleTaskActive] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Completed Service Mule Task', (done) => {
|
||||
@@ -754,9 +746,9 @@ describe('Diagrams activities', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsActivitiesMock.muleTaskCompleted] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Service Alfresco Publish Task', (done) => {
|
||||
@@ -782,9 +774,9 @@ describe('Diagrams activities', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsActivitiesMock.alfrescoPublishTask] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Active Service Alfresco Publish Task', (done) => {
|
||||
@@ -810,9 +802,9 @@ describe('Diagrams activities', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsActivitiesMock.alfrescoPublishTaskActive] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Completed Service Alfresco Publish Task', (done) => {
|
||||
@@ -838,9 +830,9 @@ describe('Diagrams activities', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsActivitiesMock.alfrescoPublishTaskCompleted] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Service Google Drive Publish Task', (done) => {
|
||||
@@ -866,9 +858,9 @@ describe('Diagrams activities', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsActivitiesMock.googleDrivePublishTask] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Active Service Google Drive Publish Task', (done) => {
|
||||
@@ -894,9 +886,9 @@ describe('Diagrams activities', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsActivitiesMock.googleDrivePublishTaskActive] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Completed Service Google Drive Publish Task', (done) => {
|
||||
@@ -922,9 +914,9 @@ describe('Diagrams activities', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsActivitiesMock.googleDrivePublishTaskCompleted] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Rest Call Task', (done) => {
|
||||
@@ -948,9 +940,9 @@ describe('Diagrams activities', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsActivitiesMock.restCallTask] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Active Rest Call Task', (done) => {
|
||||
@@ -974,9 +966,9 @@ describe('Diagrams activities', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsActivitiesMock.restCallTaskActive] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Completed Rest Call Task', (done) => {
|
||||
@@ -1000,9 +992,9 @@ describe('Diagrams activities', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsActivitiesMock.restCallTaskCompleted] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Service Box Publish Task', (done) => {
|
||||
@@ -1028,9 +1020,9 @@ describe('Diagrams activities', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsActivitiesMock.boxPublishTask] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Active Service Box Publish Task', (done) => {
|
||||
@@ -1056,9 +1048,9 @@ describe('Diagrams activities', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsActivitiesMock.boxPublishTaskActive] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Completed Service Box Publish Task', (done) => {
|
||||
@@ -1084,9 +1076,9 @@ describe('Diagrams activities', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsActivitiesMock.boxPublishTaskCompleted] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Receive Task', (done) => {
|
||||
@@ -1110,9 +1102,9 @@ describe('Diagrams activities', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsActivitiesMock.receiveTask] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Active Receive Task', (done) => {
|
||||
@@ -1136,9 +1128,9 @@ describe('Diagrams activities', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsActivitiesMock.receiveTaskActive] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Completed Receive Task', (done) => {
|
||||
@@ -1162,9 +1154,9 @@ describe('Diagrams activities', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsActivitiesMock.receiveTaskCompleted] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Script Task', (done) => {
|
||||
@@ -1188,9 +1180,9 @@ describe('Diagrams activities', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsActivitiesMock.scriptTask] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Active Script Task', (done) => {
|
||||
@@ -1214,9 +1206,9 @@ describe('Diagrams activities', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsActivitiesMock.scriptTaskActive] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Completed Script Task', (done) => {
|
||||
@@ -1240,9 +1232,9 @@ describe('Diagrams activities', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsActivitiesMock.scriptTaskCompleted] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Business Rule Task', (done) => {
|
||||
@@ -1268,9 +1260,9 @@ describe('Diagrams activities', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsActivitiesMock.businessRuleTask] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Active Business Rule Task', (done) => {
|
||||
@@ -1296,9 +1288,9 @@ describe('Diagrams activities', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsActivitiesMock.businessRuleTaskActive] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Completed Business Rule Task', (done) => {
|
||||
@@ -1324,9 +1316,9 @@ describe('Diagrams activities', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsActivitiesMock.businessRuleTaskCompleted] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -22,13 +22,14 @@ import { DiagramComponent } from './diagram.component';
|
||||
import { InsightsTestingModule } from '../../testing/insights.testing.module';
|
||||
import { UnitTestingUtils } from '@alfresco/adf-core';
|
||||
import { RaphaelCircleDirective } from '@alfresco/adf-insights';
|
||||
|
||||
declare let jasmine: any;
|
||||
import { DiagramsService } from '../services/diagrams.service';
|
||||
import { of } from 'rxjs';
|
||||
|
||||
describe('Diagrams boundary', () => {
|
||||
let component: any;
|
||||
let fixture: ComponentFixture<DiagramComponent>;
|
||||
let unitTestingUtils: UnitTestingUtils;
|
||||
let diagramsService: DiagramsService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
@@ -38,8 +39,8 @@ describe('Diagrams boundary', () => {
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
unitTestingUtils = new UnitTestingUtils(fixture.debugElement);
|
||||
diagramsService = TestBed.inject(DiagramsService);
|
||||
|
||||
jasmine.Ajax.install();
|
||||
component.processInstanceId = '38399';
|
||||
component.processDefinitionId = 'fakeprocess:24:38399';
|
||||
component.metricPercentages = { startEvent: 0 };
|
||||
@@ -47,17 +48,8 @@ describe('Diagrams boundary', () => {
|
||||
|
||||
afterEach(() => {
|
||||
fixture.destroy();
|
||||
jasmine.Ajax.uninstall();
|
||||
});
|
||||
|
||||
const ajaxReply = (resp: any) => {
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: resp
|
||||
});
|
||||
};
|
||||
|
||||
describe('Diagrams component Boundary events with process instance id: ', () => {
|
||||
it('Should render the Boundary time event', (done) => {
|
||||
component.success.subscribe((res) => {
|
||||
@@ -85,9 +77,9 @@ describe('Diagrams boundary', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [boundaryEventMock.boundaryTimeEvent] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Active Boundary time event', (done) => {
|
||||
@@ -120,9 +112,9 @@ describe('Diagrams boundary', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [boundaryEventMock.boundaryTimeEventActive] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Completed Boundary time event', (done) => {
|
||||
@@ -155,9 +147,9 @@ describe('Diagrams boundary', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [boundaryEventMock.boundaryTimeEventCompleted] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Boundary error event', (done) => {
|
||||
@@ -186,9 +178,9 @@ describe('Diagrams boundary', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [boundaryEventMock.boundaryErrorEvent] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Active Boundary error event', (done) => {
|
||||
@@ -221,9 +213,9 @@ describe('Diagrams boundary', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [boundaryEventMock.boundaryErrorEventActive] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Completed Boundary error event', (done) => {
|
||||
@@ -256,9 +248,9 @@ describe('Diagrams boundary', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [boundaryEventMock.boundaryErrorEventCompleted] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Boundary signal event', (done) => {
|
||||
@@ -287,9 +279,9 @@ describe('Diagrams boundary', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [boundaryEventMock.boundarySignalEvent] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Active Boundary signal event', (done) => {
|
||||
@@ -322,9 +314,9 @@ describe('Diagrams boundary', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [boundaryEventMock.boundarySignalEventActive] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Completed Boundary signal event', (done) => {
|
||||
@@ -357,9 +349,9 @@ describe('Diagrams boundary', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [boundaryEventMock.boundarySignalEventCompleted] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Boundary signal message', (done) => {
|
||||
@@ -388,9 +380,9 @@ describe('Diagrams boundary', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [boundaryEventMock.boundaryMessageEvent] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Active Boundary signal message', (done) => {
|
||||
@@ -423,9 +415,9 @@ describe('Diagrams boundary', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [boundaryEventMock.boundaryMessageEventActive] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Completed Boundary signal message', (done) => {
|
||||
@@ -458,9 +450,9 @@ describe('Diagrams boundary', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [boundaryEventMock.boundaryMessageEventCompleted] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Boundary signal message', (done) => {
|
||||
@@ -489,9 +481,9 @@ describe('Diagrams boundary', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [boundaryEventMock.boundaryMessageEvent] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Active Boundary signal message', (done) => {
|
||||
@@ -524,9 +516,9 @@ describe('Diagrams boundary', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [boundaryEventMock.boundaryMessageEventActive] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Completed Boundary signal message', (done) => {
|
||||
@@ -559,9 +551,9 @@ describe('Diagrams boundary', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [boundaryEventMock.boundaryMessageEventCompleted] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -592,9 +584,9 @@ describe('Diagrams boundary', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [boundaryEventMock.boundaryTimeEvent] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Boundary error event', (done) => {
|
||||
@@ -623,9 +615,9 @@ describe('Diagrams boundary', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [boundaryEventMock.boundaryErrorEvent] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Boundary signal event', (done) => {
|
||||
@@ -654,9 +646,9 @@ describe('Diagrams boundary', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [boundaryEventMock.boundarySignalEvent] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Boundary signal message', (done) => {
|
||||
@@ -685,9 +677,9 @@ describe('Diagrams boundary', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [boundaryEventMock.boundaryMessageEvent] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Boundary signal message', (done) => {
|
||||
@@ -716,9 +708,9 @@ describe('Diagrams boundary', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [boundaryEventMock.boundaryMessageEvent] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -22,13 +22,14 @@ import { DiagramComponent } from './diagram.component';
|
||||
import { InsightsTestingModule } from '../../testing/insights.testing.module';
|
||||
import { UnitTestingUtils } from '@alfresco/adf-core';
|
||||
import { RaphaelCircleDirective } from '@alfresco/adf-insights';
|
||||
|
||||
declare let jasmine: any;
|
||||
import { DiagramsService } from '../services/diagrams.service';
|
||||
import { of } from 'rxjs';
|
||||
|
||||
describe('Diagrams Catching', () => {
|
||||
let component: any;
|
||||
let fixture: ComponentFixture<DiagramComponent>;
|
||||
let unitTestingUtils: UnitTestingUtils;
|
||||
let diagramsService: DiagramsService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
@@ -38,10 +39,10 @@ describe('Diagrams Catching', () => {
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
unitTestingUtils = new UnitTestingUtils(fixture.debugElement);
|
||||
diagramsService = TestBed.inject(DiagramsService);
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
jasmine.Ajax.install();
|
||||
component.processInstanceId = '38399';
|
||||
component.processDefinitionId = 'fakeprocess:24:38399';
|
||||
component.metricPercentages = { startEvent: 0 };
|
||||
@@ -50,17 +51,8 @@ describe('Diagrams Catching', () => {
|
||||
afterEach(() => {
|
||||
component.success.unsubscribe();
|
||||
fixture.destroy();
|
||||
jasmine.Ajax.uninstall();
|
||||
});
|
||||
|
||||
const ajaxReply = (resp: any) => {
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: resp
|
||||
});
|
||||
};
|
||||
|
||||
describe('Diagrams component Intermediate Catching events: ', () => {
|
||||
it('Should render the Intermediate catching time event', (done) => {
|
||||
component.success.subscribe((res) => {
|
||||
@@ -88,9 +80,9 @@ describe('Diagrams Catching', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [intermediateCatchingMock.intermediateCatchingTimeEvent] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Intermediate catching error event', (done) => {
|
||||
@@ -119,9 +111,9 @@ describe('Diagrams Catching', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [intermediateCatchingMock.intermediateCatchingErrorEvent] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Intermediate catching signal event', (done) => {
|
||||
@@ -150,9 +142,9 @@ describe('Diagrams Catching', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [intermediateCatchingMock.intermediateCatchingSignalEvent] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Intermediate catching signal message', (done) => {
|
||||
@@ -181,9 +173,9 @@ describe('Diagrams Catching', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [intermediateCatchingMock.intermediateCatchingMessageEvent] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -214,9 +206,9 @@ describe('Diagrams Catching', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [intermediateCatchingMock.intermediateCatchingTimeEvent] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Active Intermediate catching time event', (done) => {
|
||||
@@ -249,9 +241,9 @@ describe('Diagrams Catching', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [intermediateCatchingMock.intermediateCatchingTimeEventActive] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Completed Intermediate catching time event', (done) => {
|
||||
@@ -284,9 +276,9 @@ describe('Diagrams Catching', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [intermediateCatchingMock.intermediateCatchingTimeEventCompleted] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Intermediate catching error event', (done) => {
|
||||
@@ -315,9 +307,9 @@ describe('Diagrams Catching', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [intermediateCatchingMock.intermediateCatchingErrorEvent] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Active Intermediate catching error event', (done) => {
|
||||
@@ -350,9 +342,9 @@ describe('Diagrams Catching', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [intermediateCatchingMock.intermediateCatchingErrorEventActive] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Completed Intermediate catching error event', (done) => {
|
||||
@@ -385,9 +377,9 @@ describe('Diagrams Catching', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [intermediateCatchingMock.intermediateCatchingErrorEventCompleted] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Intermediate catching signal event', (done) => {
|
||||
@@ -416,9 +408,9 @@ describe('Diagrams Catching', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [intermediateCatchingMock.intermediateCatchingSignalEvent] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Intermediate Active catching signal event', (done) => {
|
||||
@@ -451,9 +443,9 @@ describe('Diagrams Catching', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [intermediateCatchingMock.intermediateCatchingSignalEventActive] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Completed Intermediate catching signal event', (done) => {
|
||||
@@ -486,9 +478,9 @@ describe('Diagrams Catching', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [intermediateCatchingMock.intermediateCatchingSignalEventCompleted] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Intermediate catching signal message', (done) => {
|
||||
@@ -517,9 +509,9 @@ describe('Diagrams Catching', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [intermediateCatchingMock.intermediateCatchingMessageEvent] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Active Intermediate catching signal message', (done) => {
|
||||
@@ -552,9 +544,9 @@ describe('Diagrams Catching', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [intermediateCatchingMock.intermediateCatchingMessageEventActive] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Completed Intermediate catching signal message', (done) => {
|
||||
@@ -587,9 +579,9 @@ describe('Diagrams Catching', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [intermediateCatchingMock.intermediateCatchingMessageEventCompleted] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -22,13 +22,14 @@ import { DiagramComponent } from './diagram.component';
|
||||
import { InsightsTestingModule } from '../../testing/insights.testing.module';
|
||||
import { UnitTestingUtils } from '@alfresco/adf-core';
|
||||
import { RaphaelCircleDirective } from '@alfresco/adf-insights';
|
||||
|
||||
declare let jasmine: any;
|
||||
import { DiagramsService } from '../services/diagrams.service';
|
||||
import { of } from 'rxjs';
|
||||
|
||||
describe('Diagrams events', () => {
|
||||
let component: any;
|
||||
let fixture: ComponentFixture<DiagramComponent>;
|
||||
let unitTestingUtils: UnitTestingUtils;
|
||||
let diagramsService: DiagramsService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
@@ -38,8 +39,8 @@ describe('Diagrams events', () => {
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
unitTestingUtils = new UnitTestingUtils(fixture.debugElement);
|
||||
diagramsService = TestBed.inject(DiagramsService);
|
||||
|
||||
jasmine.Ajax.install();
|
||||
component.processInstanceId = '38399';
|
||||
component.processDefinitionId = 'fakeprocess:24:38399';
|
||||
component.metricPercentages = { startEvent: 0 };
|
||||
@@ -48,17 +49,8 @@ describe('Diagrams events', () => {
|
||||
afterEach(() => {
|
||||
component.success.unsubscribe();
|
||||
fixture.destroy();
|
||||
jasmine.Ajax.uninstall();
|
||||
});
|
||||
|
||||
const ajaxReply = (resp: any) => {
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: resp
|
||||
});
|
||||
};
|
||||
|
||||
describe('Diagrams component Events: ', () => {
|
||||
it('Should render the Start Event', (done) => {
|
||||
component.success.subscribe((res) => {
|
||||
@@ -73,9 +65,9 @@ describe('Diagrams events', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsEventsMock.startEvent] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Start Timer Event', (done) => {
|
||||
@@ -97,10 +89,9 @@ describe('Diagrams events', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
|
||||
const resp = { elements: [diagramsEventsMock.startTimeEvent] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Start Signal Event', (done) => {
|
||||
@@ -122,9 +113,9 @@ describe('Diagrams events', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsEventsMock.startSignalEvent] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Start Message Event', (done) => {
|
||||
@@ -146,9 +137,9 @@ describe('Diagrams events', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsEventsMock.startMessageEvent] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Start Error Event', (done) => {
|
||||
@@ -170,9 +161,9 @@ describe('Diagrams events', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsEventsMock.startErrorEvent] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the End Event', (done) => {
|
||||
@@ -188,9 +179,9 @@ describe('Diagrams events', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsEventsMock.endEvent] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the End Error Event', (done) => {
|
||||
@@ -211,9 +202,9 @@ describe('Diagrams events', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsEventsMock.endErrorEvent] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -231,9 +222,9 @@ describe('Diagrams events', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsEventsMock.startEvent] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Active Start Event', (done) => {
|
||||
@@ -249,9 +240,9 @@ describe('Diagrams events', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsEventsMock.startEventActive] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Completed Start Event', (done) => {
|
||||
@@ -267,9 +258,9 @@ describe('Diagrams events', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsEventsMock.startEventCompleted] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Start Timer Event', (done) => {
|
||||
@@ -291,10 +282,9 @@ describe('Diagrams events', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsEventsMock.startTimeEvent] };
|
||||
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Active Start Timer Event', (done) => {
|
||||
@@ -316,10 +306,9 @@ describe('Diagrams events', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsEventsMock.startTimeEventActive] };
|
||||
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Completed Start Timer Event', (done) => {
|
||||
@@ -341,10 +330,9 @@ describe('Diagrams events', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsEventsMock.startTimeEventCompleted] };
|
||||
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Start Signal Event', (done) => {
|
||||
@@ -366,9 +354,9 @@ describe('Diagrams events', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsEventsMock.startSignalEvent] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Active Start Signal Event', (done) => {
|
||||
@@ -390,9 +378,9 @@ describe('Diagrams events', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsEventsMock.startSignalEventActive] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Completed Start Signal Event', (done) => {
|
||||
@@ -414,9 +402,9 @@ describe('Diagrams events', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsEventsMock.startSignalEventCompleted] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Start Message Event', (done) => {
|
||||
@@ -438,9 +426,9 @@ describe('Diagrams events', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsEventsMock.startMessageEvent] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Active Start Message Event', (done) => {
|
||||
@@ -462,9 +450,9 @@ describe('Diagrams events', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsEventsMock.startMessageEventActive] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Completed Start Message Event', (done) => {
|
||||
@@ -486,9 +474,9 @@ describe('Diagrams events', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsEventsMock.startMessageEventCompleted] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Start Error Event', (done) => {
|
||||
@@ -510,9 +498,9 @@ describe('Diagrams events', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsEventsMock.startErrorEvent] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Active Start Error Event', (done) => {
|
||||
@@ -534,9 +522,9 @@ describe('Diagrams events', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsEventsMock.startErrorEventActive] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Completed Start Error Event', (done) => {
|
||||
@@ -558,9 +546,9 @@ describe('Diagrams events', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsEventsMock.startErrorEventCompleted] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the End Event', (done) => {
|
||||
@@ -576,9 +564,9 @@ describe('Diagrams events', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsEventsMock.endEvent] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Active End Event', (done) => {
|
||||
@@ -594,9 +582,9 @@ describe('Diagrams events', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsEventsMock.endEventActive] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Completed End Event', (done) => {
|
||||
@@ -612,9 +600,9 @@ describe('Diagrams events', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsEventsMock.endEventCompleted] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the End Error Event', (done) => {
|
||||
@@ -635,9 +623,9 @@ describe('Diagrams events', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsEventsMock.endErrorEvent] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Active End Error Event', (done) => {
|
||||
@@ -658,9 +646,9 @@ describe('Diagrams events', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsEventsMock.endErrorEventActive] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Completed End Error Event', (done) => {
|
||||
@@ -681,9 +669,9 @@ describe('Diagrams events', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsEventsMock.endErrorEventCompleted] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -20,13 +20,14 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import * as flowsMock from '../../mock/diagram/diagram-flows.mock';
|
||||
import { DiagramComponent } from './diagram.component';
|
||||
import { InsightsTestingModule } from '../../testing/insights.testing.module';
|
||||
|
||||
declare let jasmine: any;
|
||||
import { DiagramsService } from '../services/diagrams.service';
|
||||
import { of } from 'rxjs';
|
||||
|
||||
describe('Diagrams flows', () => {
|
||||
let component: any;
|
||||
let fixture: ComponentFixture<DiagramComponent>;
|
||||
let element: HTMLElement;
|
||||
let diagramsService: DiagramsService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
@@ -35,9 +36,9 @@ describe('Diagrams flows', () => {
|
||||
fixture = TestBed.createComponent(DiagramComponent);
|
||||
component = fixture.componentInstance;
|
||||
element = fixture.nativeElement;
|
||||
diagramsService = TestBed.inject(DiagramsService);
|
||||
fixture.detectChanges();
|
||||
|
||||
jasmine.Ajax.install();
|
||||
component.processInstanceId = '38399';
|
||||
component.processDefinitionId = 'fakeprocess:24:38399';
|
||||
component.metricPercentages = { startEvent: 0 };
|
||||
@@ -46,17 +47,8 @@ describe('Diagrams flows', () => {
|
||||
afterEach(() => {
|
||||
component.success.unsubscribe();
|
||||
fixture.destroy();
|
||||
jasmine.Ajax.uninstall();
|
||||
});
|
||||
|
||||
const ajaxReply = (resp: any) => {
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: resp
|
||||
});
|
||||
};
|
||||
|
||||
describe('Diagrams component Flows with process instance id: ', () => {
|
||||
it('Should render the flow', (done) => {
|
||||
component.success.subscribe((res) => {
|
||||
@@ -72,9 +64,9 @@ describe('Diagrams flows', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { flows: [flowsMock.flow] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -93,9 +85,9 @@ describe('Diagrams flows', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { flows: [flowsMock.flow] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -22,13 +22,14 @@ import { DiagramComponent } from './diagram.component';
|
||||
import { InsightsTestingModule } from '../../testing/insights.testing.module';
|
||||
import { UnitTestingUtils } from '@alfresco/adf-core';
|
||||
import { RaphaelRhombusDirective } from '@alfresco/adf-insights';
|
||||
|
||||
declare let jasmine: any;
|
||||
import { DiagramsService } from '../services/diagrams.service';
|
||||
import { of } from 'rxjs';
|
||||
|
||||
describe('Diagrams gateways', () => {
|
||||
let component: any;
|
||||
let fixture: ComponentFixture<DiagramComponent>;
|
||||
let unitTestingUtils: UnitTestingUtils;
|
||||
let diagramsService: DiagramsService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
@@ -37,9 +38,9 @@ describe('Diagrams gateways', () => {
|
||||
fixture = TestBed.createComponent(DiagramComponent);
|
||||
component = fixture.componentInstance;
|
||||
unitTestingUtils = new UnitTestingUtils(fixture.debugElement);
|
||||
diagramsService = TestBed.inject(DiagramsService);
|
||||
fixture.detectChanges();
|
||||
|
||||
jasmine.Ajax.install();
|
||||
component.processInstanceId = '38399';
|
||||
component.processDefinitionId = 'fakeprocess:24:38399';
|
||||
component.metricPercentages = { startEvent: 0 };
|
||||
@@ -48,17 +49,8 @@ describe('Diagrams gateways', () => {
|
||||
afterEach(() => {
|
||||
component.success.unsubscribe();
|
||||
fixture.destroy();
|
||||
jasmine.Ajax.uninstall();
|
||||
});
|
||||
|
||||
const ajaxReply = (resp: any) => {
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: resp
|
||||
});
|
||||
};
|
||||
|
||||
describe('Diagrams component Gateways: ', () => {
|
||||
it('Should render the Exclusive Gateway', (done) => {
|
||||
component.success.subscribe((res) => {
|
||||
@@ -77,9 +69,9 @@ describe('Diagrams gateways', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsGatewaysMock.exclusiveGateway] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Inclusive Gateway', (done) => {
|
||||
@@ -99,9 +91,9 @@ describe('Diagrams gateways', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsGatewaysMock.inclusiveGateway] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Parallel Gateway', (done) => {
|
||||
@@ -121,9 +113,9 @@ describe('Diagrams gateways', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsGatewaysMock.parallelGateway] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Event Gateway', (done) => {
|
||||
@@ -153,9 +145,9 @@ describe('Diagrams gateways', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsGatewaysMock.eventGateway] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -177,9 +169,9 @@ describe('Diagrams gateways', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsGatewaysMock.exclusiveGateway] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Active Exclusive Gateway', (done) => {
|
||||
@@ -199,9 +191,9 @@ describe('Diagrams gateways', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsGatewaysMock.exclusiveGatewayActive] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Completed Exclusive Gateway', (done) => {
|
||||
@@ -221,9 +213,9 @@ describe('Diagrams gateways', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsGatewaysMock.exclusiveGatewayCompleted] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Inclusive Gateway', (done) => {
|
||||
@@ -243,9 +235,9 @@ describe('Diagrams gateways', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsGatewaysMock.inclusiveGateway] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Active Inclusive Gateway', (done) => {
|
||||
@@ -265,9 +257,9 @@ describe('Diagrams gateways', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsGatewaysMock.inclusiveGatewayActive] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Completed Inclusive Gateway', (done) => {
|
||||
@@ -287,9 +279,9 @@ describe('Diagrams gateways', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsGatewaysMock.inclusiveGatewayCompleted] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Parallel Gateway', (done) => {
|
||||
@@ -309,9 +301,9 @@ describe('Diagrams gateways', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsGatewaysMock.parallelGateway] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Active Parallel Gateway', (done) => {
|
||||
@@ -331,9 +323,9 @@ describe('Diagrams gateways', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsGatewaysMock.parallelGatewayActive] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Completed Parallel Gateway', (done) => {
|
||||
@@ -353,9 +345,9 @@ describe('Diagrams gateways', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsGatewaysMock.parallelGatewayCompleted] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Event Gateway', (done) => {
|
||||
@@ -385,9 +377,9 @@ describe('Diagrams gateways', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsGatewaysMock.eventGateway] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Active Event Gateway', (done) => {
|
||||
@@ -417,9 +409,9 @@ describe('Diagrams gateways', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsGatewaysMock.eventGatewayActive] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Completed Event Gateway', (done) => {
|
||||
@@ -449,9 +441,9 @@ describe('Diagrams gateways', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [diagramsGatewaysMock.eventGatewayCompleted] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -21,13 +21,14 @@ import { DiagramComponent } from './diagram.component';
|
||||
import { InsightsTestingModule } from '../../testing/insights.testing.module';
|
||||
import { UnitTestingUtils } from '@alfresco/adf-core';
|
||||
import { RaphaelRectDirective } from '@alfresco/adf-insights';
|
||||
|
||||
declare let jasmine: any;
|
||||
import { DiagramsService } from '../services/diagrams.service';
|
||||
import { of } from 'rxjs';
|
||||
|
||||
describe('Diagrams structural', () => {
|
||||
let component: any;
|
||||
let fixture: ComponentFixture<DiagramComponent>;
|
||||
let unitTestingUtils: UnitTestingUtils;
|
||||
let diagramsService: DiagramsService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
@@ -37,8 +38,8 @@ describe('Diagrams structural', () => {
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
unitTestingUtils = new UnitTestingUtils(fixture.debugElement);
|
||||
diagramsService = TestBed.inject(DiagramsService);
|
||||
|
||||
jasmine.Ajax.install();
|
||||
component.processInstanceId = '38399';
|
||||
component.processDefinitionId = 'fakeprocess:24:38399';
|
||||
component.metricPercentages = { startEvent: 0 };
|
||||
@@ -47,17 +48,8 @@ describe('Diagrams structural', () => {
|
||||
afterEach(() => {
|
||||
component.success.unsubscribe();
|
||||
fixture.destroy();
|
||||
jasmine.Ajax.uninstall();
|
||||
});
|
||||
|
||||
const ajaxReply = (resp: any) => {
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: resp
|
||||
});
|
||||
};
|
||||
|
||||
describe('Diagrams component Structural: ', () => {
|
||||
it('Should render the Subprocess', (done) => {
|
||||
component.success.subscribe((res) => {
|
||||
@@ -73,9 +65,9 @@ describe('Diagrams structural', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [structuralMock.subProcess] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Event Subprocess', (done) => {
|
||||
@@ -92,9 +84,9 @@ describe('Diagrams structural', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [structuralMock.eventSubProcess] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -113,9 +105,9 @@ describe('Diagrams structural', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [structuralMock.subProcess] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Active Subprocess', (done) => {
|
||||
@@ -132,9 +124,9 @@ describe('Diagrams structural', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [structuralMock.subProcessActive] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Completed Subprocess', (done) => {
|
||||
@@ -151,9 +143,9 @@ describe('Diagrams structural', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [structuralMock.subProcessCompleted] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Event Subprocess', (done) => {
|
||||
@@ -170,9 +162,9 @@ describe('Diagrams structural', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [structuralMock.eventSubProcess] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Active Event Subprocess', (done) => {
|
||||
@@ -189,9 +181,9 @@ describe('Diagrams structural', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [structuralMock.eventSubProcessActive] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Completed Event Subprocess', (done) => {
|
||||
@@ -208,9 +200,9 @@ describe('Diagrams structural', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [structuralMock.eventSubProcessCompleted] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -21,13 +21,14 @@ import { DiagramComponent } from './diagram.component';
|
||||
import { InsightsTestingModule } from '../../testing/insights.testing.module';
|
||||
import { UnitTestingUtils } from '@alfresco/adf-core';
|
||||
import { RaphaelTextDirective } from '@alfresco/adf-insights';
|
||||
|
||||
declare let jasmine: any;
|
||||
import { DiagramsService } from '../services/diagrams.service';
|
||||
import { of } from 'rxjs';
|
||||
|
||||
describe('Diagrams swim', () => {
|
||||
let component: any;
|
||||
let fixture: ComponentFixture<DiagramComponent>;
|
||||
let unitTestingUtils: UnitTestingUtils;
|
||||
let diagramsService: DiagramsService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
@@ -37,8 +38,8 @@ describe('Diagrams swim', () => {
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
unitTestingUtils = new UnitTestingUtils(fixture.debugElement);
|
||||
diagramsService = TestBed.inject(DiagramsService);
|
||||
|
||||
jasmine.Ajax.install();
|
||||
component.processInstanceId = '38399';
|
||||
component.processDefinitionId = 'fakeprocess:24:38399';
|
||||
component.metricPercentages = { startEvent: 0 };
|
||||
@@ -47,17 +48,8 @@ describe('Diagrams swim', () => {
|
||||
afterEach(() => {
|
||||
component.success.unsubscribe();
|
||||
fixture.destroy();
|
||||
jasmine.Ajax.uninstall();
|
||||
});
|
||||
|
||||
const ajaxReply = (resp: any) => {
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: resp
|
||||
});
|
||||
};
|
||||
|
||||
describe('Diagrams component Swim lane: ', () => {
|
||||
it('Should render the Pool', (done) => {
|
||||
component.success.subscribe((res) => {
|
||||
@@ -73,9 +65,9 @@ describe('Diagrams swim', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { pools: [swimLanesMock.pool] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Pool with Lanes', (done) => {
|
||||
@@ -95,9 +87,9 @@ describe('Diagrams swim', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { pools: [swimLanesMock.poolLanes] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -116,9 +108,9 @@ describe('Diagrams swim', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { pools: [swimLanesMock.pool] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Pool with Lanes', (done) => {
|
||||
@@ -138,9 +130,9 @@ describe('Diagrams swim', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { pools: [swimLanesMock.poolLanes] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -21,23 +21,24 @@ import { DiagramComponent } from './diagram.component';
|
||||
import { InsightsTestingModule } from '../../testing/insights.testing.module';
|
||||
import { UnitTestingUtils } from '@alfresco/adf-core';
|
||||
import { RaphaelCircleDirective } from '@alfresco/adf-insights';
|
||||
|
||||
declare let jasmine: any;
|
||||
import { DiagramsService } from '../services/diagrams.service';
|
||||
import { of } from 'rxjs';
|
||||
|
||||
describe('Diagrams throw', () => {
|
||||
let component: any;
|
||||
let fixture: ComponentFixture<DiagramComponent>;
|
||||
let unitTestingUtils: UnitTestingUtils;
|
||||
let diagramsService: DiagramsService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [InsightsTestingModule]
|
||||
});
|
||||
jasmine.Ajax.install();
|
||||
|
||||
fixture = TestBed.createComponent(DiagramComponent);
|
||||
component = fixture.componentInstance;
|
||||
unitTestingUtils = new UnitTestingUtils(fixture.debugElement);
|
||||
diagramsService = TestBed.inject(DiagramsService);
|
||||
component.processInstanceId = '38399';
|
||||
component.processDefinitionId = 'fakeprocess:24:38399';
|
||||
component.metricPercentages = { startEvent: 0 };
|
||||
@@ -47,17 +48,8 @@ describe('Diagrams throw', () => {
|
||||
|
||||
afterEach(() => {
|
||||
fixture.destroy();
|
||||
jasmine.Ajax.uninstall();
|
||||
});
|
||||
|
||||
const ajaxReply = (resp: any) => {
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: resp
|
||||
});
|
||||
};
|
||||
|
||||
describe('Diagrams component Throw events with process instance id: ', () => {
|
||||
it('Should render the Throw time event', (done) => {
|
||||
component.success.subscribe((res) => {
|
||||
@@ -81,9 +73,9 @@ describe('Diagrams throw', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [throwEventMock.throwTimeEvent] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Active Throw time event', (done) => {
|
||||
@@ -112,9 +104,9 @@ describe('Diagrams throw', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [throwEventMock.throwTimeEventActive] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Completed Throw time event', (done) => {
|
||||
@@ -143,9 +135,9 @@ describe('Diagrams throw', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [throwEventMock.throwTimeEventCompleted] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Throw error event', (done) => {
|
||||
@@ -174,9 +166,9 @@ describe('Diagrams throw', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [throwEventMock.throwErrorEvent] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Active Throw error event', (done) => {
|
||||
@@ -209,9 +201,9 @@ describe('Diagrams throw', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [throwEventMock.throwErrorEventActive] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Completed Throw error event', (done) => {
|
||||
@@ -244,9 +236,9 @@ describe('Diagrams throw', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [throwEventMock.throwErrorEventCompleted] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Throw signal event', (done) => {
|
||||
@@ -275,9 +267,9 @@ describe('Diagrams throw', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [throwEventMock.throwSignalEvent] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Active Throw signal event', (done) => {
|
||||
@@ -310,9 +302,9 @@ describe('Diagrams throw', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [throwEventMock.throwSignalEventActive] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Completed Throw signal event', (done) => {
|
||||
@@ -345,9 +337,9 @@ describe('Diagrams throw', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [throwEventMock.throwSignalEventCompleted] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Throw signal message', (done) => {
|
||||
@@ -376,9 +368,9 @@ describe('Diagrams throw', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [throwEventMock.throwMessageEvent] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Active Throw signal message', (done) => {
|
||||
@@ -411,9 +403,9 @@ describe('Diagrams throw', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [throwEventMock.throwMessageEventActive] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Completed Throw signal message', (done) => {
|
||||
@@ -446,9 +438,9 @@ describe('Diagrams throw', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [throwEventMock.throwMessageEventCompleted] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Throw signal message', (done) => {
|
||||
@@ -477,9 +469,9 @@ describe('Diagrams throw', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [throwEventMock.throwMessageEvent] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Active Throw signal message', (done) => {
|
||||
@@ -512,9 +504,9 @@ describe('Diagrams throw', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [throwEventMock.throwMessageEventActive] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Completed Throw signal message', (done) => {
|
||||
@@ -547,9 +539,9 @@ describe('Diagrams throw', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [throwEventMock.throwMessageEventCompleted] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -576,9 +568,9 @@ describe('Diagrams throw', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [throwEventMock.throwTimeEvent] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Throw error event', (done) => {
|
||||
@@ -607,9 +599,9 @@ describe('Diagrams throw', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [throwEventMock.throwErrorEvent] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Throw signal event', (done) => {
|
||||
@@ -638,9 +630,9 @@ describe('Diagrams throw', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [throwEventMock.throwSignalEvent] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Throw signal message', (done) => {
|
||||
@@ -669,9 +661,9 @@ describe('Diagrams throw', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [throwEventMock.throwMessageEvent] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
|
||||
it('Should render the Throw signal message', (done) => {
|
||||
@@ -700,9 +692,9 @@ describe('Diagrams throw', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
component.ngOnChanges();
|
||||
const resp = { elements: [throwEventMock.throwMessageEvent] };
|
||||
ajaxReply(resp);
|
||||
spyOn(diagramsService, 'getProcessDefinitionModel').and.returnValue(of(resp));
|
||||
component.ngOnChanges();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -22,7 +22,7 @@ module.exports = function (config) {
|
||||
{ pattern: 'lib/process-services-cloud/**/*.ts', included: false, served: true, watched: false },
|
||||
{ pattern: 'lib/config/app.config.json', included: false, served: true, watched: false }
|
||||
],
|
||||
frameworks: ['jasmine-ajax', 'jasmine', '@angular-devkit/build-angular'],
|
||||
frameworks: ['jasmine', '@angular-devkit/build-angular'],
|
||||
proxies: {
|
||||
'/assets/': '/base/lib/process-services-cloud/src/lib/assets/',
|
||||
'/resources/i18n/en.json': '/base/lib/process-services-cloud/src/lib/mock/en.json',
|
||||
@@ -35,13 +35,11 @@ module.exports = function (config) {
|
||||
'/app.config.json': '/base/lib/config/app.config.json'
|
||||
},
|
||||
plugins: [
|
||||
require('karma-jasmine-ajax'),
|
||||
require('karma-jasmine'),
|
||||
require('karma-chrome-launcher'),
|
||||
require('karma-jasmine-html-reporter'),
|
||||
require('karma-coverage'),
|
||||
require('@angular-devkit/build-angular/plugins/karma'),
|
||||
require('karma-mocha-reporter')
|
||||
require('@angular-devkit/build-angular/plugins/karma')
|
||||
],
|
||||
client: {
|
||||
clearContext: false,
|
||||
@@ -52,9 +50,6 @@ module.exports = function (config) {
|
||||
jasmineHtmlReporter: {
|
||||
suppressAll: true // removes the duplicated traces
|
||||
},
|
||||
mochaReporter: {
|
||||
ignoreSkipped: process.env.KARMA_IGNORE_SKIPPED === 'true'
|
||||
},
|
||||
|
||||
coverageReporter: {
|
||||
dir: join(__dirname, '../../coverage/process-services-cloud'),
|
||||
@@ -77,7 +72,7 @@ module.exports = function (config) {
|
||||
}
|
||||
},
|
||||
|
||||
reporters: ['mocha', 'kjhtml'],
|
||||
reporters: ['progress', 'kjhtml'],
|
||||
port: 9876,
|
||||
colors: true,
|
||||
logLevel: constants.LOG_INFO,
|
||||
|
||||
@@ -22,7 +22,7 @@ module.exports = function (config) {
|
||||
{ pattern: 'lib/process-services/**/*.ts', included: false, served: true, watched: false },
|
||||
{ pattern: 'lib/config/app.config.json', included: false, served: true, watched: false }
|
||||
],
|
||||
frameworks: ['jasmine-ajax', 'jasmine', '@angular-devkit/build-angular'],
|
||||
frameworks: ['jasmine', '@angular-devkit/build-angular'],
|
||||
proxies: {
|
||||
'/assets/': '/base/lib/process-services/src/lib/assets/',
|
||||
'/assets/adf-core/i18n/en.json': '/base/lib/core/src/lib/i18n/en.json',
|
||||
@@ -31,13 +31,11 @@ module.exports = function (config) {
|
||||
'/app.config.json': '/base/lib/config/app.config.json'
|
||||
},
|
||||
plugins: [
|
||||
require('karma-jasmine-ajax'),
|
||||
require('karma-jasmine'),
|
||||
require('karma-chrome-launcher'),
|
||||
require('karma-jasmine-html-reporter'),
|
||||
require('karma-coverage'),
|
||||
require('@angular-devkit/build-angular/plugins/karma'),
|
||||
require('karma-mocha-reporter')
|
||||
require('@angular-devkit/build-angular/plugins/karma')
|
||||
],
|
||||
client: {
|
||||
clearContext: false,
|
||||
@@ -48,9 +46,6 @@ module.exports = function (config) {
|
||||
jasmineHtmlReporter: {
|
||||
suppressAll: true // removes the duplicated traces
|
||||
},
|
||||
mochaReporter: {
|
||||
ignoreSkipped: process.env.KARMA_IGNORE_SKIPPED === 'true'
|
||||
},
|
||||
coverageReporter: {
|
||||
dir: join(__dirname, '../../coverage/process-services'),
|
||||
subdir: '.',
|
||||
@@ -72,7 +67,7 @@ module.exports = function (config) {
|
||||
}
|
||||
},
|
||||
|
||||
reporters: ['mocha', 'kjhtml'],
|
||||
reporters: ['progress', 'kjhtml'],
|
||||
port: 9876,
|
||||
colors: true,
|
||||
logLevel: constants.LOG_INFO,
|
||||
|
||||
+9
-22
@@ -19,13 +19,14 @@ import { SimpleChange } from '@angular/core';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { CreateProcessAttachmentComponent } from './create-process-attachment.component';
|
||||
import { AlfrescoApiService, AlfrescoApiServiceMock } from '@alfresco/adf-content-services';
|
||||
|
||||
declare let jasmine: any;
|
||||
import { ProcessContentService } from '../../form/services/process-content.service';
|
||||
import { of } from 'rxjs';
|
||||
|
||||
describe('CreateProcessAttachmentComponent', () => {
|
||||
let component: CreateProcessAttachmentComponent;
|
||||
let fixture: ComponentFixture<CreateProcessAttachmentComponent>;
|
||||
let element: HTMLElement;
|
||||
let processContentService: ProcessContentService;
|
||||
|
||||
const file = new File([new Blob()], 'Test');
|
||||
const fileObj = { entry: null, file, relativeFolder: '/' };
|
||||
@@ -53,19 +54,12 @@ describe('CreateProcessAttachmentComponent', () => {
|
||||
fixture = TestBed.createComponent(CreateProcessAttachmentComponent);
|
||||
component = fixture.componentInstance;
|
||||
element = fixture.nativeElement;
|
||||
processContentService = TestBed.inject(ProcessContentService);
|
||||
|
||||
component.processInstanceId = '9999';
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
jasmine.Ajax.install();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
jasmine.Ajax.uninstall();
|
||||
});
|
||||
|
||||
it('should update the processInstanceId when it is changed', () => {
|
||||
component.processInstanceId = null;
|
||||
|
||||
@@ -76,20 +70,17 @@ describe('CreateProcessAttachmentComponent', () => {
|
||||
});
|
||||
|
||||
it('should emit content created event when the file is uploaded', (done) => {
|
||||
spyOn(processContentService, 'createProcessRelatedContent').and.returnValue(of(fakeUploadResponse) as any);
|
||||
|
||||
component.success.subscribe((res) => {
|
||||
expect(res).toBeDefined();
|
||||
expect(res).not.toBeNull();
|
||||
expect(res.id).toBe(9999);
|
||||
expect(processContentService.createProcessRelatedContent).toHaveBeenCalledWith('9999', file, { isRelatedContent: true });
|
||||
done();
|
||||
});
|
||||
|
||||
component.onFileUpload(customEvent);
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'application/json',
|
||||
responseText: JSON.stringify(fakeUploadResponse)
|
||||
});
|
||||
});
|
||||
|
||||
it('should allow user to upload files via button', (done) => {
|
||||
@@ -97,6 +88,8 @@ describe('CreateProcessAttachmentComponent', () => {
|
||||
expect(buttonUpload).toBeDefined();
|
||||
expect(buttonUpload).not.toBeNull();
|
||||
|
||||
spyOn(processContentService, 'createProcessRelatedContent').and.returnValue(of(fakeUploadResponse) as any);
|
||||
|
||||
component.success.subscribe((res) => {
|
||||
expect(res).toBeDefined();
|
||||
expect(res).not.toBeNull();
|
||||
@@ -107,11 +100,5 @@ describe('CreateProcessAttachmentComponent', () => {
|
||||
const dropEvent = new CustomEvent('upload-files', customEvent);
|
||||
buttonUpload.dispatchEvent(dropEvent);
|
||||
fixture.detectChanges();
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'application/json',
|
||||
responseText: JSON.stringify(fakeUploadResponse)
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -21,8 +21,6 @@ import { EcmModelService } from './ecm-model.service';
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { AlfrescoApiService, AlfrescoApiServiceMock } from '@alfresco/adf-content-services';
|
||||
|
||||
declare let jasmine: any;
|
||||
|
||||
describe('EcmModelService', () => {
|
||||
let service: EcmModelService;
|
||||
|
||||
@@ -32,76 +30,48 @@ describe('EcmModelService', () => {
|
||||
providers: [{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock }]
|
||||
});
|
||||
service = TestBed.inject(EcmModelService);
|
||||
jasmine.Ajax.install();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
jasmine.Ajax.uninstall();
|
||||
});
|
||||
|
||||
it('Should fetch ECM models', (done) => {
|
||||
service.getEcmModels().subscribe(() => {
|
||||
expect(jasmine.Ajax.requests.mostRecent().url.endsWith('alfresco/versions/1/cmm')).toBeTruthy();
|
||||
done();
|
||||
});
|
||||
spyOn(service.customModelApi, 'getAllCustomModel').and.returnValue(Promise.resolve({} as any));
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'application/json',
|
||||
responseText: JSON.stringify({})
|
||||
service.getEcmModels().subscribe(() => {
|
||||
expect(service.customModelApi.getAllCustomModel).toHaveBeenCalled();
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('Should fetch ECM types', (done) => {
|
||||
const modelName = 'modelTest';
|
||||
spyOn(service.customModelApi, 'getAllCustomType').and.returnValue(Promise.resolve({} as any));
|
||||
|
||||
service.getEcmType(modelName).subscribe(() => {
|
||||
expect(jasmine.Ajax.requests.mostRecent().url.endsWith('versions/1/cmm/' + modelName + '/types')).toBeTruthy();
|
||||
expect(service.customModelApi.getAllCustomType).toHaveBeenCalledWith(modelName);
|
||||
done();
|
||||
});
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'application/json',
|
||||
responseText: JSON.stringify({})
|
||||
});
|
||||
});
|
||||
|
||||
it('Should create ECM types', (done) => {
|
||||
const typeName = 'typeTest';
|
||||
const mockResponse = { entry: { name: typeName } };
|
||||
const createTypeSpy = spyOn(service.customModelApi, 'createCustomType').and.returnValue(Promise.resolve(mockResponse as any));
|
||||
|
||||
service.createEcmType(typeName, EcmModelService.MODEL_NAME, EcmModelService.TYPE_MODEL).subscribe(() => {
|
||||
expect(jasmine.Ajax.requests.mostRecent().url.endsWith('versions/1/cmm/' + EcmModelService.MODEL_NAME + '/types')).toBeTruthy();
|
||||
expect(JSON.parse(jasmine.Ajax.requests.mostRecent().params).name).toEqual(typeName);
|
||||
expect(JSON.parse(jasmine.Ajax.requests.mostRecent().params).title).toEqual(typeName);
|
||||
expect(JSON.parse(jasmine.Ajax.requests.mostRecent().params).parentName).toEqual(EcmModelService.TYPE_MODEL);
|
||||
expect(createTypeSpy).toHaveBeenCalledWith(EcmModelService.MODEL_NAME, typeName, EcmModelService.TYPE_MODEL, typeName, '');
|
||||
done();
|
||||
});
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'application/json',
|
||||
responseText: JSON.stringify({})
|
||||
});
|
||||
});
|
||||
|
||||
it('Should create ECM types with a clean and preserve real name in the title', (done) => {
|
||||
const typeName = 'typeTest:testName@#$*!';
|
||||
const cleanName = 'testName';
|
||||
const mockResponse = { entry: { name: cleanName } };
|
||||
const createTypeSpy = spyOn(service.customModelApi, 'createCustomType').and.returnValue(Promise.resolve(mockResponse as any));
|
||||
|
||||
service.createEcmType(typeName, EcmModelService.MODEL_NAME, EcmModelService.TYPE_MODEL).subscribe(() => {
|
||||
expect(jasmine.Ajax.requests.mostRecent().url.endsWith('versions/1/cmm/' + EcmModelService.MODEL_NAME + '/types')).toBeTruthy();
|
||||
expect(JSON.parse(jasmine.Ajax.requests.mostRecent().params).name).toEqual(cleanName);
|
||||
expect(JSON.parse(jasmine.Ajax.requests.mostRecent().params).title).toEqual(typeName);
|
||||
expect(JSON.parse(jasmine.Ajax.requests.mostRecent().params).parentName).toEqual(EcmModelService.TYPE_MODEL);
|
||||
expect(createTypeSpy).toHaveBeenCalledWith(EcmModelService.MODEL_NAME, cleanName, EcmModelService.TYPE_MODEL, typeName, '');
|
||||
done();
|
||||
});
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'application/json',
|
||||
responseText: JSON.stringify({})
|
||||
});
|
||||
});
|
||||
|
||||
it('Should add property to a type', (done) => {
|
||||
@@ -113,37 +83,26 @@ describe('EcmModelService', () => {
|
||||
}
|
||||
};
|
||||
|
||||
service.addPropertyToAType(EcmModelService.MODEL_NAME, typeName, formFields).subscribe(() => {
|
||||
expect(
|
||||
jasmine.Ajax.requests.mostRecent().url.endsWith('1/cmm/' + EcmModelService.MODEL_NAME + '/types/' + typeName + '?select=props')
|
||||
).toBeTruthy();
|
||||
expect(JSON.parse(jasmine.Ajax.requests.mostRecent().params).properties).toEqual([
|
||||
{
|
||||
name: 'test',
|
||||
title: 'test',
|
||||
description: 'test',
|
||||
dataType: 'd:text',
|
||||
multiValued: false,
|
||||
mandatory: false,
|
||||
mandatoryEnforced: false
|
||||
},
|
||||
{
|
||||
name: 'test2',
|
||||
title: 'test2',
|
||||
description: 'test2',
|
||||
dataType: 'd:text',
|
||||
multiValued: false,
|
||||
mandatory: false,
|
||||
mandatoryEnforced: false
|
||||
}
|
||||
]);
|
||||
done();
|
||||
});
|
||||
const mockResponse = { entry: { properties: [] } };
|
||||
const addPropertySpy = spyOn(service.customModelApi, 'addPropertyToType').and.returnValue(Promise.resolve(mockResponse as any));
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'application/json',
|
||||
responseText: JSON.stringify({})
|
||||
service.addPropertyToAType(EcmModelService.MODEL_NAME, typeName, formFields).subscribe(() => {
|
||||
const callArgs = addPropertySpy.calls.mostRecent().args;
|
||||
expect(callArgs[0]).toEqual(EcmModelService.MODEL_NAME);
|
||||
expect(callArgs[1]).toEqual(typeName);
|
||||
expect(callArgs[2]).toEqual(
|
||||
jasmine.arrayContaining([
|
||||
jasmine.objectContaining({
|
||||
name: 'test',
|
||||
title: 'test'
|
||||
}),
|
||||
jasmine.objectContaining({
|
||||
name: 'test2',
|
||||
title: 'test2'
|
||||
})
|
||||
])
|
||||
);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -157,67 +116,52 @@ describe('EcmModelService', () => {
|
||||
}
|
||||
};
|
||||
|
||||
service.addPropertyToAType(EcmModelService.MODEL_NAME, typeName, formFields).subscribe(() => {
|
||||
expect(
|
||||
jasmine.Ajax.requests.mostRecent().url.endsWith('1/cmm/' + EcmModelService.MODEL_NAME + '/types/' + cleanName + '?select=props')
|
||||
).toBeTruthy();
|
||||
expect(JSON.parse(jasmine.Ajax.requests.mostRecent().params).properties).toEqual([
|
||||
{
|
||||
name: 'test',
|
||||
title: 'test',
|
||||
description: 'test',
|
||||
dataType: 'd:text',
|
||||
multiValued: false,
|
||||
mandatory: false,
|
||||
mandatoryEnforced: false
|
||||
},
|
||||
{
|
||||
name: 'test2',
|
||||
title: 'test2',
|
||||
description: 'test2',
|
||||
dataType: 'd:text',
|
||||
multiValued: false,
|
||||
mandatory: false,
|
||||
mandatoryEnforced: false
|
||||
}
|
||||
]);
|
||||
done();
|
||||
});
|
||||
const mockResponse = { entry: { properties: [] } };
|
||||
const addPropertySpy = spyOn(service.customModelApi, 'addPropertyToType').and.returnValue(Promise.resolve(mockResponse as any));
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'application/json',
|
||||
responseText: JSON.stringify({})
|
||||
service.addPropertyToAType(EcmModelService.MODEL_NAME, typeName, formFields).subscribe(() => {
|
||||
const callArgs = addPropertySpy.calls.mostRecent().args;
|
||||
expect(callArgs[0]).toEqual(EcmModelService.MODEL_NAME);
|
||||
expect(callArgs[1]).toEqual(cleanName);
|
||||
expect(callArgs[2]).toEqual(
|
||||
jasmine.arrayContaining([
|
||||
jasmine.objectContaining({
|
||||
name: 'test',
|
||||
title: 'test'
|
||||
}),
|
||||
jasmine.objectContaining({
|
||||
name: 'test2',
|
||||
title: 'test2'
|
||||
})
|
||||
])
|
||||
);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('Should create ECM model', (done) => {
|
||||
service.createEcmModel(EcmModelService.MODEL_NAME, EcmModelService.MODEL_NAMESPACE).subscribe(() => {
|
||||
expect(jasmine.Ajax.requests.mostRecent().url.endsWith('alfresco/versions/1/cmm')).toBeTruthy();
|
||||
expect(JSON.parse(jasmine.Ajax.requests.mostRecent().params).status).toEqual('DRAFT');
|
||||
done();
|
||||
});
|
||||
const mockResponse = { entry: { name: EcmModelService.MODEL_NAME } };
|
||||
const createModelSpy = spyOn(service.customModelApi, 'createCustomModel').and.returnValue(Promise.resolve(mockResponse as any));
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'application/json',
|
||||
responseText: JSON.stringify({})
|
||||
service.createEcmModel(EcmModelService.MODEL_NAME, EcmModelService.MODEL_NAMESPACE).subscribe(() => {
|
||||
expect(createModelSpy).toHaveBeenCalledWith(
|
||||
'DRAFT',
|
||||
'',
|
||||
EcmModelService.MODEL_NAME,
|
||||
EcmModelService.MODEL_NAME,
|
||||
EcmModelService.MODEL_NAMESPACE
|
||||
);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('Should activate ECM model', (done) => {
|
||||
service.activeEcmModel(EcmModelService.MODEL_NAME).subscribe(() => {
|
||||
expect(
|
||||
jasmine.Ajax.requests.mostRecent().url.endsWith('alfresco/versions/1/cmm/' + EcmModelService.MODEL_NAME + '?select=status')
|
||||
).toBeTruthy();
|
||||
expect(JSON.parse(jasmine.Ajax.requests.mostRecent().params).status).toEqual('ACTIVE');
|
||||
done();
|
||||
});
|
||||
const mockResponse = { entry: { status: 'ACTIVE' } };
|
||||
const activateModelSpy = spyOn(service.customModelApi, 'activateCustomModel').and.returnValue(Promise.resolve(mockResponse as any));
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'application/json',
|
||||
responseText: JSON.stringify({})
|
||||
service.activeEcmModel(EcmModelService.MODEL_NAME).subscribe(() => {
|
||||
expect(activateModelSpy).toHaveBeenCalledWith(EcmModelService.MODEL_NAME);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -19,8 +19,6 @@ import { TestBed } from '@angular/core/testing';
|
||||
import { ProcessContentService } from './process-content.service';
|
||||
import { AlfrescoApiService, AlfrescoApiServiceMock } from '@alfresco/adf-content-services';
|
||||
|
||||
declare let jasmine: any;
|
||||
|
||||
const fileContentPdfResponseBody = {
|
||||
id: 999,
|
||||
name: 'fake-name.pdf',
|
||||
@@ -71,15 +69,43 @@ describe('ProcessContentService', () => {
|
||||
service = TestBed.inject(ProcessContentService);
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
jasmine.Ajax.install();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
jasmine.Ajax.uninstall();
|
||||
});
|
||||
|
||||
it('Should fetch the attachments', (done) => {
|
||||
const mockResponse = {
|
||||
size: 2,
|
||||
total: 2,
|
||||
start: 0,
|
||||
data: [
|
||||
{
|
||||
id: 8,
|
||||
name: 'fake.zip',
|
||||
created: 1494595697381,
|
||||
createdBy: { id: 2, firstName: 'user', lastName: 'user', email: 'user@user.com' },
|
||||
relatedContent: true,
|
||||
contentAvailable: true,
|
||||
link: false,
|
||||
mimeType: 'application/zip',
|
||||
simpleType: 'content',
|
||||
previewStatus: 'unsupported',
|
||||
thumbnailStatus: 'unsupported'
|
||||
},
|
||||
{
|
||||
id: 9,
|
||||
name: 'fake.jpg',
|
||||
created: 1494595655381,
|
||||
createdBy: { id: 2, firstName: 'user', lastName: 'user', email: 'user@user.com' },
|
||||
relatedContent: true,
|
||||
contentAvailable: true,
|
||||
link: false,
|
||||
mimeType: 'image/jpeg',
|
||||
simpleType: 'image',
|
||||
previewStatus: 'unsupported',
|
||||
thumbnailStatus: 'unsupported'
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
spyOn(service.contentApi, 'getRelatedContentForTask').and.returnValue(Promise.resolve(mockResponse as any));
|
||||
|
||||
service.getTaskRelatedContent('1234').subscribe((res) => {
|
||||
expect(res.data).toBeDefined();
|
||||
expect(res.data.length).toBe(2);
|
||||
@@ -91,49 +117,13 @@ describe('ProcessContentService', () => {
|
||||
expect(res.data[1].relatedContent).toBeTruthy();
|
||||
done();
|
||||
});
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'application/json',
|
||||
responseText: JSON.stringify({
|
||||
size: 2,
|
||||
total: 2,
|
||||
start: 0,
|
||||
data: [
|
||||
{
|
||||
id: 8,
|
||||
name: 'fake.zip',
|
||||
created: 1494595697381,
|
||||
createdBy: { id: 2, firstName: 'user', lastName: 'user', email: 'user@user.com' },
|
||||
relatedContent: true,
|
||||
contentAvailable: true,
|
||||
link: false,
|
||||
mimeType: 'application/zip',
|
||||
simpleType: 'content',
|
||||
previewStatus: 'unsupported',
|
||||
thumbnailStatus: 'unsupported'
|
||||
},
|
||||
{
|
||||
id: 9,
|
||||
name: 'fake.jpg',
|
||||
created: 1494595655381,
|
||||
createdBy: { id: 2, firstName: 'user', lastName: 'user', email: 'user@user.com' },
|
||||
relatedContent: true,
|
||||
contentAvailable: true,
|
||||
link: false,
|
||||
mimeType: 'image/jpeg',
|
||||
simpleType: 'image',
|
||||
previewStatus: 'unsupported',
|
||||
thumbnailStatus: 'unsupported'
|
||||
}
|
||||
]
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
it('should return the unsupported content when the file is an image', (done) => {
|
||||
const contentId: number = 888;
|
||||
|
||||
spyOn(service.contentApi, 'getContent').and.returnValue(Promise.resolve(fileContentJpgResponseBody as any));
|
||||
|
||||
service.getFileContent(contentId).subscribe((result) => {
|
||||
expect(result.id).toEqual(contentId);
|
||||
expect(result.name).toEqual('fake-name.jpg');
|
||||
@@ -141,17 +131,13 @@ describe('ProcessContentService', () => {
|
||||
expect(result.thumbnailStatus).toEqual('unsupported');
|
||||
done();
|
||||
});
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'application/json',
|
||||
responseText: JSON.stringify(fileContentJpgResponseBody)
|
||||
});
|
||||
});
|
||||
|
||||
it('should return the supported content when the file is a pdf', (done) => {
|
||||
const contentId: number = 999;
|
||||
|
||||
spyOn(service.contentApi, 'getContent').and.returnValue(Promise.resolve(fileContentPdfResponseBody as any));
|
||||
|
||||
service.getFileContent(contentId).subscribe((result) => {
|
||||
expect(result.id).toEqual(contentId);
|
||||
expect(result.name).toEqual('fake-name.pdf');
|
||||
@@ -159,12 +145,6 @@ describe('ProcessContentService', () => {
|
||||
expect(result.thumbnailStatus).toEqual('created');
|
||||
done();
|
||||
});
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'application/json',
|
||||
responseText: JSON.stringify(fileContentPdfResponseBody)
|
||||
});
|
||||
});
|
||||
|
||||
it('should return the raw content URL', () => {
|
||||
|
||||
@@ -24,8 +24,6 @@ import { ContentWidgetComponent } from './content.widget';
|
||||
import { ProcessContentService } from '../../services/process-content.service';
|
||||
import { AlfrescoApiService, AlfrescoApiServiceMock } from '@alfresco/adf-content-services';
|
||||
|
||||
declare let jasmine: any;
|
||||
|
||||
describe('ContentWidgetComponent', () => {
|
||||
let component: ContentWidgetComponent;
|
||||
let fixture: ComponentFixture<ContentWidgetComponent>;
|
||||
@@ -75,14 +73,6 @@ describe('ContentWidgetComponent', () => {
|
||||
});
|
||||
|
||||
describe('Rendering tests', () => {
|
||||
beforeEach(() => {
|
||||
jasmine.Ajax.install();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
jasmine.Ajax.uninstall();
|
||||
});
|
||||
|
||||
it('should display content thumbnail', () => {
|
||||
component.showDocumentContent = true;
|
||||
component.content = new ContentLinkModel();
|
||||
@@ -94,6 +84,26 @@ describe('ContentWidgetComponent', () => {
|
||||
|
||||
it('should load the thumbnail preview of the png image', fakeAsync(() => {
|
||||
const blob = createFakeImageBlob();
|
||||
const mockResponse = {
|
||||
id: 4004,
|
||||
name: 'Useful expressions - Email_English.png',
|
||||
created: 1490354907883,
|
||||
createdBy: {
|
||||
id: 2,
|
||||
firstName: 'admin',
|
||||
lastName: 'admin',
|
||||
email: 'administrator@admin.com'
|
||||
},
|
||||
relatedContent: false,
|
||||
contentAvailable: true,
|
||||
link: false,
|
||||
mimeType: 'image/png',
|
||||
simpleType: 'image',
|
||||
previewStatus: 'unsupported',
|
||||
thumbnailStatus: 'unsupported'
|
||||
};
|
||||
|
||||
spyOn(processContentService, 'getFileContent').and.returnValue(of(mockResponse as any));
|
||||
spyOn(processContentService, 'getFileRawContent').and.returnValue(of(blob));
|
||||
|
||||
component.thumbnailLoaded.subscribe((res) => {
|
||||
@@ -109,33 +119,30 @@ describe('ContentWidgetComponent', () => {
|
||||
const contentId = 1;
|
||||
const change = new SimpleChange(null, contentId, true);
|
||||
component.ngOnChanges({ id: change });
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: {
|
||||
id: 4004,
|
||||
name: 'Useful expressions - Email_English.png',
|
||||
created: 1490354907883,
|
||||
createdBy: {
|
||||
id: 2,
|
||||
firstName: 'admin',
|
||||
lastName: 'admin',
|
||||
email: 'administrator@admin.com'
|
||||
},
|
||||
relatedContent: false,
|
||||
contentAvailable: true,
|
||||
link: false,
|
||||
mimeType: 'image/png',
|
||||
simpleType: 'image',
|
||||
previewStatus: 'unsupported',
|
||||
thumbnailStatus: 'unsupported'
|
||||
}
|
||||
});
|
||||
}));
|
||||
|
||||
it('should load the thumbnail preview of a pdf', fakeAsync(() => {
|
||||
const blob = createFakePdfBlob();
|
||||
const mockResponse = {
|
||||
id: 4004,
|
||||
name: 'FakeBlob.pdf',
|
||||
created: 1490354907883,
|
||||
createdBy: {
|
||||
id: 2,
|
||||
firstName: 'admin',
|
||||
lastName: 'admin',
|
||||
email: 'administrator@admin.com'
|
||||
},
|
||||
relatedContent: false,
|
||||
contentAvailable: true,
|
||||
link: false,
|
||||
mimeType: 'application/pdf',
|
||||
simpleType: 'pdf',
|
||||
previewStatus: 'created',
|
||||
thumbnailStatus: 'created'
|
||||
};
|
||||
|
||||
spyOn(processContentService, 'getFileContent').and.returnValue(of(mockResponse as any));
|
||||
spyOn(processContentService, 'getContentThumbnail').and.returnValue(of(blob));
|
||||
|
||||
component.thumbnailLoaded.subscribe((res) => {
|
||||
@@ -151,32 +158,30 @@ describe('ContentWidgetComponent', () => {
|
||||
const contentId = 1;
|
||||
const change = new SimpleChange(null, contentId, true);
|
||||
component.ngOnChanges({ id: change });
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: {
|
||||
id: 4004,
|
||||
name: 'FakeBlob.pdf',
|
||||
created: 1490354907883,
|
||||
createdBy: {
|
||||
id: 2,
|
||||
firstName: 'admin',
|
||||
lastName: 'admin',
|
||||
email: 'administrator@admin.com'
|
||||
},
|
||||
relatedContent: false,
|
||||
contentAvailable: true,
|
||||
link: false,
|
||||
mimeType: 'application/pdf',
|
||||
simpleType: 'pdf',
|
||||
previewStatus: 'created',
|
||||
thumbnailStatus: 'created'
|
||||
}
|
||||
});
|
||||
}));
|
||||
|
||||
it('should show unsupported preview with unsupported file', fakeAsync(() => {
|
||||
const mockResponse = {
|
||||
id: 4004,
|
||||
name: 'FakeBlob.zip',
|
||||
created: 1490354907883,
|
||||
createdBy: {
|
||||
id: 2,
|
||||
firstName: 'admin',
|
||||
lastName: 'admin',
|
||||
email: 'administrator@admin.com'
|
||||
},
|
||||
relatedContent: false,
|
||||
contentAvailable: false,
|
||||
link: false,
|
||||
mimeType: 'application/zip',
|
||||
simpleType: 'zip',
|
||||
previewStatus: 'unsupported',
|
||||
thumbnailStatus: 'unsupported'
|
||||
};
|
||||
|
||||
spyOn(processContentService, 'getFileContent').and.returnValue(of(mockResponse as any));
|
||||
|
||||
const contentId = 1;
|
||||
const change = new SimpleChange(null, contentId, true);
|
||||
component.ngOnChanges({ id: change });
|
||||
@@ -187,29 +192,6 @@ describe('ContentWidgetComponent', () => {
|
||||
expect(thumbnailPreview).toBeDefined();
|
||||
expect(element.querySelector('div.upload-widget__content-text').innerHTML).toEqual('FakeBlob.zip');
|
||||
});
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: {
|
||||
id: 4004,
|
||||
name: 'FakeBlob.zip',
|
||||
created: 1490354907883,
|
||||
createdBy: {
|
||||
id: 2,
|
||||
firstName: 'admin',
|
||||
lastName: 'admin',
|
||||
email: 'administrator@admin.com'
|
||||
},
|
||||
relatedContent: false,
|
||||
contentAvailable: false,
|
||||
link: false,
|
||||
mimeType: 'application/zip',
|
||||
simpleType: 'zip',
|
||||
previewStatus: 'unsupported',
|
||||
thumbnailStatus: 'unsupported'
|
||||
}
|
||||
});
|
||||
}));
|
||||
|
||||
it('should open the viewer when the view button is clicked', () => {
|
||||
|
||||
@@ -21,8 +21,6 @@ import { ProcessInstanceFilterRepresentation, UserProcessInstanceFilterRepresent
|
||||
import { of } from 'rxjs';
|
||||
import { AlfrescoApiService, AlfrescoApiServiceMock } from '@alfresco/adf-content-services';
|
||||
|
||||
declare let jasmine: any;
|
||||
|
||||
const fakeProcessFiltersResponse: any = {
|
||||
size: 1,
|
||||
total: 1,
|
||||
@@ -60,12 +58,6 @@ describe('Process filter', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
getFilters = spyOn(service.userFiltersApi, 'getUserProcessInstanceFilters').and.returnValue(Promise.resolve(fakeProcessFiltersResponse));
|
||||
|
||||
jasmine.Ajax.install();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
jasmine.Ajax.uninstall();
|
||||
});
|
||||
|
||||
describe('get filters', () => {
|
||||
@@ -102,6 +94,30 @@ describe('Process filter', () => {
|
||||
});
|
||||
|
||||
it('should return the default filters', (done) => {
|
||||
const runningFilterResponse = {
|
||||
appId: 1001,
|
||||
id: 111,
|
||||
name: 'Running',
|
||||
icon: 'fake-icon',
|
||||
recent: false
|
||||
};
|
||||
const completedFilterResponse = {
|
||||
appId: 1001,
|
||||
id: 222,
|
||||
name: 'Completed',
|
||||
icon: 'fake-icon',
|
||||
recent: false
|
||||
};
|
||||
const allFilterResponse = {
|
||||
appId: 1001,
|
||||
id: 333,
|
||||
name: 'All',
|
||||
icon: 'fake-icon',
|
||||
recent: false
|
||||
};
|
||||
|
||||
spyOn(service, 'addProcessFilter').and.returnValues(of(runningFilterResponse), of(completedFilterResponse), of(allFilterResponse));
|
||||
|
||||
service.createDefaultFilters(1234).subscribe((res) => {
|
||||
expect(res).toBeDefined();
|
||||
expect(res.length).toEqual(3);
|
||||
@@ -113,45 +129,33 @@ describe('Process filter', () => {
|
||||
expect(res[2].id).toEqual(333);
|
||||
done();
|
||||
});
|
||||
|
||||
jasmine.Ajax.requests.at(0).respondWith({
|
||||
status: 200,
|
||||
contentType: 'application/json',
|
||||
responseText: JSON.stringify({
|
||||
appId: 1001,
|
||||
id: 111,
|
||||
name: 'Running',
|
||||
icon: 'fake-icon',
|
||||
recent: false
|
||||
})
|
||||
});
|
||||
|
||||
jasmine.Ajax.requests.at(1).respondWith({
|
||||
status: 200,
|
||||
contentType: 'application/json',
|
||||
responseText: JSON.stringify({
|
||||
appId: 1001,
|
||||
id: 222,
|
||||
name: 'Completed',
|
||||
icon: 'fake-icon',
|
||||
recent: false
|
||||
})
|
||||
});
|
||||
|
||||
jasmine.Ajax.requests.at(2).respondWith({
|
||||
status: 200,
|
||||
contentType: 'application/json',
|
||||
responseText: JSON.stringify({
|
||||
appId: 1001,
|
||||
id: 333,
|
||||
name: 'All',
|
||||
icon: 'fake-icon',
|
||||
recent: false
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
it('should be able create filters and add sorting information to the response', (done) => {
|
||||
const runningFilterResponse = {
|
||||
appId: 1001,
|
||||
id: 111,
|
||||
name: 'Running',
|
||||
icon: 'fake-icon',
|
||||
recent: false
|
||||
};
|
||||
const completedFilterResponse = {
|
||||
appId: 1001,
|
||||
id: 222,
|
||||
name: 'Completed',
|
||||
icon: 'fake-icon',
|
||||
recent: false
|
||||
};
|
||||
const allFilterResponse = {
|
||||
appId: 1001,
|
||||
id: 333,
|
||||
name: 'All',
|
||||
icon: 'fake-icon',
|
||||
recent: false
|
||||
};
|
||||
|
||||
spyOn(service, 'addProcessFilter').and.returnValues(of(runningFilterResponse), of(completedFilterResponse), of(allFilterResponse));
|
||||
|
||||
service.createDefaultFilters(1234).subscribe((res) => {
|
||||
expect(res).toBeDefined();
|
||||
expect(res.length).toEqual(3);
|
||||
@@ -168,42 +172,6 @@ describe('Process filter', () => {
|
||||
expect(res[2].filter.state).toEqual('all');
|
||||
done();
|
||||
});
|
||||
|
||||
jasmine.Ajax.requests.at(0).respondWith({
|
||||
status: 200,
|
||||
contentType: 'application/json',
|
||||
responseText: JSON.stringify({
|
||||
appId: 1001,
|
||||
id: 111,
|
||||
name: 'Running',
|
||||
icon: 'fake-icon',
|
||||
recent: false
|
||||
})
|
||||
});
|
||||
|
||||
jasmine.Ajax.requests.at(1).respondWith({
|
||||
status: 200,
|
||||
contentType: 'application/json',
|
||||
responseText: JSON.stringify({
|
||||
appId: 1001,
|
||||
id: 222,
|
||||
name: 'Completed',
|
||||
icon: 'fake-icon',
|
||||
recent: false
|
||||
})
|
||||
});
|
||||
|
||||
jasmine.Ajax.requests.at(2).respondWith({
|
||||
status: 200,
|
||||
contentType: 'application/json',
|
||||
responseText: JSON.stringify({
|
||||
appId: 1001,
|
||||
id: 333,
|
||||
name: 'All',
|
||||
icon: 'fake-icon',
|
||||
recent: false
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
it('should pass on any error that is returned by the API', (done) => {
|
||||
|
||||
@@ -20,8 +20,6 @@ import { PeopleProcessService } from './people-process.service';
|
||||
import { LightUserRepresentation } from '@alfresco/js-api';
|
||||
import { AlfrescoApiService, AlfrescoApiServiceMock } from '@alfresco/adf-content-services';
|
||||
|
||||
declare let jasmine: any;
|
||||
|
||||
const firstInvolvedUser: LightUserRepresentation = {
|
||||
id: 1,
|
||||
email: 'fake-user1@fake.com',
|
||||
@@ -51,15 +49,9 @@ describe('PeopleProcessService', () => {
|
||||
});
|
||||
|
||||
describe('when user is logged in', () => {
|
||||
beforeEach(() => {
|
||||
jasmine.Ajax.install();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
jasmine.Ajax.uninstall();
|
||||
});
|
||||
|
||||
it('should be able to retrieve people to involve in the task', fakeAsync(() => {
|
||||
spyOn(service.userApi, 'getUsers').and.returnValue(Promise.resolve({ data: fakeInvolveUserList } as any));
|
||||
|
||||
service.getWorkflowUsers('fake-task-id', 'fake-filter').subscribe((users) => {
|
||||
expect(users).toBeDefined();
|
||||
expect(users.length).toBe(2);
|
||||
@@ -68,27 +60,17 @@ describe('PeopleProcessService', () => {
|
||||
expect(users[0].firstName).toEqual('fakeName1');
|
||||
expect(users[0].lastName).toEqual('fakeLast1');
|
||||
});
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: { data: fakeInvolveUserList }
|
||||
});
|
||||
}));
|
||||
|
||||
it('should be able to get people images for people retrieved', fakeAsync(() => {
|
||||
spyOn(service.userApi, 'getUsers').and.returnValue(Promise.resolve({ data: fakeInvolveUserList } as any));
|
||||
|
||||
service.getWorkflowUsers('fake-task-id', 'fake-filter').subscribe((users) => {
|
||||
expect(users).toBeDefined();
|
||||
expect(users.length).toBe(2);
|
||||
expect(service.getUserImage(users[0].id.toString())).toContain('/users/' + users[0].id + '/picture');
|
||||
expect(service.getUserImage(users[1].id.toString())).toContain('/users/' + users[1].id + '/picture');
|
||||
});
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: { data: fakeInvolveUserList }
|
||||
});
|
||||
}));
|
||||
|
||||
it('should return user image url', () => {
|
||||
@@ -98,77 +80,61 @@ describe('PeopleProcessService', () => {
|
||||
});
|
||||
|
||||
it('should return empty list when there are no users to involve', fakeAsync(() => {
|
||||
spyOn(service.userApi, 'getUsers').and.returnValue(Promise.resolve({} as any));
|
||||
|
||||
service.getWorkflowUsers('fake-task-id', 'fake-filter').subscribe((users) => {
|
||||
expect(users).toBeDefined();
|
||||
expect(users.length).toBe(0);
|
||||
});
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'json',
|
||||
responseText: {}
|
||||
});
|
||||
}));
|
||||
|
||||
it('getWorkflowUsers catch errors call', fakeAsync(() => {
|
||||
spyOn(service.userApi, 'getUsers').and.returnValue(Promise.reject(errorResponse));
|
||||
|
||||
service.getWorkflowUsers('fake-task-id', 'fake-filter').subscribe(
|
||||
() => {},
|
||||
(error) => {
|
||||
expect(error).toEqual(errorResponse);
|
||||
}
|
||||
);
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 403
|
||||
});
|
||||
}));
|
||||
|
||||
it('should be able to involve people in the task', fakeAsync(() => {
|
||||
service.involveUserWithTask('fake-task-id', 'fake-user-id').subscribe(() => {
|
||||
expect(jasmine.Ajax.requests.mostRecent().method).toBe('PUT');
|
||||
expect(jasmine.Ajax.requests.mostRecent().url).toContain('tasks/fake-task-id/action/involve');
|
||||
});
|
||||
const involveSpy = spyOn(service.taskActionsApi, 'involveUser').and.returnValue(Promise.resolve([] as any));
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200
|
||||
service.involveUserWithTask('fake-task-id', 'fake-user-id').subscribe(() => {
|
||||
expect(involveSpy).toHaveBeenCalledWith('fake-task-id', { userId: 'fake-user-id' });
|
||||
});
|
||||
}));
|
||||
|
||||
it('involveUserWithTask catch errors call', fakeAsync(() => {
|
||||
spyOn(service.taskActionsApi, 'involveUser').and.returnValue(Promise.reject(errorResponse));
|
||||
|
||||
service.involveUserWithTask('fake-task-id', 'fake-user-id').subscribe(
|
||||
() => {},
|
||||
(error) => {
|
||||
expect(error).toEqual(errorResponse);
|
||||
}
|
||||
);
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 403
|
||||
});
|
||||
}));
|
||||
|
||||
it('should be able to remove involved people from task', fakeAsync(() => {
|
||||
service.removeInvolvedUser('fake-task-id', 'fake-user-id').subscribe(() => {
|
||||
expect(jasmine.Ajax.requests.mostRecent().method).toBe('PUT');
|
||||
expect(jasmine.Ajax.requests.mostRecent().url).toContain('tasks/fake-task-id/action/remove-involved');
|
||||
});
|
||||
const removeSpy = spyOn(service.taskActionsApi, 'removeInvolvedUser').and.returnValue(Promise.resolve([] as any));
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200
|
||||
service.removeInvolvedUser('fake-task-id', 'fake-user-id').subscribe(() => {
|
||||
expect(removeSpy).toHaveBeenCalledWith('fake-task-id', { userId: 'fake-user-id' });
|
||||
});
|
||||
}));
|
||||
|
||||
it('removeInvolvedUser catch errors call', fakeAsync(() => {
|
||||
spyOn(service.taskActionsApi, 'removeInvolvedUser').and.returnValue(Promise.reject(errorResponse));
|
||||
|
||||
service.removeInvolvedUser('fake-task-id', 'fake-user-id').subscribe(
|
||||
() => {},
|
||||
(error) => {
|
||||
expect(error).toEqual(errorResponse);
|
||||
}
|
||||
);
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 403
|
||||
});
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
||||
+30
-62
@@ -42,8 +42,6 @@ import { MatMenuItemHarness } from '@angular/material/menu/testing';
|
||||
import { AlfrescoApiService, AlfrescoApiServiceMock } from '@alfresco/adf-content-services';
|
||||
import { CommonModule } from '@angular/common';
|
||||
|
||||
declare let jasmine: any;
|
||||
|
||||
describe('TaskListComponent', () => {
|
||||
let component: TaskListComponent;
|
||||
let fixture: ComponentFixture<TaskListComponent>;
|
||||
@@ -51,16 +49,22 @@ describe('TaskListComponent', () => {
|
||||
let appConfig: AppConfigService;
|
||||
let taskListService: TaskListService;
|
||||
|
||||
const transformDates = (taskData: any) => ({
|
||||
...taskData,
|
||||
data: taskData.data.map((task: any) => ({
|
||||
...task,
|
||||
created: task.created ? new Date(task.created) : undefined,
|
||||
dueDate: task.dueDate ? new Date(task.dueDate) : undefined,
|
||||
endDate: task.endDate ? new Date(task.endDate) : undefined
|
||||
}))
|
||||
});
|
||||
|
||||
const testMostRecentCall = (changes: SimpleChanges) => {
|
||||
spyOn(taskListService, 'findTasksByState').and.returnValue(of(transformDates(fakeGlobalTask)));
|
||||
|
||||
component.ngAfterContentInit();
|
||||
component.ngOnChanges(changes);
|
||||
fixture.detectChanges();
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'application/json',
|
||||
responseText: JSON.stringify(fakeGlobalTask)
|
||||
});
|
||||
};
|
||||
|
||||
const testSubscribeForFilteredTaskList = (done: DoneFn) => {
|
||||
@@ -76,7 +80,7 @@ describe('TaskListComponent', () => {
|
||||
};
|
||||
|
||||
const testRowSelection = async (selectionMode?: string) => {
|
||||
spyOn(taskListService, 'findTasksByState').and.returnValues(of(fakeGlobalTask));
|
||||
spyOn(taskListService, 'findTasksByState').and.returnValues(of(transformDates(fakeGlobalTask)));
|
||||
const state = new SimpleChange(null, 'open', true);
|
||||
component.multiselect = true;
|
||||
if (selectionMode) {
|
||||
@@ -129,12 +133,7 @@ describe('TaskListComponent', () => {
|
||||
});
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
jasmine.Ajax.install();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
jasmine.Ajax.uninstall();
|
||||
fixture.destroy();
|
||||
});
|
||||
|
||||
@@ -314,14 +313,11 @@ describe('TaskListComponent', () => {
|
||||
expect(component.rows[0]['name']).toEqual('nameFake1');
|
||||
done();
|
||||
});
|
||||
|
||||
spyOn(taskListService, 'findTasksByState').and.returnValue(of(transformDates(fakeGlobalTask)));
|
||||
|
||||
fixture.detectChanges();
|
||||
component.reload();
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'application/json',
|
||||
responseText: JSON.stringify(fakeGlobalTask)
|
||||
});
|
||||
});
|
||||
|
||||
it('should emit row click event', (done) => {
|
||||
@@ -363,6 +359,8 @@ describe('TaskListComponent', () => {
|
||||
const landingTaskId = '888';
|
||||
const change = new SimpleChange(null, landingTaskId, true);
|
||||
|
||||
spyOn(taskListService, 'findTasksByState').and.returnValue(of(transformDates(fakeGlobalTask)));
|
||||
|
||||
component.success.subscribe((res) => {
|
||||
expect(res).toBeDefined();
|
||||
expect(component.rows).toBeDefined();
|
||||
@@ -371,12 +369,6 @@ describe('TaskListComponent', () => {
|
||||
});
|
||||
|
||||
component.ngOnChanges({ landingTaskId: change });
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'application/json',
|
||||
responseText: JSON.stringify(fakeGlobalTask)
|
||||
});
|
||||
});
|
||||
|
||||
it('should NOT reload the task list when no parameters changed', () => {
|
||||
@@ -390,6 +382,8 @@ describe('TaskListComponent', () => {
|
||||
const appId = '1';
|
||||
const change = new SimpleChange(null, appId, true);
|
||||
|
||||
spyOn(taskListService, 'findTasksByState').and.returnValue(of(transformDates(fakeGlobalTask)));
|
||||
|
||||
component.success.subscribe((res) => {
|
||||
expect(res).toBeDefined();
|
||||
expect(component.rows).toBeDefined();
|
||||
@@ -399,18 +393,14 @@ describe('TaskListComponent', () => {
|
||||
done();
|
||||
});
|
||||
component.ngOnChanges({ appId: change });
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'application/json',
|
||||
responseText: JSON.stringify(fakeGlobalTask)
|
||||
});
|
||||
});
|
||||
|
||||
it('should reload the list when the processDefinitionKey parameter changes', (done) => {
|
||||
const processDefinitionKey = 'fakeprocess';
|
||||
const change = new SimpleChange(null, processDefinitionKey, true);
|
||||
|
||||
spyOn(taskListService, 'findTasksByState').and.returnValue(of(transformDates(fakeGlobalTask)));
|
||||
|
||||
component.success.subscribe((res) => {
|
||||
expect(res).toBeDefined();
|
||||
expect(component.rows).toBeDefined();
|
||||
@@ -421,18 +411,14 @@ describe('TaskListComponent', () => {
|
||||
});
|
||||
|
||||
component.ngOnChanges({ processDefinitionKey: change });
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'application/json',
|
||||
responseText: JSON.stringify(fakeGlobalTask)
|
||||
});
|
||||
});
|
||||
|
||||
it('should reload the list when the state parameter changes', (done) => {
|
||||
const state = 'open';
|
||||
const change = new SimpleChange(null, state, true);
|
||||
|
||||
spyOn(taskListService, 'findTasksByState').and.returnValue(of(transformDates(fakeGlobalTask)));
|
||||
|
||||
component.success.subscribe((res) => {
|
||||
expect(res).toBeDefined();
|
||||
expect(component.rows).toBeDefined();
|
||||
@@ -443,18 +429,14 @@ describe('TaskListComponent', () => {
|
||||
});
|
||||
|
||||
component.ngOnChanges({ state: change });
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'application/json',
|
||||
responseText: JSON.stringify(fakeGlobalTask)
|
||||
});
|
||||
});
|
||||
|
||||
it('should reload the list when the sort parameter changes', (done) => {
|
||||
const sort = 'desc';
|
||||
const change = new SimpleChange(null, sort, true);
|
||||
|
||||
spyOn(taskListService, 'findTasksByState').and.returnValue(of(transformDates(fakeGlobalTask)));
|
||||
|
||||
component.success.subscribe((res) => {
|
||||
expect(res).toBeDefined();
|
||||
expect(component.rows).toBeDefined();
|
||||
@@ -465,18 +447,14 @@ describe('TaskListComponent', () => {
|
||||
});
|
||||
|
||||
component.ngOnChanges({ sort: change });
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'application/json',
|
||||
responseText: JSON.stringify(fakeGlobalTask)
|
||||
});
|
||||
});
|
||||
|
||||
it('should reload the process list when the name parameter changes', (done) => {
|
||||
const name = 'FakeTaskName';
|
||||
const change = new SimpleChange(null, name, true);
|
||||
|
||||
spyOn(taskListService, 'findTasksByState').and.returnValue(of(transformDates(fakeGlobalTask)));
|
||||
|
||||
component.success.subscribe((res) => {
|
||||
expect(res).toBeDefined();
|
||||
expect(component.rows).toBeDefined();
|
||||
@@ -487,18 +465,14 @@ describe('TaskListComponent', () => {
|
||||
});
|
||||
|
||||
component.ngOnChanges({ name: change });
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'application/json',
|
||||
responseText: JSON.stringify(fakeGlobalTask)
|
||||
});
|
||||
});
|
||||
|
||||
it('should reload the list when the assignment parameter changes', (done) => {
|
||||
const assignment = 'assignee';
|
||||
const change = new SimpleChange(null, assignment, true);
|
||||
|
||||
spyOn(taskListService, 'findTasksByState').and.returnValue(of(transformDates(fakeGlobalTask)));
|
||||
|
||||
component.success.subscribe((res) => {
|
||||
expect(res).toBeDefined();
|
||||
expect(component.rows).toBeDefined();
|
||||
@@ -509,12 +483,6 @@ describe('TaskListComponent', () => {
|
||||
});
|
||||
|
||||
component.ngOnChanges({ assignment: change });
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
contentType: 'application/json',
|
||||
responseText: JSON.stringify(fakeGlobalTask)
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user