mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
prepare tests for ng-12 upgrade (#7099)
* prepare tests for ng12 upgrade * fix lint * fix tests * test fixes * fix code and tests * fix code and tests * test fixes * test fixes
This commit is contained in:
@@ -25,7 +25,7 @@ import { setupTestBed, AuthenticationService, SitesService, AlfrescoApiService,
|
||||
import { AttachFileWidgetDialogComponentData } from './attach-file-widget-dialog-component.interface';
|
||||
import { of, throwError } from 'rxjs';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { Node, SiteEntry, NodeEntry } from '@alfresco/js-api';
|
||||
import { Node, SiteEntry, NodeEntry, SitePaging } from '@alfresco/js-api';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
|
||||
describe('AttachFileWidgetDialogComponent', () => {
|
||||
@@ -76,10 +76,10 @@ describe('AttachFileWidgetDialogComponent', () => {
|
||||
|
||||
spyOn(documentListService, 'getFolderNode').and.returnValue(of(<NodeEntry> { entry: { path: { elements: [] } } }));
|
||||
spyOn(documentListService, 'getFolder').and.returnValue(throwError('No results for test'));
|
||||
spyOn(nodeService, 'getNode').and.returnValue(of({ id: 'fake-node', path: { elements: [{ nodeType: 'st:site', name: 'fake-site'}] } }));
|
||||
spyOn(nodeService, 'getNode').and.returnValue(of(new Node({ id: 'fake-node', path: { elements: [{ nodeType: 'st:site', name: 'fake-site'}] } })));
|
||||
|
||||
spyOn(siteService, 'getSite').and.returnValue(of(fakeSite));
|
||||
spyOn(siteService, 'getSites').and.returnValue(of({ list: { entries: [] } }));
|
||||
spyOn(siteService, 'getSites').and.returnValue(of(new SitePaging({ list: { entries: [] } })));
|
||||
spyOn(widget, 'isLoggedIn').and.callFake(() => {
|
||||
return isLogged;
|
||||
});
|
||||
@@ -203,7 +203,7 @@ describe('AttachFileWidgetDialogComponent', () => {
|
||||
it('should close the dialog immediately if user already loggedIn', () => {
|
||||
isLogged = true;
|
||||
fixture.detectChanges();
|
||||
spyOn(apiService, 'getInstance').and.returnValue({ isLoggedIn: () => true });
|
||||
spyOn(apiService, 'getInstance').and.returnValue({ isLoggedIn: () => true } as any);
|
||||
widget.updateExternalHost();
|
||||
expect(matDialogRef.close).toHaveBeenCalled();
|
||||
});
|
||||
|
@@ -45,7 +45,7 @@ describe('AttachFileWidgetDialogService', () => {
|
||||
componentInstance: {
|
||||
error: new Subject<any>()
|
||||
}
|
||||
});
|
||||
} as any);
|
||||
});
|
||||
|
||||
it('should be able to open the dialog when node has permission', () => {
|
||||
|
@@ -110,7 +110,7 @@ const fakeMinimalNode: Node = <Node> {
|
||||
}
|
||||
};
|
||||
|
||||
const fakePngUpload = {
|
||||
const fakePngUpload: any = {
|
||||
'id': 1166,
|
||||
'name': 'fake-png.png',
|
||||
'created': '2017-07-25T17:17:37.099Z',
|
||||
@@ -125,7 +125,7 @@ const fakePngUpload = {
|
||||
'thumbnailStatus': 'queued'
|
||||
};
|
||||
|
||||
const fakePngAnswer = {
|
||||
const fakePngAnswer: any = {
|
||||
'id': 1155,
|
||||
'name': 'a_png_file.png',
|
||||
'created': '2017-07-25T17:17:37.099Z',
|
||||
|
@@ -21,7 +21,8 @@ import { TestBed, ComponentFixture } from '@angular/core/testing';
|
||||
import { Observable, of, throwError } from 'rxjs';
|
||||
import { FormFieldModel, FormFieldTypes, FormModel, FormOutcomeEvent, FormOutcomeModel,
|
||||
FormService, WidgetVisibilityService, NodeService, ContainerModel, fakeForm,
|
||||
setupTestBed } from '@alfresco/adf-core';
|
||||
setupTestBed,
|
||||
NodeMetadata } from '@alfresco/adf-core';
|
||||
import { FormComponent } from './form.component';
|
||||
import { ProcessFormRenderingService } from './process-form-rendering.service';
|
||||
import { ProcessTestingModule } from '../testing/process.testing.module';
|
||||
@@ -235,7 +236,7 @@ describe('FormComponent', () => {
|
||||
});
|
||||
});
|
||||
|
||||
spyOn(visibilityService, 'getTaskProcessVariable').and.returnValue(of({}));
|
||||
spyOn(visibilityService, 'getTaskProcessVariable').and.returnValue(of(null));
|
||||
spyOn(formService, 'getTask').and.callFake((currentTaskId) => {
|
||||
return new Observable((observer) => {
|
||||
observer.next({ taskId: currentTaskId, processDefinitionId: '10201' });
|
||||
@@ -258,7 +259,7 @@ describe('FormComponent', () => {
|
||||
});
|
||||
});
|
||||
|
||||
spyOn(visibilityService, 'getTaskProcessVariable').and.returnValue(of({}));
|
||||
spyOn(visibilityService, 'getTaskProcessVariable').and.returnValue(of(null));
|
||||
spyOn(formService, 'getTask').and.callFake((currentTaskId) => {
|
||||
return new Observable((observer) => {
|
||||
observer.next({ taskId: currentTaskId, processDefinitionId: 'null' });
|
||||
@@ -758,10 +759,7 @@ describe('FormComponent', () => {
|
||||
it('should load form for ecm node', () => {
|
||||
const metadata = {};
|
||||
spyOn(nodeService, 'getNodeMetadata').and.returnValue(
|
||||
new Observable((observer) => {
|
||||
observer.next({ metadata: metadata });
|
||||
observer.complete();
|
||||
})
|
||||
of(new NodeMetadata(metadata, null))
|
||||
);
|
||||
spyOn(formComponent, 'loadFormFromActiviti').and.stub();
|
||||
|
||||
|
@@ -15,8 +15,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { CommentModel } from '@alfresco/adf-core';
|
||||
|
||||
export let mockProcessInstanceComments = [
|
||||
{ message: 'Test1', created: Date.now(), createdBy: {firstName: 'Admin', lastName: 'User'} },
|
||||
{ message: 'Test2', created: Date.now(), createdBy: {firstName: 'Admin', lastName: 'User'} },
|
||||
{ message: 'Test3', created: Date.now(), createdBy: {firstName: 'Admin', lastName: 'User'} }
|
||||
new CommentModel({ message: 'Test1', created: Date.now(), createdBy: {firstName: 'Admin', lastName: 'User'} }),
|
||||
new CommentModel({ message: 'Test2', created: Date.now(), createdBy: {firstName: 'Admin', lastName: 'User'} }),
|
||||
new CommentModel({ message: 'Test3', created: Date.now(), createdBy: {firstName: 'Admin', lastName: 'User'} })
|
||||
];
|
||||
|
@@ -15,7 +15,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export let fakeProcessInstance = {
|
||||
import { ProcessListModel } from '../../process-list/models/process-list.model';
|
||||
|
||||
export let fakeProcessInstance = new ProcessListModel({
|
||||
size: 2,
|
||||
total: 2,
|
||||
start: 0,
|
||||
@@ -81,7 +83,7 @@ export let fakeProcessInstance = {
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
});
|
||||
|
||||
export let fakeProcessInstancesWithNoName = {
|
||||
size: 2,
|
||||
@@ -123,12 +125,12 @@ export let fakeProcessInstancesWithNoName = {
|
||||
]
|
||||
};
|
||||
|
||||
export let fakeProcessInstancesEmpty = {
|
||||
export let fakeProcessInstancesEmpty = new ProcessListModel({
|
||||
size: 0,
|
||||
total: 0,
|
||||
start: 0,
|
||||
data: []
|
||||
};
|
||||
});
|
||||
|
||||
export let fakeProcessCustomSchema = [
|
||||
{
|
||||
|
@@ -15,6 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { UserRepresentation } from '@alfresco/js-api';
|
||||
import { TaskDetailsModel } from '../../task-list/models/task-details.model';
|
||||
|
||||
export let standaloneTaskWithForm = new TaskDetailsModel({
|
||||
@@ -938,7 +939,7 @@ export const involvedGroupTaskForm = {
|
||||
managerOfCandidateGroup: false
|
||||
};
|
||||
|
||||
export const fakeUser = {
|
||||
export const fakeUser = new UserRepresentation({
|
||||
id: 1001,
|
||||
email: 'fake-email@gmail.com',
|
||||
firstName: 'fake',
|
||||
@@ -972,4 +973,4 @@ export const fakeUser = {
|
||||
apps: [],
|
||||
tenantPictureId: null,
|
||||
tenantName: 'abc'
|
||||
};
|
||||
});
|
||||
|
@@ -15,17 +15,15 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { AppDefinitionRepresentationModel, FilterRepresentationModel } from '../../task-list/models/filter.model';
|
||||
import { FilterRepresentationModel } from '../../task-list/models/filter.model';
|
||||
|
||||
export let fakeFiltersResponse = {
|
||||
export let fakeFiltersResponse: any = {
|
||||
size: 2, total: 2, start: 0,
|
||||
data: [
|
||||
new AppDefinitionRepresentationModel(
|
||||
{
|
||||
id: 1, name: 'FakeInvolvedTasks', recent: false, icon: 'glyphicon-align-left',
|
||||
filter: { sort: 'created-desc', name: '', state: 'open', assignment: 'fake-involved' }
|
||||
}
|
||||
),
|
||||
{
|
||||
id: 1, name: 'FakeInvolvedTasks', recent: false, icon: 'glyphicon-align-left',
|
||||
filter: { sort: 'created-desc', name: '', state: 'open', assignment: 'fake-involved' }
|
||||
},
|
||||
{
|
||||
id: 2, name: 'FakeMyTasks', recent: false, icon: 'glyphicon-align-left',
|
||||
filter: { sort: 'created-desc', name: '', state: 'open', assignment: 'fake-assignee' }
|
||||
|
@@ -15,7 +15,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export const fakeGlobalTask = {
|
||||
import { TaskListModel } from '../../task-list/models/task-list.model';
|
||||
|
||||
export const fakeGlobalTask = new TaskListModel({
|
||||
size: 2,
|
||||
start: 0,
|
||||
total: 2,
|
||||
@@ -74,7 +76,7 @@ export const fakeGlobalTask = {
|
||||
endDate: null
|
||||
}
|
||||
]
|
||||
};
|
||||
});
|
||||
|
||||
export let fakeCustomSchema = [
|
||||
{
|
||||
@@ -124,7 +126,7 @@ export let fakeEmptyTask = {
|
||||
data: []
|
||||
};
|
||||
|
||||
export const paginatedTask = {
|
||||
export const paginatedTask = new TaskListModel({
|
||||
'size': 5,
|
||||
'total': 9,
|
||||
'start': 0,
|
||||
@@ -284,4 +286,4 @@ export const paginatedTask = {
|
||||
'memberOfCandidateUsers': false,
|
||||
'managerOfCandidateGroup': false
|
||||
}]
|
||||
};
|
||||
});
|
||||
|
@@ -15,6 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { TaskListModel } from '../../task-list/models/task-list.model';
|
||||
import { fakeAppFilter } from './task-filters.mock';
|
||||
|
||||
export let fakeApps = {
|
||||
@@ -35,7 +36,7 @@ export let fakeUser1 = { id: 1, email: 'fake-email@dom.com', firstName: 'firstNa
|
||||
|
||||
export let fakeUser2 = { id: 1001, email: 'some-one@somegroup.com', firstName: 'some', lastName: 'one' };
|
||||
|
||||
export let fakeTaskList = {
|
||||
export let fakeTaskList = new TaskListModel({
|
||||
size: 1, total: 1, start: 0,
|
||||
data: [
|
||||
{
|
||||
@@ -44,7 +45,7 @@ export let fakeTaskList = {
|
||||
created: '2016-07-15T11:19:17.440+0000'
|
||||
}
|
||||
]
|
||||
};
|
||||
});
|
||||
|
||||
export let fakeTaskListDifferentProcessDefinitionKey = {
|
||||
size: 2, total: 1, start: 0,
|
||||
@@ -188,16 +189,16 @@ export let fakeTaskCompleted2 = {
|
||||
endDate: '2016-11-03T15:25:42.749+0000'
|
||||
};
|
||||
|
||||
export let fakeOpenTaskList = {
|
||||
export let fakeOpenTaskList = new TaskListModel({
|
||||
size: 2,
|
||||
total: 2,
|
||||
start: 0,
|
||||
data: [fakeTaskOpen1, fakeTaskOpen2]
|
||||
};
|
||||
});
|
||||
|
||||
export let fakeCompletedTaskList = {
|
||||
export let fakeCompletedTaskList = new TaskListModel({
|
||||
size: 2,
|
||||
total: 2,
|
||||
start: 0,
|
||||
data: [fakeTaskCompleted1, fakeTaskCompleted2]
|
||||
};
|
||||
});
|
||||
|
@@ -30,7 +30,7 @@ describe('ProcessNamePipe', () => {
|
||||
const defaultName = 'default-name';
|
||||
const datetimeIdentifier = '%{datetime}';
|
||||
const processDefinitionIdentifier = '%{processDefinition}';
|
||||
const mockCurrentDate = 'Wed Oct 23 2019';
|
||||
const mockCurrentDate = new Date('Wed Oct 23 2019');
|
||||
const mockLocalizedCurrentDate = 'Oct 23, 2019, 12:00:00 AM';
|
||||
const nameWithProcessDefinitionIdentifier = `${defaultName} - ${processDefinitionIdentifier}`;
|
||||
const nameWithDatetimeIdentifier = `${defaultName} - ${datetimeIdentifier}`;
|
||||
|
@@ -17,7 +17,7 @@
|
||||
|
||||
import { CUSTOM_ELEMENTS_SCHEMA, SimpleChange } from '@angular/core';
|
||||
import { AppsProcessService, setupTestBed } from '@alfresco/adf-core';
|
||||
import { from } from 'rxjs';
|
||||
import { from, of } from 'rxjs';
|
||||
import { FilterProcessRepresentationModel } from '../models/filter-process.model';
|
||||
import { ProcessFilterService } from '../services/process-filter.service';
|
||||
import { ProcessFiltersComponent } from './process-filters.component';
|
||||
@@ -33,8 +33,6 @@ describe('ProcessFiltersComponent', () => {
|
||||
let fixture: ComponentFixture<ProcessFiltersComponent>;
|
||||
let processFilterService: ProcessFilterService;
|
||||
let appsProcessService: AppsProcessService;
|
||||
let fakeGlobalFilterPromise;
|
||||
let mockErrorFilterPromise;
|
||||
|
||||
setupTestBed({
|
||||
imports: [
|
||||
@@ -47,7 +45,6 @@ describe('ProcessFiltersComponent', () => {
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(ProcessFiltersComponent);
|
||||
filterList = fixture.componentInstance;
|
||||
fakeGlobalFilterPromise = Promise.resolve(fakeProcessFilters);
|
||||
processFilterService = TestBed.inject(ProcessFilterService);
|
||||
appsProcessService = TestBed.inject(AppsProcessService);
|
||||
});
|
||||
@@ -56,11 +53,10 @@ describe('ProcessFiltersComponent', () => {
|
||||
fixture.destroy();
|
||||
});
|
||||
|
||||
it('should return the filter task list', (done) => {
|
||||
spyOn(processFilterService, 'getProcessFilters').and.returnValue(from(fakeGlobalFilterPromise));
|
||||
it('should return the filter task list', async (done) => {
|
||||
spyOn(processFilterService, 'getProcessFilters').and.returnValue(of(fakeProcessFilters));
|
||||
const appId = '1';
|
||||
const change = new SimpleChange(null, appId, true);
|
||||
filterList.ngOnChanges({ 'appId': change });
|
||||
|
||||
filterList.success.subscribe((res) => {
|
||||
expect(res).toBeDefined();
|
||||
@@ -72,16 +68,21 @@ describe('ProcessFiltersComponent', () => {
|
||||
done();
|
||||
});
|
||||
|
||||
fixture.detectChanges();
|
||||
});
|
||||
spyOn(filterList, 'getFiltersByAppId').and.callThrough();
|
||||
|
||||
it('should select the Running process filter', (done) => {
|
||||
spyOn(processFilterService, 'getProcessFilters').and.returnValue(from(fakeGlobalFilterPromise));
|
||||
const appId = '1';
|
||||
const change = new SimpleChange(null, appId, true);
|
||||
filterList.ngOnChanges({ 'appId': change });
|
||||
|
||||
expect(filterList.currentFilter).toBeUndefined();
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
expect(filterList.getFiltersByAppId).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should select the Running process filter', async (done) => {
|
||||
spyOn(processFilterService, 'getProcessFilters').and.returnValue(of(fakeProcessFilters));
|
||||
|
||||
const appId = '1';
|
||||
const change = new SimpleChange(null, appId, true);
|
||||
|
||||
filterList.success.subscribe(() => {
|
||||
filterList.selectRunningFilter();
|
||||
@@ -89,24 +90,26 @@ describe('ProcessFiltersComponent', () => {
|
||||
done();
|
||||
});
|
||||
|
||||
filterList.ngOnChanges({ 'appId': change });
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
});
|
||||
|
||||
it('should emit the selected filter based on the filterParam input', (done) => {
|
||||
spyOn(processFilterService, 'getProcessFilters').and.returnValue(from(fakeGlobalFilterPromise));
|
||||
it('should emit the selected filter based on the filterParam input', async (done) => {
|
||||
spyOn(processFilterService, 'getProcessFilters').and.returnValue(of(fakeProcessFilters));
|
||||
filterList.filterParam = new FilterProcessRepresentationModel({ id: 10 });
|
||||
const appId = '1';
|
||||
const change = new SimpleChange(null, appId, true);
|
||||
filterList.ngOnChanges({ 'appId': change });
|
||||
|
||||
expect(filterList.currentFilter).toBeUndefined();
|
||||
|
||||
filterList.filterSelected.subscribe((filter) => {
|
||||
expect(filter.name).toEqual('FakeCompleted');
|
||||
done();
|
||||
});
|
||||
|
||||
filterList.ngOnChanges({ 'appId': change });
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
});
|
||||
|
||||
it('should filterClicked emit when a filter is clicked from the UI', async () => {
|
||||
@@ -123,7 +126,7 @@ describe('ProcessFiltersComponent', () => {
|
||||
});
|
||||
|
||||
it('should reset selection when filterParam is a filter that does not exist', async () => {
|
||||
spyOn(processFilterService, 'getProcessFilters').and.returnValue(from(fakeGlobalFilterPromise));
|
||||
spyOn(processFilterService, 'getProcessFilters').and.returnValue(of(fakeProcessFilters));
|
||||
|
||||
const nonExistingFilterParam = { name: 'non-existing-filter' };
|
||||
const appId = '1';
|
||||
@@ -141,7 +144,7 @@ describe('ProcessFiltersComponent', () => {
|
||||
|
||||
it('should return the filter task list, filtered By Name', (done) => {
|
||||
spyOn(appsProcessService, 'getDeployedApplicationsByName').and.returnValue(from(Promise.resolve({ id: 1 })));
|
||||
spyOn(processFilterService, 'getProcessFilters').and.returnValue(from(fakeGlobalFilterPromise));
|
||||
spyOn(processFilterService, 'getProcessFilters').and.returnValue(of(fakeProcessFilters));
|
||||
|
||||
const change = new SimpleChange(null, 'test', true);
|
||||
filterList.ngOnChanges({ 'appName': change });
|
||||
@@ -157,7 +160,7 @@ describe('ProcessFiltersComponent', () => {
|
||||
});
|
||||
|
||||
it('should emit an error with a bad response', (done) => {
|
||||
mockErrorFilterPromise = Promise.reject({
|
||||
const mockErrorFilterPromise = Promise.reject({
|
||||
error: 'wrong request'
|
||||
});
|
||||
spyOn(processFilterService, 'getProcessFilters').and.returnValue(from(mockErrorFilterPromise));
|
||||
@@ -175,6 +178,9 @@ describe('ProcessFiltersComponent', () => {
|
||||
});
|
||||
|
||||
it('should emit an error with a bad response', (done) => {
|
||||
const mockErrorFilterPromise = Promise.reject({
|
||||
error: 'wrong request'
|
||||
});
|
||||
spyOn(appsProcessService, 'getDeployedApplicationsByName').and.returnValue(from(mockErrorFilterPromise));
|
||||
|
||||
const appId = 'fake-app';
|
||||
@@ -196,7 +202,7 @@ describe('ProcessFiltersComponent', () => {
|
||||
filter: { state: 'open', assignment: 'fake-involved' }
|
||||
});
|
||||
|
||||
filterList.filterClicked.subscribe((filter: FilterProcessRepresentationModel) => {
|
||||
filterList.filterClicked.subscribe((filter) => {
|
||||
expect(filter).toBeDefined();
|
||||
expect(filter).toEqual(currentFilter);
|
||||
expect(filterList.currentFilter).toEqual(currentFilter);
|
||||
@@ -247,7 +253,7 @@ describe('ProcessFiltersComponent', () => {
|
||||
});
|
||||
|
||||
it('should select the filter passed as input by id', (done) => {
|
||||
spyOn(processFilterService, 'getProcessFilters').and.returnValue(from(fakeGlobalFilterPromise));
|
||||
spyOn(processFilterService, 'getProcessFilters').and.returnValue(of(fakeProcessFilters));
|
||||
|
||||
filterList.filterParam = new FilterProcessRepresentationModel({ id: 20 });
|
||||
|
||||
@@ -267,7 +273,7 @@ describe('ProcessFiltersComponent', () => {
|
||||
});
|
||||
|
||||
it('should select the filter passed as input by name', (done) => {
|
||||
spyOn(processFilterService, 'getProcessFilters').and.returnValue(from(fakeGlobalFilterPromise));
|
||||
spyOn(processFilterService, 'getProcessFilters').and.returnValue(of(fakeProcessFilters));
|
||||
|
||||
filterList.filterParam = new FilterProcessRepresentationModel({ name: 'FakeAll' });
|
||||
|
||||
@@ -287,7 +293,7 @@ describe('ProcessFiltersComponent', () => {
|
||||
});
|
||||
|
||||
it('should attach specific icon for each filter if hasIcon is true', (done) => {
|
||||
spyOn(processFilterService, 'getProcessFilters').and.returnValue(from(fakeGlobalFilterPromise));
|
||||
spyOn(processFilterService, 'getProcessFilters').and.returnValue(of(fakeProcessFilters));
|
||||
filterList.showIcon = true;
|
||||
const change = new SimpleChange(undefined, 1, true);
|
||||
filterList.ngOnChanges({ 'appId': change });
|
||||
@@ -305,7 +311,7 @@ describe('ProcessFiltersComponent', () => {
|
||||
});
|
||||
|
||||
it('should not attach icons for each filter if hasIcon is false', (done) => {
|
||||
spyOn(processFilterService, 'getProcessFilters').and.returnValue(from(fakeGlobalFilterPromise));
|
||||
spyOn(processFilterService, 'getProcessFilters').and.returnValue(of(fakeProcessFilters));
|
||||
filterList.showIcon = false;
|
||||
const change = new SimpleChange(undefined, 1, true);
|
||||
filterList.ngOnChanges({ 'appId': change });
|
||||
|
@@ -125,7 +125,7 @@ describe('ProcessInstanceListComponent', () => {
|
||||
component.state = 'open';
|
||||
fixture.detectChanges();
|
||||
tick();
|
||||
expect(emitSpy).toHaveBeenCalledWith(fakeProcessInstance);
|
||||
expect(emitSpy).toHaveBeenCalledWith(jasmine.objectContaining(fakeProcessInstance));
|
||||
}));
|
||||
|
||||
it('should return the process instances list in original order when datalist passed non-existent columns', async(() => {
|
||||
@@ -207,7 +207,7 @@ describe('ProcessInstanceListComponent', () => {
|
||||
const emitSpy = spyOn(component.success, 'emit');
|
||||
component.reload();
|
||||
tick();
|
||||
expect(emitSpy).toHaveBeenCalledWith(fakeProcessInstance);
|
||||
expect(emitSpy).toHaveBeenCalledWith(jasmine.objectContaining(fakeProcessInstance));
|
||||
}));
|
||||
|
||||
it('should reload processes when reload() is called', (done) => {
|
||||
|
@@ -137,7 +137,7 @@ describe('AttachFormComponent', () => {
|
||||
component.taskId = 1;
|
||||
component.attachFormControl.setValue(10);
|
||||
component.formKey = 12;
|
||||
spyOn(taskService, 'deleteForm').and.returnValue(of({}));
|
||||
spyOn(taskService, 'deleteForm').and.returnValue(of(null));
|
||||
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
|
@@ -42,10 +42,10 @@ describe('ChecklistComponent', () => {
|
||||
|
||||
beforeEach(async(() => {
|
||||
service = TestBed.inject(TaskListService);
|
||||
spyOn(service, 'getTaskChecklist').and.returnValue(of([{
|
||||
spyOn(service, 'getTaskChecklist').and.returnValue(of([new TaskDetailsModel({
|
||||
id: 'fake-check-changed-id',
|
||||
name: 'fake-check-changed-name'
|
||||
}]));
|
||||
})]));
|
||||
|
||||
fixture = TestBed.createComponent(ChecklistComponent);
|
||||
checklistComponent = fixture.componentInstance;
|
||||
@@ -177,9 +177,9 @@ describe('ChecklistComponent', () => {
|
||||
});
|
||||
|
||||
it('should add checklist', async(() => {
|
||||
spyOn(service, 'addTask').and.returnValue(of({
|
||||
spyOn(service, 'addTask').and.returnValue(of(new TaskDetailsModel({
|
||||
id: 'fake-check-added-id', name: 'fake-check-added-name'
|
||||
}));
|
||||
})));
|
||||
|
||||
showChecklistDialog.click();
|
||||
const addButtonDialog = <HTMLElement> window.document.querySelector('#add-check');
|
||||
@@ -193,7 +193,7 @@ describe('ChecklistComponent', () => {
|
||||
}));
|
||||
|
||||
it('should remove a checklist element', async(() => {
|
||||
spyOn(service, 'deleteTask').and.returnValue(of(''));
|
||||
spyOn(service, 'deleteTask').and.returnValue(of(null));
|
||||
|
||||
checklistComponent.taskId = 'new-fake-task-id';
|
||||
checklistComponent.checklist.push(new TaskDetailsModel({
|
||||
@@ -213,7 +213,7 @@ describe('ChecklistComponent', () => {
|
||||
}));
|
||||
|
||||
it('should send an event when the checklist is deleted', async(() => {
|
||||
spyOn(service, 'deleteTask').and.returnValue(of(''));
|
||||
spyOn(service, 'deleteTask').and.returnValue(of(null));
|
||||
checklistComponent.taskId = 'new-fake-task-id';
|
||||
checklistComponent.checklist.push(new TaskDetailsModel({
|
||||
id: 'fake-check-id',
|
||||
@@ -273,7 +273,7 @@ describe('ChecklistComponent', () => {
|
||||
}));
|
||||
|
||||
it('should emit checklist task created event when the checklist is successfully added', (done) => {
|
||||
spyOn(service, 'addTask').and.returnValue(of({ id: 'fake-check-added-id', name: 'fake-check-added-name' }));
|
||||
spyOn(service, 'addTask').and.returnValue(of(new TaskDetailsModel({ id: 'fake-check-added-id', name: 'fake-check-added-name' })));
|
||||
|
||||
const disposableCreated = checklistComponent.checklistTaskCreated.subscribe((taskAdded: TaskDetailsModel) => {
|
||||
fixture.detectChanges();
|
||||
|
@@ -17,7 +17,7 @@
|
||||
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { setupTestBed, LogService } from '@alfresco/adf-core';
|
||||
import { of, throwError, Observable } from 'rxjs';
|
||||
import { of, throwError } from 'rxjs';
|
||||
import { TaskListService } from '../services/tasklist.service';
|
||||
import { StartTaskComponent } from './start-task.component';
|
||||
import { ProcessTestingModule } from '../../testing/process.testing.module';
|
||||
@@ -64,10 +64,7 @@ describe('StartTaskComponent', () => {
|
||||
service = TestBed.inject(TaskListService);
|
||||
logService = TestBed.inject(LogService);
|
||||
|
||||
getFormListSpy = spyOn(service, 'getFormList').and.returnValue(new Observable((observer) => {
|
||||
observer.next(fakeForms$);
|
||||
observer.complete();
|
||||
}));
|
||||
getFormListSpy = spyOn(service, 'getFormList').and.returnValue(of(fakeForms$));
|
||||
|
||||
fixture.detectChanges();
|
||||
}));
|
||||
@@ -93,7 +90,7 @@ describe('StartTaskComponent', () => {
|
||||
name: 'fakeName',
|
||||
formKey: null,
|
||||
assignee: null
|
||||
}
|
||||
} as any
|
||||
));
|
||||
});
|
||||
|
||||
@@ -150,7 +147,7 @@ describe('StartTaskComponent', () => {
|
||||
name: 'fakeName',
|
||||
formKey: null,
|
||||
assignee: null
|
||||
}
|
||||
} as any
|
||||
));
|
||||
});
|
||||
|
||||
@@ -213,7 +210,7 @@ describe('StartTaskComponent', () => {
|
||||
name: 'fakeName',
|
||||
formKey: null,
|
||||
assignee: null
|
||||
}
|
||||
} as any
|
||||
));
|
||||
spyOn(service, 'attachFormToATask').and.returnValue(of(
|
||||
{
|
||||
@@ -229,7 +226,7 @@ describe('StartTaskComponent', () => {
|
||||
name: 'fakeName',
|
||||
formKey: 1204,
|
||||
assignee: testUser
|
||||
}
|
||||
} as any
|
||||
));
|
||||
});
|
||||
|
||||
@@ -288,14 +285,8 @@ describe('StartTaskComponent', () => {
|
||||
});
|
||||
|
||||
it('should not attach a form when a form id is not selected', () => {
|
||||
const attachFormToATask = spyOn(service, 'attachFormToATask').and.returnValue([]);
|
||||
spyOn(service, 'createNewTask').and.callFake(
|
||||
function() {
|
||||
return new Observable((observer) => {
|
||||
observer.next({ id: 'task-id'});
|
||||
observer.complete();
|
||||
});
|
||||
});
|
||||
const attachFormToATask = spyOn(service, 'attachFormToATask').and.returnValue(of([]));
|
||||
spyOn(service, 'createNewTask').and.returnValue(of(new TaskDetailsModel({ id: 'task-id'})));
|
||||
component.taskForm.controls['name'].setValue('fakeName');
|
||||
fixture.detectChanges();
|
||||
const createTaskButton = <HTMLElement> element.querySelector('#button-start');
|
||||
|
@@ -28,7 +28,8 @@ import {
|
||||
BpmUserService,
|
||||
CommentProcessService, LogService, AuthenticationService,
|
||||
UserProcessModel,
|
||||
PeopleProcessService
|
||||
PeopleProcessService,
|
||||
CommentModel
|
||||
} from '@alfresco/adf-core';
|
||||
import { TaskDetailsModel } from '../models/task-details.model';
|
||||
import {
|
||||
@@ -43,7 +44,14 @@ import { TaskDetailsComponent } from './task-details.component';
|
||||
import { ProcessTestingModule } from '../../testing/process.testing.module';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
|
||||
const fakeUser: UserProcessModel = new UserProcessModel({
|
||||
const fakeUser = new UserProcessModel({
|
||||
id: 'fake-id',
|
||||
firstName: 'fake-name',
|
||||
lastName: 'fake-last',
|
||||
email: 'fake@mail.com'
|
||||
});
|
||||
|
||||
const fakeTaskAssignResponse = new TaskDetailsModel({
|
||||
id: 'fake-id',
|
||||
firstName: 'fake-name',
|
||||
lastName: 'fake-last',
|
||||
@@ -76,7 +84,7 @@ describe('TaskDetailsComponent', () => {
|
||||
logService = TestBed.inject(LogService);
|
||||
|
||||
const userService: BpmUserService = TestBed.inject(BpmUserService);
|
||||
spyOn(userService, 'getCurrentUserInfo').and.returnValue(of({}));
|
||||
spyOn(userService, 'getCurrentUserInfo').and.returnValue(of(null));
|
||||
|
||||
service = TestBed.inject(TaskListService);
|
||||
spyOn(service, 'getTaskChecklist').and.returnValue(of(noDataMock));
|
||||
@@ -89,16 +97,16 @@ describe('TaskDetailsComponent', () => {
|
||||
spyOn(formService, 'getTask').and.returnValue(of(taskDetailsMock));
|
||||
|
||||
getTasksSpy = spyOn(service, 'getTasks').and.returnValue(of(tasksMock));
|
||||
assignTaskSpy = spyOn(service, 'assignTask').and.returnValue(of(fakeUser));
|
||||
assignTaskSpy = spyOn(service, 'assignTask').and.returnValue(of(fakeTaskAssignResponse));
|
||||
commentProcessService = TestBed.inject(CommentProcessService);
|
||||
|
||||
authService = TestBed.inject(AuthenticationService);
|
||||
spyOn(authService, 'getBpmLoggedUser').and.returnValue(of({ email: 'fake-email' }));
|
||||
|
||||
spyOn(commentProcessService, 'getTaskComments').and.returnValue(of([
|
||||
{ message: 'Test1', created: Date.now(), createdBy: { firstName: 'Admin', lastName: 'User' } },
|
||||
{ message: 'Test2', created: Date.now(), createdBy: { firstName: 'Admin', lastName: 'User' } },
|
||||
{ message: 'Test3', created: Date.now(), createdBy: { firstName: 'Admin', lastName: 'User' } }
|
||||
new CommentModel({ message: 'Test1', created: Date.now(), createdBy: { firstName: 'Admin', lastName: 'User' } }),
|
||||
new CommentModel({ message: 'Test2', created: Date.now(), createdBy: { firstName: 'Admin', lastName: 'User' } }),
|
||||
new CommentModel({ message: 'Test3', created: Date.now(), createdBy: { firstName: 'Admin', lastName: 'User' } })
|
||||
]));
|
||||
|
||||
fixture = TestBed.createComponent(TaskDetailsComponent);
|
||||
|
@@ -33,23 +33,6 @@ describe('TaskFiltersComponent', () => {
|
||||
let taskListService: TaskListService;
|
||||
let taskFilterService: TaskFilterService;
|
||||
let appsProcessService: AppsProcessService;
|
||||
|
||||
const fakeGlobalFilterPromise = new Promise(function (resolve) {
|
||||
resolve(fakeTaskFilters);
|
||||
});
|
||||
|
||||
const fakeGlobalEmptyFilter = {
|
||||
message: 'invalid data'
|
||||
};
|
||||
|
||||
const fakeGlobalEmptyFilterPromise = new Promise(function (resolve) {
|
||||
resolve(fakeGlobalEmptyFilter);
|
||||
});
|
||||
|
||||
const mockErrorFilterList = {
|
||||
error: 'wrong request'
|
||||
};
|
||||
|
||||
let component: TaskFiltersComponent;
|
||||
let fixture: ComponentFixture<TaskFiltersComponent>;
|
||||
|
||||
@@ -73,6 +56,9 @@ describe('TaskFiltersComponent', () => {
|
||||
});
|
||||
|
||||
it('should emit an error with a bad response', (done) => {
|
||||
const mockErrorFilterList = {
|
||||
error: 'wrong request'
|
||||
};
|
||||
const mockErrorFilterPromise = Promise.reject(mockErrorFilterList);
|
||||
spyOn(taskFilterService, 'getTaskListFilters').and.returnValue(from(mockErrorFilterPromise));
|
||||
|
||||
@@ -86,11 +72,10 @@ describe('TaskFiltersComponent', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should return the filter task list', (done) => {
|
||||
spyOn(taskFilterService, 'getTaskListFilters').and.returnValue(from(fakeGlobalFilterPromise));
|
||||
it('should return the filter task list', async (done) => {
|
||||
spyOn(taskFilterService, 'getTaskListFilters').and.returnValue(of(fakeTaskFilters));
|
||||
const appId = '1';
|
||||
const change = new SimpleChange(null, appId, true);
|
||||
component.ngOnChanges({ 'appId': change });
|
||||
|
||||
component.success.subscribe((res) => {
|
||||
expect(res).toBeDefined();
|
||||
@@ -103,11 +88,15 @@ describe('TaskFiltersComponent', () => {
|
||||
});
|
||||
|
||||
component.ngOnInit();
|
||||
component.ngOnChanges({ 'appId': change });
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
});
|
||||
|
||||
it('Should call the API to create the default task filters when no task filters exist', async () => {
|
||||
spyOn(taskFilterService, 'getTaskListFilters').and.returnValue(of([]));
|
||||
const filtersMock = [{ name: 'default-task-filter-1'}, { name: 'default-task-filter-2'}];
|
||||
const filtersMock: any[] = [{ name: 'default-task-filter-1'}, { name: 'default-task-filter-2'}];
|
||||
const createDefaultFiltersSpy = spyOn(taskFilterService, 'createDefaultFilters').and.returnValue(of(filtersMock));
|
||||
const appId = '2';
|
||||
const change = new SimpleChange(null, appId, true);
|
||||
@@ -117,17 +106,11 @@ describe('TaskFiltersComponent', () => {
|
||||
expect(createDefaultFiltersSpy).toHaveBeenCalledWith(appId);
|
||||
});
|
||||
|
||||
it('should return the filter task list, filtered By Name', (done) => {
|
||||
|
||||
const fakeDeployedApplicationsPromise = new Promise(function (resolve) {
|
||||
resolve({});
|
||||
});
|
||||
|
||||
spyOn(appsProcessService, 'getDeployedApplicationsByName').and.returnValue(from(fakeDeployedApplicationsPromise));
|
||||
spyOn(taskFilterService, 'getTaskListFilters').and.returnValue(from(fakeGlobalFilterPromise));
|
||||
it('should return the filter task list, filtered By Name', async (done) => {
|
||||
spyOn(appsProcessService, 'getDeployedApplicationsByName').and.returnValue(of({} as any));
|
||||
spyOn(taskFilterService, 'getTaskListFilters').and.returnValue(of(fakeTaskFilters));
|
||||
|
||||
const change = new SimpleChange(null, 'test', true);
|
||||
component.ngOnChanges({ 'appName': change });
|
||||
|
||||
component.success.subscribe((res) => {
|
||||
const deployApp: any = appsProcessService.getDeployedApplicationsByName;
|
||||
@@ -137,77 +120,90 @@ describe('TaskFiltersComponent', () => {
|
||||
});
|
||||
|
||||
component.ngOnInit();
|
||||
component.ngOnChanges({ 'appName': change });
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
});
|
||||
|
||||
it('should be able to fetch and select the default if the input filter is not valid', (done) => {
|
||||
spyOn(taskFilterService, 'getTaskListFilters').and.returnValue(from(fakeGlobalEmptyFilterPromise));
|
||||
it('should be able to fetch and select the default if the input filter is not valid', async (done) => {
|
||||
const fakeGlobalEmptyFilter: any = {
|
||||
message: 'invalid data'
|
||||
};
|
||||
spyOn(taskFilterService, 'getTaskListFilters').and.returnValue(of(fakeGlobalEmptyFilter));
|
||||
spyOn(component, 'createFiltersByAppId').and.stub();
|
||||
|
||||
const appId = '1';
|
||||
const change = new SimpleChange(null, appId, true);
|
||||
component.ngOnChanges({ 'appId': change });
|
||||
|
||||
component.success.subscribe((res) => {
|
||||
expect(res).toBeDefined();
|
||||
expect(component.createFiltersByAppId).not.toHaveBeenCalled();
|
||||
done();
|
||||
});
|
||||
|
||||
component.ngOnChanges({ 'appId': change });
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
});
|
||||
|
||||
it('should select the task filter based on the input by name param', (done) => {
|
||||
spyOn(taskFilterService, 'getTaskListFilters').and.returnValue(from(fakeGlobalFilterPromise));
|
||||
it('should select the task filter based on the input by name param', async (done) => {
|
||||
spyOn(taskFilterService, 'getTaskListFilters').and.returnValue(of(fakeTaskFilters));
|
||||
|
||||
component.filterParam = new FilterParamsModel({ name: 'FakeMyTasks1' });
|
||||
const appId = '1';
|
||||
const change = new SimpleChange(null, appId, true);
|
||||
|
||||
fixture.detectChanges();
|
||||
component.ngOnChanges({ 'appId': change });
|
||||
|
||||
component.success.subscribe((res) => {
|
||||
expect(res).toBeDefined();
|
||||
expect(component.currentFilter).toBeDefined();
|
||||
expect(component.currentFilter.name).toEqual('FakeMyTasks1');
|
||||
done();
|
||||
});
|
||||
|
||||
component.ngOnChanges({ 'appId': change });
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
});
|
||||
|
||||
it('should select the task filter based on the input by index param', (done) => {
|
||||
spyOn(taskFilterService, 'getTaskListFilters').and.returnValue(from(fakeGlobalFilterPromise));
|
||||
it('should select the task filter based on the input by index param', async (done) => {
|
||||
spyOn(taskFilterService, 'getTaskListFilters').and.returnValue(of(fakeTaskFilters));
|
||||
|
||||
component.filterParam = new FilterParamsModel({ index: 2 });
|
||||
|
||||
const appId = '1';
|
||||
const change = new SimpleChange(null, appId, true);
|
||||
|
||||
fixture.detectChanges();
|
||||
component.ngOnChanges({ 'appId': change });
|
||||
|
||||
component.success.subscribe((res) => {
|
||||
expect(res).toBeDefined();
|
||||
expect(component.currentFilter).toBeDefined();
|
||||
expect(component.currentFilter.name).toEqual('FakeMyTasks2');
|
||||
done();
|
||||
});
|
||||
|
||||
component.ngOnChanges({ 'appId': change });
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
});
|
||||
|
||||
it('should select the task filter based on the input by id param', (done) => {
|
||||
spyOn(taskFilterService, 'getTaskListFilters').and.returnValue(from(fakeGlobalFilterPromise));
|
||||
it('should select the task filter based on the input by id param', async (done) => {
|
||||
spyOn(taskFilterService, 'getTaskListFilters').and.returnValue(of(fakeTaskFilters));
|
||||
|
||||
component.filterParam = new FilterParamsModel({ id: 10 });
|
||||
|
||||
const appId = '1';
|
||||
const change = new SimpleChange(null, appId, true);
|
||||
|
||||
fixture.detectChanges();
|
||||
component.ngOnChanges({ 'appId': change });
|
||||
|
||||
component.success.subscribe((res) => {
|
||||
expect(res).toBeDefined();
|
||||
expect(component.currentFilter).toBeDefined();
|
||||
expect(component.currentFilter.name).toEqual('FakeInvolvedTasks');
|
||||
done();
|
||||
});
|
||||
|
||||
component.ngOnChanges({ 'appId': change });
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
});
|
||||
|
||||
it('should emit the selected filter based on the filterParam input', () => {
|
||||
@@ -321,7 +317,7 @@ describe('TaskFiltersComponent', () => {
|
||||
}));
|
||||
|
||||
it('should attach specific icon for each filter if showIcon is true', (done) => {
|
||||
spyOn(taskFilterService, 'getTaskListFilters').and.returnValue(from(fakeGlobalFilterPromise));
|
||||
spyOn(taskFilterService, 'getTaskListFilters').and.returnValue(of(fakeTaskFilters));
|
||||
component.showIcon = true;
|
||||
const change = new SimpleChange(undefined, 1, true);
|
||||
component.ngOnChanges({ 'appId': change });
|
||||
@@ -339,7 +335,7 @@ describe('TaskFiltersComponent', () => {
|
||||
});
|
||||
|
||||
it('should not attach icons for each filter if showIcon is false', (done) => {
|
||||
spyOn(taskFilterService, 'getTaskListFilters').and.returnValue(from(fakeGlobalFilterPromise));
|
||||
spyOn(taskFilterService, 'getTaskListFilters').and.returnValue(of(fakeTaskFilters));
|
||||
component.showIcon = false;
|
||||
const change = new SimpleChange(undefined, 1, true);
|
||||
component.ngOnChanges({ 'appId': change });
|
||||
@@ -353,7 +349,7 @@ describe('TaskFiltersComponent', () => {
|
||||
});
|
||||
|
||||
it('should reset selection when filterParam is a filter that does not exist', async () => {
|
||||
spyOn(taskFilterService, 'getTaskListFilters').and.returnValue(from(fakeGlobalFilterPromise));
|
||||
spyOn(taskFilterService, 'getTaskListFilters').and.returnValue(of(fakeTaskFilters));
|
||||
component.currentFilter = fakeTaskFilters[0];
|
||||
component.filterParam = new FilterRepresentationModel( {name: 'non-existing-filter'});
|
||||
const appId = '1';
|
||||
@@ -368,7 +364,7 @@ describe('TaskFiltersComponent', () => {
|
||||
|
||||
it('Should be able to display default task filters', async () => {
|
||||
spyOn(taskFilterService, 'getTaskListFilters').and.returnValue(of([]));
|
||||
const defaultTaskFiltersMock = [
|
||||
const defaultTaskFiltersMock: any = [
|
||||
{ name: 'default-my-filter' },
|
||||
{ name: 'default-involved-filter' },
|
||||
{ name: 'default-completed-filter' }
|
||||
|
@@ -57,7 +57,7 @@ describe('ClaimTaskDirective', () => {
|
||||
});
|
||||
|
||||
it('Should be able to call claim task service', () => {
|
||||
const claimTaskSpy = spyOn(taskListService, 'claimTask').and.returnValue(of({}));
|
||||
const claimTaskSpy = spyOn(taskListService, 'claimTask').and.returnValue(of(null));
|
||||
|
||||
const button = fixture.nativeElement.querySelector('button');
|
||||
button.click();
|
||||
@@ -66,7 +66,7 @@ describe('ClaimTaskDirective', () => {
|
||||
});
|
||||
|
||||
it('Should be able to catch success event on click of claim button', async() => {
|
||||
spyOn(taskListService, 'claimTask').and.returnValue(of({}));
|
||||
spyOn(taskListService, 'claimTask').and.returnValue(of(null));
|
||||
const unclaimSpy = spyOn(fixture.componentInstance.claim, 'emit');
|
||||
|
||||
const button = fixture.nativeElement.querySelector('button');
|
||||
|
@@ -663,7 +663,7 @@ describe('TaskFormComponent', () => {
|
||||
});
|
||||
|
||||
it('should emit taskClaimed when task is claimed', (done) => {
|
||||
spyOn(taskListService, 'claimTask').and.returnValue(of({}));
|
||||
spyOn(taskListService, 'claimTask').and.returnValue(of(null));
|
||||
getTaskDetailsSpy.and.returnValue(of(claimableTaskDetailsMock));
|
||||
|
||||
component.taskId = 'mock-task-id';
|
||||
@@ -700,7 +700,7 @@ describe('TaskFormComponent', () => {
|
||||
});
|
||||
|
||||
it('should emit taskUnClaimed when task is unclaimed', (done) => {
|
||||
spyOn(taskListService, 'unclaimTask').and.returnValue(of({}));
|
||||
spyOn(taskListService, 'unclaimTask').and.returnValue(of(null));
|
||||
getBpmLoggedUserSpy.and.returnValue(of(claimedTaskDetailsMock.assignee));
|
||||
getTaskDetailsSpy.and.returnValue(of(claimedTaskDetailsMock));
|
||||
|
||||
|
@@ -57,7 +57,7 @@ describe('UnclaimTaskDirective', () => {
|
||||
});
|
||||
|
||||
it('Should be able to call unclaim task service', () => {
|
||||
const claimTaskSpy = spyOn(taskListService, 'unclaimTask').and.returnValue(of({}));
|
||||
const claimTaskSpy = spyOn(taskListService, 'unclaimTask').and.returnValue(of(null));
|
||||
|
||||
const button = fixture.nativeElement.querySelector('button');
|
||||
button.click();
|
||||
@@ -66,7 +66,7 @@ describe('UnclaimTaskDirective', () => {
|
||||
});
|
||||
|
||||
it('Should be able to catch success event on click of unclaim button', async() => {
|
||||
spyOn(taskListService, 'unclaimTask').and.returnValue(of({}));
|
||||
spyOn(taskListService, 'unclaimTask').and.returnValue(of(null));
|
||||
const unclaimSpy = spyOn(fixture.componentInstance.unclaim, 'emit');
|
||||
|
||||
const button = fixture.nativeElement.querySelector('button');
|
||||
|
@@ -17,7 +17,7 @@
|
||||
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { AppConfigService, setupTestBed, BpmUserService } from '@alfresco/adf-core';
|
||||
import { AppConfigService, setupTestBed, BpmUserService, BpmUserModel } from '@alfresco/adf-core';
|
||||
import { of } from 'rxjs';
|
||||
import {
|
||||
completedTaskDetailsMock,
|
||||
@@ -42,7 +42,7 @@ describe('TaskHeaderComponent', () => {
|
||||
let userBpmService: BpmUserService;
|
||||
let appConfigService: AppConfigService;
|
||||
|
||||
const fakeBpmAssignedUser = {
|
||||
const fakeBpmAssignedUser = new BpmUserModel({
|
||||
id: 1001,
|
||||
apps: [],
|
||||
capabilities: 'fake-capability',
|
||||
@@ -54,7 +54,7 @@ describe('TaskHeaderComponent', () => {
|
||||
lastName: 'Adams',
|
||||
fullname: 'Wilbur Adams',
|
||||
groups: []
|
||||
};
|
||||
});
|
||||
|
||||
setupTestBed({
|
||||
imports: [
|
||||
@@ -252,7 +252,7 @@ describe('TaskHeaderComponent', () => {
|
||||
}));
|
||||
|
||||
it('should emit claim event when task is claimed', (done) => {
|
||||
spyOn(service, 'claimTask').and.returnValue(of({}));
|
||||
spyOn(service, 'claimTask').and.returnValue(of(null));
|
||||
component.taskDetails = claimableTaskDetailsMock;
|
||||
|
||||
component.claim.subscribe((taskId) => {
|
||||
@@ -268,7 +268,7 @@ describe('TaskHeaderComponent', () => {
|
||||
});
|
||||
|
||||
it('should emit unclaim event when task is unclaimed', (done) => {
|
||||
spyOn(service, 'unclaimTask').and.returnValue(of({}));
|
||||
spyOn(service, 'unclaimTask').and.returnValue(of(null));
|
||||
component.taskDetails = claimedTaskDetailsMock;
|
||||
|
||||
component.unclaim.subscribe((taskId: string) => {
|
||||
|
Reference in New Issue
Block a user