[AAE-7244] fix process services cloud eslint warnings (#7503)

* fix process services cloud eslint warnings

* fix export of private consts

* improve constant export

* fix unit tests
This commit is contained in:
Denys Vuika
2022-02-17 14:08:41 +00:00
committed by GitHub
parent e017423c8c
commit 5b7f255eec
95 changed files with 2496 additions and 2613 deletions
@@ -16,7 +16,7 @@
*/ */
import { Component, OnInit, OnDestroy } from '@angular/core'; import { Component, OnInit, OnDestroy } from '@angular/core';
import { EditProcessFilterCloudComponent, ProcessFilterAction, ProcessFilterCloudModel } from '@alfresco/adf-process-services-cloud'; import { ProcessFilterAction, ProcessFilterCloudModel, PROCESS_FILTER_ACTION_DELETE, PROCESS_FILTER_ACTION_SAVE, PROCESS_FILTER_ACTION_SAVE_AS } from '@alfresco/adf-process-services-cloud';
import { ActivatedRoute, Router } from '@angular/router'; import { ActivatedRoute, Router } from '@angular/router';
import { UserPreferencesService, DataCellEvent } from '@alfresco/adf-core'; import { UserPreferencesService, DataCellEvent } from '@alfresco/adf-core';
import { CloudLayoutService, CloudServiceSettings } from './services/cloud-layout.service'; import { CloudLayoutService, CloudServiceSettings } from './services/cloud-layout.service';
@@ -124,13 +124,13 @@ export class ProcessesCloudDemoComponent implements OnInit, OnDestroy {
} }
onProcessFilterAction(filterAction: ProcessFilterAction) { onProcessFilterAction(filterAction: ProcessFilterAction) {
if (filterAction.actionType === EditProcessFilterCloudComponent.ACTION_DELETE) { if (filterAction.actionType === PROCESS_FILTER_ACTION_DELETE) {
this.cloudLayoutService.setCurrentProcessFilterParam({ index: 0 }); this.cloudLayoutService.setCurrentProcessFilterParam({ index: 0 });
} else { } else {
this.cloudLayoutService.setCurrentProcessFilterParam({ id: filterAction.filter.id }); this.cloudLayoutService.setCurrentProcessFilterParam({ id: filterAction.filter.id });
} }
if ([EditProcessFilterCloudComponent.ACTION_SAVE, EditProcessFilterCloudComponent.ACTION_SAVE_AS].includes(filterAction.actionType)) { if ([PROCESS_FILTER_ACTION_SAVE, PROCESS_FILTER_ACTION_SAVE_AS].includes(filterAction.actionType)) {
this.onFilterChange(filterAction.filter); this.onFilterChange(filterAction.filter);
} }
} }
+3 -2
View File
@@ -24,13 +24,14 @@
"@typescript-eslint/naming-convention": "warn", "@typescript-eslint/naming-convention": "warn",
"@typescript-eslint/consistent-type-assertions": "warn", "@typescript-eslint/consistent-type-assertions": "warn",
"@typescript-eslint/prefer-for-of": "warn", "@typescript-eslint/prefer-for-of": "warn",
"no-underscore-dangle": "warn", "@typescript-eslint/member-ordering": "off",
"no-underscore-dangle": ["error", { "allowAfterThis": true }],
"no-shadow": "warn", "no-shadow": "warn",
"quote-props": "warn", "quote-props": "warn",
"object-shorthand": "warn", "object-shorthand": "warn",
"prefer-const": "warn", "prefer-const": "warn",
"arrow-body-style": "warn", "arrow-body-style": "warn",
"@angular-eslint/no-output-native": "warn", "@angular-eslint/no-output-native": "off",
"space-before-function-paren": "warn", "space-before-function-paren": "warn",
"@angular-eslint/component-selector": [ "@angular-eslint/component-selector": [
@@ -35,6 +35,7 @@ export class AppDetailsCloudComponent {
/** /**
* Pass the selected app as next * Pass the selected app as next
*
* @param app * @param app
*/ */
onSelectApp(app: ApplicationInstanceModel): void { onSelectApp(app: ApplicationInstanceModel): void {
@@ -21,7 +21,7 @@ import { setupTestBed, AlfrescoApiService } from '@alfresco/adf-core';
import { of, throwError } from 'rxjs'; import { of, throwError } from 'rxjs';
import { fakeApplicationInstance } from '../mock/app-model.mock'; import { fakeApplicationInstance } from '../mock/app-model.mock';
import { AppListCloudComponent } from './app-list-cloud.component'; import { AppListCloudComponent, LAYOUT_GRID, LAYOUT_LIST } from './app-list-cloud.component';
import { AppsProcessCloudService } from '../services/apps-process-cloud.service'; import { AppsProcessCloudService } from '../services/apps-process-cloud.service';
import { ProcessServiceCloudTestingModule } from '../../testing/process-service-cloud.testing.module'; import { ProcessServiceCloudTestingModule } from '../../testing/process-service-cloud.testing.module';
import { TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
@@ -38,9 +38,7 @@ describe('AppListCloudComponent', () => {
oauth2Auth: { oauth2Auth: {
callCustomApi: () => Promise.resolve(fakeApplicationInstance) callCustomApi: () => Promise.resolve(fakeApplicationInstance)
}, },
isEcmLoggedIn() { isEcmLoggedIn: () => false,
return false;
},
reply: jasmine.createSpy('reply') reply: jasmine.createSpy('reply')
}; };
@@ -155,7 +153,7 @@ describe('AppListCloudComponent', () => {
}); });
it('should display a grid when configured to', () => { it('should display a grid when configured to', () => {
component.layoutType = AppListCloudComponent.LAYOUT_GRID; component.layoutType = LAYOUT_GRID;
fixture.detectChanges(); fixture.detectChanges();
expect(component.isGrid()).toBe(true); expect(component.isGrid()).toBe(true);
expect(component.isList()).toBe(false); expect(component.isList()).toBe(false);
@@ -170,7 +168,7 @@ describe('AppListCloudComponent', () => {
describe('List Layout ', () => { describe('List Layout ', () => {
beforeEach(() => { beforeEach(() => {
component.layoutType = AppListCloudComponent.LAYOUT_LIST; component.layoutType = LAYOUT_LIST;
}); });
it('should display a LIST when configured to', () => { it('should display a LIST when configured to', () => {
@@ -22,17 +22,16 @@ import { AppsProcessCloudService } from '../services/apps-process-cloud.service'
import { ApplicationInstanceModel } from '../models/application-instance.model'; import { ApplicationInstanceModel } from '../models/application-instance.model';
import { catchError } from 'rxjs/operators'; import { catchError } from 'rxjs/operators';
export const LAYOUT_LIST: string = 'LIST';
export const LAYOUT_GRID: string = 'GRID';
export const RUNNING_STATUS: string = 'RUNNING';
@Component({ @Component({
selector: 'adf-cloud-app-list', selector: 'adf-cloud-app-list',
templateUrl: './app-list-cloud.component.html', templateUrl: './app-list-cloud.component.html',
styleUrls: ['./app-list-cloud.component.scss'] styleUrls: ['./app-list-cloud.component.scss']
}) })
export class AppListCloudComponent implements OnInit, AfterContentInit { export class AppListCloudComponent implements OnInit, AfterContentInit {
public static LAYOUT_LIST: string = 'LIST';
public static LAYOUT_GRID: string = 'GRID';
public static RUNNING_STATUS: string = 'RUNNING';
@ContentChild(CustomEmptyContentTemplateDirective) @ContentChild(CustomEmptyContentTemplateDirective)
emptyCustomContent: CustomEmptyContentTemplateDirective; emptyCustomContent: CustomEmptyContentTemplateDirective;
@@ -40,7 +39,7 @@ export class AppListCloudComponent implements OnInit, AfterContentInit {
* values, "GRID" and "LIST". * values, "GRID" and "LIST".
*/ */
@Input() @Input()
layoutType: string = AppListCloudComponent.LAYOUT_GRID; layoutType: string = LAYOUT_GRID;
/** Emitted when an app entry is clicked. */ /** Emitted when an app entry is clicked. */
@Output() @Output()
@@ -57,7 +56,7 @@ export class AppListCloudComponent implements OnInit, AfterContentInit {
this.setDefaultLayoutType(); this.setDefaultLayoutType();
} }
this.apps$ = this.appsProcessCloudService.getDeployedApplicationsByStatus(AppListCloudComponent.RUNNING_STATUS) this.apps$ = this.appsProcessCloudService.getDeployedApplicationsByStatus(RUNNING_STATUS)
.pipe( .pipe(
catchError(() => { catchError(() => {
this.loadingError$.next(true); this.loadingError$.next(true);
@@ -80,7 +79,7 @@ export class AppListCloudComponent implements OnInit, AfterContentInit {
* Check if the value of the layoutType property is an allowed value * Check if the value of the layoutType property is an allowed value
*/ */
isValidType(): boolean { isValidType(): boolean {
if (this.layoutType && (this.layoutType === AppListCloudComponent.LAYOUT_LIST || this.layoutType === AppListCloudComponent.LAYOUT_GRID)) { if (this.layoutType && (this.layoutType === LAYOUT_LIST || this.layoutType === LAYOUT_GRID)) {
return true; return true;
} }
return false; return false;
@@ -90,20 +89,20 @@ export class AppListCloudComponent implements OnInit, AfterContentInit {
* Assign the default value to LayoutType * Assign the default value to LayoutType
*/ */
setDefaultLayoutType(): void { setDefaultLayoutType(): void {
this.layoutType = AppListCloudComponent.LAYOUT_GRID; this.layoutType = LAYOUT_GRID;
} }
/** /**
* Return true if the layout type is LIST * Return true if the layout type is LIST
*/ */
isList(): boolean { isList(): boolean {
return this.layoutType === AppListCloudComponent.LAYOUT_LIST; return this.layoutType === LAYOUT_LIST;
} }
/** /**
* Return true if the layout type is GRID * Return true if the layout type is GRID
*/ */
isGrid(): boolean { isGrid(): boolean {
return this.layoutType === AppListCloudComponent.LAYOUT_GRID; return this.layoutType === LAYOUT_GRID;
} }
} }
@@ -34,9 +34,7 @@ describe('AppsProcessCloudService', () => {
oauth2Auth: { oauth2Auth: {
callCustomApi: () => Promise.resolve({list : { entries: [ {entry: fakeApplicationInstance[0]}, {entry: fakeApplicationInstance[1]}] }}) callCustomApi: () => Promise.resolve({list : { entries: [ {entry: fakeApplicationInstance[0]}, {entry: fakeApplicationInstance[1]}] }})
}, },
isEcmLoggedIn() { isEcmLoggedIn: () => false,
return false;
},
reply: jasmine.createSpy('reply') reply: jasmine.createSpy('reply')
}; };
@@ -102,7 +102,7 @@ describe('DateRangeFilterComponent', () => {
it('should not emit any date change events when any type is selected', () => { it('should not emit any date change events when any type is selected', () => {
spyOn(component.dateChanged, 'emit'); spyOn(component.dateChanged, 'emit');
const value = <MatSelectChange> { value: DateCloudFilterType.RANGE }; const value = { value: DateCloudFilterType.RANGE } as MatSelectChange;
component.onSelectionChange(value); component.onSelectionChange(value);
expect(component.dateChanged.emit).not.toHaveBeenCalled(); expect(component.dateChanged.emit).not.toHaveBeenCalled();
}); });
@@ -114,7 +114,7 @@ describe('DateRangeFilterComponent', () => {
}); });
it('should show date-range picker when type is range', async () => { it('should show date-range picker when type is range', async () => {
const value = <MatSelectChange> { value: DateCloudFilterType.RANGE }; const value = { value: DateCloudFilterType.RANGE } as MatSelectChange;
component.onSelectionChange(value); component.onSelectionChange(value);
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -127,7 +127,9 @@ describe('DateRangeFilterComponent', () => {
component.ngOnInit(); component.ngOnInit();
fixture.detectChanges(); fixture.detectChanges();
// eslint-disable-next-line no-underscore-dangle
expect(component.dateRangeForm.get('from').value).toEqual(moment(mockFilterProperty.value._startFrom)); expect(component.dateRangeForm.get('from').value).toEqual(moment(mockFilterProperty.value._startFrom));
// eslint-disable-next-line no-underscore-dangle
expect(component.dateRangeForm.get('to').value).toEqual(moment(mockFilterProperty.value._startTo)); expect(component.dateRangeForm.get('to').value).toEqual(moment(mockFilterProperty.value._startTo));
}); });
@@ -33,10 +33,10 @@ export class CloudFormRenderingService extends FormRenderingService {
super(); super();
this.register({ this.register({
'upload': () => AttachFileCloudWidgetComponent, upload: () => AttachFileCloudWidgetComponent,
'dropdown': () => DropdownCloudWidgetComponent, dropdown: () => DropdownCloudWidgetComponent,
'date': () => DateCloudWidgetComponent, date: () => DateCloudWidgetComponent,
'people': () => PeopleCloudWidgetComponent, people: () => PeopleCloudWidgetComponent,
'functional-group': () => GroupCloudWidgetComponent, 'functional-group': () => GroupCloudWidgetComponent,
'properties-viewer': () => PropertiesViewerWidgetComponent, 'properties-viewer': () => PropertiesViewerWidgetComponent,
'radio-buttons': () => RadioButtonsCloudWidgetComponent 'radio-buttons': () => RadioButtonsCloudWidgetComponent
@@ -15,6 +15,8 @@
* limitations under the License. * limitations under the License.
*/ */
/* eslint-disable @typescript-eslint/naming-convention */
import { Component, DebugElement, SimpleChange, NgModule, Injector, ComponentFactoryResolver, ViewChild } from '@angular/core'; import { Component, DebugElement, SimpleChange, NgModule, Injector, ComponentFactoryResolver, ViewChild } from '@angular/core';
import { By } from '@angular/platform-browser'; import { By } from '@angular/platform-browser';
import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ComponentFixture, TestBed } from '@angular/core/testing';
@@ -85,7 +87,7 @@ describe('FormCloudComponent', () => {
}) })
class CustomUploadModule { } class CustomUploadModule { }
function buildWidget(type: string, injector: Injector): any { const buildWidget = (type: string, injector: Injector): any => {
const resolver = formRenderingService.getComponentTypeResolver(type); const resolver = formRenderingService.getComponentTypeResolver(type);
const widgetType = resolver(null); const widgetType = resolver(null);
@@ -94,7 +96,7 @@ describe('FormCloudComponent', () => {
const componentRef = factory.create(injector); const componentRef = factory.create(injector);
return componentRef.instance; return componentRef.instance;
} };
setupTestBed({ setupTestBed({
imports: [ imports: [
@@ -231,14 +233,14 @@ describe('FormCloudComponent', () => {
it('should enable custom outcome buttons', () => { it('should enable custom outcome buttons', () => {
const formModel = new FormModel(); const formModel = new FormModel();
formComponent.form = formModel; formComponent.form = formModel;
const outcome = new FormOutcomeModel(<any> formModel, { id: 'action1', name: 'Action 1' }); const outcome = new FormOutcomeModel(formModel, { id: 'action1', name: 'Action 1' });
expect(formComponent.isOutcomeButtonVisible(outcome, formComponent.form.readOnly)).toBeTruthy(); expect(formComponent.isOutcomeButtonVisible(outcome, formComponent.form.readOnly)).toBeTruthy();
}); });
it('should allow controlling [complete] button visibility', () => { it('should allow controlling [complete] button visibility', () => {
const formModel = new FormModel(); const formModel = new FormModel();
formComponent.form = formModel; formComponent.form = formModel;
const outcome = new FormOutcomeModel(<any> formModel, { id: '$save', name: FormOutcomeModel.SAVE_ACTION }); const outcome = new FormOutcomeModel(formModel, { id: '$save', name: FormOutcomeModel.SAVE_ACTION });
formComponent.showSaveButton = true; formComponent.showSaveButton = true;
expect(formComponent.isOutcomeButtonVisible(outcome, formComponent.form.readOnly)).toBeTruthy(); expect(formComponent.isOutcomeButtonVisible(outcome, formComponent.form.readOnly)).toBeTruthy();
@@ -251,7 +253,7 @@ describe('FormCloudComponent', () => {
const formModel = new FormModel(); const formModel = new FormModel();
formModel.readOnly = true; formModel.readOnly = true;
formComponent.form = formModel; formComponent.form = formModel;
const outcome = new FormOutcomeModel(<any> formModel, { id: '$complete', name: FormOutcomeModel.COMPLETE_ACTION }); const outcome = new FormOutcomeModel(formModel, { id: '$complete', name: FormOutcomeModel.COMPLETE_ACTION });
formComponent.showCompleteButton = true; formComponent.showCompleteButton = true;
expect(formComponent.isOutcomeButtonVisible(outcome, formComponent.form.readOnly)).toBeTruthy(); expect(formComponent.isOutcomeButtonVisible(outcome, formComponent.form.readOnly)).toBeTruthy();
@@ -261,7 +263,7 @@ describe('FormCloudComponent', () => {
const formModel = new FormModel(); const formModel = new FormModel();
formModel.readOnly = true; formModel.readOnly = true;
formComponent.form = formModel; formComponent.form = formModel;
const outcome = new FormOutcomeModel(<any> formModel, { id: '$save', name: FormOutcomeModel.SAVE_ACTION }); const outcome = new FormOutcomeModel(formModel, { id: '$save', name: FormOutcomeModel.SAVE_ACTION });
formComponent.showSaveButton = true; formComponent.showSaveButton = true;
expect(formComponent.isOutcomeButtonVisible(outcome, formComponent.form.readOnly)).toBeFalsy(); expect(formComponent.isOutcomeButtonVisible(outcome, formComponent.form.readOnly)).toBeFalsy();
@@ -271,13 +273,13 @@ describe('FormCloudComponent', () => {
const formModel = new FormModel({ selectedOutcome: 'custom-outcome' }); const formModel = new FormModel({ selectedOutcome: 'custom-outcome' });
formModel.readOnly = true; formModel.readOnly = true;
formComponent.form = formModel; formComponent.form = formModel;
let outcome = new FormOutcomeModel(<any> formModel, { id: '$customoutome', name: 'custom-outcome' }); let outcome = new FormOutcomeModel(formModel, { id: '$customoutome', name: 'custom-outcome' });
formComponent.showCompleteButton = true; formComponent.showCompleteButton = true;
formComponent.showSaveButton = true; formComponent.showSaveButton = true;
expect(formComponent.isOutcomeButtonVisible(outcome, formComponent.form.readOnly)).toBeTruthy(); expect(formComponent.isOutcomeButtonVisible(outcome, formComponent.form.readOnly)).toBeTruthy();
outcome = new FormOutcomeModel(<any> formModel, { id: '$customoutome2', name: 'custom-outcome2' }); outcome = new FormOutcomeModel(formModel, { id: '$customoutome2', name: 'custom-outcome2' });
expect(formComponent.isOutcomeButtonVisible(outcome, formComponent.form.readOnly)).toBeFalsy(); expect(formComponent.isOutcomeButtonVisible(outcome, formComponent.form.readOnly)).toBeFalsy();
}); });
@@ -285,7 +287,7 @@ describe('FormCloudComponent', () => {
const formModel = new FormModel(); const formModel = new FormModel();
formModel.readOnly = false; formModel.readOnly = false;
formComponent.form = formModel; formComponent.form = formModel;
const outcome = new FormOutcomeModel(<any> formModel, { id: '$save', name: FormOutcomeModel.COMPLETE_ACTION }); const outcome = new FormOutcomeModel(formModel, { id: '$save', name: FormOutcomeModel.COMPLETE_ACTION });
formComponent.showCompleteButton = true; formComponent.showCompleteButton = true;
expect(formComponent.isOutcomeButtonVisible(outcome, formComponent.form.readOnly)).toBeTruthy(); expect(formComponent.isOutcomeButtonVisible(outcome, formComponent.form.readOnly)).toBeTruthy();
@@ -302,20 +304,16 @@ describe('FormCloudComponent', () => {
}); });
it('should get task variables if a task form is rendered', () => { it('should get task variables if a task form is rendered', () => {
spyOn(formCloudService, 'getTaskForm').and.callFake((currentTaskId) => { spyOn(formCloudService, 'getTaskForm').and.callFake((currentTaskId) => new Observable((observer) => {
return new Observable((observer) => {
observer.next({ formRepresentation: { taskId: currentTaskId } }); observer.next({ formRepresentation: { taskId: currentTaskId } });
observer.complete(); observer.complete();
}); }));
});
spyOn(formCloudService, 'getTaskVariables').and.returnValue(of([])); spyOn(formCloudService, 'getTaskVariables').and.returnValue(of([]));
spyOn(formCloudService, 'getTask').and.callFake((currentTaskId) => { spyOn(formCloudService, 'getTask').and.callFake((currentTaskId) => new Observable((observer) => {
return new Observable((observer) => {
observer.next({ formRepresentation: { taskId: currentTaskId } } as any); observer.next({ formRepresentation: { taskId: currentTaskId } } as any);
observer.complete(); observer.complete();
}); }));
});
const taskId = '123'; const taskId = '123';
const appName = 'test-app'; const appName = 'test-app';
@@ -327,12 +325,10 @@ describe('FormCloudComponent', () => {
}); });
it('should not get task variables and form if task id is not specified', () => { it('should not get task variables and form if task id is not specified', () => {
spyOn(formCloudService, 'getTaskForm').and.callFake((currentTaskId) => { spyOn(formCloudService, 'getTaskForm').and.callFake((currentTaskId) => new Observable((observer) => {
return new Observable((observer) => {
observer.next({ taskId: currentTaskId }); observer.next({ taskId: currentTaskId });
observer.complete(); observer.complete();
}); }));
});
spyOn(formCloudService, 'getTaskVariables').and.returnValue(of([])); spyOn(formCloudService, 'getTaskVariables').and.returnValue(of([]));
@@ -380,7 +376,7 @@ describe('FormCloudComponent', () => {
formComponent.appName = appName; formComponent.appName = appName;
formComponent.appVersion = 1; formComponent.appVersion = 1;
const change = new SimpleChange(null, taskId, true); const change = new SimpleChange(null, taskId, true);
formComponent.ngOnChanges({ 'taskId': change }); formComponent.ngOnChanges({ taskId: change });
expect(formComponent.getFormByTaskId).toHaveBeenCalledWith(appName, taskId, 1); expect(formComponent.getFormByTaskId).toHaveBeenCalledWith(appName, taskId, 1);
}); });
@@ -393,7 +389,7 @@ describe('FormCloudComponent', () => {
formComponent.appName = appName; formComponent.appName = appName;
formComponent.appVersion = 1; formComponent.appVersion = 1;
const change = new SimpleChange(null, formId, true); const change = new SimpleChange(null, formId, true);
formComponent.ngOnChanges({ 'formId': change }); formComponent.ngOnChanges({ formId: change });
expect(formComponent.getFormById).toHaveBeenCalledWith(appName, formId, 1); expect(formComponent.getFormById).toHaveBeenCalledWith(appName, formId, 1);
}); });
@@ -414,7 +410,7 @@ describe('FormCloudComponent', () => {
spyOn(formComponent, 'getFormByTaskId').and.stub(); spyOn(formComponent, 'getFormByTaskId').and.stub();
spyOn(formComponent, 'getFormById').and.stub(); spyOn(formComponent, 'getFormById').and.stub();
formComponent.ngOnChanges({ 'tag': new SimpleChange(null, 'hello world', false) }); formComponent.ngOnChanges({ tag: new SimpleChange(null, 'hello world', false) });
expect(formComponent.getFormByTaskId).not.toHaveBeenCalled(); expect(formComponent.getFormByTaskId).not.toHaveBeenCalled();
expect(formComponent.getFormById).not.toHaveBeenCalled(); expect(formComponent.getFormById).not.toHaveBeenCalled();
@@ -423,7 +419,7 @@ describe('FormCloudComponent', () => {
it('should complete form on custom outcome click', () => { it('should complete form on custom outcome click', () => {
const formModel = new FormModel(); const formModel = new FormModel();
const outcomeName = 'Custom Action'; const outcomeName = 'Custom Action';
const outcome = new FormOutcomeModel(<any> formModel, { id: 'custom1', name: outcomeName }); const outcome = new FormOutcomeModel(formModel, { id: 'custom1', name: outcomeName });
let saved = false; let saved = false;
formComponent.form = formModel; formComponent.form = formModel;
@@ -438,7 +434,7 @@ describe('FormCloudComponent', () => {
it('should save form on [save] outcome click', () => { it('should save form on [save] outcome click', () => {
const formModel = new FormModel(); const formModel = new FormModel();
const outcome = new FormOutcomeModel(<any> formModel, { const outcome = new FormOutcomeModel(formModel, {
id: FormCloudComponent.SAVE_OUTCOME_ID, id: FormCloudComponent.SAVE_OUTCOME_ID,
name: 'Save', name: 'Save',
isSystem: true isSystem: true
@@ -454,7 +450,7 @@ describe('FormCloudComponent', () => {
it('should complete form on [complete] outcome click', () => { it('should complete form on [complete] outcome click', () => {
const formModel = new FormModel(); const formModel = new FormModel();
const outcome = new FormOutcomeModel(<any> formModel, { const outcome = new FormOutcomeModel(formModel, {
id: FormCloudComponent.COMPLETE_OUTCOME_ID, id: FormCloudComponent.COMPLETE_OUTCOME_ID,
name: 'Complete', name: 'Complete',
isSystem: true isSystem: true
@@ -470,7 +466,7 @@ describe('FormCloudComponent', () => {
it('should emit form saved event on custom outcome click', () => { it('should emit form saved event on custom outcome click', () => {
const formModel = new FormModel(); const formModel = new FormModel();
const outcome = new FormOutcomeModel(<any> formModel, { const outcome = new FormOutcomeModel(formModel, {
id: FormCloudComponent.CUSTOM_OUTCOME_ID, id: FormCloudComponent.CUSTOM_OUTCOME_ID,
name: 'Custom', name: 'Custom',
isSystem: true isSystem: true
@@ -488,7 +484,7 @@ describe('FormCloudComponent', () => {
it('should do nothing when clicking outcome for readonly form', () => { it('should do nothing when clicking outcome for readonly form', () => {
const formModel = new FormModel(); const formModel = new FormModel();
const outcomeName = 'Custom Action'; const outcomeName = 'Custom Action';
const outcome = new FormOutcomeModel(<any> formModel, { id: 'custom1', name: outcomeName }); const outcome = new FormOutcomeModel(formModel, { id: 'custom1', name: outcomeName });
formComponent.form = formModel; formComponent.form = formModel;
spyOn(formComponent, 'completeTaskForm').and.stub(); spyOn(formComponent, 'completeTaskForm').and.stub();
@@ -507,7 +503,7 @@ describe('FormCloudComponent', () => {
it('should require loaded form when clicking outcome', () => { it('should require loaded form when clicking outcome', () => {
const formModel = new FormModel(); const formModel = new FormModel();
const outcomeName = 'Custom Action'; const outcomeName = 'Custom Action';
const outcome = new FormOutcomeModel(<any> formModel, { id: 'custom1', name: outcomeName }); const outcome = new FormOutcomeModel(formModel, { id: 'custom1', name: outcomeName });
formComponent.readOnly = false; formComponent.readOnly = false;
formComponent.form = null; formComponent.form = null;
@@ -516,7 +512,7 @@ describe('FormCloudComponent', () => {
it('should not execute unknown system outcome', () => { it('should not execute unknown system outcome', () => {
const formModel = new FormModel(); const formModel = new FormModel();
const outcome = new FormOutcomeModel(<any> formModel, { id: 'unknown', name: 'Unknown', isSystem: true }); const outcome = new FormOutcomeModel(formModel, { id: 'unknown', name: 'Unknown', isSystem: true });
formComponent.form = formModel; formComponent.form = formModel;
expect(formComponent.onOutcomeClicked(outcome)).toBeFalsy(); expect(formComponent.onOutcomeClicked(outcome)).toBeFalsy();
@@ -524,12 +520,12 @@ describe('FormCloudComponent', () => {
it('should require custom action name to complete form', () => { it('should require custom action name to complete form', () => {
const formModel = new FormModel(); const formModel = new FormModel();
let outcome = new FormOutcomeModel(<any> formModel, { id: 'custom' }); let outcome = new FormOutcomeModel(formModel, { id: 'custom' });
formComponent.form = formModel; formComponent.form = formModel;
expect(formComponent.onOutcomeClicked(outcome)).toBeFalsy(); expect(formComponent.onOutcomeClicked(outcome)).toBeFalsy();
outcome = new FormOutcomeModel(<any> formModel, { id: 'custom', name: 'Custom' }); outcome = new FormOutcomeModel(formModel, { id: 'custom', name: 'Custom' });
spyOn(formComponent, 'completeTaskForm').and.stub(); spyOn(formComponent, 'completeTaskForm').and.stub();
expect(formComponent.onOutcomeClicked(outcome)).toBeTruthy(); expect(formComponent.onOutcomeClicked(outcome)).toBeTruthy();
}); });
@@ -540,7 +536,7 @@ describe('FormCloudComponent', () => {
spyOn(formCloudService, 'getTask').and.returnValue(of({})); spyOn(formCloudService, 'getTask').and.returnValue(of({}));
spyOn(formCloudService, 'getTaskVariables').and.returnValue(of([])); spyOn(formCloudService, 'getTaskVariables').and.returnValue(of([]));
spyOn(formCloudService, 'getTaskForm').and.returnValue(of({ taskId: taskId, selectedOutcome: 'custom-outcome' })); spyOn(formCloudService, 'getTaskForm').and.returnValue(of({ taskId, selectedOutcome: 'custom-outcome' }));
formComponent.formLoaded.subscribe(() => { formComponent.formLoaded.subscribe(() => {
expect(formCloudService.getTaskForm).toHaveBeenCalledWith(appName, taskId, 1); expect(formCloudService.getTaskForm).toHaveBeenCalledWith(appName, taskId, 1);
@@ -561,9 +557,7 @@ describe('FormCloudComponent', () => {
spyOn(formCloudService, 'getTask').and.returnValue(of({})); spyOn(formCloudService, 'getTask').and.returnValue(of({}));
spyOn(formCloudService, 'getTaskVariables').and.returnValue(of([])); spyOn(formCloudService, 'getTaskVariables').and.returnValue(of([]));
spyOn(formComponent, 'handleError').and.stub(); spyOn(formComponent, 'handleError').and.stub();
spyOn(formCloudService, 'getTaskForm').and.callFake(() => { spyOn(formCloudService, 'getTaskForm').and.callFake(() => throwError(error));
return throwError(error);
});
formComponent.getFormByTaskId('test-app', '123').then((_) => { formComponent.getFormByTaskId('test-app', '123').then((_) => {
expect(formComponent.handleError).toHaveBeenCalledWith(error); expect(formComponent.handleError).toHaveBeenCalledWith(error);
@@ -609,16 +603,14 @@ describe('FormCloudComponent', () => {
const formValues: any[] = []; const formValues: any[] = [];
const change = new SimpleChange(null, formValues, false); const change = new SimpleChange(null, formValues, false);
formComponent.data = formValues; formComponent.data = formValues;
formComponent.ngOnChanges({ 'data': change }); formComponent.ngOnChanges({ data: change });
}); });
it('should save task form and raise corresponding event', () => { it('should save task form and raise corresponding event', () => {
spyOn(formCloudService, 'saveTaskForm').and.callFake(() => { spyOn(formCloudService, 'saveTaskForm').and.callFake(() => new Observable((observer) => {
return new Observable((observer) => {
observer.next(); observer.next();
observer.complete(); observer.complete();
}); }));
});
let saved = false; let saved = false;
let savedForm = null; let savedForm = null;
@@ -633,7 +625,7 @@ describe('FormCloudComponent', () => {
const formModel = new FormModel({ const formModel = new FormModel({
id: '23', id: '23',
taskId: taskId, taskId,
fields: [ fields: [
{ id: 'field1' }, { id: 'field1' },
{ id: 'field2' } { id: 'field2' }
@@ -660,7 +652,7 @@ describe('FormCloudComponent', () => {
const appName = 'test-app'; const appName = 'test-app';
const formModel = new FormModel({ const formModel = new FormModel({
id: '23', id: '23',
taskId: taskId, taskId,
fields: [ fields: [
{ id: 'field1' }, { id: 'field1' },
{ id: 'field2' } { id: 'field2' }
@@ -711,12 +703,10 @@ describe('FormCloudComponent', () => {
}); });
it('should complete form and raise corresponding event', () => { it('should complete form and raise corresponding event', () => {
spyOn(formCloudService, 'completeTaskForm').and.callFake(() => { spyOn(formCloudService, 'completeTaskForm').and.callFake(() => new Observable((observer) => {
return new Observable((observer) => {
observer.next(); observer.next();
observer.complete(); observer.complete();
}); }));
});
const outcome = 'complete'; const outcome = 'complete';
let completed = false; let completed = false;
@@ -729,7 +719,7 @@ describe('FormCloudComponent', () => {
const formModel = new FormModel({ const formModel = new FormModel({
id: '23', id: '23',
taskId: taskId, taskId,
fields: [ fields: [
{ id: 'field1' }, { id: 'field1' },
{ id: 'field2' } { id: 'field2' }
@@ -767,7 +757,7 @@ describe('FormCloudComponent', () => {
it('should prevent default outcome execution', () => { it('should prevent default outcome execution', () => {
const outcome = new FormOutcomeModel(<any> new FormModel(), { const outcome = new FormOutcomeModel(new FormModel(), {
id: FormCloudComponent.CUSTOM_OUTCOME_ID, id: FormCloudComponent.CUSTOM_OUTCOME_ID,
name: 'Custom' name: 'Custom'
}); });
@@ -784,7 +774,7 @@ describe('FormCloudComponent', () => {
}); });
it('should not prevent default outcome execution', () => { it('should not prevent default outcome execution', () => {
const outcome = new FormOutcomeModel(<any> new FormModel(), { const outcome = new FormOutcomeModel(new FormModel(), {
id: FormCloudComponent.CUSTOM_OUTCOME_ID, id: FormCloudComponent.CUSTOM_OUTCOME_ID,
name: 'Custom' name: 'Custom'
}); });
@@ -812,7 +802,7 @@ describe('FormCloudComponent', () => {
formComponent.checkVisibility(field); formComponent.checkVisibility(field);
expect(visibilityService.refreshVisibility).not.toHaveBeenCalled(); expect(visibilityService.refreshVisibility).not.toHaveBeenCalled();
field = new FormFieldModel(<any> new FormModel()); field = new FormFieldModel(new FormModel());
formComponent.checkVisibility(field); formComponent.checkVisibility(field);
expect(visibilityService.refreshVisibility).toHaveBeenCalledWith(field.form); expect(visibilityService.refreshVisibility).toHaveBeenCalledWith(field.form);
}); });
@@ -822,7 +812,7 @@ describe('FormCloudComponent', () => {
formModel.readOnly = true; formModel.readOnly = true;
formComponent.form = formModel; formComponent.form = formModel;
const outcome = new FormOutcomeModel(<any> new FormModel(), { const outcome = new FormOutcomeModel(new FormModel(), {
id: FormCloudComponent.CUSTOM_OUTCOME_ID, id: FormCloudComponent.CUSTOM_OUTCOME_ID,
name: 'Custom' name: 'Custom'
}); });
@@ -901,7 +891,7 @@ describe('FormCloudComponent', () => {
done(); done();
}); });
const outcome = new FormOutcomeModel(<any> new FormModel(), { const outcome = new FormOutcomeModel(new FormModel(), {
id: FormCloudComponent.CUSTOM_OUTCOME_ID, id: FormCloudComponent.CUSTOM_OUTCOME_ID,
name: 'Custom' name: 'Custom'
}); });
@@ -935,7 +925,7 @@ describe('FormCloudComponent', () => {
done(); done();
}); });
formComponent.ngOnChanges({ 'data': change }); formComponent.ngOnChanges({ data: change });
}); });
it('should refresh radio buttons value when id is given to data', () => { it('should refresh radio buttons value when id is given to data', () => {
@@ -947,7 +937,7 @@ describe('FormCloudComponent', () => {
const formValues: any[] = [{ name: 'radiobuttons1', value: 'option_2' }]; const formValues: any[] = [{ name: 'radiobuttons1', value: 'option_2' }];
const change = new SimpleChange(null, formValues, false); const change = new SimpleChange(null, formValues, false);
formComponent.data = formValues; formComponent.data = formValues;
formComponent.ngOnChanges({ 'data': change }); formComponent.ngOnChanges({ data: change });
formFields = formComponent.form.getFormFields(); formFields = formComponent.form.getFormFields();
radioFieldById = formFields.find((field) => field.id === 'radiobuttons1'); radioFieldById = formFields.find((field) => field.id === 'radiobuttons1');
@@ -962,7 +952,7 @@ describe('FormCloudComponent', () => {
formComponent.formId = formId; formComponent.formId = formId;
formComponent.appVersion = 1; formComponent.appVersion = 1;
formComponent.ngOnChanges({ 'appName': new SimpleChange(null, appName, true) }); formComponent.ngOnChanges({ appName: new SimpleChange(null, appName, true) });
expect(formCloudService.getForm).toHaveBeenCalledWith(appName, formId, 1); expect(formCloudService.getForm).toHaveBeenCalledWith(appName, formId, 1);
fixture.detectChanges(); fixture.detectChanges();
@@ -984,7 +974,7 @@ describe('FormCloudComponent', () => {
formComponent.formId = formId; formComponent.formId = formId;
formComponent.appVersion = 1; formComponent.appVersion = 1;
formComponent.ngOnChanges({ 'appName': new SimpleChange(null, appName, true) }); formComponent.ngOnChanges({ appName: new SimpleChange(null, appName, true) });
expect(formCloudService.getForm).toHaveBeenCalledWith(appName, formId, 1); expect(formCloudService.getForm).toHaveBeenCalledWith(appName, formId, 1);
fixture.detectChanges(); fixture.detectChanges();
@@ -1009,7 +999,7 @@ describe('FormCloudComponent', () => {
formComponent.formId = formId; formComponent.formId = formId;
formComponent.appVersion = 1; formComponent.appVersion = 1;
formComponent.ngOnChanges({ 'appName': new SimpleChange(null, appName, true) }); formComponent.ngOnChanges({ appName: new SimpleChange(null, appName, true) });
expect(formCloudService.getForm).toHaveBeenCalledWith(appName, formId, 1); expect(formCloudService.getForm).toHaveBeenCalledWith(appName, formId, 1);
fixture.detectChanges(); fixture.detectChanges();
@@ -1029,10 +1019,10 @@ describe('FormCloudComponent', () => {
expect(getLabelValue('amountField')).toEqual('Champ Montant'); expect(getLabelValue('amountField')).toEqual('Champ Montant');
}); });
function getLabelValue(containerId: string): string { const getLabelValue = (containerId: string): string => {
const label = fixture.debugElement.nativeElement.querySelector(`[id="field-${containerId}-container"] label`); const label = fixture.debugElement.nativeElement.querySelector(`[id="field-${containerId}-container"] label`);
return label.innerText; return label.innerText;
} };
}); });
}); });
@@ -1144,7 +1134,7 @@ describe('retrieve metadata on submit', () => {
let fixture: ComponentFixture<FormCloudComponent>; let fixture: ComponentFixture<FormCloudComponent>;
let formService: FormService; let formService: FormService;
const fakeNodeWithProperties: Node = <Node> { const fakeNodeWithProperties = {
id: 'fake-properties', id: 'fake-properties',
name: 'fake-properties-name', name: 'fake-properties-name',
content: { content: {
@@ -1154,7 +1144,7 @@ describe('retrieve metadata on submit', () => {
'pfx:property_one': 'testValue', 'pfx:property_one': 'testValue',
'pfx:property_two': true 'pfx:property_two': true
} }
}; } as Node;
beforeEach(() => { beforeEach(() => {
const apiService = TestBed.inject(AlfrescoApiService); const apiService = TestBed.inject(AlfrescoApiService);
@@ -1225,7 +1215,7 @@ describe('retrieve metadata on submit', () => {
}); });
it('should cancel bubbling a keydown event', () => { it('should cancel bubbling a keydown event', () => {
const escapeKeyboardEvent = new KeyboardEvent('keydown', { 'keyCode': ESCAPE } as any); const escapeKeyboardEvent = new KeyboardEvent('keydown', { keyCode: ESCAPE } as any);
fixture.debugElement.triggerEventHandler('keydown', escapeKeyboardEvent); fixture.debugElement.triggerEventHandler('keydown', escapeKeyboardEvent);
expect(escapeKeyboardEvent.cancelBubble).toBe(true); expect(escapeKeyboardEvent.cancelBubble).toBe(true);
@@ -210,7 +210,7 @@ export class FormCloudComponent extends FormBaseComponent implements OnChanges,
this.data = data[1]; this.data = data[1];
const parsedForm = this.parseForm(this.formCloudRepresentationJSON); const parsedForm = this.parseForm(this.formCloudRepresentationJSON);
this.visibilityService.refreshVisibility(<any> parsedForm, this.data); this.visibilityService.refreshVisibility(parsedForm, this.data);
parsedForm.validateForm(); parsedForm.validateForm();
this.form = parsedForm; this.form = parsedForm;
this.form.nodeId = '-my-'; this.form.nodeId = '-my-';
@@ -239,7 +239,7 @@ export class FormCloudComponent extends FormBaseComponent implements OnChanges,
(form) => { (form) => {
this.formCloudRepresentationJSON = form; this.formCloudRepresentationJSON = form;
const parsedForm = this.parseForm(form); const parsedForm = this.parseForm(form);
this.visibilityService.refreshVisibility(<any> parsedForm); this.visibilityService.refreshVisibility(parsedForm);
parsedForm.validateForm(); parsedForm.validateForm();
this.form = parsedForm; this.form = parsedForm;
this.form.nodeId = '-my-'; this.form.nodeId = '-my-';
@@ -300,11 +300,12 @@ export class FormCloudComponent extends FormBaseComponent implements OnChanges,
/** /**
* Get custom set of outcomes for a Form Definition. * Get custom set of outcomes for a Form Definition.
*
* @param form Form definition model. * @param form Form definition model.
*/ */
getFormDefinitionOutcomes(form: FormModel): FormOutcomeModel[] { getFormDefinitionOutcomes(form: FormModel): FormOutcomeModel[] {
return [ return [
new FormOutcomeModel(<any> form, { id: '$save', name: FormOutcomeModel.SAVE_ACTION, isSystem: true }) new FormOutcomeModel(form, { id: '$save', name: FormOutcomeModel.SAVE_ACTION, isSystem: true })
]; ];
} }
@@ -25,7 +25,6 @@ import {
FormFieldModel, FormFieldModel,
FormModel, FormModel,
FormFieldTypes, FormFieldTypes,
FormFieldMetadata,
FormService, FormService,
DownloadService, DownloadService,
AppConfigService, AppConfigService,
@@ -84,22 +83,22 @@ describe('AttachFileCloudWidgetComponent', () => {
let openUploadFileDialogSpy: jasmine.Spy; let openUploadFileDialogSpy: jasmine.Spy;
let localizedDataPipe: LocalizedDatePipe; let localizedDataPipe: LocalizedDatePipe;
function createUploadWidgetField(form: FormModel, fieldId: string, value?: any, params?: any, multiple?: boolean, name?: string, readOnly?: boolean) { const createUploadWidgetField = (form: FormModel, fieldId: string, value?: any, params?: any, multiple?: boolean, name?: string, readOnly?: boolean) => {
widget.field = new FormFieldModel(form, { widget.field = new FormFieldModel(form, {
type: FormFieldTypes.UPLOAD, type: FormFieldTypes.UPLOAD,
value: value, value,
id: fieldId, id: fieldId,
readOnly: readOnly, readOnly,
name: name, name,
tooltip: 'attach file widget', tooltip: 'attach file widget',
params: <FormFieldMetadata> { ...params, multiple: multiple } params: { ...params, multiple }
}); });
} };
function clickOnAttachFileWidget(id: string) { const clickOnAttachFileWidget = (id: string) => {
const attachButton: HTMLButtonElement = element.querySelector(`#${id}`); const attachButton: HTMLButtonElement = element.querySelector(`#${id}`);
attachButton.click(); attachButton.click();
} };
setupTestBed({ setupTestBed({
imports: [ imports: [
@@ -366,7 +365,7 @@ describe('AttachFileCloudWidgetComponent', () => {
appConfigService.config = Object.assign(appConfigService.config, { appConfigService.config = Object.assign(appConfigService.config, {
'alfresco-deployed-apps': [ 'alfresco-deployed-apps': [
{ {
'name': 'fakeapp' name: 'fakeapp'
} }
] ]
}); });
@@ -464,10 +463,7 @@ describe('AttachFileCloudWidgetComponent', () => {
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
const menuButton = <HTMLButtonElement> ( const menuButton = fixture.debugElement.query(By.css('#file-1155-option-menu')).nativeElement as HTMLButtonElement;
fixture.debugElement.query(By.css('#file-1155-option-menu'))
.nativeElement
);
menuButton.click(); menuButton.click();
fixture.detectChanges(); fixture.detectChanges();
@@ -498,7 +494,7 @@ describe('AttachFileCloudWidgetComponent', () => {
value: [] value: []
}); });
widget.field.id = 'attach-file-alfresco'; widget.field.id = 'attach-file-alfresco';
widget.field.params = <FormFieldMetadata> menuTestSourceParam; widget.field.params = menuTestSourceParam;
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -511,16 +507,10 @@ describe('AttachFileCloudWidgetComponent', () => {
it('should remove file when remove is clicked', (done) => { it('should remove file when remove is clicked', (done) => {
fixture.detectChanges(); fixture.detectChanges();
const menuButton: HTMLButtonElement = <HTMLButtonElement> ( const menuButton = fixture.debugElement.query(By.css('#file-fake-properties-option-menu')).nativeElement as HTMLButtonElement;
fixture.debugElement.query(By.css('#file-fake-properties-option-menu'))
.nativeElement
);
menuButton.click(); menuButton.click();
fixture.detectChanges(); fixture.detectChanges();
const removeOption: HTMLButtonElement = <HTMLButtonElement> ( const removeOption = fixture.debugElement.query(By.css('#file-fake-properties-remove')).nativeElement as HTMLButtonElement;
fixture.debugElement.query(By.css('#file-fake-properties-remove'))
.nativeElement
);
removeOption.click(); removeOption.click();
fixture.detectChanges(); fixture.detectChanges();
fixture.whenRenderingDone().then(() => { fixture.whenRenderingDone().then(() => {
@@ -536,19 +526,11 @@ describe('AttachFileCloudWidgetComponent', () => {
fixture.detectChanges(); fixture.detectChanges();
const menuButton: HTMLButtonElement = <HTMLButtonElement> ( const menuButton = fixture.debugElement.query(By.css('#file-fake-properties-option-menu')).nativeElement as HTMLButtonElement;
fixture.debugElement.query(By.css('#file-fake-properties-option-menu'))
.nativeElement
);
menuButton.click(); menuButton.click();
fixture.detectChanges(); fixture.detectChanges();
const downloadOption: HTMLButtonElement = <HTMLButtonElement> ( const downloadOption = fixture.debugElement.query(By.css('#file-fake-properties-download-file')).nativeElement as HTMLButtonElement;
fixture.debugElement.query(By.css('#file-fake-properties-download-file'))
.nativeElement
);
downloadOption.click(); downloadOption.click();
fixture.detectChanges(); fixture.detectChanges();
@@ -568,18 +550,10 @@ describe('AttachFileCloudWidgetComponent', () => {
); );
fixture.detectChanges(); fixture.detectChanges();
const menuButton: HTMLButtonElement = <HTMLButtonElement> ( const menuButton = fixture.debugElement.query(By.css('#file-fake-properties-option-menu')).nativeElement as HTMLButtonElement;
fixture.debugElement.query(
By.css('#file-fake-properties-option-menu')
).nativeElement
);
menuButton.click(); menuButton.click();
fixture.detectChanges(); fixture.detectChanges();
const showOption: HTMLButtonElement = <HTMLButtonElement> ( const showOption = fixture.debugElement.query(By.css('#file-fake-properties-show-file')).nativeElement as HTMLButtonElement;
fixture.debugElement.query(
By.css('#file-fake-properties-show-file')
).nativeElement
);
showOption.click(); showOption.click();
}); });
@@ -588,19 +562,11 @@ describe('AttachFileCloudWidgetComponent', () => {
widget.field.value = [fakeNodeWithProperties]; widget.field.value = [fakeNodeWithProperties];
fixture.detectChanges(); fixture.detectChanges();
const menuButton: HTMLButtonElement = <HTMLButtonElement> ( const menuButton = fixture.debugElement.query(By.css('#file-fake-properties-option-menu')).nativeElement as HTMLButtonElement;
fixture.debugElement.query(By.css('#file-fake-properties-option-menu'))
.nativeElement
);
menuButton.click(); menuButton.click();
fixture.detectChanges(); fixture.detectChanges();
const retrieveMetadataOption: HTMLButtonElement = <HTMLButtonElement> ( const retrieveMetadataOption = fixture.debugElement.query(By.css('#file-fake-properties-retrieve-file-metadata')).nativeElement as HTMLButtonElement;
fixture.debugElement.query(By.css('#file-fake-properties-retrieve-file-metadata'))
.nativeElement
);
retrieveMetadataOption.click(); retrieveMetadataOption.click();
expect(apiServiceSpy).toHaveBeenCalledWith(fakeNodeWithProperties.id); expect(apiServiceSpy).toHaveBeenCalledWith(fakeNodeWithProperties.id);
@@ -612,7 +578,7 @@ describe('AttachFileCloudWidgetComponent', () => {
}); });
it('should display the default menu options if no options are provided', () => { it('should display the default menu options if no options are provided', () => {
widget.field.params = <FormFieldMetadata> onlyLocalParams; widget.field.params = onlyLocalParams;
fixture.detectChanges(); fixture.detectChanges();
fixture.whenStable().then(() => { fixture.whenStable().then(() => {
const inputDebugElement = fixture.debugElement.query( const inputDebugElement = fixture.debugElement.query(
@@ -622,30 +588,14 @@ describe('AttachFileCloudWidgetComponent', () => {
target: { files: [fakeLocalPngAnswer] } target: { files: [fakeLocalPngAnswer] }
}); });
fixture.detectChanges(); fixture.detectChanges();
const menuButton: HTMLButtonElement = <HTMLButtonElement> ( const menuButton = fixture.debugElement.query(By.css('#file-1155-option-menu')).nativeElement as HTMLButtonElement;
fixture.debugElement.query(
By.css('#file-1155-option-menu')
).nativeElement
);
menuButton.click(); menuButton.click();
fixture.detectChanges(); fixture.detectChanges();
const showOption: HTMLButtonElement = <HTMLButtonElement> (
fixture.debugElement.query( const showOption = fixture.debugElement.query(By.css('#file-1155-show-file')).nativeElement as HTMLButtonElement;
By.css('#file-1155-show-file') const downloadOption = fixture.debugElement.query(By.css('#file-1155-download-file')).nativeElement as HTMLButtonElement;
).nativeElement const retrieveMetadataOption = fixture.debugElement.query(By.css('#file-1155-retrieve-file-metadata')).nativeElement as HTMLButtonElement;
); const removeOption = fixture.debugElement.query(By.css('#file-1155-remove')).nativeElement as HTMLButtonElement;
const downloadOption: HTMLButtonElement = <HTMLButtonElement> (
fixture.debugElement.query(By.css('#file-1155-download-file'))
.nativeElement
);
const retrieveMetadataOption: HTMLButtonElement = <HTMLButtonElement> (
fixture.debugElement.query(By.css('#file-1155-retrieve-file-metadata'))
.nativeElement
);
const removeOption: HTMLButtonElement = <HTMLButtonElement> (
fixture.debugElement.query(By.css('#file-1155-remove'))
.nativeElement
);
expect(showOption).not.toBeNull(); expect(showOption).not.toBeNull();
expect(downloadOption).not.toBeNull(); expect(downloadOption).not.toBeNull();
@@ -668,7 +618,7 @@ describe('AttachFileCloudWidgetComponent', () => {
}); });
widget.field.id = 'attach-file-alfresco'; widget.field.id = 'attach-file-alfresco';
widget.field.params = <FormFieldMetadata> menuTestSourceParam; widget.field.params = menuTestSourceParam;
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
}); });
@@ -37,6 +37,12 @@ import { UploadCloudWidgetComponent } from './upload-cloud.widget';
import { DestinationFolderPathModel, DestinationFolderPathType } from '../../../models/form-cloud-representation.model'; import { DestinationFolderPathModel, DestinationFolderPathType } from '../../../models/form-cloud-representation.model';
import { ContentNodeSelectorPanelService } from '@alfresco/adf-content-services'; import { ContentNodeSelectorPanelService } from '@alfresco/adf-content-services';
export const RETRIEVE_METADATA_OPTION = 'retrieveMetadata';
export const ALIAS_ROOT_FOLDER = '-root-';
export const ALIAS_USER_FOLDER = '-my-';
export const APP_NAME = '-appname-';
export const VALID_ALIAS = [ ALIAS_ROOT_FOLDER, ALIAS_USER_FOLDER, '-shared-' ];
@Component({ @Component({
selector: 'adf-cloud-attach-file-cloud-widget', selector: 'adf-cloud-attach-file-cloud-widget',
templateUrl: './attach-file-cloud-widget.component.html', templateUrl: './attach-file-cloud-widget.component.html',
@@ -55,18 +61,8 @@ import { ContentNodeSelectorPanelService } from '@alfresco/adf-content-services'
encapsulation: ViewEncapsulation.None encapsulation: ViewEncapsulation.None
}) })
export class AttachFileCloudWidgetComponent extends UploadCloudWidgetComponent implements OnInit, OnDestroy { export class AttachFileCloudWidgetComponent extends UploadCloudWidgetComponent implements OnInit, OnDestroy {
static ALIAS_ROOT_FOLDER = '-root-';
static ALIAS_USER_FOLDER = '-my-';
static APP_NAME = '-appname-';
static VALID_ALIAS = [
AttachFileCloudWidgetComponent.ALIAS_ROOT_FOLDER,
AttachFileCloudWidgetComponent.ALIAS_USER_FOLDER, '-shared-'
];
static RETRIEVE_METADATA_OPTION = 'retrieveMetadata';
typeId = 'AttachFileCloudWidgetComponent'; typeId = 'AttachFileCloudWidgetComponent';
rootNodeId = AttachFileCloudWidgetComponent.ALIAS_USER_FOLDER; rootNodeId = ALIAS_USER_FOLDER;
selectedNode: Node; selectedNode: Node;
_nodesApi: NodesApi; _nodesApi: NodesApi;
@@ -121,9 +117,9 @@ export class AttachFileCloudWidgetComponent extends UploadCloudWidgetComponent i
} }
replaceAppNameAliasWithValue(path: string): string { replaceAppNameAliasWithValue(path: string): string {
if (path?.match(AttachFileCloudWidgetComponent.APP_NAME)) { if (path?.match(APP_NAME)) {
const appName = this.fetchAppNameFromAppConfig(); const appName = this.fetchAppNameFromAppConfig();
return path.replace(AttachFileCloudWidgetComponent.APP_NAME, appName); return path.replace(APP_NAME, appName);
} }
return path; return path;
} }
@@ -131,7 +127,7 @@ export class AttachFileCloudWidgetComponent extends UploadCloudWidgetComponent i
async openSelectDialog() { async openSelectDialog() {
const selectedMode = this.field.params.multiple ? 'multiple' : 'single'; const selectedMode = this.field.params.multiple ? 'multiple' : 'single';
const nodeId = await this.getDestinationFolderNodeId(); const nodeId = await this.getDestinationFolderNodeId();
this.rootNodeId = nodeId ? nodeId : AttachFileCloudWidgetComponent.ALIAS_USER_FOLDER; this.rootNodeId = nodeId ? nodeId : ALIAS_USER_FOLDER;
this.contentNodeSelectorPanelService.customModels = this.field.params.customModels; this.contentNodeSelectorPanelService.customModels = this.field.params.customModels;
this.contentNodeSelectorService this.contentNodeSelectorService
@@ -160,7 +156,7 @@ export class AttachFileCloudWidgetComponent extends UploadCloudWidgetComponent i
rootNodeId = await this.getNodeIdFromFolderVariableValue(this.field.params.fileSource.destinationFolderPath); rootNodeId = await this.getNodeIdFromFolderVariableValue(this.field.params.fileSource.destinationFolderPath);
break; break;
default: default:
rootNodeId = await this.getNodeIdFromPath({ type: '', value: AttachFileCloudWidgetComponent.ALIAS_USER_FOLDER }); rootNodeId = await this.getNodeIdFromPath({ type: '', value: ALIAS_USER_FOLDER });
break; break;
} }
@@ -183,7 +179,7 @@ export class AttachFileCloudWidgetComponent extends UploadCloudWidgetComponent i
async getNodeIdFromFolderVariableValue(destinationFolderPath: DestinationFolderPath): Promise<string> { async getNodeIdFromFolderVariableValue(destinationFolderPath: DestinationFolderPath): Promise<string> {
let nodeId: string; let nodeId: string;
try { try {
nodeId = await this.contentNodeSelectorService.getNodeIdFromFolderVariableValue(destinationFolderPath.value, AttachFileCloudWidgetComponent.ALIAS_USER_FOLDER); nodeId = await this.contentNodeSelectorService.getNodeIdFromFolderVariableValue(destinationFolderPath.value, ALIAS_USER_FOLDER);
} catch (error) { } catch (error) {
this.logService.error(error); this.logService.error(error);
} }
@@ -203,7 +199,7 @@ export class AttachFileCloudWidgetComponent extends UploadCloudWidgetComponent i
} }
} }
return this.isValidAlias(alias) ? { alias, path } : { alias: AttachFileCloudWidgetComponent.ALIAS_USER_FOLDER, path: undefined }; return this.isValidAlias(alias) ? { alias, path } : { alias: ALIAS_USER_FOLDER, path: undefined };
} }
removeExistingSelection(selections: Node[]) { removeExistingSelection(selections: Node[]) {
@@ -252,11 +248,11 @@ export class AttachFileCloudWidgetComponent extends UploadCloudWidgetComponent i
} }
isRetrieveMetadataOptionEnabled(): boolean { isRetrieveMetadataOptionEnabled(): boolean {
return this.field?.params?.menuOptions && this.field.params.menuOptions[AttachFileCloudWidgetComponent.RETRIEVE_METADATA_OPTION]; return this.field?.params?.menuOptions && this.field.params.menuOptions[RETRIEVE_METADATA_OPTION];
} }
isValidAlias(alias: string): boolean { isValidAlias(alias: string): boolean {
return alias && AttachFileCloudWidgetComponent.VALID_ALIAS.includes(alias); return alias && VALID_ALIAS.includes(alias);
} }
ngOnDestroy() { ngOnDestroy() {
@@ -21,15 +21,14 @@ import { Component, EventEmitter, Input, Output } from '@angular/core';
import { LocalizedDatePipe, ThumbnailService } from '@alfresco/adf-core'; import { LocalizedDatePipe, ThumbnailService } from '@alfresco/adf-core';
import { Node } from '@alfresco/js-api'; import { Node } from '@alfresco/js-api';
export const RETRIEVE_METADATA_OPTION = 'retrieveMetadata';
@Component({ @Component({
selector: 'adf-cloud-file-properties-table', selector: 'adf-cloud-file-properties-table',
templateUrl: './file-properties-table-cloud.component.html', templateUrl: './file-properties-table-cloud.component.html',
styleUrls: ['./file-properties-table-cloud.component.scss'] styleUrls: ['./file-properties-table-cloud.component.scss']
}) })
export class FilePropertiesTableCloudComponent { export class FilePropertiesTableCloudComponent {
static RETRIEVE_METADATA_OPTION = 'retrieveMetadata';
@Input() @Input()
uploadedFiles; uploadedFiles;
@@ -109,6 +108,6 @@ export class FilePropertiesTableCloudComponent {
} }
displayMenuOption(option: string): boolean { displayMenuOption(option: string): boolean {
return this.field?.params?.menuOptions ? this.field.params.menuOptions[option] : option !== FilePropertiesTableCloudComponent.RETRIEVE_METADATA_OPTION; return this.field?.params?.menuOptions ? this.field.params.menuOptions[option] : option !== RETRIEVE_METADATA_OPTION;
} }
} }
@@ -16,7 +16,7 @@
*/ */
import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ComponentFixture, TestBed } from '@angular/core/testing';
import { DateCloudWidgetComponent } from './date-cloud.widget'; import { DateCloudWidgetComponent, DATE_FORMAT_CLOUD } from './date-cloud.widget';
import { setupTestBed, FormFieldModel, FormModel } from '@alfresco/adf-core'; import { setupTestBed, FormFieldModel, FormModel } from '@alfresco/adf-core';
import moment from 'moment-es6'; import moment from 'moment-es6';
import { ProcessServiceCloudTestingModule } from '../../../../testing/process-service-cloud.testing.module'; import { ProcessServiceCloudTestingModule } from '../../../../testing/process-service-cloud.testing.module';
@@ -46,19 +46,19 @@ describe('DateWidgetComponent', () => {
widget.field = new FormFieldModel(null, { widget.field = new FormFieldModel(null, {
id: 'date-id', id: 'date-id',
name: 'date-name', name: 'date-name',
minValue: minValue minValue
}); });
widget.ngOnInit(); widget.ngOnInit();
const expected = moment(minValue, widget.DATE_FORMAT_CLOUD); const expected = moment(minValue, DATE_FORMAT_CLOUD);
expect(widget.minDate.isSame(expected)).toBeTruthy(); expect(widget.minDate.isSame(expected)).toBeTruthy();
}); });
it('should date field be present', () => { it('should date field be present', () => {
const minValue = '1982-03-13'; const minValue = '1982-03-13';
widget.field = new FormFieldModel(null, { widget.field = new FormFieldModel(null, {
minValue: minValue minValue
}); });
fixture.detectChanges(); fixture.detectChanges();
@@ -70,11 +70,11 @@ describe('DateWidgetComponent', () => {
it('should setup max value for date picker', () => { it('should setup max value for date picker', () => {
const maxValue = '1982-03-13'; const maxValue = '1982-03-13';
widget.field = new FormFieldModel(null, { widget.field = new FormFieldModel(null, {
maxValue: maxValue maxValue
}); });
widget.ngOnInit(); widget.ngOnInit();
const expected = moment(maxValue, widget.DATE_FORMAT_CLOUD); const expected = moment(maxValue, DATE_FORMAT_CLOUD);
expect(widget.maxDate.isSame(expected)).toBeTruthy(); expect(widget.maxDate.isSame(expected)).toBeTruthy();
}); });
@@ -28,6 +28,8 @@ import {
UserPreferencesService, UserPreferenceValues, FormService UserPreferencesService, UserPreferenceValues, FormService
} from '@alfresco/adf-core'; } from '@alfresco/adf-core';
export const DATE_FORMAT_CLOUD = 'YYYY-MM-DD';
@Component({ @Component({
selector: 'date-widget', selector: 'date-widget',
providers: [ providers: [
@@ -49,9 +51,7 @@ import {
encapsulation: ViewEncapsulation.None encapsulation: ViewEncapsulation.None
}) })
export class DateCloudWidgetComponent extends WidgetComponent implements OnInit, OnDestroy { export class DateCloudWidgetComponent extends WidgetComponent implements OnInit, OnDestroy {
typeId = 'DateCloudWidgetComponent'; typeId = 'DateCloudWidgetComponent';
DATE_FORMAT_CLOUD = 'YYYY-MM-DD';
minDate: Moment; minDate: Moment;
maxDate: Moment; maxDate: Moment;
@@ -70,16 +70,16 @@ export class DateCloudWidgetComponent extends WidgetComponent implements OnInit,
.pipe(takeUntil(this.onDestroy$)) .pipe(takeUntil(this.onDestroy$))
.subscribe(locale => this.dateAdapter.setLocale(locale)); .subscribe(locale => this.dateAdapter.setLocale(locale));
const momentDateAdapter = <MomentDateAdapter> this.dateAdapter; const momentDateAdapter = this.dateAdapter as MomentDateAdapter;
momentDateAdapter.overrideDisplayFormat = this.field.dateDisplayFormat; momentDateAdapter.overrideDisplayFormat = this.field.dateDisplayFormat;
if (this.field) { if (this.field) {
if (this.field.minValue) { if (this.field.minValue) {
this.minDate = moment(this.field.minValue, this.DATE_FORMAT_CLOUD); this.minDate = moment(this.field.minValue, DATE_FORMAT_CLOUD);
} }
if (this.field.maxValue) { if (this.field.maxValue) {
this.maxDate = moment(this.field.maxValue, this.DATE_FORMAT_CLOUD); this.maxDate = moment(this.field.maxValue, DATE_FORMAT_CLOUD);
} }
} }
} }
@@ -41,13 +41,13 @@ describe('DropdownCloudWidgetComponent', () => {
let fixture: ComponentFixture<DropdownCloudWidgetComponent>; let fixture: ComponentFixture<DropdownCloudWidgetComponent>;
let element: HTMLElement; let element: HTMLElement;
async function openSelect(_selector?: string) { const openSelect = async (_selector?: string) => {
const dropdown: HTMLElement = element.querySelector('.mat-select-trigger'); const dropdown: HTMLElement = element.querySelector('.mat-select-trigger');
dropdown.click(); dropdown.click();
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
fixture.detectChanges(); fixture.detectChanges();
} };
setupTestBed({ setupTestBed({
imports: [ imports: [
@@ -71,9 +71,7 @@ describe('DropdownCloudWidgetComponent', () => {
describe('Simple Dropdown', () => { describe('Simple Dropdown', () => {
beforeEach(() => { beforeEach(() => {
spyOn(formService, 'getRestFieldValues').and.callFake(() => { spyOn(formService, 'getRestFieldValues').and.callFake(() => of(fakeOptionList));
return of(fakeOptionList);
});
widget.field = new FormFieldModel(new FormModel({ taskId: 'fake-task-id' }), { widget.field = new FormFieldModel(new FormModel({ taskId: 'fake-task-id' }), {
id: 'dropdown-id', id: 'dropdown-id',
name: 'date-name', name: 'date-name',
@@ -366,7 +364,7 @@ describe('DropdownCloudWidgetComponent', () => {
await openSelect('child-dropdown-id'); await openSelect('child-dropdown-id');
const defaultOption: any = fixture.debugElement.query(By.css('[id="empty"]')); const defaultOption: any = fixture.debugElement.query(By.css('[id="empty"]'));
expect(widget.field.options).toEqual([{ 'id': 'empty', 'name': 'Choose one...' }]); expect(widget.field.options).toEqual([{ id: 'empty', name: 'Choose one...' }]);
expect(defaultOption.context.value).toBe('empty'); expect(defaultOption.context.value).toBe('empty');
expect(defaultOption.context.viewValue).toBe('Choose one...'); expect(defaultOption.context.viewValue).toBe('Choose one...');
}); });
@@ -396,11 +394,11 @@ describe('DropdownCloudWidgetComponent', () => {
const mockParentDropdown = { id: 'parentDropdown', value: 'mock-value', validate: () => true }; const mockParentDropdown = { id: 'parentDropdown', value: 'mock-value', validate: () => true };
spyOn(widget.field.form, 'getFormFields').and.returnValue([mockParentDropdown]); spyOn(widget.field.form, 'getFormFields').and.returnValue([mockParentDropdown]);
function selectParentOption(parentOptionName: string) { const selectParentOption = (parentOptionName: string) => {
parentDropdown.value = parentOptionName; parentDropdown.value = parentOptionName;
widget.selectionChangedForField(parentDropdown); widget.selectionChangedForField(parentDropdown);
fixture.detectChanges(); fixture.detectChanges();
} };
selectParentOption('UK'); selectParentOption('UK');
await openSelect('child-dropdown-id'); await openSelect('child-dropdown-id');
@@ -495,7 +493,7 @@ describe('DropdownCloudWidgetComponent', () => {
await openSelect('child-dropdown-id'); await openSelect('child-dropdown-id');
const defaultOption: any = fixture.debugElement.query(By.css('[id="empty"]')); const defaultOption: any = fixture.debugElement.query(By.css('[id="empty"]'));
expect(widget.field.options).toEqual([{ 'id': 'empty', 'name': 'Choose one...' }]); expect(widget.field.options).toEqual([{ id: 'empty', name: 'Choose one...' }]);
expect(defaultOption.context.value).toBe('empty'); expect(defaultOption.context.value).toBe('empty');
expect(defaultOption.context.viewValue).toBe('Choose one...'); expect(defaultOption.context.viewValue).toBe('Choose one...');
}); });
@@ -31,6 +31,12 @@ import { FormCloudService } from '../../../services/form-cloud.service';
import { BehaviorSubject, combineLatest, Observable, of, Subject } from 'rxjs'; import { BehaviorSubject, combineLatest, Observable, of, Subject } from 'rxjs';
import { filter, map, takeUntil } from 'rxjs/operators'; import { filter, map, takeUntil } from 'rxjs/operators';
export const DEFAULT_OPTION = {
id: 'empty',
name: 'Choose one...'
};
export const HIDE_FILTER_LIMIT = 5;
/* eslint-disable @angular-eslint/component-selector */ /* eslint-disable @angular-eslint/component-selector */
@Component({ @Component({
@@ -51,13 +57,7 @@ import { filter, map, takeUntil } from 'rxjs/operators';
encapsulation: ViewEncapsulation.None encapsulation: ViewEncapsulation.None
}) })
export class DropdownCloudWidgetComponent extends WidgetComponent implements OnInit, OnDestroy { export class DropdownCloudWidgetComponent extends WidgetComponent implements OnInit, OnDestroy {
static DEFAULT_OPTION = {
id: 'empty',
name: 'Choose one...'
};
typeId = 'DropdownCloudWidgetComponent'; typeId = 'DropdownCloudWidgetComponent';
HIDE_FILTER_LIMIT = 5;
showInputFilter = false; showInputFilter = false;
isRestApiFailed = false; isRestApiFailed = false;
restApiHostName: string; restApiHostName: string;
@@ -151,7 +151,7 @@ export class DropdownCloudWidgetComponent extends WidgetComponent implements OnI
} }
private isDefaultValue(value: string): boolean { private isDefaultValue(value: string): boolean {
return value === DropdownCloudWidgetComponent.DEFAULT_OPTION.id; return value === DEFAULT_OPTION.id;
} }
private getFormFieldById(fieldId): FormFieldModel { private getFormFieldById(fieldId): FormFieldModel {
@@ -200,7 +200,7 @@ export class DropdownCloudWidgetComponent extends WidgetComponent implements OnI
} }
private addDefaultOption() { private addDefaultOption() {
this.field.options = [DropdownCloudWidgetComponent.DEFAULT_OPTION]; this.field.options = [DEFAULT_OPTION];
this.updateOptions(); this.updateOptions();
} }
@@ -252,7 +252,7 @@ export class DropdownCloudWidgetComponent extends WidgetComponent implements OnI
} }
let optionValue: string = ''; let optionValue: string = '';
if (option.id === DropdownCloudWidgetComponent.DEFAULT_OPTION.id || option.name !== fieldValue) { if (option.id === DEFAULT_OPTION.id || option.name !== fieldValue) {
optionValue = option.id; optionValue = option.id;
} else { } else {
optionValue = option.name; optionValue = option.name;
@@ -278,7 +278,7 @@ export class DropdownCloudWidgetComponent extends WidgetComponent implements OnI
} }
updateOptions(): void { updateOptions(): void {
this.showInputFilter = this.field.options.length > this.appConfig.get<number>('form.dropDownFilterLimit', this.HIDE_FILTER_LIMIT); this.showInputFilter = this.field.options.length > this.appConfig.get<number>('form.dropDownFilterLimit', HIDE_FILTER_LIMIT);
this.list$ = combineLatest([of(this.field.options), this.filter$]) this.list$ = combineLatest([of(this.field.options), this.filter$])
.pipe( .pipe(
map(([items, search]) => { map(([items, search]) => {
@@ -60,7 +60,7 @@ describe('RadioButtonsCloudWidgetComponent', () => {
const fieldId = '<field-id>'; const fieldId = '<field-id>';
const form = new FormModel({ const form = new FormModel({
taskId: taskId taskId
}); });
widget.field = new FormFieldModel(form, { widget.field = new FormFieldModel(form, {
@@ -124,13 +124,13 @@ describe('RadioButtonsCloudWidgetComponent', () => {
expect(widgetLabel.innerText).toBe('radio-name-label*'); expect(widgetLabel.innerText).toBe('radio-name-label*');
expect(widget.field.isValid).toBe(false); expect(widget.field.isValid).toBe(false);
const option: HTMLElement = <HTMLElement> element.querySelector('#radio-id-opt-1 label'); const option = element.querySelector<HTMLElement>('#radio-id-opt-1 label');
option.click(); option.click();
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
fixture.detectChanges(); fixture.detectChanges();
const selectedOption: HTMLElement = <HTMLElement> element.querySelector('[class*="mat-radio-checked"]'); const selectedOption = element.querySelector<HTMLElement>('[class*="mat-radio-checked"]');
expect(selectedOption.innerText).toBe('opt-name-1'); expect(selectedOption.innerText).toBe('opt-name-1');
expect(widget.field.isValid).toBe(true); expect(widget.field.isValid).toBe(true);
}); });
@@ -149,7 +149,7 @@ describe('RadioButtonsCloudWidgetComponent', () => {
}); });
fixture.detectChanges(); fixture.detectChanges();
const selectedOption: HTMLElement = <HTMLElement> element.querySelector('[class*="mat-radio-checked"]'); const selectedOption = element.querySelector<HTMLElement>('[class*="mat-radio-checked"]');
expect(selectedOption.innerText).toBe('opt-name-2'); expect(selectedOption.innerText).toBe('opt-name-2');
expect(widget.field.isValid).toBe(true); expect(widget.field.isValid).toBe(true);
}); });
@@ -168,7 +168,7 @@ describe('RadioButtonsCloudWidgetComponent', () => {
}); });
fixture.detectChanges(); fixture.detectChanges();
const selectedOption: HTMLElement = <HTMLElement> element.querySelector('[class*="mat-radio-checked"]'); const selectedOption = element.querySelector<HTMLElement>('[class*="mat-radio-checked"]');
expect(selectedOption.innerText).toBe('opt-name-1'); expect(selectedOption.innerText).toBe('opt-name-1');
expect(widget.field.isValid).toBe(true); expect(widget.field.isValid).toBe(true);
}); });
@@ -15,7 +15,10 @@
* limitations under the License. * limitations under the License.
*/ */
/* eslint-disable @typescript-eslint/naming-convention */
import { Node } from '@alfresco/js-api'; import { Node } from '@alfresco/js-api';
import { FormFieldMetadata } from '@alfresco/adf-core';
import { FileSourceTypes, DestinationFolderPathType } from '../models/form-cloud-representation.model'; import { FileSourceTypes, DestinationFolderPathType } from '../models/form-cloud-representation.model';
export const fakeLocalPngResponse = { export const fakeLocalPngResponse = {
@@ -101,14 +104,14 @@ export const onlyLocalParams = {
fileSource: { fileSource: {
serviceId: 'local-file' serviceId: 'local-file'
} }
}; } as FormFieldMetadata;
export const contentSourceParam = { export const contentSourceParam = {
fileSource: { fileSource: {
name: 'mock-alf-content', name: 'mock-alf-content',
serviceId: FileSourceTypes.ALFRESCO_CONTENT_SOURCES_SERVICE_ID serviceId: FileSourceTypes.ALFRESCO_CONTENT_SOURCES_SERVICE_ID
} }
}; } as FormFieldMetadata;
export const menuTestSourceParam = { export const menuTestSourceParam = {
fileSource: { fileSource: {
@@ -121,7 +124,7 @@ export const menuTestSourceParam = {
retrieveMetadata: true, retrieveMetadata: true,
remove: true remove: true
} }
}; } as FormFieldMetadata;
export const allSourceParamsWithRelativePath = { export const allSourceParamsWithRelativePath = {
fileSource: { fileSource: {
@@ -156,32 +159,32 @@ export const displayableCMParams = {
}, },
displayableCMProperties: [ displayableCMProperties: [
{ {
'name': 'name', name: 'name',
'prefixedName': 'a:name', prefixedName: 'a:name',
'title': '', title: '',
'dataType': 'd:text', dataType: 'd:text',
'defaultValue': 'Bob' defaultValue: 'Bob'
}, },
{ {
'name': 'age', name: 'age',
'prefixedName': 'a:age', prefixedName: 'a:age',
'title': 'Age', title: 'Age',
'dataType': 'd:text', dataType: 'd:text',
'defaultValue': '' defaultValue: ''
}, },
{ {
'name': 'dob', name: 'dob',
'prefixedName': 'a:dob', prefixedName: 'a:dob',
'title': 'Date of Birth', title: 'Date of Birth',
'dataType': 'd:date', dataType: 'd:date',
'defaultValue': '' defaultValue: ''
}, },
{ {
'name': 'doj', name: 'doj',
'prefixedName': 'a:doj', prefixedName: 'a:doj',
'title': 'Date of Joining', title: 'Date of Joining',
'dataType': 'd:datetime', dataType: 'd:datetime',
'defaultValue': '' defaultValue: ''
} }
] ]
}; };
@@ -260,15 +263,15 @@ export const allSourceWithoutValueProperty = {
} }
}; };
export const fakeMinimalNode: Node = <Node> { export const fakeMinimalNode = {
id: 'fake', id: 'fake',
name: 'fake-name', name: 'fake-name',
content: { content: {
mimeType: 'application/pdf' mimeType: 'application/pdf'
} }
}; } as Node;
export const fakeNodeWithProperties: Node = <Node> { export const fakeNodeWithProperties = {
id: 'fake-properties', id: 'fake-properties',
name: 'fake-properties-name', name: 'fake-properties-name',
content: { content: {
@@ -278,22 +281,22 @@ export const fakeNodeWithProperties: Node = <Node> {
'pfx:property_one': 'testValue', 'pfx:property_one': 'testValue',
'pfx:property_two': true 'pfx:property_two': true
} }
}; } as Node;
export const expectedValues = { export const expectedValues = {
pfx_property_one: 'testValue', pfx_property_one: 'testValue',
pfx_property_two: true pfx_property_two: true
}; };
export const mockNodeId = new Promise<string>(function(resolve) { export const mockNodeId = new Promise<string>((resolve) => {
resolve('mock-node-id'); resolve('mock-node-id');
}); });
export const mockNodeIdBasedOnStringVariableValue = new Promise<string>(function(resolve) { export const mockNodeIdBasedOnStringVariableValue = new Promise<string>((resolve) => {
resolve('mock-string-value-node-id'); resolve('mock-string-value-node-id');
}); });
export const mockNodeIdBasedOnFolderVariableValue = new Promise(function(resolve) { export const mockNodeIdBasedOnFolderVariableValue = new Promise((resolve) => {
resolve('mock-folder-value-node-id'); resolve('mock-folder-value-node-id');
}); });
@@ -391,61 +394,61 @@ export const mockAllFileSourceWithRenamedFolderVariablePathType = {
export const formVariables = [ export const formVariables = [
{ {
'id': 'bfca9766-7bc1-45cc-8ecf-cdad551e36e2', id: 'bfca9766-7bc1-45cc-8ecf-cdad551e36e2',
'name': 'name1', name: 'name1',
'type': 'string', type: 'string',
'value': 'hello' value: 'hello'
}, },
{ {
'id': '3ed9f28a-dbae-463f-b991-47ef06658bb6', id: '3ed9f28a-dbae-463f-b991-47ef06658bb6',
'name': 'name2', name: 'name2',
'type': 'folder' type: 'folder'
}, },
{ {
'id': 'booleanVar', id: 'booleanVar',
'name': 'bool', name: 'bool',
'type': 'boolean', type: 'boolean',
'value': 'true' value: 'true'
} }
]; ];
export const processVariables = [ export const processVariables = [
{ {
'serviceName': 'mock-variable-mapping-rb', serviceName: 'mock-variable-mapping-rb',
'serviceFullName': 'mock-variable-mapping-rb', serviceFullName: 'mock-variable-mapping-rb',
'serviceVersion': '', serviceVersion: '',
'appName': 'mock-variable-mapping', appName: 'mock-variable-mapping',
'appVersion': '', appVersion: '',
'serviceType': null, serviceType: null,
'id': 3, id: 3,
'type': 'string', type: 'string',
'name': 'variables.name1', name: 'variables.name1',
'createTime': 1566989626284, createTime: 1566989626284,
'lastUpdatedTime': 1566989626284, lastUpdatedTime: 1566989626284,
'executionId': null, executionId: null,
'value': '-root-/pathBasedOnStringvariablevalue', value: '-root-/pathBasedOnStringvariablevalue',
'markedAsDeleted': false, markedAsDeleted: false,
'processInstanceId': '1be4785f-c982-11e9-bdd8-96d6903e4e44', processInstanceId: '1be4785f-c982-11e9-bdd8-96d6903e4e44',
'taskId': '1beab9f6-c982-11e9-bdd8-96d6903e4e44', taskId: '1beab9f6-c982-11e9-bdd8-96d6903e4e44',
'taskVariable': true taskVariable: true
}, },
{ {
'serviceName': 'mock-variable-mapping-rb', serviceName: 'mock-variable-mapping-rb',
'serviceFullName': 'mock-variable-mapping-rb', serviceFullName: 'mock-variable-mapping-rb',
'serviceVersion': '', serviceVersion: '',
'appName': 'mock-variable-mapping', appName: 'mock-variable-mapping',
'appVersion': '', appVersion: '',
'serviceType': null, serviceType: null,
'id': 1, id: 1,
'type': 'folder', type: 'folder',
'name': 'variables.name2', name: 'variables.name2',
'createTime': 1566989626283, createTime: 1566989626283,
'lastUpdatedTime': 1566989626283, lastUpdatedTime: 1566989626283,
'executionId': null, executionId: null,
'value': [{ id: 'mock-folder-id'}], value: [{ id: 'mock-folder-id'}],
'markedAsDeleted': false, markedAsDeleted: false,
'processInstanceId': '1be4785f-c982-11e9-bdd8-96d6903e4e44', processInstanceId: '1be4785f-c982-11e9-bdd8-96d6903e4e44',
'taskId': '1beab9f6-c982-11e9-bdd8-96d6903e4e44', taskId: '1beab9f6-c982-11e9-bdd8-96d6903e4e44',
'taskVariable': true taskVariable: true
} }
]; ];
File diff suppressed because it is too large Load Diff
@@ -32,8 +32,7 @@ export class FormCloudServiceMock implements FormCloudServiceInterface {
getTaskForm(appName: string, taskId: string, version?: number): Observable<any> { getTaskForm(appName: string, taskId: string, version?: number): Observable<any> {
return this.getTask(appName, taskId).pipe( return this.getTask(appName, taskId).pipe(
switchMap((task) => { switchMap((task) => this.getForm(appName, task.formKey, version).pipe(
return this.getForm(appName, task.formKey, version).pipe(
map((form: FormContent) => { map((form: FormContent) => {
const flattenForm = { const flattenForm = {
...form.formRepresentation, ...form.formRepresentation,
@@ -46,8 +45,7 @@ export class FormCloudServiceMock implements FormCloudServiceInterface {
delete flattenForm.formDefinition; delete flattenForm.formDefinition;
return flattenForm; return flattenForm;
}) })
); ))
})
); );
} }
@@ -27,10 +27,10 @@ import { mockFormRepresentations } from './form-representation.mock';
export class FormDefinitionSelectorCloudServiceMock implements FormDefinitionSelectorCloudServiceInterface { export class FormDefinitionSelectorCloudServiceMock implements FormDefinitionSelectorCloudServiceInterface {
getForms(_appName: string): Observable<FormRepresentation[]> { getForms(_appName: string): Observable<FormRepresentation[]> {
return of(mockFormRepresentations.map(response => <FormRepresentation> response.formRepresentation)); return of(mockFormRepresentations.map(response => response.formRepresentation));
} }
getStandAloneTaskForms(_appName: string): Observable<FormRepresentation[]> { getStandAloneTaskForms(_appName: string): Observable<FormRepresentation[]> {
return of(mockFormRepresentations.map(response => <FormRepresentation> response.formRepresentation).filter((form: any) => form.standalone ? form : undefined)); return of(mockFormRepresentations.map(response => response.formRepresentation).filter((form: any) => form.standalone ? form : undefined));
} }
} }
@@ -15,6 +15,8 @@
* limitations under the License. * limitations under the License.
*/ */
/* eslint-disable no-shadow */
/* eslint-disable @typescript-eslint/naming-convention */
export class FormCloudRepresentation { export class FormCloudRepresentation {
id?: string; id?: string;
@@ -77,7 +77,7 @@ describe('FormCloud', () => {
form.fields = []; form.fields = [];
expect(form.hasFields()).toBeFalsy(); expect(form.hasFields()).toBeFalsy();
const field = new FormFieldModel(<any> form); const field = new FormFieldModel(form);
form.fields = [new ContainerModel(field)]; form.fields = [new ContainerModel(field)];
expect(form.hasFields()).toBeTruthy(); expect(form.hasFields()).toBeTruthy();
}); });
@@ -51,7 +51,7 @@ export class ContentCloudNodeSelectorService {
openUploadFileDialog(currentFolderId?: string, selectionMode?: string, isAllFileSources?: boolean, restrictRootToCurrentFolderId?: boolean): Observable<Node[]> { openUploadFileDialog(currentFolderId?: string, selectionMode?: string, isAllFileSources?: boolean, restrictRootToCurrentFolderId?: boolean): Observable<Node[]> {
const select = new Subject<Node[]>(); const select = new Subject<Node[]>();
select.subscribe({ complete: this.close.bind(this) }); select.subscribe({ complete: this.close.bind(this) });
const data = <ContentNodeSelectorComponentData> { const data = {
title: 'Select a file', title: 'Select a file',
actionName: NodeAction.ATTACH, actionName: NodeAction.ATTACH,
currentFolderId, currentFolderId,
@@ -62,7 +62,7 @@ export class ContentCloudNodeSelectorService {
showFilesInResult: true, showFilesInResult: true,
showDropdownSiteList: false, showDropdownSiteList: false,
showLocalUploadButton: isAllFileSources showLocalUploadButton: isAllFileSources
}; } as ContentNodeSelectorComponentData;
this.openContentNodeDialog(data, 'adf-content-node-selector-dialog', '66%'); this.openContentNodeDialog(data, 'adf-content-node-selector-dialog', '66%');
return select; return select;
} }
@@ -51,10 +51,8 @@ describe('Form Cloud service', () => {
apiService = TestBed.inject(AlfrescoApiService); apiService = TestBed.inject(AlfrescoApiService);
spyOn(apiService, 'getInstance').and.returnValue({ spyOn(apiService, 'getInstance').and.returnValue({
oauth2Auth: oauth2Auth, oauth2Auth,
isEcmLoggedIn() { isEcmLoggedIn: () => false,
return false;
},
reply: jasmine.createSpy('reply') reply: jasmine.createSpy('reply')
} as any); } as any);
}); });
@@ -102,36 +100,36 @@ describe('Form Cloud service', () => {
it('should fetch task variables', (done) => { it('should fetch task variables', (done) => {
oauth2Auth.callCustomApi.and.returnValue(Promise.resolve({ oauth2Auth.callCustomApi.and.returnValue(Promise.resolve({
'list': { list: {
'entries': [ entries: [
{ {
'entry': { entry: {
'serviceName': 'fake-rb', serviceName: 'fake-rb',
'serviceFullName': 'fake-rb', serviceFullName: 'fake-rb',
'serviceVersion': '', serviceVersion: '',
'appName': 'fake', appName: 'fake',
'appVersion': '', appVersion: '',
'serviceType': null, serviceType: null,
'id': 25, id: 25,
'type': 'string', type: 'string',
'name': 'fakeProperty', name: 'fakeProperty',
'createTime': 1556112661342, createTime: 1556112661342,
'lastUpdatedTime': 1556112661342, lastUpdatedTime: 1556112661342,
'executionId': null, executionId: null,
'value': 'fakeValue', value: 'fakeValue',
'markedAsDeleted': false, markedAsDeleted: false,
'processInstanceId': '18e16bc7-6694-11e9-9c1b-0a586460028a', processInstanceId: '18e16bc7-6694-11e9-9c1b-0a586460028a',
'taskId': '18e192da-6694-11e9-9c1b-0a586460028a', taskId: '18e192da-6694-11e9-9c1b-0a586460028a',
'taskVariable': true taskVariable: true
} }
} }
], ],
'pagination': { pagination: {
'skipCount': 0, skipCount: 0,
'maxItems': 100, maxItems: 100,
'count': 1, count: 1,
'hasMoreItems': false, hasMoreItems: false,
'totalItems': 1 totalItems: 1
} }
} }
})); }));
@@ -149,36 +147,36 @@ describe('Form Cloud service', () => {
it('should fetch result if the variable value is 0', (done) => { it('should fetch result if the variable value is 0', (done) => {
oauth2Auth.callCustomApi.and.returnValue(Promise.resolve({ oauth2Auth.callCustomApi.and.returnValue(Promise.resolve({
'list': { list: {
'entries': [ entries: [
{ {
'entry': { entry: {
'serviceName': 'fake-rb', serviceName: 'fake-rb',
'serviceFullName': 'fake-rb', serviceFullName: 'fake-rb',
'serviceVersion': '', serviceVersion: '',
'appName': 'fake', appName: 'fake',
'appVersion': '', appVersion: '',
'serviceType': null, serviceType: null,
'id': 25, id: 25,
'type': 'string', type: 'string',
'name': 'fakeProperty', name: 'fakeProperty',
'createTime': 1556112661342, createTime: 1556112661342,
'lastUpdatedTime': 1556112661342, lastUpdatedTime: 1556112661342,
'executionId': null, executionId: null,
'value': 0, value: 0,
'markedAsDeleted': false, markedAsDeleted: false,
'processInstanceId': '18e16bc7-6694-11e9-9c1b-0a586460028a', processInstanceId: '18e16bc7-6694-11e9-9c1b-0a586460028a',
'taskId': '18e192da-6694-11e9-9c1b-0a586460028a', taskId: '18e192da-6694-11e9-9c1b-0a586460028a',
'taskVariable': true taskVariable: true
} }
} }
], ],
'pagination': { pagination: {
'skipCount': 0, skipCount: 0,
'maxItems': 100, maxItems: 100,
'count': 1, count: 1,
'hasMoreItems': false, hasMoreItems: false,
'totalItems': 1 totalItems: 1
} }
} }
})); }));
@@ -53,6 +53,7 @@ export class FormCloudService extends BaseCloudService implements FormCloudServi
/** /**
* Gets the form definition of a task. * Gets the form definition of a task.
*
* @param appName Name of the app * @param appName Name of the app
* @param taskId ID of the target task * @param taskId ID of the target task
* @param version Version of the form * @param version Version of the form
@@ -60,8 +61,7 @@ export class FormCloudService extends BaseCloudService implements FormCloudServi
*/ */
getTaskForm(appName: string, taskId: string, version?: number): Observable<any> { getTaskForm(appName: string, taskId: string, version?: number): Observable<any> {
return this.getTask(appName, taskId).pipe( return this.getTask(appName, taskId).pipe(
switchMap(task => { switchMap(task => this.getForm(appName, task.formKey, version).pipe(
return this.getForm(appName, task.formKey, version).pipe(
map((form: FormContent) => { map((form: FormContent) => {
const flattenForm = { const flattenForm = {
...form.formRepresentation, ...form.formRepresentation,
@@ -74,13 +74,13 @@ export class FormCloudService extends BaseCloudService implements FormCloudServi
delete flattenForm.formDefinition; delete flattenForm.formDefinition;
return flattenForm; return flattenForm;
}) })
); ))
})
); );
} }
/** /**
* Saves a task form. * Saves a task form.
*
* @param appName Name of the app * @param appName Name of the app
* @param taskId ID of the target task * @param taskId ID of the target task
* @param processInstanceId ID of processInstance * @param processInstanceId ID of processInstance
@@ -120,6 +120,7 @@ export class FormCloudService extends BaseCloudService implements FormCloudServi
/** /**
* Completes a task form. * Completes a task form.
*
* @param appName Name of the app * @param appName Name of the app
* @param taskId ID of the target task * @param taskId ID of the target task
* @param processInstanceId ID of processInstance * @param processInstanceId ID of processInstance
@@ -131,11 +132,12 @@ export class FormCloudService extends BaseCloudService implements FormCloudServi
*/ */
completeTaskForm(appName: string, taskId: string, processInstanceId: string, formId: string, formValues: FormValues, outcome: string, version: number): Observable<TaskDetailsCloudModel> { completeTaskForm(appName: string, taskId: string, processInstanceId: string, formId: string, formValues: FormValues, outcome: string, version: number): Observable<TaskDetailsCloudModel> {
const apiUrl = `${this.getBasePath(appName)}/form/v1/forms/${formId}/submit/versions/${version}`; const apiUrl = `${this.getBasePath(appName)}/form/v1/forms/${formId}/submit/versions/${version}`;
const completeFormRepresentation = <CompleteFormRepresentation> { const completeFormRepresentation = {
values: formValues, values: formValues,
taskId: taskId, taskId,
processInstanceId: processInstanceId processInstanceId
}; } as CompleteFormRepresentation;
if (outcome) { if (outcome) {
completeFormRepresentation.outcome = outcome; completeFormRepresentation.outcome = outcome;
} }
@@ -147,6 +149,7 @@ export class FormCloudService extends BaseCloudService implements FormCloudServi
/** /**
* Gets details of a task * Gets details of a task
*
* @param appName Name of the app * @param appName Name of the app
* @param taskId ID of the target task * @param taskId ID of the target task
* @returns Details of the task * @returns Details of the task
@@ -161,6 +164,7 @@ export class FormCloudService extends BaseCloudService implements FormCloudServi
/** /**
* Gets the variables of a task. * Gets the variables of a task.
*
* @param appName Name of the app * @param appName Name of the app
* @param taskId ID of the target task * @param taskId ID of the target task
* @returns Task variables * @returns Task variables
@@ -169,14 +173,13 @@ export class FormCloudService extends BaseCloudService implements FormCloudServi
const apiUrl = `${this.getBasePath(appName)}/query/v1/tasks/${taskId}/variables`; const apiUrl = `${this.getBasePath(appName)}/query/v1/tasks/${taskId}/variables`;
return this.get(apiUrl).pipe( return this.get(apiUrl).pipe(
map((res: any) => { map((res: any) => res.list.entries.map((variable) => new TaskVariableCloud(variable.entry)))
return res.list.entries.map((variable) => new TaskVariableCloud(variable.entry));
})
); );
} }
/** /**
* Gets a form definition. * Gets a form definition.
*
* @param appName Name of the app * @param appName Name of the app
* @param formKey key of the target task * @param formKey key of the target task
* @param version Version of the form * @param version Version of the form
@@ -200,6 +203,7 @@ export class FormCloudService extends BaseCloudService implements FormCloudServi
/** /**
* Parses JSON data to create a corresponding form. * Parses JSON data to create a corresponding form.
*
* @param json JSON data to create the form * @param json JSON data to create the form
* @param data Values for the form's fields * @param data Values for the form's fields
* @param readOnly Toggles whether or not the form should be read-only * @param readOnly Toggles whether or not the form should be read-only
@@ -221,7 +225,7 @@ export class FormCloudService extends BaseCloudService implements FormCloudServi
const form = new FormModel(flattenForm, formValues, readOnly); const form = new FormModel(flattenForm, formValues, readOnly);
if (!json.fields) { if (!json.fields) {
form.outcomes = [ form.outcomes = [
new FormOutcomeModel(<any> form, { new FormOutcomeModel(form, {
id: '$save', id: '$save',
name: FormOutcomeModel.SAVE_ACTION, name: FormOutcomeModel.SAVE_ACTION,
isSystem: true isSystem: true
@@ -43,10 +43,8 @@ describe('Form Definition Selector Cloud Service', () => {
service = TestBed.inject(FormDefinitionSelectorCloudService); service = TestBed.inject(FormDefinitionSelectorCloudService);
apiService = TestBed.inject(AlfrescoApiService); apiService = TestBed.inject(AlfrescoApiService);
spyOn(apiService, 'getInstance').and.returnValue({ spyOn(apiService, 'getInstance').and.returnValue({
oauth2Auth: oauth2Auth, oauth2Auth,
isEcmLoggedIn() { isEcmLoggedIn: () => false,
return false;
},
reply: jasmine.createSpy('reply') reply: jasmine.createSpy('reply')
} as any); } as any);
}); });
@@ -35,6 +35,7 @@ export class FormDefinitionSelectorCloudService extends BaseCloudService impleme
/** /**
* Get all forms of an app. * Get all forms of an app.
*
* @param appName Name of the application * @param appName Name of the application
* @returns Details of the forms * @returns Details of the forms
*/ */
@@ -42,24 +43,19 @@ export class FormDefinitionSelectorCloudService extends BaseCloudService impleme
const url = `${this.getBasePath(appName)}/form/v1/forms`; const url = `${this.getBasePath(appName)}/form/v1/forms`;
return this.get(url).pipe( return this.get(url).pipe(
map((data: any) => { map((data: any) => data.map((formData: any) => formData.formRepresentation))
return data.map((formData: any) => {
return <FormRepresentation> formData.formRepresentation;
});
})
); );
} }
/** /**
* Get all forms of an app. * Get all forms of an app.
*
* @param appName Name of the application * @param appName Name of the application
* @returns Details of the forms * @returns Details of the forms
*/ */
getStandAloneTaskForms(appName: string): Observable<FormRepresentation[]> { getStandAloneTaskForms(appName: string): Observable<FormRepresentation[]> {
return from(this.getForms(appName)).pipe( return from(this.getForms(appName)).pipe(
map((data: any) => { map((data: any) => data.filter((formData: any) => formData.standalone || formData.standalone === undefined))
return data.filter((formData: any) => formData.standalone || formData.standalone === undefined);
})
); );
} }
} }
@@ -59,12 +59,10 @@ export class ProcessCloudContentService {
return from( return from(
this.uploadApi.uploadFile(file, '', nodeId, '', { overwrite: true }) this.uploadApi.uploadFile(file, '', nodeId, '', { overwrite: true })
).pipe( ).pipe(
map((res: any) => { map((res: any) => ({
return {
...res.entry, ...res.entry,
nodeId: res.entry.id nodeId: res.entry.id
}; })),
}),
catchError(err => this.handleError(err)) catchError(err => this.handleError(err))
); );
} }
@@ -44,14 +44,13 @@ describe('GroupCloudComponent', () => {
oauth2Auth: { oauth2Auth: {
callCustomApi: () => Promise.resolve(mockIdentityGroups) callCustomApi: () => Promise.resolve(mockIdentityGroups)
}, },
isEcmLoggedIn() { isEcmLoggedIn: () => false,
return false;
},
reply: jasmine.createSpy('reply') reply: jasmine.createSpy('reply')
}; };
// eslint-disable-next-line prefer-arrow/prefer-arrow-functions
function getElement<T = HTMLElement>(selector: string): T { function getElement<T = HTMLElement>(selector: string): T {
return <T> fixture.nativeElement.querySelector(selector); return fixture.nativeElement.querySelector(selector);
} }
setupTestBed({ setupTestBed({
@@ -110,10 +109,10 @@ describe('GroupCloudComponent', () => {
it('should not be able to search for a group that its name matches one of the preselected groups name', (done) => { it('should not be able to search for a group that its name matches one of the preselected groups name', (done) => {
component.preSelectGroups = [{ name: mockIdentityGroups[0].name }]; component.preSelectGroups = [{ name: mockIdentityGroups[0].name }];
const changes = new SimpleChange(null, [{ name: mockIdentityGroups[0].name }], false); const changes = new SimpleChange(null, [{ name: mockIdentityGroups[0].name }], false);
component.ngOnChanges({ 'preSelectGroups': changes }); component.ngOnChanges({ preSelectGroups: changes });
fixture.detectChanges(); fixture.detectChanges();
const inputHTMLElement: HTMLInputElement = <HTMLInputElement> element.querySelector('input'); const inputHTMLElement = element.querySelector<HTMLInputElement>('input');
inputHTMLElement.focus(); inputHTMLElement.focus();
inputHTMLElement.value = 'mock-group'; inputHTMLElement.value = 'mock-group';
inputHTMLElement.dispatchEvent(new Event('keyup')); inputHTMLElement.dispatchEvent(new Event('keyup'));
@@ -242,7 +241,7 @@ describe('GroupCloudComponent', () => {
component.appName = 'mock-app-name'; component.appName = 'mock-app-name';
const change = new SimpleChange(null, 'mock-app-name', false); const change = new SimpleChange(null, 'mock-app-name', false);
component.ngOnChanges({ 'appName': change }); component.ngOnChanges({ appName: change });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -486,8 +485,8 @@ describe('GroupCloudComponent', () => {
beforeEach(() => { beforeEach(() => {
component.mode = 'single'; component.mode = 'single';
component.preSelectGroups = <any> mockIdentityGroups; component.preSelectGroups = mockIdentityGroups;
component.ngOnChanges({ 'preSelectGroups': changes }); component.ngOnChanges({ preSelectGroups: changes });
fixture.detectChanges(); fixture.detectChanges();
}); });
@@ -503,15 +502,15 @@ describe('GroupCloudComponent', () => {
beforeEach(() => { beforeEach(() => {
component.mode = 'multiple'; component.mode = 'multiple';
component.preSelectGroups = <any> mockIdentityGroups; component.preSelectGroups = mockIdentityGroups;
component.ngOnChanges({ 'preSelectGroups': change }); component.ngOnChanges({ preSelectGroups: change });
fixture.detectChanges(); fixture.detectChanges();
}); });
it('should render all preselected groups', () => { it('should render all preselected groups', () => {
component.mode = 'multiple'; component.mode = 'multiple';
fixture.detectChanges(); fixture.detectChanges();
component.ngOnChanges({ 'preSelectGroups': change }); component.ngOnChanges({ preSelectGroups: change });
fixture.detectChanges(); fixture.detectChanges();
const chips = fixture.debugElement.queryAll(By.css('mat-chip')); const chips = fixture.debugElement.queryAll(By.css('mat-chip'));
expect(chips.length).toBe(5); expect(chips.length).toBe(5);
@@ -551,7 +550,7 @@ describe('GroupCloudComponent', () => {
]; ];
const change = new SimpleChange(null, component.preSelectGroups, false); const change = new SimpleChange(null, component.preSelectGroups, false);
component.mode = 'multiple'; component.mode = 'multiple';
component.ngOnChanges({ 'preSelectGroups': change }); component.ngOnChanges({ preSelectGroups: change });
fixture.detectChanges(); fixture.detectChanges();
fixture.whenStable().then(() => { fixture.whenStable().then(() => {
@@ -579,7 +578,7 @@ describe('GroupCloudComponent', () => {
const change = new SimpleChange(null, component.preSelectGroups, false); const change = new SimpleChange(null, component.preSelectGroups, false);
component.mode = 'multiple'; component.mode = 'multiple';
component.ngOnChanges({ 'preSelectGroups': change }); component.ngOnChanges({ preSelectGroups: change });
const removeGroupSpy = spyOn(component.removeGroup, 'emit'); const removeGroupSpy = spyOn(component.removeGroup, 'emit');
fixture.detectChanges(); fixture.detectChanges();
@@ -610,8 +609,8 @@ describe('GroupCloudComponent', () => {
it('should chip list be disabled and show one single chip - single mode', () => { it('should chip list be disabled and show one single chip - single mode', () => {
component.mode = 'single'; component.mode = 'single';
component.readOnly = true; component.readOnly = true;
component.preSelectGroups = <any> mockIdentityGroups; component.preSelectGroups = mockIdentityGroups;
component.ngOnChanges({ 'preSelectGroups': change }); component.ngOnChanges({ preSelectGroups: change });
fixture.detectChanges(); fixture.detectChanges();
@@ -627,8 +626,8 @@ describe('GroupCloudComponent', () => {
it('should chip list be disabled and show all the chips - multiple mode', () => { it('should chip list be disabled and show all the chips - multiple mode', () => {
component.mode = 'multiple'; component.mode = 'multiple';
component.readOnly = true; component.readOnly = true;
component.preSelectGroups = <any> mockIdentityGroups; component.preSelectGroups = mockIdentityGroups;
component.ngOnChanges({ 'preSelectGroups': change }); component.ngOnChanges({ preSelectGroups: change });
fixture.detectChanges(); fixture.detectChanges();
@@ -663,8 +662,8 @@ describe('GroupCloudComponent', () => {
component.mode = 'single'; component.mode = 'single';
component.validate = true; component.validate = true;
component.preSelectGroups = <any> [mockIdentityGroups[0], mockIdentityGroups[1]]; component.preSelectGroups = [mockIdentityGroups[0], mockIdentityGroups[1]];
component.ngOnChanges({ 'preSelectGroups': new SimpleChange(null, [mockIdentityGroups[0], mockIdentityGroups[1]], false) }); component.ngOnChanges({ preSelectGroups: new SimpleChange(null, [mockIdentityGroups[0], mockIdentityGroups[1]], false) });
}); });
it('should check validation for all the groups and emit warning - multiple mode', (done) => { it('should check validation for all the groups and emit warning - multiple mode', (done) => {
@@ -694,9 +693,9 @@ describe('GroupCloudComponent', () => {
component.mode = 'multiple'; component.mode = 'multiple';
component.validate = true; component.validate = true;
component.preSelectGroups = <any> [mockIdentityGroups[0], mockIdentityGroups[1]]; component.preSelectGroups = [mockIdentityGroups[0], mockIdentityGroups[1]];
component.ngOnChanges({ component.ngOnChanges({
'preSelectGroups': new SimpleChange(null, [mockIdentityGroups[0], mockIdentityGroups[1]], false) preSelectGroups: new SimpleChange(null, [mockIdentityGroups[0], mockIdentityGroups[1]], false)
}); });
}); });
}); });
@@ -235,9 +235,7 @@ export class GroupCloudComponent implements OnInit, OnChanges, OnDestroy {
private isGroupAlreadySelected(group: IdentityGroupModel): boolean { private isGroupAlreadySelected(group: IdentityGroupModel): boolean {
if (this.selectedGroups && this.selectedGroups.length > 0) { if (this.selectedGroups && this.selectedGroups.length > 0) {
const result = this.selectedGroups.find((selectedGroup: IdentityGroupModel) => { const result = this.selectedGroups.find((selectedGroup: IdentityGroupModel) => selectedGroup.name === group.name);
return selectedGroup.name === group.name;
});
return !!result; return !!result;
} }
@@ -317,7 +315,7 @@ export class GroupCloudComponent implements OnInit, OnChanges, OnDestroy {
filterGroupsByRoles(group: IdentityGroupModel): Observable<IdentityGroupModel> { filterGroupsByRoles(group: IdentityGroupModel): Observable<IdentityGroupModel> {
return this.identityGroupService.checkGroupHasRole(group.id, this.roles).pipe( return this.identityGroupService.checkGroupHasRole(group.id, this.roles).pipe(
map((hasRole: boolean) => ({ hasRole: hasRole, group: group })), map((hasRole: boolean) => ({ hasRole, group })),
filter((filteredGroup: { hasRole: boolean; group: IdentityGroupModel }) => filteredGroup.hasRole), filter((filteredGroup: { hasRole: boolean; group: IdentityGroupModel }) => filteredGroup.hasRole),
map((filteredGroup: { hasRole: boolean; group: IdentityGroupModel }) => filteredGroup.group)); map((filteredGroup: { hasRole: boolean; group: IdentityGroupModel }) => filteredGroup.group));
} }
@@ -370,9 +368,7 @@ export class GroupCloudComponent implements OnInit, OnChanges, OnDestroy {
} }
private removeGroupFromSelected({ id, name }: IdentityGroupModel): void { private removeGroupFromSelected({ id, name }: IdentityGroupModel): void {
const indexToRemove = this.selectedGroups.findIndex(group => { const indexToRemove = this.selectedGroups.findIndex(group => group.id === id && group.name === name);
return group.id === id && group.name === name;
});
if (indexToRemove !== -1) { if (indexToRemove !== -1) {
this.selectedGroups.splice(indexToRemove, 1); this.selectedGroups.splice(indexToRemove, 1);
@@ -380,9 +376,7 @@ export class GroupCloudComponent implements OnInit, OnChanges, OnDestroy {
} }
private removeGroupFromValidation({ id, name }: IdentityGroupModel): void { private removeGroupFromValidation({ id, name }: IdentityGroupModel): void {
const indexToRemove = this.invalidGroups.findIndex(group => { const indexToRemove = this.invalidGroups.findIndex(group => group.id === id && group.name === name);
return group.id === id && group.name === name;
});
if (indexToRemove !== -1) { if (indexToRemove !== -1) {
this.invalidGroups.splice(indexToRemove, 1); this.invalidGroups.splice(indexToRemove, 1);
@@ -428,9 +422,7 @@ export class GroupCloudComponent implements OnInit, OnChanges, OnDestroy {
removeDuplicatedGroups(groups: IdentityGroupModel[]): IdentityGroupModel[] { removeDuplicatedGroups(groups: IdentityGroupModel[]): IdentityGroupModel[] {
return groups.filter((group, index, self) => return groups.filter((group, index, self) =>
index === self.findIndex((auxGroup) => { index === self.findIndex((auxGroup) => group.id === auxGroup.id && group.name === auxGroup.name));
return group.id === auxGroup.id && group.name === auxGroup.name;
}));
} }
private hasPreSelectGroups(): boolean { private hasPreSelectGroups(): boolean {
@@ -25,7 +25,7 @@ describe('InitialGroupNamePipe', () => {
beforeEach(() => { beforeEach(() => {
pipe = new InitialGroupNamePipe(); pipe = new InitialGroupNamePipe();
fakeGroup = <IdentityGroupModel> {name: 'mock'}; fakeGroup = {name: 'mock'};
}); });
it('should return with the group initial', () => { it('should return with the group initial', () => {
@@ -15,6 +15,9 @@
* limitations under the License. * limitations under the License.
*/ */
/* eslint-disable @typescript-eslint/naming-convention */
// eslint-disable-next-line no-shadow
export enum DateCloudFilterType { export enum DateCloudFilterType {
NO_DATE = 'NO_DATE', NO_DATE = 'NO_DATE',
TODAY = 'TODAY', TODAY = 'TODAY',
@@ -44,9 +44,7 @@ describe('PeopleCloudComponent', () => {
oauth2Auth: { oauth2Auth: {
callCustomApi: () => Promise.resolve(mockUsers) callCustomApi: () => Promise.resolve(mockUsers)
}, },
isEcmLoggedIn() { isEcmLoggedIn: () => false,
return false;
},
reply: jasmine.createSpy('reply') reply: jasmine.createSpy('reply')
}; };
@@ -55,8 +53,9 @@ describe('PeopleCloudComponent', () => {
{ id: mockUsers[2].id, username: mockUsers[2].username } { id: mockUsers[2].id, username: mockUsers[2].username }
]; ];
// eslint-disable-next-line prefer-arrow/prefer-arrow-functions
function getElement<T = HTMLElement>(selector: string): T { function getElement<T = HTMLElement>(selector: string): T {
return <T> fixture.nativeElement.querySelector(selector); return fixture.nativeElement.querySelector(selector);
} }
setupTestBed({ setupTestBed({
@@ -125,10 +124,10 @@ describe('PeopleCloudComponent', () => {
it('should not be able to search for a user that his username matches one of the preselected users username', (done) => { it('should not be able to search for a user that his username matches one of the preselected users username', (done) => {
component.preSelectUsers = [{ username: mockUsers[0].username }]; component.preSelectUsers = [{ username: mockUsers[0].username }];
const changes = new SimpleChange(null, [{ username: mockUsers[0].username }], false); const changes = new SimpleChange(null, [{ username: mockUsers[0].username }], false);
component.ngOnChanges({ 'preSelectUsers': changes }); component.ngOnChanges({ preSelectUsers: changes });
fixture.detectChanges(); fixture.detectChanges();
const inputHTMLElement: HTMLInputElement = <HTMLInputElement> element.querySelector('input'); const inputHTMLElement = element.querySelector<HTMLInputElement>('input');
inputHTMLElement.focus(); inputHTMLElement.focus();
inputHTMLElement.value = 'first-name'; inputHTMLElement.value = 'first-name';
inputHTMLElement.dispatchEvent(new Event('keyup')); inputHTMLElement.dispatchEvent(new Event('keyup'));
@@ -145,10 +144,10 @@ describe('PeopleCloudComponent', () => {
it('should not be able to search for a user that his id matches one of the preselected users id', (done) => { it('should not be able to search for a user that his id matches one of the preselected users id', (done) => {
component.preSelectUsers = [{ id: mockUsers[0].id }]; component.preSelectUsers = [{ id: mockUsers[0].id }];
const changes = new SimpleChange(null, [{ id: mockUsers[0].id }], false); const changes = new SimpleChange(null, [{ id: mockUsers[0].id }], false);
component.ngOnChanges({ 'preSelectUsers': changes }); component.ngOnChanges({ preSelectUsers: changes });
fixture.detectChanges(); fixture.detectChanges();
const inputHTMLElement: HTMLInputElement = <HTMLInputElement> element.querySelector('input'); const inputHTMLElement = element.querySelector<HTMLInputElement>('input');
inputHTMLElement.focus(); inputHTMLElement.focus();
inputHTMLElement.value = 'first-name'; inputHTMLElement.value = 'first-name';
inputHTMLElement.dispatchEvent(new Event('keyup')); inputHTMLElement.dispatchEvent(new Event('keyup'));
@@ -165,10 +164,10 @@ describe('PeopleCloudComponent', () => {
it('should not be able to search for a user that his email matches one of the preselected users email', (done) => { it('should not be able to search for a user that his email matches one of the preselected users email', (done) => {
component.preSelectUsers = [{ email: mockUsers[0].email }]; component.preSelectUsers = [{ email: mockUsers[0].email }];
const changes = new SimpleChange(null, [{ email: mockUsers[0].email }], false); const changes = new SimpleChange(null, [{ email: mockUsers[0].email }], false);
component.ngOnChanges({ 'preSelectUsers': changes }); component.ngOnChanges({ preSelectUsers: changes });
fixture.detectChanges(); fixture.detectChanges();
const inputHTMLElement: HTMLInputElement = <HTMLInputElement> element.querySelector('input'); const inputHTMLElement = element.querySelector<HTMLInputElement>('input');
inputHTMLElement.focus(); inputHTMLElement.focus();
inputHTMLElement.value = 'first-name'; inputHTMLElement.value = 'first-name';
inputHTMLElement.dispatchEvent(new Event('keyup')); inputHTMLElement.dispatchEvent(new Event('keyup'));
@@ -186,7 +185,7 @@ describe('PeopleCloudComponent', () => {
component.excludedUsers = [{ email: mockUsers[0].email }]; component.excludedUsers = [{ email: mockUsers[0].email }];
fixture.detectChanges(); fixture.detectChanges();
const inputHTMLElement: HTMLInputElement = <HTMLInputElement> element.querySelector('input'); const inputHTMLElement = element.querySelector<HTMLInputElement>('input');
inputHTMLElement.focus(); inputHTMLElement.focus();
inputHTMLElement.value = 'first-name'; inputHTMLElement.value = 'first-name';
inputHTMLElement.dispatchEvent(new Event('keyup')); inputHTMLElement.dispatchEvent(new Event('keyup'));
@@ -204,7 +203,7 @@ describe('PeopleCloudComponent', () => {
component.excludedUsers = [{ email: mockUsers[0].email }]; component.excludedUsers = [{ email: mockUsers[0].email }];
fixture.detectChanges(); fixture.detectChanges();
const inputHTMLElement: HTMLInputElement = <HTMLInputElement> element.querySelector('input'); const inputHTMLElement = element.querySelector<HTMLInputElement>('input');
inputHTMLElement.focus(); inputHTMLElement.focus();
inputHTMLElement.value = 'first-name'; inputHTMLElement.value = 'first-name';
inputHTMLElement.dispatchEvent(new Event('keyup')); inputHTMLElement.dispatchEvent(new Event('keyup'));
@@ -222,7 +221,7 @@ describe('PeopleCloudComponent', () => {
component.excludedUsers = [{ email: mockUsers[0].email }]; component.excludedUsers = [{ email: mockUsers[0].email }];
fixture.detectChanges(); fixture.detectChanges();
const inputHTMLElement: HTMLInputElement = <HTMLInputElement> element.querySelector('input'); const inputHTMLElement = element.querySelector<HTMLInputElement>('input');
inputHTMLElement.focus(); inputHTMLElement.focus();
inputHTMLElement.value = 'first-name'; inputHTMLElement.value = 'first-name';
inputHTMLElement.dispatchEvent(new Event('keyup')); inputHTMLElement.dispatchEvent(new Event('keyup'));
@@ -350,7 +349,7 @@ describe('PeopleCloudComponent', () => {
component.appName = 'mock-app-name'; component.appName = 'mock-app-name';
const change = new SimpleChange(null, 'mock-app-name', false); const change = new SimpleChange(null, 'mock-app-name', false);
component.ngOnChanges({ 'appName': change }); component.ngOnChanges({ appName: change });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -592,8 +591,8 @@ describe('PeopleCloudComponent', () => {
beforeEach(() => { beforeEach(() => {
component.mode = 'single'; component.mode = 'single';
component.preSelectUsers = <any> mockPreselectedUsers; component.preSelectUsers = mockPreselectedUsers;
component.ngOnChanges({ 'preSelectUsers': changes }); component.ngOnChanges({ preSelectUsers: changes });
fixture.detectChanges(); fixture.detectChanges();
element = fixture.nativeElement; element = fixture.nativeElement;
@@ -620,8 +619,8 @@ describe('PeopleCloudComponent', () => {
const changes = new SimpleChange(null, mockPreselectedUsers, false); const changes = new SimpleChange(null, mockPreselectedUsers, false);
component.preSelectUsers = <any> mockPreselectedUsers; component.preSelectUsers = mockPreselectedUsers;
component.ngOnChanges({ 'preSelectUsers': changes }); component.ngOnChanges({ preSelectUsers: changes });
fixture.detectChanges(); fixture.detectChanges();
fixture.whenStable().then(() => { fixture.whenStable().then(() => {
@@ -644,7 +643,7 @@ describe('PeopleCloudComponent', () => {
]; ];
const change = new SimpleChange(null, component.preSelectUsers, false); const change = new SimpleChange(null, component.preSelectUsers, false);
component.ngOnChanges({ 'preSelectUsers': change }); component.ngOnChanges({ preSelectUsers: change });
fixture.detectChanges(); fixture.detectChanges();
fixture.whenStable().then(() => { fixture.whenStable().then(() => {
@@ -669,7 +668,7 @@ describe('PeopleCloudComponent', () => {
]; ];
const change = new SimpleChange(null, component.preSelectUsers, false); const change = new SimpleChange(null, component.preSelectUsers, false);
component.ngOnChanges({ 'preSelectUsers': change }); component.ngOnChanges({ preSelectUsers: change });
const removeUserSpy = spyOn(component.removeUser, 'emit'); const removeUserSpy = spyOn(component.removeUser, 'emit');
@@ -700,8 +699,8 @@ describe('PeopleCloudComponent', () => {
it('should chip list be disabled and show one single chip - single mode', () => { it('should chip list be disabled and show one single chip - single mode', () => {
component.mode = 'single'; component.mode = 'single';
component.readOnly = true; component.readOnly = true;
component.preSelectUsers = <any> mockPreselectedUsers; component.preSelectUsers = mockPreselectedUsers;
component.ngOnChanges({ 'preSelectUsers': change }); component.ngOnChanges({ preSelectUsers: change });
fixture.detectChanges(); fixture.detectChanges();
@@ -717,8 +716,8 @@ describe('PeopleCloudComponent', () => {
it('should chip list be disabled and show mat chips for all the preselected users - multiple mode', () => { it('should chip list be disabled and show mat chips for all the preselected users - multiple mode', () => {
component.mode = 'multiple'; component.mode = 'multiple';
component.readOnly = true; component.readOnly = true;
component.preSelectUsers = <any> mockPreselectedUsers; component.preSelectUsers = mockPreselectedUsers;
component.ngOnChanges({ 'preSelectUsers': change }); component.ngOnChanges({ preSelectUsers: change });
fixture.detectChanges(); fixture.detectChanges();
@@ -751,9 +750,9 @@ describe('PeopleCloudComponent', () => {
component.mode = 'single'; component.mode = 'single';
component.validate = true; component.validate = true;
component.preSelectUsers = <any> [mockPreselectedUsers[0], mockPreselectedUsers[1]]; component.preSelectUsers = [mockPreselectedUsers[0], mockPreselectedUsers[1]];
component.ngOnChanges({ component.ngOnChanges({
'preSelectUsers': new SimpleChange(null, [mockPreselectedUsers[0], mockPreselectedUsers[1]], false) preSelectUsers: new SimpleChange(null, [mockPreselectedUsers[0], mockPreselectedUsers[1]], false)
}); });
}); });
@@ -766,9 +765,9 @@ describe('PeopleCloudComponent', () => {
component.warning.subscribe(() => warnings++); component.warning.subscribe(() => warnings++);
component.mode = 'single'; component.mode = 'single';
component.validate = false; component.validate = false;
component.preSelectUsers = <any> [mockPreselectedUsers[0], mockPreselectedUsers[1]]; component.preSelectUsers = [mockPreselectedUsers[0], mockPreselectedUsers[1]];
component.ngOnChanges({ component.ngOnChanges({
'preSelectUsers': new SimpleChange(null, [mockPreselectedUsers[0], mockPreselectedUsers[1]], false) preSelectUsers: new SimpleChange(null, [mockPreselectedUsers[0], mockPreselectedUsers[1]], false)
}); });
expect(warnings).toBe(0); expect(warnings).toBe(0);
@@ -798,9 +797,9 @@ describe('PeopleCloudComponent', () => {
component.mode = 'multiple'; component.mode = 'multiple';
component.validate = true; component.validate = true;
component.preSelectUsers = <any> [mockPreselectedUsers[0], mockPreselectedUsers[1]]; component.preSelectUsers = [mockPreselectedUsers[0], mockPreselectedUsers[1]];
component.ngOnChanges({ component.ngOnChanges({
'preSelectUsers': new SimpleChange(null, [mockPreselectedUsers[0], mockPreselectedUsers[1]], false) preSelectUsers: new SimpleChange(null, [mockPreselectedUsers[0], mockPreselectedUsers[1]], false)
}); });
}); });
}); });
@@ -264,16 +264,14 @@ export class PeopleCloudComponent implements OnInit, OnChanges, OnDestroy {
filterUsersByRoles(user: IdentityUserModel): Observable<IdentityUserModel> { filterUsersByRoles(user: IdentityUserModel): Observable<IdentityUserModel> {
return this.identityUserService.checkUserHasRole(user.id, this.roles).pipe( return this.identityUserService.checkUserHasRole(user.id, this.roles).pipe(
map((hasRole: boolean) => ({ hasRole: hasRole, user: user })), map((hasRole: boolean) => ({ hasRole, user })),
filter((filteredUser: { hasRole: boolean; user: IdentityUserModel }) => filteredUser.hasRole), filter((filteredUser: { hasRole: boolean; user: IdentityUserModel }) => filteredUser.hasRole),
map((filteredUser: { hasRole: boolean; user: IdentityUserModel }) => filteredUser.user)); map((filteredUser: { hasRole: boolean; user: IdentityUserModel }) => filteredUser.user));
} }
private isUserAlreadySelected(searchUser: IdentityUserModel): boolean { private isUserAlreadySelected(searchUser: IdentityUserModel): boolean {
if (this.selectedUsers && this.selectedUsers.length > 0) { if (this.selectedUsers && this.selectedUsers.length > 0) {
const result = this.selectedUsers.find((selectedUser) => { const result = this.selectedUsers.find((selectedUser) => this.compare(selectedUser, searchUser));
return this.compare(selectedUser, searchUser);
});
return !!result; return !!result;
} }
@@ -442,11 +440,9 @@ export class PeopleCloudComponent implements OnInit, OnChanges, OnDestroy {
} }
private removeUserFromSelected({ id, username, email }: IdentityUserModel): void { private removeUserFromSelected({ id, username, email }: IdentityUserModel): void {
const indexToRemove = this.selectedUsers.findIndex(user => { const indexToRemove = this.selectedUsers.findIndex(user => user.id === id
return user.id === id
&& user.username === username && user.username === username
&& user.email === email; && user.email === email);
});
if (indexToRemove !== -1) { if (indexToRemove !== -1) {
this.selectedUsers.splice(indexToRemove, 1); this.selectedUsers.splice(indexToRemove, 1);
@@ -454,11 +450,9 @@ export class PeopleCloudComponent implements OnInit, OnChanges, OnDestroy {
} }
private removeUserFromValidation({ id, username, email }: IdentityUserModel): void { private removeUserFromValidation({ id, username, email }: IdentityUserModel): void {
const indexToRemove = this.invalidUsers.findIndex(user => { const indexToRemove = this.invalidUsers.findIndex(user => user.id === id
return user.id === id
&& user.username === username && user.username === username
&& user.email === email; && user.email === email);
});
if (indexToRemove !== -1) { if (indexToRemove !== -1) {
this.invalidUsers.splice(indexToRemove, 1); this.invalidUsers.splice(indexToRemove, 1);
@@ -20,28 +20,28 @@ import moment from 'moment-es6';
import { LocalizedDatePipe } from '@alfresco/adf-core'; import { LocalizedDatePipe } from '@alfresco/adf-core';
import { ProcessInstanceCloud } from '../process/start-process/models/process-instance-cloud.model'; import { ProcessInstanceCloud } from '../process/start-process/models/process-instance-cloud.model';
export const DATE_TIME_IDENTIFIER_REG_EXP = new RegExp('%{datetime}', 'i');
export const PROCESS_DEFINITION_IDENTIFIER_REG_EXP = new RegExp('%{processdefinition}', 'i');
@Pipe({ name: 'processNameCloud' }) @Pipe({ name: 'processNameCloud' })
export class ProcessNameCloudPipe implements PipeTransform { export class ProcessNameCloudPipe implements PipeTransform {
static DATE_TIME_IDENTIFIER_REG_EXP = new RegExp('%{datetime}', 'i');
static PROCESS_DEFINITION_IDENTIFIER_REG_EXP = new RegExp('%{processdefinition}', 'i');
constructor(private localizedDatePipe: LocalizedDatePipe) { constructor(private localizedDatePipe: LocalizedDatePipe) {
} }
transform(processNameFormat: string, processInstance?: ProcessInstanceCloud): string { transform(processNameFormat: string, processInstance?: ProcessInstanceCloud): string {
let processName = processNameFormat; let processName = processNameFormat;
if (processName.match(ProcessNameCloudPipe.DATE_TIME_IDENTIFIER_REG_EXP)) { if (processName.match(DATE_TIME_IDENTIFIER_REG_EXP)) {
const presentDateTime = moment.now(); const presentDateTime = moment.now();
processName = processName.replace( processName = processName.replace(
ProcessNameCloudPipe.DATE_TIME_IDENTIFIER_REG_EXP, DATE_TIME_IDENTIFIER_REG_EXP,
this.localizedDatePipe.transform(presentDateTime, 'medium') this.localizedDatePipe.transform(presentDateTime, 'medium')
); );
} }
if (processName.match(ProcessNameCloudPipe.PROCESS_DEFINITION_IDENTIFIER_REG_EXP)) { if (processName.match(PROCESS_DEFINITION_IDENTIFIER_REG_EXP)) {
const selectedProcessDefinitionName = processInstance ? processInstance.processDefinitionName : ''; const selectedProcessDefinitionName = processInstance ? processInstance.processDefinitionName : '';
processName = processName.replace( processName = processName.replace(
ProcessNameCloudPipe.PROCESS_DEFINITION_IDENTIFIER_REG_EXP, PROCESS_DEFINITION_IDENTIFIER_REG_EXP,
selectedProcessDefinitionName selectedProcessDefinitionName
); );
} }
@@ -69,9 +69,7 @@ describe('EditProcessFilterCloudComponent', () => {
oauth2Auth: { oauth2Auth: {
callCustomApi: () => Promise.resolve(fakeApplicationInstance) callCustomApi: () => Promise.resolve(fakeApplicationInstance)
}, },
isEcmLoggedIn() { isEcmLoggedIn: () => false,
return false;
},
reply: jasmine.createSpy('reply') reply: jasmine.createSpy('reply')
}; };
@@ -97,13 +95,11 @@ describe('EditProcessFilterCloudComponent', () => {
alfrescoApiService = TestBed.inject(AlfrescoApiService); alfrescoApiService = TestBed.inject(AlfrescoApiService);
dialog = TestBed.inject(MatDialog); dialog = TestBed.inject(MatDialog);
spyOn(dialog, 'open').and.returnValue({ spyOn(dialog, 'open').and.returnValue({
afterClosed() { afterClosed: () => of({
return of({
action: ProcessFilterDialogCloudComponent.ACTION_SAVE, action: ProcessFilterDialogCloudComponent.ACTION_SAVE,
icon: 'icon', icon: 'icon',
name: 'fake-name' name: 'fake-name'
}); })
}
} as any); } as any);
getProcessFilterByIdSpy = spyOn(service, 'getFilterById').and.returnValue(of(fakeFilter)); getProcessFilterByIdSpy = spyOn(service, 'getFilterById').and.returnValue(of(fakeFilter));
getRunningApplicationsSpy = spyOn(appsService, 'getDeployedApplicationsByStatus').and.returnValue(of(fakeApplicationInstance)); getRunningApplicationsSpy = spyOn(appsService, 'getDeployedApplicationsByStatus').and.returnValue(of(fakeApplicationInstance));
@@ -128,7 +124,7 @@ describe('EditProcessFilterCloudComponent', () => {
it('should fetch process instance filter by id', async () => { it('should fetch process instance filter by id', async () => {
const processFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true); const processFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true);
component.ngOnChanges({ 'id': processFilterIdChange }); component.ngOnChanges({ id: processFilterIdChange });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -144,7 +140,7 @@ describe('EditProcessFilterCloudComponent', () => {
it('should display filter name as title', async () => { it('should display filter name as title', async () => {
const processFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true); const processFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true);
component.showProcessFilterName = true; component.showProcessFilterName = true;
component.ngOnChanges({ 'id': processFilterIdChange }); component.ngOnChanges({ id: processFilterIdChange });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -161,7 +157,7 @@ describe('EditProcessFilterCloudComponent', () => {
it('should not display filter name as title if the flag is false', async () => { it('should not display filter name as title if the flag is false', async () => {
const processFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true); const processFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true);
component.showProcessFilterName = false; component.showProcessFilterName = false;
component.ngOnChanges({ 'id': processFilterIdChange }); component.ngOnChanges({ id: processFilterIdChange });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -172,7 +168,7 @@ describe('EditProcessFilterCloudComponent', () => {
it('should not display mat-spinner if isloading set to false', async () => { it('should not display mat-spinner if isloading set to false', async () => {
const processFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true); const processFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true);
component.ngOnChanges({ 'id': processFilterIdChange }); component.ngOnChanges({ id: processFilterIdChange });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -191,7 +187,7 @@ describe('EditProcessFilterCloudComponent', () => {
it('should display mat-spinner if isloading set to true', async () => { it('should display mat-spinner if isloading set to true', async () => {
component.isLoading = true; component.isLoading = true;
const processFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true); const processFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true);
component.ngOnChanges({ 'id': processFilterIdChange }); component.ngOnChanges({ id: processFilterIdChange });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -204,7 +200,7 @@ describe('EditProcessFilterCloudComponent', () => {
beforeEach(() => { beforeEach(() => {
const processFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true); const processFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true);
component.ngOnChanges({ 'id': processFilterIdChange }); component.ngOnChanges({ id: processFilterIdChange });
fixture.detectChanges(); fixture.detectChanges();
}); });
@@ -288,7 +284,7 @@ describe('EditProcessFilterCloudComponent', () => {
})); }));
const processFilterIdChange = new SimpleChange(null, 'filter-id', true); const processFilterIdChange = new SimpleChange(null, 'filter-id', true);
component.ngOnChanges({ 'id': processFilterIdChange }); component.ngOnChanges({ id: processFilterIdChange });
fixture.detectChanges(); fixture.detectChanges();
component.toggleFilterActions = true; component.toggleFilterActions = true;
@@ -324,7 +320,7 @@ describe('EditProcessFilterCloudComponent', () => {
})); }));
const processFilterIdChange = new SimpleChange(null, 'filter-id', true); const processFilterIdChange = new SimpleChange(null, 'filter-id', true);
component.ngOnChanges({ 'id': processFilterIdChange }); component.ngOnChanges({ id: processFilterIdChange });
fixture.detectChanges(); fixture.detectChanges();
component.toggleFilterActions = true; component.toggleFilterActions = true;
@@ -466,7 +462,7 @@ describe('EditProcessFilterCloudComponent', () => {
await fixture.whenStable(); await fixture.whenStable();
const processFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true); const processFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true);
component.ngOnChanges({ 'id': processFilterIdChange }); component.ngOnChanges({ id: processFilterIdChange });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -485,7 +481,7 @@ describe('EditProcessFilterCloudComponent', () => {
await fixture.whenStable(); await fixture.whenStable();
const processFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true); const processFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true);
component.ngOnChanges({ 'id': processFilterIdChange }); component.ngOnChanges({ id: processFilterIdChange });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -517,7 +513,7 @@ describe('EditProcessFilterCloudComponent', () => {
await fixture.whenStable(); await fixture.whenStable();
const processFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true); const processFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true);
component.ngOnChanges({ 'id': processFilterIdChange }); component.ngOnChanges({ id: processFilterIdChange });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -535,7 +531,7 @@ describe('EditProcessFilterCloudComponent', () => {
await fixture.whenStable(); await fixture.whenStable();
const processFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true); const processFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true);
component.ngOnChanges({ 'id': processFilterIdChange }); component.ngOnChanges({ id: processFilterIdChange });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -569,7 +565,7 @@ describe('EditProcessFilterCloudComponent', () => {
await fixture.whenStable(); await fixture.whenStable();
const processFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true); const processFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true);
component.ngOnChanges({ 'id': processFilterIdChange }); component.ngOnChanges({ id: processFilterIdChange });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -587,7 +583,7 @@ describe('EditProcessFilterCloudComponent', () => {
await fixture.whenStable(); await fixture.whenStable();
const processFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true); const processFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true);
component.ngOnChanges({ 'id': processFilterIdChange }); component.ngOnChanges({ id: processFilterIdChange });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -611,7 +607,7 @@ describe('EditProcessFilterCloudComponent', () => {
fixture.detectChanges(); fixture.detectChanges();
const processFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true); const processFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true);
component.ngOnChanges({ 'id': processFilterIdChange }); component.ngOnChanges({ id: processFilterIdChange });
fixture.detectChanges(); fixture.detectChanges();
const controller = component.editProcessFilterForm.get('appVersionMultiple'); const controller = component.editProcessFilterForm.get('appVersionMultiple');
@@ -638,7 +634,7 @@ describe('EditProcessFilterCloudComponent', () => {
await fixture.whenStable(); await fixture.whenStable();
const processFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true); const processFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true);
component.ngOnChanges({ 'id': processFilterIdChange }); component.ngOnChanges({ id: processFilterIdChange });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -659,7 +655,7 @@ describe('EditProcessFilterCloudComponent', () => {
it('should display default sort properties', async () => { it('should display default sort properties', async () => {
const processFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true); const processFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true);
component.ngOnChanges({ 'id': processFilterIdChange }); component.ngOnChanges({ id: processFilterIdChange });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -697,7 +693,7 @@ describe('EditProcessFilterCloudComponent', () => {
await fixture.whenStable(); await fixture.whenStable();
const processFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true); const processFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true);
component.ngOnChanges({ 'id': processFilterIdChange }); component.ngOnChanges({ id: processFilterIdChange });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -733,7 +729,7 @@ describe('EditProcessFilterCloudComponent', () => {
})); }));
component.sortProperties = ['name']; component.sortProperties = ['name'];
const processFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true); const processFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true);
component.ngOnChanges({ 'id': processFilterIdChange }); component.ngOnChanges({ id: processFilterIdChange });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -760,7 +756,7 @@ describe('EditProcessFilterCloudComponent', () => {
const processFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true); const processFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true);
getProcessFilterByIdSpy.and.returnValue(of(fakeFilter)); getProcessFilterByIdSpy.and.returnValue(of(fakeFilter));
component.ngOnChanges({ 'id': processFilterIdChange }); component.ngOnChanges({ id: processFilterIdChange });
fixture.detectChanges(); fixture.detectChanges();
}); });
@@ -882,7 +878,7 @@ describe('EditProcessFilterCloudComponent', () => {
await fixture.whenStable(); await fixture.whenStable();
const processFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true); const processFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true);
component.ngOnChanges({ 'id': processFilterIdChange }); component.ngOnChanges({ id: processFilterIdChange });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -920,7 +916,7 @@ describe('EditProcessFilterCloudComponent', () => {
component.appName = 'fake'; component.appName = 'fake';
component.filterProperties = ['appName', 'processInstanceId', 'priority', 'lastModified']; component.filterProperties = ['appName', 'processInstanceId', 'priority', 'lastModified'];
const processFilterIdChange = new SimpleChange(undefined, 'mock-process-filter-id', true); const processFilterIdChange = new SimpleChange(undefined, 'mock-process-filter-id', true);
component.ngOnChanges({ 'id': processFilterIdChange }); component.ngOnChanges({ id: processFilterIdChange });
fixture.detectChanges(); fixture.detectChanges();
const date = moment(); const date = moment();
@@ -943,7 +939,7 @@ describe('EditProcessFilterCloudComponent', () => {
component.appName = 'fake'; component.appName = 'fake';
component.filterProperties = ['appName', 'processInstanceId', 'priority', 'completedDateRange']; component.filterProperties = ['appName', 'processInstanceId', 'priority', 'completedDateRange'];
const processFilterIdChange = new SimpleChange(undefined, 'mock-process-filter-id', true); const processFilterIdChange = new SimpleChange(undefined, 'mock-process-filter-id', true);
component.ngOnChanges({ 'id': processFilterIdChange }); component.ngOnChanges({ id: processFilterIdChange });
fixture.detectChanges(); fixture.detectChanges();
component.filterChange.subscribe(() => { component.filterChange.subscribe(() => {
@@ -977,7 +973,7 @@ describe('EditProcessFilterCloudComponent', () => {
component.appName = 'fake'; component.appName = 'fake';
component.filterProperties = ['appName', 'processInstanceId', 'priority', 'completedDateRange']; component.filterProperties = ['appName', 'processInstanceId', 'priority', 'completedDateRange'];
const processFilterIdChange = new SimpleChange(undefined, 'mock-process-filter-id', true); const processFilterIdChange = new SimpleChange(undefined, 'mock-process-filter-id', true);
component.ngOnChanges({ 'id': processFilterIdChange }); component.ngOnChanges({ id: processFilterIdChange });
fixture.detectChanges(); fixture.detectChanges();
component.filterChange.subscribe(() => { component.filterChange.subscribe(() => {
@@ -998,7 +994,7 @@ describe('EditProcessFilterCloudComponent', () => {
component.appName = 'fake'; component.appName = 'fake';
component.filterProperties = ['appName', 'processInstanceId', 'priority', 'completedDateRange']; component.filterProperties = ['appName', 'processInstanceId', 'priority', 'completedDateRange'];
const processFilterIdChange = new SimpleChange(undefined, 'mock-process-filter-id', true); const processFilterIdChange = new SimpleChange(undefined, 'mock-process-filter-id', true);
component.ngOnChanges({ 'id': processFilterIdChange }); component.ngOnChanges({ id: processFilterIdChange });
fixture.detectChanges(); fixture.detectChanges();
const dateFilter = { const dateFilter = {
@@ -1088,7 +1084,7 @@ describe('EditProcessFilterCloudComponent', () => {
component.appName = 'fake'; component.appName = 'fake';
component.filterProperties = ['appName', 'initiator']; component.filterProperties = ['appName', 'initiator'];
const processFilterIdChange = new SimpleChange(undefined, 'mock-process-filter-id', true); const processFilterIdChange = new SimpleChange(undefined, 'mock-process-filter-id', true);
component.ngOnChanges({ 'id': processFilterIdChange }); component.ngOnChanges({ id: processFilterIdChange });
fixture.detectChanges(); fixture.detectChanges();
expect(component.initiatorOptions).toEqual([ { username: 'user1' }, { username: 'user2'} ]); expect(component.initiatorOptions).toEqual([ { username: 'user1' }, { username: 'user2'} ]);
@@ -31,6 +31,13 @@ import { ProcessFilterDialogCloudComponent } from './process-filter-dialog-cloud
import { ProcessCloudService } from '../../services/process-cloud.service'; import { ProcessCloudService } from '../../services/process-cloud.service';
import { DateCloudFilterType, DateRangeFilter } from '../../../models/date-cloud-filter.model'; import { DateCloudFilterType, DateRangeFilter } from '../../../models/date-cloud-filter.model';
export const PROCESS_FILTER_ACTION_SAVE = 'save';
export const PROCESS_FILTER_ACTION_SAVE_AS = 'saveAs';
export const PROCESS_FILTER_ACTION_DELETE = 'delete';
const DEFAULT_PROCESS_FILTER_PROPERTIES = ['status', 'sort', 'order', 'lastModified'];
const DEFAULT_SORT_PROPERTIES = ['id', 'name', 'status', 'startDate'];
const DEFAULT_ACTIONS = ['save', 'saveAs', 'delete'];
export interface DropdownOption { export interface DropdownOption {
value: string; value: string;
label: string; label: string;
@@ -43,15 +50,6 @@ export interface DropdownOption {
encapsulation: ViewEncapsulation.None encapsulation: ViewEncapsulation.None
}) })
export class EditProcessFilterCloudComponent implements OnInit, OnChanges, OnDestroy { export class EditProcessFilterCloudComponent implements OnInit, OnChanges, OnDestroy {
public static ACTION_SAVE = 'save';
public static ACTION_SAVE_AS = 'saveAs';
public static ACTION_DELETE = 'delete';
public static DEFAULT_PROCESS_FILTER_PROPERTIES = ['status', 'sort', 'order', 'lastModified'];
public static DEFAULT_SORT_PROPERTIES = ['id', 'name', 'status', 'startDate'];
public static DEFAULT_ACTIONS = ['save', 'saveAs', 'delete'];
public DATE_FORMAT: string = 'DD/MM/YYYY';
/** The name of the application. */ /** The name of the application. */
@Input() @Input()
appName: string = ''; appName: string = '';
@@ -66,15 +64,15 @@ export class EditProcessFilterCloudComponent implements OnInit, OnChanges, OnDes
/** List of process filter properties to display */ /** List of process filter properties to display */
@Input() @Input()
filterProperties = EditProcessFilterCloudComponent.DEFAULT_PROCESS_FILTER_PROPERTIES; filterProperties = DEFAULT_PROCESS_FILTER_PROPERTIES;
/** List of sort properties to display. */ /** List of sort properties to display. */
@Input() @Input()
sortProperties = EditProcessFilterCloudComponent.DEFAULT_SORT_PROPERTIES; sortProperties = DEFAULT_SORT_PROPERTIES;
/** List of sort actions. */ /** List of sort actions. */
@Input() @Input()
actions = EditProcessFilterCloudComponent.DEFAULT_ACTIONS; actions = DEFAULT_ACTIONS;
/** Toggles editing of process filter actions. */ /** Toggles editing of process filter actions. */
@Input() @Input()
@@ -139,8 +137,8 @@ export class EditProcessFilterCloudComponent implements OnInit, OnChanges, OnDes
{ value: 'DESC', label: 'ADF_CLOUD_PROCESS_FILTERS.DIRECTION.DESCENDING' } { value: 'DESC', label: 'ADF_CLOUD_PROCESS_FILTERS.DIRECTION.DESCENDING' }
]; ];
actionDisabledForDefault = [ actionDisabledForDefault = [
EditProcessFilterCloudComponent.ACTION_SAVE, PROCESS_FILTER_ACTION_SAVE,
EditProcessFilterCloudComponent.ACTION_DELETE PROCESS_FILTER_ACTION_DELETE
]; ];
applicationNames: any[] = []; applicationNames: any[] = [];
allProcessDefinitionNamesOption: DropdownOption = { allProcessDefinitionNamesOption: DropdownOption = {
@@ -274,7 +272,7 @@ export class EditProcessFilterCloudComponent implements OnInit, OnChanges, OnDes
if (this.filterProperties.includes('initiator')) { if (this.filterProperties.includes('initiator')) {
this.initiatorOptions = !!this.processFilter.initiator this.initiatorOptions = !!this.processFilter.initiator
? this.processFilter.initiator.split(',').map( username => Object.assign({}, { username: username })) ? this.processFilter.initiator.split(',').map( username => Object.assign({}, { username }))
: []; : [];
} }
@@ -297,7 +295,7 @@ export class EditProcessFilterCloudComponent implements OnInit, OnChanges, OnDes
checkMandatoryFilterProperties() { checkMandatoryFilterProperties() {
if (this.filterProperties === undefined || this.filterProperties.length === 0) { if (this.filterProperties === undefined || this.filterProperties.length === 0) {
this.filterProperties = EditProcessFilterCloudComponent.DEFAULT_PROCESS_FILTER_PROPERTIES; this.filterProperties = DEFAULT_PROCESS_FILTER_PROPERTIES;
} }
} }
@@ -323,7 +321,7 @@ export class EditProcessFilterCloudComponent implements OnInit, OnChanges, OnDes
checkMandatorySortProperties() { checkMandatorySortProperties() {
if (this.sortProperties === undefined || this.sortProperties.length === 0) { if (this.sortProperties === undefined || this.sortProperties.length === 0) {
this.sortProperties = EditProcessFilterCloudComponent.DEFAULT_SORT_PROPERTIES; this.sortProperties = DEFAULT_SORT_PROPERTIES;
} }
} }
@@ -335,7 +333,7 @@ export class EditProcessFilterCloudComponent implements OnInit, OnChanges, OnDes
checkMandatoryActions() { checkMandatoryActions() {
if (this.actions === undefined || this.actions.length === 0) { if (this.actions === undefined || this.actions.length === 0) {
this.actions = EditProcessFilterCloudComponent.DEFAULT_ACTIONS; this.actions = DEFAULT_ACTIONS;
} }
} }
@@ -419,11 +417,11 @@ export class EditProcessFilterCloudComponent implements OnInit, OnChanges, OnDes
} }
executeFilterActions(action: ProcessFilterAction): void { executeFilterActions(action: ProcessFilterAction): void {
if (action.actionType === EditProcessFilterCloudComponent.ACTION_SAVE) { if (action.actionType === PROCESS_FILTER_ACTION_SAVE) {
this.save(action); this.save(action);
} else if (action.actionType === EditProcessFilterCloudComponent.ACTION_SAVE_AS) { } else if (action.actionType === PROCESS_FILTER_ACTION_SAVE_AS) {
this.saveAs(action); this.saveAs(action);
} else if (action.actionType === EditProcessFilterCloudComponent.ACTION_DELETE) { } else if (action.actionType === PROCESS_FILTER_ACTION_DELETE) {
this.delete(action); this.delete(action);
} }
} }
@@ -489,6 +487,7 @@ export class EditProcessFilterCloudComponent implements OnInit, OnChanges, OnDes
/** /**
* Return filter name * Return filter name
*
* @param filterName * @param filterName
*/ */
getSanitizeFilterName(filterName: string): string { getSanitizeFilterName(filterName: string): string {
@@ -498,6 +497,7 @@ export class EditProcessFilterCloudComponent implements OnInit, OnChanges, OnDes
/** /**
* Return name with hyphen * Return name with hyphen
*
* @param name * @param name
*/ */
replaceSpaceWithHyphen(name: string): string { replaceSpaceWithHyphen(name: string): string {
@@ -525,8 +525,8 @@ export class EditProcessFilterCloudComponent implements OnInit, OnChanges, OnDes
} }
hasFilterChanged(action: ProcessFilterAction): boolean { hasFilterChanged(action: ProcessFilterAction): boolean {
return action.actionType === EditProcessFilterCloudComponent.ACTION_SAVE || return action.actionType === PROCESS_FILTER_ACTION_SAVE ||
action.actionType === EditProcessFilterCloudComponent.ACTION_SAVE_AS ? action.actionType === PROCESS_FILTER_ACTION_SAVE_AS ?
!this.filterHasBeenChanged : false; !this.filterHasBeenChanged : false;
} }
@@ -545,17 +545,17 @@ export class EditProcessFilterCloudComponent implements OnInit, OnChanges, OnDes
private createFilterActions(): ProcessFilterAction[] { private createFilterActions(): ProcessFilterAction[] {
return [ return [
{ {
actionType: EditProcessFilterCloudComponent.ACTION_SAVE, actionType: PROCESS_FILTER_ACTION_SAVE,
icon: 'adf:save', icon: 'adf:save',
tooltip: 'ADF_CLOUD_EDIT_PROCESS_FILTER.TOOL_TIP.SAVE' tooltip: 'ADF_CLOUD_EDIT_PROCESS_FILTER.TOOL_TIP.SAVE'
}, },
{ {
actionType: EditProcessFilterCloudComponent.ACTION_SAVE_AS, actionType: PROCESS_FILTER_ACTION_SAVE_AS,
icon: 'adf:save-as', icon: 'adf:save-as',
tooltip: 'ADF_CLOUD_EDIT_PROCESS_FILTER.TOOL_TIP.SAVE_AS' tooltip: 'ADF_CLOUD_EDIT_PROCESS_FILTER.TOOL_TIP.SAVE_AS'
}, },
{ {
actionType: EditProcessFilterCloudComponent.ACTION_DELETE, actionType: PROCESS_FILTER_ACTION_DELETE,
icon: 'delete', icon: 'delete',
tooltip: 'ADF_CLOUD_EDIT_PROCESS_FILTER.TOOL_TIP.DELETE' tooltip: 'ADF_CLOUD_EDIT_PROCESS_FILTER.TOOL_TIP.DELETE'
} }
@@ -26,6 +26,7 @@ import { FormBuilder, FormGroup, AbstractControl, Validators } from '@angular/fo
}) })
export class ProcessFilterDialogCloudComponent implements OnInit { export class ProcessFilterDialogCloudComponent implements OnInit {
// eslint-disable-next-line @typescript-eslint/naming-convention
public static ACTION_SAVE = 'SAVE'; public static ACTION_SAVE = 'SAVE';
defaultIcon = 'inbox'; defaultIcon = 'inbox';
@@ -60,7 +60,7 @@ describe('ProcessFiltersCloudComponent', () => {
it('should attach specific icon for each filter if hasIcon is true', async () => { it('should attach specific icon for each filter if hasIcon is true', async () => {
const change = new SimpleChange(undefined, 'my-app-1', true); const change = new SimpleChange(undefined, 'my-app-1', true);
component.ngOnChanges({'appName': change}); component.ngOnChanges({appName: change});
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -81,7 +81,7 @@ describe('ProcessFiltersCloudComponent', () => {
it('should not attach icons for each filter if hasIcon is false', async () => { it('should not attach icons for each filter if hasIcon is false', async () => {
component.showIcons = false; component.showIcons = false;
const change = new SimpleChange(undefined, 'my-app-1', true); const change = new SimpleChange(undefined, 'my-app-1', true);
component.ngOnChanges({ 'appName': change }); component.ngOnChanges({ appName: change });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -92,7 +92,7 @@ describe('ProcessFiltersCloudComponent', () => {
it('should display the filters', async () => { it('should display the filters', async () => {
const change = new SimpleChange(undefined, 'my-app-1', true); const change = new SimpleChange(undefined, 'my-app-1', true);
component.ngOnChanges({'appName': change}); component.ngOnChanges({appName: change});
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -124,7 +124,7 @@ describe('ProcessFiltersCloudComponent', () => {
done(); done();
}); });
component.ngOnChanges({'appName': change}); component.ngOnChanges({appName: change});
fixture.detectChanges(); fixture.detectChanges();
}); });
@@ -133,7 +133,7 @@ describe('ProcessFiltersCloudComponent', () => {
const appName = 'my-app-1'; const appName = 'my-app-1';
const change = new SimpleChange(null, appName, true); const change = new SimpleChange(null, appName, true);
component.ngOnChanges({ 'appName': change }); component.ngOnChanges({ appName: change });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -148,7 +148,7 @@ describe('ProcessFiltersCloudComponent', () => {
const appName = 'my-app-1'; const appName = 'my-app-1';
const change = new SimpleChange(null, appName, true); const change = new SimpleChange(null, appName, true);
component.ngOnChanges({ 'appName': change }); component.ngOnChanges({ appName: change });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -159,7 +159,7 @@ describe('ProcessFiltersCloudComponent', () => {
const change = new SimpleChange(null, { name: 'nonexistentFilter' }, true); const change = new SimpleChange(null, { name: 'nonexistentFilter' }, true);
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
component.ngOnChanges({ 'filterParam': change }); component.ngOnChanges({ filterParam: change });
expect(component.currentFilter).toBeUndefined(); expect(component.currentFilter).toBeUndefined();
}); });
@@ -170,7 +170,7 @@ describe('ProcessFiltersCloudComponent', () => {
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
component.ngOnChanges({ 'filterParam': change }); component.ngOnChanges({ filterParam: change });
expect(component.currentFilter).toEqual(mockProcessFilters[1]); expect(component.currentFilter).toEqual(mockProcessFilters[1]);
expect(filterSelectedSpy).toHaveBeenCalledWith(mockProcessFilters[1]); expect(filterSelectedSpy).toHaveBeenCalledWith(mockProcessFilters[1]);
@@ -182,7 +182,7 @@ describe('ProcessFiltersCloudComponent', () => {
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
component.ngOnChanges({ 'filterParam': change }); component.ngOnChanges({ filterParam: change });
expect(component.currentFilter).toEqual(mockProcessFilters[2]); expect(component.currentFilter).toEqual(mockProcessFilters[2]);
expect(filterSelectedSpy).toHaveBeenCalledWith(mockProcessFilters[2]); expect(filterSelectedSpy).toHaveBeenCalledWith(mockProcessFilters[2]);
@@ -194,7 +194,7 @@ describe('ProcessFiltersCloudComponent', () => {
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
component.ngOnChanges({ 'filterParam': change }); component.ngOnChanges({ filterParam: change });
expect(component.currentFilter).toEqual(mockProcessFilters[2]); expect(component.currentFilter).toEqual(mockProcessFilters[2]);
expect(filterSelectedSpy).toHaveBeenCalledWith(mockProcessFilters[2]); expect(filterSelectedSpy).toHaveBeenCalledWith(mockProcessFilters[2]);
@@ -206,7 +206,7 @@ describe('ProcessFiltersCloudComponent', () => {
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
component.ngOnChanges({ 'filterParam': change }); component.ngOnChanges({ filterParam: change });
expect(component.currentFilter).toEqual(mockProcessFilters[2]); expect(component.currentFilter).toEqual(mockProcessFilters[2]);
expect(filterSelectedSpy).toHaveBeenCalledWith(mockProcessFilters[2]); expect(filterSelectedSpy).toHaveBeenCalledWith(mockProcessFilters[2]);
@@ -216,7 +216,7 @@ describe('ProcessFiltersCloudComponent', () => {
const filterClickedSpy = spyOn(component.filterClicked, 'emit'); const filterClickedSpy = spyOn(component.filterClicked, 'emit');
const appName = 'my-app-1'; const appName = 'my-app-1';
const change = new SimpleChange(null, appName, true); const change = new SimpleChange(null, appName, true);
component.ngOnChanges({ 'appName': change }); component.ngOnChanges({ appName: change });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -234,7 +234,7 @@ describe('ProcessFiltersCloudComponent', () => {
it('should reset the filter when the param is undefined', () => { it('should reset the filter when the param is undefined', () => {
const change = new SimpleChange(mockProcessFilters[0], undefined, false); const change = new SimpleChange(mockProcessFilters[0], undefined, false);
component.currentFilter = mockProcessFilters[0]; component.currentFilter = mockProcessFilters[0];
component.ngOnChanges({ 'filterParam': change }); component.ngOnChanges({ filterParam: change });
expect(component.currentFilter).toEqual(undefined); expect(component.currentFilter).toEqual(undefined);
}); });
@@ -245,7 +245,7 @@ describe('ProcessFiltersCloudComponent', () => {
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
component.ngOnChanges({ 'filterParam': change }); component.ngOnChanges({ filterParam: change });
expect(component.currentFilter).toBe(mockProcessFilters[0]); expect(component.currentFilter).toBe(mockProcessFilters[0]);
expect(filterClickedSpy).not.toHaveBeenCalled(); expect(filterClickedSpy).not.toHaveBeenCalled();
@@ -256,7 +256,7 @@ describe('ProcessFiltersCloudComponent', () => {
const appName = 'my-app-1'; const appName = 'my-app-1';
const change = new SimpleChange(null, appName, true); const change = new SimpleChange(null, appName, true);
component.ngOnChanges({ 'appName': change }); component.ngOnChanges({ appName: change });
expect(component.getFilters).toHaveBeenCalledWith(appName); expect(component.getFilters).toHaveBeenCalledWith(appName);
}); });
@@ -266,7 +266,7 @@ describe('ProcessFiltersCloudComponent', () => {
const appName = null; const appName = null;
const change = new SimpleChange(undefined, appName, true); const change = new SimpleChange(undefined, appName, true);
component.ngOnChanges({ 'appName': change }); component.ngOnChanges({ appName: change });
expect(component.getFilters).not.toHaveBeenCalledWith(appName); expect(component.getFilters).not.toHaveBeenCalledWith(appName);
}); });
@@ -276,7 +276,7 @@ describe('ProcessFiltersCloudComponent', () => {
const appName = 'fake-app-name'; const appName = 'fake-app-name';
const change = new SimpleChange(null, appName, true); const change = new SimpleChange(null, appName, true);
component.ngOnChanges({ 'appName': change }); component.ngOnChanges({ appName: change });
expect(component.getFilters).toHaveBeenCalledWith(appName); expect(component.getFilters).toHaveBeenCalledWith(appName);
}); });
@@ -296,21 +296,21 @@ describe('ProcessFiltersCloudComponent', () => {
const runningProcessesFilterKey = mockProcessFilters[1].key; const runningProcessesFilterKey = mockProcessFilters[1].key;
const completedProcessesFilterKey = mockProcessFilters[2].key; const completedProcessesFilterKey = mockProcessFilters[2].key;
function getActiveFilterElement(filterKey: string): Element { const getActiveFilterElement = (filterKey: string): Element => {
const activeFilter = fixture.debugElement.query(By.css(`.adf-active`)); const activeFilter = fixture.debugElement.query(By.css(`.adf-active`));
return activeFilter.nativeElement.querySelector(`[data-automation-id="${filterKey}_filter"]`); return activeFilter.nativeElement.querySelector(`[data-automation-id="${filterKey}_filter"]`);
} };
async function clickOnFilter(filterKey: string) { const clickOnFilter = async (filterKey: string) => {
fixture.debugElement.nativeElement.querySelector(`[data-automation-id="${filterKey}_filter"]`).click(); fixture.debugElement.nativeElement.querySelector(`[data-automation-id="${filterKey}_filter"]`).click();
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
} };
it('should apply active CSS class on filter click', async () => { it('should apply active CSS class on filter click', async () => {
component.appName = 'mock-app-name'; component.appName = 'mock-app-name';
const appNameChange = new SimpleChange(null, 'mock-app-name', true); const appNameChange = new SimpleChange(null, 'mock-app-name', true);
component.ngOnChanges({ 'appName': appNameChange }); component.ngOnChanges({ appName: appNameChange });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -335,7 +335,7 @@ describe('ProcessFiltersCloudComponent', () => {
it('Should apply active CSS class when filterParam input changed', async () => { it('Should apply active CSS class when filterParam input changed', async () => {
fixture.detectChanges(); fixture.detectChanges();
component.ngOnChanges({ 'filterParam': new SimpleChange(null, { key: allProcessesFilterKey }, true) }); component.ngOnChanges({ filterParam: new SimpleChange(null, { key: allProcessesFilterKey }, true) });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -343,7 +343,7 @@ describe('ProcessFiltersCloudComponent', () => {
expect(getActiveFilterElement(runningProcessesFilterKey)).toBeNull(); expect(getActiveFilterElement(runningProcessesFilterKey)).toBeNull();
expect(getActiveFilterElement(completedProcessesFilterKey)).toBeNull(); expect(getActiveFilterElement(completedProcessesFilterKey)).toBeNull();
component.ngOnChanges({ 'filterParam': new SimpleChange(null, { key: runningProcessesFilterKey }, true) }); component.ngOnChanges({ filterParam: new SimpleChange(null, { key: runningProcessesFilterKey }, true) });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -351,7 +351,7 @@ describe('ProcessFiltersCloudComponent', () => {
expect(getActiveFilterElement(runningProcessesFilterKey)).toBeDefined(); expect(getActiveFilterElement(runningProcessesFilterKey)).toBeDefined();
expect(getActiveFilterElement(completedProcessesFilterKey)).toBeNull(); expect(getActiveFilterElement(completedProcessesFilterKey)).toBeNull();
component.ngOnChanges({ 'filterParam': new SimpleChange(null, { key: completedProcessesFilterKey }, true) }); component.ngOnChanges({ filterParam: new SimpleChange(null, { key: completedProcessesFilterKey }, true) });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -111,12 +111,10 @@ export class ProcessFiltersCloudComponent implements OnInit, OnChanges, OnDestro
*/ */
public selectFilter(paramFilter: FilterParamsModel) { public selectFilter(paramFilter: FilterParamsModel) {
if (paramFilter) { if (paramFilter) {
this.currentFilter = this.filters.find((filter, index) => { this.currentFilter = this.filters.find((filter, index) => paramFilter.id === filter.id ||
return paramFilter.id === filter.id ||
(paramFilter.name && this.checkFilterNamesEquality(paramFilter.name, filter.name)) || (paramFilter.name && this.checkFilterNamesEquality(paramFilter.name, filter.name)) ||
(paramFilter.key && (paramFilter.key === filter.key)) || (paramFilter.key && (paramFilter.key === filter.key)) ||
paramFilter.index === index; paramFilter.index === index);
});
} }
} }
@@ -146,7 +144,7 @@ export class ProcessFiltersCloudComponent implements OnInit, OnChanges, OnDestro
* Select filter with the id * Select filter with the id
*/ */
public selectFilterById(id: string) { public selectFilterById(id: string) {
this.selectFilterAndEmit(<ProcessFilterCloudModel> {id: id}); this.selectFilterAndEmit({id});
} }
/** /**
@@ -14,14 +14,14 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
/* eslint-disable no-underscore-dangle */
import { DateCloudFilterType } from '../../../models/date-cloud-filter.model'; import { DateCloudFilterType } from '../../../models/date-cloud-filter.model';
import { DateRangeFilterService } from '../../../common/date-range-filter/date-range-filter.service'; import { DateRangeFilterService } from '../../../common/date-range-filter/date-range-filter.service';
import { ComponentSelectionMode } from '../../../types'; import { ComponentSelectionMode } from '../../../types';
export class ProcessFilterCloudModel { export class ProcessFilterCloudModel {
private dateRangeFilterService = new DateRangeFilterService();
id: string; id: string;
name: string; name: string;
key: string; key: string;
@@ -47,6 +47,7 @@ export class ProcessFilterCloudModel {
suspendedDateType: DateCloudFilterType; suspendedDateType: DateCloudFilterType;
completedDate: Date; completedDate: Date;
private dateRangeFilterService = new DateRangeFilterService();
private _completedFrom: string; private _completedFrom: string;
private _completedTo: string; private _completedTo: string;
private _startFrom: string; private _startFrom: string;
@@ -90,6 +90,7 @@ export class ProcessFilterCloudService {
/** /**
* Creates and returns the default process instance filters for a app. * Creates and returns the default process instance filters for a app.
*
* @param appName Name of the target app * @param appName Name of the target app
* @returns Observable of default process instance filters just created or created filters * @returns Observable of default process instance filters just created or created filters
*/ */
@@ -114,6 +115,7 @@ export class ProcessFilterCloudService {
/** /**
* Gets all process instance filters for a process app. * Gets all process instance filters for a process app.
*
* @param appName Name of the target app * @param appName Name of the target app
* @returns Observable of process filters details * @returns Observable of process filters details
*/ */
@@ -124,6 +126,7 @@ export class ProcessFilterCloudService {
/** /**
* Get process instance filter for given filter id * Get process instance filter for given filter id
*
* @param appName Name of the target app * @param appName Name of the target app
* @param id Id of the target process instance filter * @param id Id of the target process instance filter
* @returns Observable of process instance filter details * @returns Observable of process instance filter details
@@ -138,17 +141,14 @@ export class ProcessFilterCloudService {
return of(filters); return of(filters);
} }
}), }),
map((filters: ProcessFilterCloudModel[]) => { map((filters: ProcessFilterCloudModel[]) => filters.filter((filter: ProcessFilterCloudModel) => filter.id === id)[0]),
return filters.filter((filter: ProcessFilterCloudModel) => {
return filter.id === id;
})[0];
}),
catchError((err) => this.handleProcessError(err)) catchError((err) => this.handleProcessError(err))
); );
} }
/** /**
* Adds a new process instance filter * Adds a new process instance filter
*
* @param filter The new filter to add * @param filter The new filter to add
* @returns Observable of process instance filters with newly added filter * @returns Observable of process instance filters with newly added filter
*/ */
@@ -180,6 +180,7 @@ export class ProcessFilterCloudService {
/** /**
* Update process instance filter * Update process instance filter
*
* @param filter The new filter to update * @param filter The new filter to update
* @returns Observable of process instance filters with updated filter * @returns Observable of process instance filters with updated filter
*/ */
@@ -205,6 +206,7 @@ export class ProcessFilterCloudService {
/** /**
* Delete process instance filter * Delete process instance filter
*
* @param filter The new filter to delete * @param filter The new filter to delete
* @returns Observable of process instance filters without deleted filter * @returns Observable of process instance filters without deleted filter
*/ */
@@ -230,6 +232,7 @@ export class ProcessFilterCloudService {
/** /**
* Checks if given filter is a default filter * Checks if given filter is a default filter
*
* @param filterName Name of the target process filter * @param filterName Name of the target process filter
* @returns Boolean value for whether the filter is a default filter * @returns Boolean value for whether the filter is a default filter
*/ */
@@ -240,6 +243,7 @@ export class ProcessFilterCloudService {
/** /**
* Checks user preference are empty or not * Checks user preference are empty or not
*
* @param preferences User preferences of the target app * @param preferences User preferences of the target app
* @returns Boolean value if the preferences are not empty * @returns Boolean value if the preferences are not empty
*/ */
@@ -249,6 +253,7 @@ export class ProcessFilterCloudService {
/** /**
* Checks for process instance filters in given user preferences * Checks for process instance filters in given user preferences
*
* @param preferences User preferences of the target app * @param preferences User preferences of the target app
* @param key Key of the process instance filters * @param key Key of the process instance filters
* @param filters Details of create filter * @param filters Details of create filter
@@ -261,6 +266,7 @@ export class ProcessFilterCloudService {
/** /**
* Calls create preference api to create process instance filters * Calls create preference api to create process instance filters
*
* @param appName Name of the target app * @param appName Name of the target app
* @param key Key of the process instance filters * @param key Key of the process instance filters
* @param filters Details of new process instance filter * @param filters Details of new process instance filter
@@ -272,6 +278,7 @@ export class ProcessFilterCloudService {
/** /**
* Calls get preference api to get process instance filter by preference key * Calls get preference api to get process instance filter by preference key
*
* @param appName Name of the target app * @param appName Name of the target app
* @param key Key of the process instance filters * @param key Key of the process instance filters
* @returns Observable of process instance filters * @returns Observable of process instance filters
@@ -282,6 +289,7 @@ export class ProcessFilterCloudService {
/** /**
* Calls update preference api to update process instance filter * Calls update preference api to update process instance filter
*
* @param appName Name of the target app * @param appName Name of the target app
* @param key Key of the process instance filters * @param key Key of the process instance filters
* @param filters Details of update filter * @param filters Details of update filter
@@ -293,6 +301,7 @@ export class ProcessFilterCloudService {
/** /**
* Creates a uniq key with appName and username * Creates a uniq key with appName and username
*
* @param appName Name of the target app * @param appName Name of the target app
* @returns String of process instance filters preference key * @returns String of process instance filters preference key
*/ */
@@ -303,6 +312,7 @@ export class ProcessFilterCloudService {
/** /**
* Finds and returns the process instance filters from preferences * Finds and returns the process instance filters from preferences
*
* @returns Array of ProcessFilterCloudModel * @returns Array of ProcessFilterCloudModel
* @param preferences * @param preferences
* @param key * @param key
@@ -322,6 +332,7 @@ export class ProcessFilterCloudService {
/** /**
* Creates and returns the default filters for a process app. * Creates and returns the default filters for a process app.
*
* @param appName Name of the target app * @param appName Name of the target app
* @returns Array of ProcessFilterCloudModel * @returns Array of ProcessFilterCloudModel
*/ */
@@ -84,19 +84,19 @@ describe('ProcessListCloudComponent', () => {
component = fixture.componentInstance; component = fixture.componentInstance;
appConfig.config = Object.assign(appConfig.config, { appConfig.config = Object.assign(appConfig.config, {
'adf-cloud-process-list': { 'adf-cloud-process-list': {
'presets': { presets: {
'fakeCustomSchema': [ fakeCustomSchema: [
{ {
'key': 'fakeName', key: 'fakeName',
'type': 'text', type: 'text',
'title': 'ADF_CLOUD_TASK_LIST.PROPERTIES.FAKE', title: 'ADF_CLOUD_TASK_LIST.PROPERTIES.FAKE',
'sortable': true sortable: true
}, },
{ {
'key': 'fakeTaskName', key: 'fakeTaskName',
'type': 'text', type: 'text',
'title': 'ADF_CLOUD_TASK_LIST.PROPERTIES.TASK_FAKE', title: 'ADF_CLOUD_TASK_LIST.PROPERTIES.TASK_FAKE',
'sortable': true sortable: true
} }
] ]
} }
@@ -219,7 +219,7 @@ describe('ProcessListCloudComponent', () => {
done(); done();
}); });
component.appName = appName.currentValue; component.appName = appName.currentValue;
component.ngOnChanges({ 'appName': appName }); component.ngOnChanges({ appName });
fixture.detectChanges(); fixture.detectChanges();
}); });
@@ -263,9 +263,9 @@ describe('ProcessListCloudComponent', () => {
const initiatorChange = new SimpleChange(undefined, 'mock-initiator', true); const initiatorChange = new SimpleChange(undefined, 'mock-initiator', true);
component.ngOnChanges({ component.ngOnChanges({
'appName': appNameChange, appName: appNameChange,
'assignee': initiatorChange, assignee: initiatorChange,
'status': statusChange status: statusChange
}); });
fixture.detectChanges(); fixture.detectChanges();
expect(component.isListEmpty()).toBeFalsy(); expect(component.isListEmpty()).toBeFalsy();
@@ -285,7 +285,7 @@ describe('ProcessListCloudComponent', () => {
]; ];
const sortChange = new SimpleChange(undefined, mockSort, true); const sortChange = new SimpleChange(undefined, mockSort, true);
component.ngOnChanges({ component.ngOnChanges({
'sorting': sortChange sorting: sortChange
}); });
fixture.detectChanges(); fixture.detectChanges();
expect(component.formatSorting).toHaveBeenCalledWith(mockSort); expect(component.formatSorting).toHaveBeenCalledWith(mockSort);
@@ -26,6 +26,8 @@ import { processCloudPresetsDefaultModel } from '../models/process-cloud-preset.
import { ProcessQueryCloudRequestModel } from '../models/process-cloud-query-request.model'; import { ProcessQueryCloudRequestModel } from '../models/process-cloud-query-request.model';
import { ProcessListCloudSortingModel } from '../models/process-list-sorting.model'; import { ProcessListCloudSortingModel } from '../models/process-list-sorting.model';
const PRESET_KEY = 'adf-cloud-process-list.presets';
@Component({ @Component({
selector: 'adf-cloud-process-list', selector: 'adf-cloud-process-list',
templateUrl: './process-list-cloud.component.html', templateUrl: './process-list-cloud.component.html',
@@ -33,9 +35,6 @@ import { ProcessListCloudSortingModel } from '../models/process-list-sorting.mod
encapsulation: ViewEncapsulation.None encapsulation: ViewEncapsulation.None
}) })
export class ProcessListCloudComponent extends DataTableSchema implements OnChanges, AfterContentInit, PaginatedComponent { export class ProcessListCloudComponent extends DataTableSchema implements OnChanges, AfterContentInit, PaginatedComponent {
static PRESET_KEY = 'adf-cloud-process-list.presets';
@ViewChild(DataTableComponent) @ViewChild(DataTableComponent)
dataTable: DataTableComponent; dataTable: DataTableComponent;
@@ -198,12 +197,12 @@ export class ProcessListCloudComponent extends DataTableSchema implements OnChan
constructor(private processListCloudService: ProcessListCloudService, constructor(private processListCloudService: ProcessListCloudService,
appConfigService: AppConfigService, appConfigService: AppConfigService,
private userPreferences: UserPreferencesService) { private userPreferences: UserPreferencesService) {
super(appConfigService, ProcessListCloudComponent.PRESET_KEY, processCloudPresetsDefaultModel); super(appConfigService, PRESET_KEY, processCloudPresetsDefaultModel);
this.size = userPreferences.paginationSize; this.size = userPreferences.paginationSize;
this.userPreferences.select(UserPreferenceValues.PaginationSize).subscribe((pageSize) => { this.userPreferences.select(UserPreferenceValues.PaginationSize).subscribe((pageSize) => {
this.size = pageSize; this.size = pageSize;
}); });
this.pagination = new BehaviorSubject<PaginationModel>(<PaginationModel> { this.pagination = new BehaviorSubject<PaginationModel>({
maxItems: this.size, maxItems: this.size,
skipCount: 0, skipCount: 0,
totalItems: 0 totalItems: 0
@@ -282,6 +281,7 @@ export class ProcessListCloudComponent extends DataTableSchema implements OnChan
/** /**
* Resets the pagination values and * Resets the pagination values and
* Reloads the process list * Reloads the process list
*
* @param pagination Pagination values to be set * @param pagination Pagination values to be set
*/ */
updatePagination(pagination: PaginationModel) { updatePagination(pagination: PaginationModel) {
@@ -82,85 +82,85 @@ export const fakeProcessCloudList = {
} }
}; };
export let fakeCustomSchema = export const fakeCustomSchema =
[ [
new ObjectDataColumn({ new ObjectDataColumn({
'key': 'fakeName', key: 'fakeName',
'type': 'text', type: 'text',
'title': 'ADF_CLOUD_TASK_LIST.PROPERTIES.FAKE', title: 'ADF_CLOUD_TASK_LIST.PROPERTIES.FAKE',
'sortable': true sortable: true
}), }),
new ObjectDataColumn({ new ObjectDataColumn({
'key': 'fakeTaskName', key: 'fakeTaskName',
'type': 'text', type: 'text',
'title': 'ADF_CLOUD_TASK_LIST.PROPERTIES.TASK_FAKE', title: 'ADF_CLOUD_TASK_LIST.PROPERTIES.TASK_FAKE',
'sortable': true sortable: true
}) })
]; ];
export const processListSchemaMock = { export const processListSchemaMock = {
'presets': { presets: {
'default': [ default: [
{ {
'key': 'id', key: 'id',
'type': 'text', type: 'text',
'title': 'ADF_CLOUD_PROCESS_LIST.PROPERTIES.ID', title: 'ADF_CLOUD_PROCESS_LIST.PROPERTIES.ID',
'sortable': true sortable: true
}, },
{ {
'key': 'name', key: 'name',
'type': 'text', type: 'text',
'title': 'ADF_CLOUD_PROCESS_LIST.PROPERTIES.NAME', title: 'ADF_CLOUD_PROCESS_LIST.PROPERTIES.NAME',
'sortable': true sortable: true
}, },
{ {
'key': 'status', key: 'status',
'type': 'text', type: 'text',
'title': 'ADF_CLOUD_PROCESS_LIST.PROPERTIES.STATUS', title: 'ADF_CLOUD_PROCESS_LIST.PROPERTIES.STATUS',
'sortable': true sortable: true
}, },
{ {
'key': 'startDate', key: 'startDate',
'type': 'date', type: 'date',
'title': 'ADF_CLOUD_PROCESS_LIST.PROPERTIES.START_DATE', title: 'ADF_CLOUD_PROCESS_LIST.PROPERTIES.START_DATE',
'sortable': true, sortable: true,
'format': 'timeAgo' format: 'timeAgo'
}, },
{ {
'key': 'appName', key: 'appName',
'type': 'text', type: 'text',
'title': 'ADF_CLOUD_PROCESS_LIST.PROPERTIES.APP_NAME', title: 'ADF_CLOUD_PROCESS_LIST.PROPERTIES.APP_NAME',
'sortable': true sortable: true
}, },
{ {
'key': 'businessKey', key: 'businessKey',
'type': 'text', type: 'text',
'title': 'ADF_CLOUD_PROCESS_LIST.PROPERTIES.BUSINESS_KEY', title: 'ADF_CLOUD_PROCESS_LIST.PROPERTIES.BUSINESS_KEY',
'sortable': true sortable: true
}, },
{ {
'key': 'initiator', key: 'initiator',
'type': 'text', type: 'text',
'title': 'ADF_CLOUD_PROCESS_LIST.PROPERTIES.INITIATOR', title: 'ADF_CLOUD_PROCESS_LIST.PROPERTIES.INITIATOR',
'sortable': true sortable: true
}, },
{ {
'key': 'lastModified', key: 'lastModified',
'type': 'date', type: 'date',
'title': 'ADF_CLOUD_PROCESS_LIST.PROPERTIES.LAST_MODIFIED', title: 'ADF_CLOUD_PROCESS_LIST.PROPERTIES.LAST_MODIFIED',
'sortable': true sortable: true
}, },
{ {
'key': 'processDefinitionId', key: 'processDefinitionId',
'type': 'text', type: 'text',
'title': 'ADF_CLOUD_PROCESS_LIST.PROPERTIES.PROCESS_DEF_ID', title: 'ADF_CLOUD_PROCESS_LIST.PROPERTIES.PROCESS_DEF_ID',
'sortable': true sortable: true
}, },
{ {
'key': 'processDefinitionKey', key: 'processDefinitionKey',
'type': 'text', type: 'text',
'title': 'ADF_CLOUD_PROCESS_LIST.PROPERTIES.PROCESS_DEF_KEY', title: 'ADF_CLOUD_PROCESS_LIST.PROPERTIES.PROCESS_DEF_KEY',
'sortable': true sortable: true
} }
] ]
} }
@@ -15,21 +15,21 @@
* limitations under the License. * limitations under the License.
*/ */
export let processCloudPresetsDefaultModel = { export const processCloudPresetsDefaultModel = {
'default': [ default: [
{ {
'key': 'name', key: 'name',
'type': 'text', type: 'text',
'title': 'ADF_CLOUD_PROCESS_LIST.PROPERTIES.NAME', title: 'ADF_CLOUD_PROCESS_LIST.PROPERTIES.NAME',
'sortable': true sortable: true
}, },
{ {
'key': 'startDate', key: 'startDate',
'type': 'date', type: 'date',
'title': 'ADF_CLOUD_PROCESS_LIST.PROPERTIES.START_DATE', title: 'ADF_CLOUD_PROCESS_LIST.PROPERTIES.START_DATE',
'cssClass': 'hidden', cssClass: 'hidden',
'sortable': true, sortable: true,
'format': 'timeAgo' format: 'timeAgo'
} }
] ]
}; };
@@ -24,31 +24,19 @@ describe('ProcessListCloudService', () => {
let service: ProcessListCloudService; let service: ProcessListCloudService;
let alfrescoApiService: AlfrescoApiService; let alfrescoApiService: AlfrescoApiService;
function returnCallQueryParameters(): any { const returnCallQueryParameters = (): any => ({
return {
oauth2Auth: { oauth2Auth: {
callCustomApi: (_queryUrl, _operation, _context, queryParams) => { callCustomApi: (_queryUrl, _operation, _context, queryParams) => Promise.resolve(queryParams)
return Promise.resolve(queryParams);
}
}, },
isEcmLoggedIn() { isEcmLoggedIn: () => false
return false; });
}
};
}
function returnCallUrl(): any { const returnCallUrl = (): any => ({
return {
oauth2Auth: { oauth2Auth: {
callCustomApi: (queryUrl) => { callCustomApi: (queryUrl) => Promise.resolve(queryUrl)
return Promise.resolve(queryUrl);
}
}, },
isEcmLoggedIn() { isEcmLoggedIn: () => false
return false; });
}
};
}
setupTestBed({ setupTestBed({
imports: [ imports: [
@@ -33,6 +33,7 @@ export class ProcessListCloudService extends BaseCloudService {
/** /**
* Finds a process using an object with optional query properties. * Finds a process using an object with optional query properties.
*
* @param requestNode Query object * @param requestNode Query object
* @param queryUrl Query url * @param queryUrl Query url
* @returns Process information * @returns Process information
@@ -50,9 +51,7 @@ export class ProcessListCloudService extends BaseCloudService {
map((response: any) => { map((response: any) => {
const entries = response.list && response.list.entries; const entries = response.list && response.list.entries;
if (entries) { if (entries) {
response.list.entries = entries.map((entryData) => { response.list.entries = entries.map((entryData) => entryData.entry);
return entryData.entry;
});
} }
return response; return response;
}) })
@@ -40,6 +40,7 @@ export class ProcessCloudService extends BaseCloudService implements ProcessClou
/** /**
* Gets details of a process instance. * Gets details of a process instance.
*
* @param appName Name of the app * @param appName Name of the app
* @param processInstanceId ID of the process instance whose details you want * @param processInstanceId ID of the process instance whose details you want
* @returns Process instance details * @returns Process instance details
@@ -62,6 +63,7 @@ export class ProcessCloudService extends BaseCloudService implements ProcessClou
/** /**
* Gets the process definitions associated with an app. * Gets the process definitions associated with an app.
*
* @param appName Name of the target app * @param appName Name of the target app
* @returns Array of process definitions * @returns Array of process definitions
*/ */
@@ -70,9 +72,7 @@ export class ProcessCloudService extends BaseCloudService implements ProcessClou
const url = `${this.getBasePath(appName)}/rb/v1/process-definitions`; const url = `${this.getBasePath(appName)}/rb/v1/process-definitions`;
return this.get(url).pipe( return this.get(url).pipe(
map((res: any) => { map((res: any) => res.list.entries.map((processDefs) => new ProcessDefinitionCloud(processDefs.entry)))
return res.list.entries.map((processDefs) => new ProcessDefinitionCloud(processDefs.entry));
})
); );
} else { } else {
this.logService.error('AppName is mandatory for querying task'); this.logService.error('AppName is mandatory for querying task');
@@ -82,6 +82,7 @@ export class ProcessCloudService extends BaseCloudService implements ProcessClou
/** /**
* Gets the application versions associated with an app. * Gets the application versions associated with an app.
*
* @param appName Name of the target app * @param appName Name of the target app
* @returns Array of Application Version Models * @returns Array of Application Version Models
*/ */
@@ -90,9 +91,7 @@ export class ProcessCloudService extends BaseCloudService implements ProcessClou
const url = `${this.getBasePath(appName)}/query/v1/applications`; const url = `${this.getBasePath(appName)}/query/v1/applications`;
return this.get<any>(url).pipe( return this.get<any>(url).pipe(
map((appEntities: ApplicationVersionResponseModel) => { map((appEntities: ApplicationVersionResponseModel) => appEntities.list.entries),
return appEntities.list.entries;
}),
catchError((err) => this.handleError(err)) catchError((err) => this.handleError(err))
); );
} else { } else {
@@ -103,6 +102,7 @@ export class ProcessCloudService extends BaseCloudService implements ProcessClou
/** /**
* Cancels a process. * Cancels a process.
*
* @param appName Name of the app * @param appName Name of the app
* @param processInstanceId Id of the process to cancel * @param processInstanceId Id of the process to cancel
* @returns Operation Information * @returns Operation Information
@@ -72,11 +72,11 @@ describe('StartProcessCloudComponent', () => {
} }
}; };
function typeValueInto(selector: any, value: string) { const typeValueInto = (selector: any, value: string) => {
const inputElement = fixture.debugElement.query(By.css(`${selector}`)); const inputElement = fixture.debugElement.query(By.css(`${selector}`));
inputElement.nativeElement.value = value; inputElement.nativeElement.value = value;
inputElement.nativeElement.dispatchEvent(new Event('input')); inputElement.nativeElement.dispatchEvent(new Event('input'));
} };
setupTestBed({ setupTestBed({
imports: [ imports: [
@@ -120,7 +120,7 @@ describe('StartProcessCloudComponent', () => {
component.appName = 'myApp'; component.appName = 'myApp';
fixture.detectChanges(); fixture.detectChanges();
const change = new SimpleChange(null, 'MyApp', true); const change = new SimpleChange(null, 'MyApp', true);
component.ngOnChanges({ 'appName': change }); component.ngOnChanges({ appName: change });
fixture.detectChanges(); fixture.detectChanges();
}); });
@@ -131,7 +131,7 @@ describe('StartProcessCloudComponent', () => {
fixture.detectChanges(); fixture.detectChanges();
const change = new SimpleChange(null, 'MyApp', true); const change = new SimpleChange(null, 'MyApp', true);
component.ngOnChanges({ 'appName': change }); component.ngOnChanges({ appName: change });
fixture.detectChanges(); fixture.detectChanges();
tick(550); tick(550);
@@ -162,7 +162,7 @@ describe('StartProcessCloudComponent', () => {
const change = new SimpleChange(null, 'MyApp', false); const change = new SimpleChange(null, 'MyApp', false);
fixture.detectChanges(); fixture.detectChanges();
component.ngOnChanges({ 'appName': change }); component.ngOnChanges({ appName: change });
fixture.detectChanges(); fixture.detectChanges();
tick(); tick();
typeValueInto('#processName', 'OLE'); typeValueInto('#processName', 'OLE');
@@ -209,24 +209,24 @@ describe('StartProcessCloudComponent', () => {
beforeEach(() => { beforeEach(() => {
component.name = 'My new process with form'; component.name = 'My new process with form';
component.values = [{ component.values = [{
'id': '1', id: '1',
'type': 'string', type: 'string',
'name': 'firstName', name: 'firstName',
'value': 'FakeName', value: 'FakeName',
get 'hasValue'() { get hasValue() {
return this['value']; return this['value'];
}, },
set 'hasValue'(value) { set hasValue(value) {
this['value'] = value; this['value'] = value;
} }
}, { }, {
'id': '1', 'type': 'string', id: '1', type: 'string',
'name': 'lastName', name: 'lastName',
'value': 'FakeLastName', value: 'FakeLastName',
get 'hasValue'() { get hasValue() {
return this['value']; return this['value'];
}, },
set 'hasValue'(value) { set hasValue(value) {
this['value'] = value; this['value'] = value;
} }
}]; }];
@@ -239,7 +239,7 @@ describe('StartProcessCloudComponent', () => {
formDefinitionSpy = spyOn(formCloudService, 'getForm').and.returnValue(of(fakeStartForm)); formDefinitionSpy = spyOn(formCloudService, 'getForm').and.returnValue(of(fakeStartForm));
const change = new SimpleChange(null, 'MyApp', true); const change = new SimpleChange(null, 'MyApp', true);
component.ngOnChanges({ 'appName': change }); component.ngOnChanges({ appName: change });
fixture.detectChanges(); fixture.detectChanges();
tick(); tick();
typeValueInto('#processName', 'My new process with form'); typeValueInto('#processName', 'My new process with form');
@@ -265,7 +265,7 @@ describe('StartProcessCloudComponent', () => {
formDefinitionSpy = spyOn(formCloudService, 'getForm').and.returnValue(of(fakeStartFormNotValid)); formDefinitionSpy = spyOn(formCloudService, 'getForm').and.returnValue(of(fakeStartFormNotValid));
const change = new SimpleChange(null, 'MyApp', true); const change = new SimpleChange(null, 'MyApp', true);
component.ngOnChanges({ 'appName': change }); component.ngOnChanges({ appName: change });
fixture.detectChanges(); fixture.detectChanges();
tick(); tick();
@@ -293,7 +293,7 @@ describe('StartProcessCloudComponent', () => {
formDefinitionSpy = spyOn(formCloudService, 'getForm').and.returnValue(of(fakeStartForm)); formDefinitionSpy = spyOn(formCloudService, 'getForm').and.returnValue(of(fakeStartForm));
const change = new SimpleChange(null, 'MyApp', true); const change = new SimpleChange(null, 'MyApp', true);
component.ngOnChanges({ 'appName': change }); component.ngOnChanges({ appName: change });
fixture.detectChanges(); fixture.detectChanges();
tick(); tick();
@@ -323,7 +323,7 @@ describe('StartProcessCloudComponent', () => {
formDefinitionSpy = spyOn(formCloudService, 'getForm').and.returnValue(of(fakeStartFormNotValid)); formDefinitionSpy = spyOn(formCloudService, 'getForm').and.returnValue(of(fakeStartFormNotValid));
const change = new SimpleChange(null, 'MyApp', true); const change = new SimpleChange(null, 'MyApp', true);
component.ngOnChanges({ 'appName': change }); component.ngOnChanges({ appName: change });
fixture.detectChanges(); fixture.detectChanges();
tick(); tick();
@@ -355,7 +355,7 @@ describe('StartProcessCloudComponent', () => {
formDefinitionSpy = spyOn(formCloudService, 'getForm').and.returnValue(of(fakeStartForm)); formDefinitionSpy = spyOn(formCloudService, 'getForm').and.returnValue(of(fakeStartForm));
const change = new SimpleChange(null, 'MyApp', true); const change = new SimpleChange(null, 'MyApp', true);
component.ngOnChanges({ 'appName': change }); component.ngOnChanges({ appName: change });
fixture.detectChanges(); fixture.detectChanges();
tick(550); tick(550);
@@ -382,7 +382,7 @@ describe('StartProcessCloudComponent', () => {
formDefinitionSpy = spyOn(formCloudService, 'getForm').and.returnValue(of(fakeStartForm)); formDefinitionSpy = spyOn(formCloudService, 'getForm').and.returnValue(of(fakeStartForm));
const change = new SimpleChange(null, 'MyApp', true); const change = new SimpleChange(null, 'MyApp', true);
component.ngOnChanges({ 'appName': change }); component.ngOnChanges({ appName: change });
fixture.detectChanges(); fixture.detectChanges();
tick(550); tick(550);
@@ -401,7 +401,7 @@ describe('StartProcessCloudComponent', () => {
component.appName = 'myApp'; component.appName = 'myApp';
fixture.detectChanges(); fixture.detectChanges();
const change = new SimpleChange(null, 'MyApp', true); const change = new SimpleChange(null, 'MyApp', true);
component.ngOnChanges({ 'appName': change }); component.ngOnChanges({ appName: change });
fixture.detectChanges(); fixture.detectChanges();
}); });
@@ -853,11 +853,11 @@ describe('StartProcessCloudComponent', () => {
component.processDefinitionName = 'fake-name'; component.processDefinitionName = 'fake-name';
const change = new SimpleChange(null, 'MyApp', true); const change = new SimpleChange(null, 'MyApp', true);
component.ngOnChanges({ 'appName': change }); component.ngOnChanges({ appName: change });
}); });
it('should cancel bubbling a keydown event ()', () => { it('should cancel bubbling a keydown event ()', () => {
const escapeKeyboardEvent = new KeyboardEvent('keydown', { 'keyCode': ESCAPE } as any); const escapeKeyboardEvent = new KeyboardEvent('keydown', { keyCode: ESCAPE } as any);
fixture.debugElement.triggerEventHandler('keydown', escapeKeyboardEvent); fixture.debugElement.triggerEventHandler('keydown', escapeKeyboardEvent);
expect(escapeKeyboardEvent.cancelBubble).toBe(true); expect(escapeKeyboardEvent.cancelBubble).toBe(true);
@@ -31,6 +31,11 @@ import { ProcessDefinitionCloud } from '../../../models/process-definition-cloud
import { Subject, Observable } from 'rxjs'; import { Subject, Observable } from 'rxjs';
import { TaskVariableCloud } from '../../../form/models/task-variable-cloud.model'; import { TaskVariableCloud } from '../../../form/models/task-variable-cloud.model';
import { ProcessNameCloudPipe } from '../../../pipes/process-name-cloud.pipe'; import { ProcessNameCloudPipe } from '../../../pipes/process-name-cloud.pipe';
const MAX_NAME_LENGTH: number = 255;
const PROCESS_DEFINITION_DEBOUNCE: number = 300;
const PROCESS_FORM_DEBOUNCE: number = 400;
@Component({ @Component({
selector: 'adf-cloud-start-process', selector: 'adf-cloud-start-process',
templateUrl: './start-process-cloud.component.html', templateUrl: './start-process-cloud.component.html',
@@ -38,11 +43,6 @@ import { ProcessNameCloudPipe } from '../../../pipes/process-name-cloud.pipe';
encapsulation: ViewEncapsulation.None encapsulation: ViewEncapsulation.None
}) })
export class StartProcessCloudComponent implements OnChanges, OnInit, OnDestroy { export class StartProcessCloudComponent implements OnChanges, OnInit, OnDestroy {
static MAX_NAME_LENGTH: number = 255;
static PROCESS_DEFINITION_DEBOUNCE: number = 300;
static PROCESS_FORM_DEBOUNCE: number = 400;
@ViewChild(MatAutocompleteTrigger) @ViewChild(MatAutocompleteTrigger)
inputAutocomplete: MatAutocompleteTrigger; inputAutocomplete: MatAutocompleteTrigger;
@@ -52,7 +52,7 @@ export class StartProcessCloudComponent implements OnChanges, OnInit, OnDestroy
/** Maximum length of the process name. */ /** Maximum length of the process name. */
@Input() @Input()
maxNameLength: number = StartProcessCloudComponent.MAX_NAME_LENGTH; maxNameLength: number = MAX_NAME_LENGTH;
/** Name of the process. */ /** Name of the process. */
@Input() @Input()
@@ -121,15 +121,15 @@ export class StartProcessCloudComponent implements OnChanges, OnInit, OnDestroy
}); });
this.processDefinition.valueChanges this.processDefinition.valueChanges
.pipe(debounceTime(StartProcessCloudComponent.PROCESS_DEFINITION_DEBOUNCE)) .pipe(debounceTime(PROCESS_DEFINITION_DEBOUNCE))
.pipe(takeUntil(this.onDestroy$)) .pipe(takeUntil(this.onDestroy$))
.subscribe((processDefinitionName) => { .subscribe((processDefinitionName) => {
this.selectProcessDefinitionByProcesDefinitionName(processDefinitionName); this.selectProcessDefinitionByProcessDefinitionName(processDefinitionName);
}); });
this.processForm.valueChanges this.processForm.valueChanges
.pipe( .pipe(
debounceTime(StartProcessCloudComponent.PROCESS_FORM_DEBOUNCE), debounceTime(PROCESS_FORM_DEBOUNCE),
tap(() => this.disableStartButton = true), tap(() => this.disableStartButton = true),
distinctUntilChanged(), distinctUntilChanged(),
filter(() => this.isProcessSelectionValid()), filter(() => this.isProcessSelectionValid()),
@@ -170,8 +170,7 @@ export class StartProcessCloudComponent implements OnChanges, OnInit, OnDestroy
} }
private getMaxNameLength(): number { private getMaxNameLength(): number {
return this.maxNameLength > StartProcessCloudComponent.MAX_NAME_LENGTH ? return this.maxNameLength > MAX_NAME_LENGTH ? MAX_NAME_LENGTH : this.maxNameLength;
StartProcessCloudComponent.MAX_NAME_LENGTH : this.maxNameLength;
} }
private generateProcessInstance(): Observable<ProcessInstanceCloud> { private generateProcessInstance(): Observable<ProcessInstanceCloud> {
@@ -187,7 +186,7 @@ export class StartProcessCloudComponent implements OnChanges, OnInit, OnDestroy
} }
} }
private selectProcessDefinitionByProcesDefinitionName(processDefinitionName: string): void { private selectProcessDefinitionByProcessDefinitionName(processDefinitionName: string): void {
this.filteredProcesses = this.getProcessDefinitionListByNameOrKey(processDefinitionName); this.filteredProcesses = this.getProcessDefinitionListByNameOrKey(processDefinitionName);
if (this.isProcessFormValid() && if (this.isProcessFormValid() &&
@@ -205,9 +204,7 @@ export class StartProcessCloudComponent implements OnChanges, OnInit, OnDestroy
} }
private getProcessDefinitionListByNameOrKey(processDefinitionName: string): ProcessDefinitionCloud[] { private getProcessDefinitionListByNameOrKey(processDefinitionName: string): ProcessDefinitionCloud[] {
return this.processDefinitionList.filter((processDefinitionCloud) => { return this.processDefinitionList.filter((processDefinitionCloud) => !processDefinitionName || this.getProcessDefinition(processDefinitionCloud, processDefinitionName));
return !processDefinitionName || this.getProcessDefinition(processDefinitionCloud, processDefinitionName);
});
} }
private getProcessIfExists(processDefinition: string): ProcessDefinitionCloud { private getProcessIfExists(processDefinition: string): ProcessDefinitionCloud {
@@ -74,29 +74,25 @@ export const fakeProcessDefinitions: ProcessDefinitionCloud[] = [
}) })
]; ];
export function fakeSingleProcessDefinition(name: string): ProcessDefinitionCloud[] { export const fakeSingleProcessDefinition = (name: string): ProcessDefinitionCloud[] => [
return [
new ProcessDefinitionCloud({ new ProcessDefinitionCloud({
appName: 'startformwithoutupload', appName: 'startformwithoutupload',
formKey: 'form-a5d50817-5183-4850-802d-17af54b2632f', formKey: 'form-a5d50817-5183-4850-802d-17af54b2632f',
id: 'd00c0237-8772-11e9-859a-428f83d5904f', id: 'd00c0237-8772-11e9-859a-428f83d5904f',
key: 'process-5151ad1d-f992-4ee6-9742-3a04617469fe', key: 'process-5151ad1d-f992-4ee6-9742-3a04617469fe',
name: name name
}) })
]; ];
}
export function fakeSingleProcessDefinitionWithoutForm(name: string): ProcessDefinitionCloud[] { export const fakeSingleProcessDefinitionWithoutForm = (name: string): ProcessDefinitionCloud[] => [
return [
new ProcessDefinitionCloud({ new ProcessDefinitionCloud({
appName: 'startformwithoutupload', appName: 'startformwithoutupload',
formKey: '', formKey: '',
id: 'd00c0237-8772-11e9-859a-428f83d5904f', id: 'd00c0237-8772-11e9-859a-428f83d5904f',
key: 'process-5151ad1d-f992-4ee6-9742-3a04617469fe', key: 'process-5151ad1d-f992-4ee6-9742-3a04617469fe',
name: name name
}) })
]; ];
}
export const fakeNoNameProcessDefinitions: ProcessDefinitionCloud[] = [ export const fakeNoNameProcessDefinitions: ProcessDefinitionCloud[] = [
new ProcessDefinitionCloud({ new ProcessDefinitionCloud({
@@ -122,129 +118,129 @@ export const fakeProcessPayload = new ProcessPayloadCloud({
}); });
export const fakeStartForm = { export const fakeStartForm = {
'formRepresentation': { formRepresentation: {
'id': 'form-de8895be-d0d7-4434-beef-559b15305d72', id: 'form-de8895be-d0d7-4434-beef-559b15305d72',
'name': 'StartEventForm', name: 'StartEventForm',
'description': '', description: '',
'version': 0, version: 0,
'formDefinition': { formDefinition: {
'tabs': [], tabs: [],
'fields': [ fields: [
{ {
'type': 'container', type: 'container',
'id': '5a6b24c1-db2b-45e9-9aff-142395433d23', id: '5a6b24c1-db2b-45e9-9aff-142395433d23',
'name': 'Label', name: 'Label',
'tab': null, tab: null,
'fields': { fields: {
'1': [ 1: [
{ {
'type': 'text', type: 'text',
'id': 'firstName', id: 'firstName',
'name': 'firstName', name: 'firstName',
'colspan': 1, colspan: 1,
'params': { params: {
'existingColspan': 1, existingColspan: 1,
'maxColspan': 2 maxColspan: 2
}, },
'visibilityCondition': null, visibilityCondition: null,
'placeholder': null, placeholder: null,
'value': null, value: null,
'required': false, required: false,
'minLength': 0, minLength: 0,
'maxLength': 0, maxLength: 0,
'regexPattern': null regexPattern: null
} }
], ],
'2': [ 2: [
{ {
'type': 'text', type: 'text',
'id': 'lastName', id: 'lastName',
'name': 'lastName', name: 'lastName',
'colspan': 1, colspan: 1,
'params': { params: {
'existingColspan': 1, existingColspan: 1,
'maxColspan': 2 maxColspan: 2
}, },
'visibilityCondition': null, visibilityCondition: null,
'placeholder': null, placeholder: null,
'value': null, value: null,
'required': false, required: false,
'minLength': 0, minLength: 0,
'maxLength': 0, maxLength: 0,
'regexPattern': null regexPattern: null
} }
] ]
}, },
'numberOfColumns': 2 numberOfColumns: 2
} }
], ],
'outcomes': [], outcomes: [],
'metadata': {}, metadata: {},
'variables': [] variables: []
} }
} }
}; };
export const fakeStartFormNotValid = { export const fakeStartFormNotValid = {
'formRepresentation': { formRepresentation: {
'id': 'form-a5d50817-5183-4850-802d-17af54b2632f', id: 'form-a5d50817-5183-4850-802d-17af54b2632f',
'name': 'simpleform', name: 'simpleform',
'description': '', description: '',
'version': 0, version: 0,
'formDefinition': { formDefinition: {
'tabs': [], tabs: [],
'fields': [ fields: [
{ {
'type': 'container', type: 'container',
'id': '5a6b24c1-db2b-45e9-9aff-142395433d23', id: '5a6b24c1-db2b-45e9-9aff-142395433d23',
'name': 'Label', name: 'Label',
'tab': null, tab: null,
'fields': { fields: {
'1': [ 1: [
{ {
'type': 'text', type: 'text',
'id': 'firstName', id: 'firstName',
'name': 'firstName', name: 'firstName',
'colspan': 1, colspan: 1,
'params': { params: {
'existingColspan': 1, existingColspan: 1,
'maxColspan': 2 maxColspan: 2
}, },
'visibilityCondition': null, visibilityCondition: null,
'placeholder': null, placeholder: null,
'value': null, value: null,
'required': true, required: true,
'minLength': 15, minLength: 15,
'maxLength': 0, maxLength: 0,
'regexPattern': null regexPattern: null
} }
], ],
'2': [ 2: [
{ {
'type': 'text', type: 'text',
'id': 'lastName', id: 'lastName',
'name': 'lastName', name: 'lastName',
'colspan': 1, colspan: 1,
'params': { params: {
'existingColspan': 1, existingColspan: 1,
'maxColspan': 2 maxColspan: 2
}, },
'visibilityCondition': null, visibilityCondition: null,
'placeholder': null, placeholder: null,
'value': null, value: null,
'required': false, required: false,
'minLength': 0, minLength: 0,
'maxLength': 0, maxLength: 0,
'regexPattern': null regexPattern: null
} }
] ]
}, },
'numberOfColumns': 2 numberOfColumns: 2
} }
], ],
'outcomes': [], outcomes: [],
'metadata': {}, metadata: {},
'variables': [] variables: []
} }
} }
}; };
@@ -38,9 +38,7 @@ describe('StartProcessCloudService', () => {
} }
}) })
}, },
isEcmLoggedIn() { isEcmLoggedIn: () => false
return false;
}
}; };
setupTestBed({ setupTestBed({
@@ -37,6 +37,7 @@ export class StartProcessCloudService extends BaseCloudService {
/** /**
* Gets the process definitions associated with an app. * Gets the process definitions associated with an app.
*
* @param appName Name of the target app * @param appName Name of the target app
* @returns Array of process definitions * @returns Array of process definitions
*/ */
@@ -45,9 +46,7 @@ export class StartProcessCloudService extends BaseCloudService {
const url = `${this.getBasePath(appName)}/rb/v1/process-definitions`; const url = `${this.getBasePath(appName)}/rb/v1/process-definitions`;
return this.get(url).pipe( return this.get(url).pipe(
map((res: any) => { map((res: any) => res.list.entries.map((processDefs) => new ProcessDefinitionCloud(processDefs.entry)))
return res.list.entries.map((processDefs) => new ProcessDefinitionCloud(processDefs.entry));
})
); );
} else { } else {
this.logService.error('AppName is mandatory for querying task'); this.logService.error('AppName is mandatory for querying task');
@@ -57,6 +56,7 @@ export class StartProcessCloudService extends BaseCloudService {
/** /**
* Create a process based on a process definition, name, form values or variables. * Create a process based on a process definition, name, form values or variables.
*
* @param appName name of the Application * @param appName name of the Application
* @param payload Details of the process (definition key, name, variables, etc) * @param payload Details of the process (definition key, name, variables, etc)
* @returns Details of the process instance just created * @returns Details of the process instance just created
@@ -72,6 +72,7 @@ export class StartProcessCloudService extends BaseCloudService {
/** /**
* Starts an already created process using the process instance id. * Starts an already created process using the process instance id.
*
* @param createdProcessInstanceId process instance id of the process previously created * @param createdProcessInstanceId process instance id of the process previously created
* @returns Details of the process instance just started * @returns Details of the process instance just started
*/ */
@@ -85,6 +86,7 @@ export class StartProcessCloudService extends BaseCloudService {
/** /**
* Starts a process based on a process definition, name, form values or variables. * Starts a process based on a process definition, name, form values or variables.
*
* @param appName name of the Application * @param appName name of the Application
* @param payload Details of the process (definition key, name, variables, etc) * @param payload Details of the process (definition key, name, variables, etc)
* @returns Details of the process instance just started * @returns Details of the process instance just started
@@ -98,6 +100,7 @@ export class StartProcessCloudService extends BaseCloudService {
/** /**
* Update an existing process instance * Update an existing process instance
*
* @param appName name of the Application * @param appName name of the Application
* @param processInstanceId process instance to update * @param processInstanceId process instance to update
* @param payload Details of the process (definition key, name, variables, etc) * @param payload Details of the process (definition key, name, variables, etc)
@@ -114,6 +117,7 @@ export class StartProcessCloudService extends BaseCloudService {
/** /**
* Delete an existing process instance * Delete an existing process instance
*
* @param appName name of the Application * @param appName name of the Application
* @param processInstanceId process instance to update * @param processInstanceId process instance to update
*/ */
@@ -200,6 +200,7 @@ export interface TextField extends FormField {
placeholder: string | null; placeholder: string | null;
} }
// eslint-disable-next-line no-shadow
export enum PeopleModeOptions { export enum PeopleModeOptions {
single = 'single', single = 'single',
multiple = 'multiple' multiple = 'multiple'
@@ -210,6 +211,7 @@ export interface PeopleField extends FormField {
optionType: PeopleModeOptions; optionType: PeopleModeOptions;
} }
// eslint-disable-next-line no-shadow
export enum FormFieldType { export enum FormFieldType {
text = 'text', text = 'text',
multiline = 'multi-line-text', multiline = 'multi-line-text',
@@ -27,6 +27,7 @@ export class LocalPreferenceCloudService implements PreferenceCloudServiceInterf
/** /**
* Gets local preferences * Gets local preferences
*
* @param _ Name of the target app * @param _ Name of the target app
* @param key Key of the target preference * @param key Key of the target preference
* @returns List of local preferences * @returns List of local preferences
@@ -37,8 +38,8 @@ export class LocalPreferenceCloudService implements PreferenceCloudServiceInterf
} }
return of( return of(
{ {
'list': { list: {
'entries': [] entries: []
} }
} }
); );
@@ -46,6 +47,7 @@ export class LocalPreferenceCloudService implements PreferenceCloudServiceInterf
/** /**
* Gets local preference. * Gets local preference.
*
* @param _ Name of the target app * @param _ Name of the target app
* @param key Key of the target preference * @param key Key of the target preference
* @returns Observable of local preference * @returns Observable of local preference
@@ -56,6 +58,7 @@ export class LocalPreferenceCloudService implements PreferenceCloudServiceInterf
/** /**
* Creates local preference. * Creates local preference.
*
* @param _ Name of the target app * @param _ Name of the target app
* @param key Key of the target preference * @param key Key of the target preference
* @param newPreference Details of new local preference * @param newPreference Details of new local preference
@@ -70,6 +73,7 @@ export class LocalPreferenceCloudService implements PreferenceCloudServiceInterf
/** /**
* Updates local preference. * Updates local preference.
*
* @param _ Name of the target app * @param _ Name of the target app
* @param key Key of the target preference * @param key Key of the target preference
* @param updatedPreference Details of updated preference * @param updatedPreference Details of updated preference
@@ -84,6 +88,7 @@ export class LocalPreferenceCloudService implements PreferenceCloudServiceInterf
/** /**
* Deletes local preference by given preference key. * Deletes local preference by given preference key.
*
* @param key Key of the target preference * @param key Key of the target preference
* @param preferences Details of updated preferences * @param preferences Details of updated preferences
* @returns Observable of preferences without deleted preference * @returns Observable of preferences without deleted preference
@@ -97,12 +102,12 @@ export class LocalPreferenceCloudService implements PreferenceCloudServiceInterf
prepareLocalPreferenceResponse(key: string): any { prepareLocalPreferenceResponse(key: string): any {
return { return {
'list': { list: {
'entries': [ entries: [
{ {
'entry': { entry: {
'key': key, key,
'value': this.storage.getItem(key) || '[]' value: this.storage.getItem(key) || '[]'
} }
} }
] ]
@@ -29,7 +29,7 @@ describe('NotificationCloudService', () => {
let apolloSubscribeSpy: jasmine.Spy; let apolloSubscribeSpy: jasmine.Spy;
let apiService: AlfrescoApiService; let apiService: AlfrescoApiService;
const useMock: any = { const useMock: any = {
subscribe() {} subscribe: () => {}
}; };
const queryMock = ` const queryMock = `
@@ -47,9 +47,7 @@ describe('NotificationCloudService', () => {
oauth2Auth: { oauth2Auth: {
token: '1234567' token: '1234567'
}, },
isEcmLoggedIn() { isEcmLoggedIn: () => false,
return false;
},
reply: jasmine.createSpy('reply') reply: jasmine.createSpy('reply')
}; };
@@ -61,6 +61,7 @@ export class NotificationCloudService extends BaseCloudService {
lazy: true, lazy: true,
connectionParams: { connectionParams: {
kaInterval: 2000, kaInterval: 2000,
// eslint-disable-next-line @typescript-eslint/naming-convention
'X-Authorization': 'Bearer ' + this.apiService.getInstance().oauth2Auth.token 'X-Authorization': 'Bearer ' + this.apiService.getInstance().oauth2Auth.token
} }
} }
@@ -84,6 +85,7 @@ export class NotificationCloudService extends BaseCloudService {
operation.setContext({ operation.setContext({
headers: { headers: {
...oldHeaders, ...oldHeaders,
// eslint-disable-next-line @typescript-eslint/naming-convention
'X-Authorization': 'Bearer ' + this.apiService.getInstance().oauth2Auth.token 'X-Authorization': 'Bearer ' + this.apiService.getInstance().oauth2Auth.token
} }
}); });
@@ -32,27 +32,19 @@ describe('PreferenceService', () => {
state: 404, stateText: 'Not Found' state: 404, stateText: 'Not Found'
}; };
function apiMock(mockResponse): any { const apiMock = (mockResponse): any => ({
return {
oauth2Auth: { oauth2Auth: {
callCustomApi: () => { callCustomApi: () => Promise.resolve(mockResponse)
return Promise.resolve(mockResponse);
}
},
isEcmLoggedIn() {
return false;
}, },
isEcmLoggedIn: () => false,
reply: jasmine.createSpy('reply') reply: jasmine.createSpy('reply')
}; });
}
const apiErrorMock: any = { const apiErrorMock: any = {
oauth2Auth: { oauth2Auth: {
callCustomApi: () => Promise.reject(errorResponse) callCustomApi: () => Promise.reject(errorResponse)
}, },
isEcmLoggedIn() { isEcmLoggedIn:() => false
return false;
}
}; };
setupTestBed({ setupTestBed({
@@ -33,6 +33,7 @@ export class UserPreferenceCloudService extends BaseCloudService implements Pref
/** /**
* Gets user preferences * Gets user preferences
*
* @param appName Name of the target app * @param appName Name of the target app
* @returns List of user preferences * @returns List of user preferences
*/ */
@@ -48,6 +49,7 @@ export class UserPreferenceCloudService extends BaseCloudService implements Pref
/** /**
* Gets user preference. * Gets user preference.
*
* @param appName Name of the target app * @param appName Name of the target app
* @param key Key of the target preference * @param key Key of the target preference
* @returns Observable of user preference * @returns Observable of user preference
@@ -64,6 +66,7 @@ export class UserPreferenceCloudService extends BaseCloudService implements Pref
/** /**
* Creates user preference. * Creates user preference.
*
* @param appName Name of the target app * @param appName Name of the target app
* @param key Key of the target preference * @param key Key of the target preference
* @newPreference Details of new user preference * @newPreference Details of new user preference
@@ -83,6 +86,7 @@ export class UserPreferenceCloudService extends BaseCloudService implements Pref
/** /**
* Updates user preference. * Updates user preference.
*
* @param appName Name of the target app * @param appName Name of the target app
* @param key Key of the target preference * @param key Key of the target preference
* @param updatedPreference Details of updated preference * @param updatedPreference Details of updated preference
@@ -94,6 +98,7 @@ export class UserPreferenceCloudService extends BaseCloudService implements Pref
/** /**
* Deletes user preference by given preference key. * Deletes user preference by given preference key.
*
* @param appName Name of the target app * @param appName Name of the target app
* @param key Key of the target preference * @param key Key of the target preference
* @returns Observable of delete operation status * @returns Observable of delete operation status
@@ -113,7 +113,7 @@ describe('Claim Task Directive validation errors', () => {
selector: 'adf-cloud-claim-undefined-appname-component', selector: 'adf-cloud-claim-undefined-appname-component',
template: '<button adf-cloud-claim-task [taskId]="taskMock" [appName]="appNameUndefined"></button>' template: '<button adf-cloud-claim-task [taskId]="taskMock" [appName]="appNameUndefined"></button>'
}) })
class ClaimTestInvalidAppNameUndefineddDirectiveComponent { class ClaimTestInvalidAppNameUndefinedDirectiveComponent {
appNameUndefined = undefined; appNameUndefined = undefined;
taskMock = 'test1234'; taskMock = 'test1234';
@@ -126,7 +126,7 @@ describe('Claim Task Directive validation errors', () => {
selector: 'adf-cloud-claim-null-appname-component', selector: 'adf-cloud-claim-null-appname-component',
template: '<button adf-cloud-claim-task [taskId]="taskMock" [appName]="appNameNull"></button>' template: '<button adf-cloud-claim-task [taskId]="taskMock" [appName]="appNameNull"></button>'
}) })
class ClaimTestInvalidAppNameNulldDirectiveComponent { class ClaimTestInvalidAppNameNullDirectiveComponent {
appNameNull = null; appNameNull = null;
taskMock = 'test1234'; taskMock = 'test1234';
@@ -144,8 +144,8 @@ describe('Claim Task Directive validation errors', () => {
], ],
declarations: [ declarations: [
ClaimTestMissingTaskIdDirectiveComponent, ClaimTestMissingTaskIdDirectiveComponent,
ClaimTestInvalidAppNameUndefineddDirectiveComponent, ClaimTestInvalidAppNameUndefinedDirectiveComponent,
ClaimTestInvalidAppNameNulldDirectiveComponent, ClaimTestInvalidAppNameNullDirectiveComponent,
ClaimTestMissingInputDirectiveComponent ClaimTestMissingInputDirectiveComponent
] ]
}); });
@@ -165,12 +165,12 @@ describe('Claim Task Directive validation errors', () => {
}); });
it('should throw error when appName is undefined', () => { it('should throw error when appName is undefined', () => {
fixture = TestBed.createComponent(ClaimTestInvalidAppNameUndefineddDirectiveComponent); fixture = TestBed.createComponent(ClaimTestInvalidAppNameUndefinedDirectiveComponent);
expect( () => fixture.detectChanges()).toThrowError('Attribute appName is required'); expect( () => fixture.detectChanges()).toThrowError('Attribute appName is required');
}); });
it('should throw error when appName is null', () => { it('should throw error when appName is null', () => {
fixture = TestBed.createComponent(ClaimTestInvalidAppNameUndefineddDirectiveComponent); fixture = TestBed.createComponent(ClaimTestInvalidAppNameUndefinedDirectiveComponent);
expect( () => fixture.detectChanges()).toThrowError('Attribute appName is required'); expect( () => fixture.detectChanges()).toThrowError('Attribute appName is required');
}); });
}); });
@@ -125,7 +125,7 @@ describe('Complete Task Directive validation errors', () => {
selector: 'adf-cloud-undefined-appname-component', selector: 'adf-cloud-undefined-appname-component',
template: '<button adf-cloud-complete-task [taskId]="taskMock" [appName]="appNameUndefined" (success)="onCompleteTask($event)"></button>' template: '<button adf-cloud-complete-task [taskId]="taskMock" [appName]="appNameUndefined" (success)="onCompleteTask($event)"></button>'
}) })
class TestInvalidAppNameUndefineddDirectiveComponent { class TestInvalidAppNameUndefinedDirectiveComponent {
appName = 'simple-app'; appName = 'simple-app';
taskMock = 'test1234'; taskMock = 'test1234';
@@ -142,7 +142,7 @@ describe('Complete Task Directive validation errors', () => {
selector: 'adf-cloud-null-appname-component', selector: 'adf-cloud-null-appname-component',
template: '<button adf-cloud-complete-task [taskId]="taskMock" [appName]="appNameNull" (success)="onCompleteTask($event)"></button>' template: '<button adf-cloud-complete-task [taskId]="taskMock" [appName]="appNameNull" (success)="onCompleteTask($event)"></button>'
}) })
class TestInvalidAppNameNulldDirectiveComponent { class TestInvalidAppNameNullDirectiveComponent {
appName = 'simple-app'; appName = 'simple-app';
taskMock = 'test1234'; taskMock = 'test1234';
@@ -164,8 +164,8 @@ describe('Complete Task Directive validation errors', () => {
], ],
declarations: [ declarations: [
TestMissingTaskIdDirectiveComponent, TestMissingTaskIdDirectiveComponent,
TestInvalidAppNameUndefineddDirectiveComponent, TestInvalidAppNameUndefinedDirectiveComponent,
TestInvalidAppNameNulldDirectiveComponent, TestInvalidAppNameNullDirectiveComponent,
TestMissingInputDirectiveComponent TestMissingInputDirectiveComponent
] ]
}); });
@@ -184,12 +184,12 @@ describe('Complete Task Directive validation errors', () => {
}); });
it('should throw error when appName is undefined', () => { it('should throw error when appName is undefined', () => {
fixture = TestBed.createComponent(TestInvalidAppNameUndefineddDirectiveComponent); fixture = TestBed.createComponent(TestInvalidAppNameUndefinedDirectiveComponent);
expect( () => fixture.detectChanges()).toThrowError('Attribute appName is required'); expect( () => fixture.detectChanges()).toThrowError('Attribute appName is required');
}); });
it('should throw error when appName is null', () => { it('should throw error when appName is null', () => {
fixture = TestBed.createComponent(TestInvalidAppNameUndefineddDirectiveComponent); fixture = TestBed.createComponent(TestInvalidAppNameUndefinedDirectiveComponent);
expect( () => fixture.detectChanges()).toThrowError('Attribute appName is required'); expect( () => fixture.detectChanges()).toThrowError('Attribute appName is required');
}); });
}); });
@@ -113,7 +113,7 @@ describe('UnClaim Task Directive validation errors', () => {
selector: 'adf-cloud-claim-undefined-appname-component', selector: 'adf-cloud-claim-undefined-appname-component',
template: '<button adf-cloud-unclaim-task [taskId]="taskMock" [appName]="appNameUndefined"></button>' template: '<button adf-cloud-unclaim-task [taskId]="taskMock" [appName]="appNameUndefined"></button>'
}) })
class ClaimTestInvalidAppNameUndefineddDirectiveComponent { class ClaimTestInvalidAppNameUndefinedDirectiveComponent {
appNameUndefined = undefined; appNameUndefined = undefined;
taskMock = 'test1234'; taskMock = 'test1234';
@@ -126,7 +126,7 @@ describe('UnClaim Task Directive validation errors', () => {
selector: 'adf-cloud-claim-null-appname-component', selector: 'adf-cloud-claim-null-appname-component',
template: '<button adf-cloud-unclaim-task [taskId]="taskMock" [appName]="appNameNull"></button>' template: '<button adf-cloud-unclaim-task [taskId]="taskMock" [appName]="appNameNull"></button>'
}) })
class ClaimTestInvalidAppNameNulldDirectiveComponent { class ClaimTestInvalidAppNameNullDirectiveComponent {
appNameNull = null; appNameNull = null;
taskMock = 'test1234'; taskMock = 'test1234';
@@ -144,8 +144,8 @@ describe('UnClaim Task Directive validation errors', () => {
], ],
declarations: [ declarations: [
ClaimTestMissingTaskIdDirectiveComponent, ClaimTestMissingTaskIdDirectiveComponent,
ClaimTestInvalidAppNameUndefineddDirectiveComponent, ClaimTestInvalidAppNameUndefinedDirectiveComponent,
ClaimTestInvalidAppNameNulldDirectiveComponent, ClaimTestInvalidAppNameNullDirectiveComponent,
ClaimTestMissingInputDirectiveComponent ClaimTestMissingInputDirectiveComponent
] ]
}); });
@@ -165,12 +165,12 @@ describe('UnClaim Task Directive validation errors', () => {
}); });
it('should throw error when appName is undefined', () => { it('should throw error when appName is undefined', () => {
fixture = TestBed.createComponent(ClaimTestInvalidAppNameUndefineddDirectiveComponent); fixture = TestBed.createComponent(ClaimTestInvalidAppNameUndefinedDirectiveComponent);
expect( () => fixture.detectChanges()).toThrowError('Attribute appName is required'); expect( () => fixture.detectChanges()).toThrowError('Attribute appName is required');
}); });
it('should throw error when appName is null', () => { it('should throw error when appName is null', () => {
fixture = TestBed.createComponent(ClaimTestInvalidAppNameUndefineddDirectiveComponent); fixture = TestBed.createComponent(ClaimTestInvalidAppNameUndefinedDirectiveComponent);
expect( () => fixture.detectChanges()).toThrowError('Attribute appName is required'); expect( () => fixture.detectChanges()).toThrowError('Attribute appName is required');
}); });
}); });
@@ -15,6 +15,7 @@
* limitations under the License. * limitations under the License.
*/ */
// eslint-disable-next-line no-shadow
export enum ClaimTaskEnum { export enum ClaimTaskEnum {
claim = 'claim', claim = 'claim',
unclaim = 'unclaim' unclaim = 'unclaim'
@@ -32,75 +32,45 @@ describe('Task Cloud Service', () => {
let identityUserService: IdentityUserService; let identityUserService: IdentityUserService;
let translateService: TranslationService; let translateService: TranslationService;
function returnFakeTaskCompleteResults(): any { const returnFakeTaskCompleteResults = (): any => ({
return {
reply: () => {}, reply: () => {},
oauth2Auth: { oauth2Auth: {
callCustomApi : () => { callCustomApi : () => Promise.resolve(taskCompleteCloudMock)
return Promise.resolve(taskCompleteCloudMock);
}
}, },
isEcmLoggedIn() { isEcmLoggedIn: () => false
return false; });
}
};
}
function returnFakeTaskCompleteResultsError(): any { const returnFakeTaskCompleteResultsError = (): any => ({
return {
reply: () => {}, reply: () => {},
oauth2Auth: { oauth2Auth: {
callCustomApi : () => { callCustomApi : () => Promise.reject(taskCompleteCloudMock)
return Promise.reject(taskCompleteCloudMock);
}
}, },
isEcmLoggedIn() { isEcmLoggedIn: () => false
return false; });
}
};
}
function returnFakeTaskDetailsResults(): any { const returnFakeTaskDetailsResults = (): any => ({
return {
reply: () => {}, reply: () => {},
oauth2Auth: { oauth2Auth: {
callCustomApi : () => { callCustomApi : () => Promise.resolve(fakeTaskDetailsCloud)
return Promise.resolve(fakeTaskDetailsCloud);
}
}, },
isEcmLoggedIn() { isEcmLoggedIn: () => false
return false; });
}
};
}
function returnFakeCandidateUsersResults(): any { const returnFakeCandidateUsersResults = (): any => ({
return {
reply: () => {}, reply: () => {},
oauth2Auth: { oauth2Auth: {
callCustomApi : () => { callCustomApi : () => Promise.resolve(['mockuser1', 'mockuser2', 'mockuser3'])
return Promise.resolve(['mockuser1', 'mockuser2', 'mockuser3']);
}
}, },
isEcmLoggedIn() { isEcmLoggedIn: () => false
return false; });
}
};
}
function returnFakeCandidateGroupResults(): any { const returnFakeCandidateGroupResults = (): any => ({
return {
reply: () => {}, reply: () => {},
oauth2Auth: { oauth2Auth: {
callCustomApi : () => { callCustomApi : () => Promise.resolve(['mockgroup1', 'mockgroup2', 'mockgroup3'])
return Promise.resolve(['mockgroup1', 'mockgroup2', 'mockgroup3']);
}
}, },
isEcmLoggedIn() { isEcmLoggedIn: () => false
return false; });
}
};
}
setupTestBed({ setupTestBed({
imports: [ imports: [
@@ -45,6 +45,7 @@ export class TaskCloudService extends BaseCloudService implements TaskCloudServi
/** /**
* Complete a task. * Complete a task.
*
* @param appName Name of the app * @param appName Name of the app
* @param taskId ID of the task to complete * @param taskId ID of the task to complete
* @returns Details of the task that was completed * @returns Details of the task that was completed
@@ -52,7 +53,7 @@ export class TaskCloudService extends BaseCloudService implements TaskCloudServi
completeTask(appName: string, taskId: string): Observable<TaskDetailsCloudModel> { completeTask(appName: string, taskId: string): Observable<TaskDetailsCloudModel> {
if ((appName || appName === '') && taskId) { if ((appName || appName === '') && taskId) {
const url = `${this.getBasePath(appName)}/rb/v1/tasks/${taskId}/complete`; const url = `${this.getBasePath(appName)}/rb/v1/tasks/${taskId}/complete`;
const payload = { 'payloadType': 'CompleteTaskPayload' }; const payload = { payloadType: 'CompleteTaskPayload' };
return this.post<any, TaskDetailsCloudModel>(url, payload); return this.post<any, TaskDetailsCloudModel>(url, payload);
} else { } else {
@@ -63,6 +64,7 @@ export class TaskCloudService extends BaseCloudService implements TaskCloudServi
/** /**
* Validate if a task can be completed. * Validate if a task can be completed.
*
* @param taskDetails task details object * @param taskDetails task details object
* @returns Boolean value if the task can be completed * @returns Boolean value if the task can be completed
*/ */
@@ -72,6 +74,7 @@ export class TaskCloudService extends BaseCloudService implements TaskCloudServi
/** /**
* Validate if a task is editable. * Validate if a task is editable.
*
* @param taskDetails task details object * @param taskDetails task details object
* @returns Boolean value if the task is editable * @returns Boolean value if the task is editable
*/ */
@@ -90,6 +93,7 @@ export class TaskCloudService extends BaseCloudService implements TaskCloudServi
/** /**
* Validate if a task can be claimed. * Validate if a task can be claimed.
*
* @param taskDetails task details object * @param taskDetails task details object
* @returns Boolean value if the task can be completed * @returns Boolean value if the task can be completed
*/ */
@@ -99,6 +103,7 @@ export class TaskCloudService extends BaseCloudService implements TaskCloudServi
/** /**
* Validate if a task can be unclaimed. * Validate if a task can be unclaimed.
*
* @param taskDetails task details object * @param taskDetails task details object
* @returns Boolean value if the task can be completed * @returns Boolean value if the task can be completed
*/ */
@@ -109,6 +114,7 @@ export class TaskCloudService extends BaseCloudService implements TaskCloudServi
/** /**
* Claims a task for an assignee. * Claims a task for an assignee.
*
* @param appName Name of the app * @param appName Name of the app
* @param taskId ID of the task to claim * @param taskId ID of the task to claim
* @param assignee User to assign the task to * @param assignee User to assign the task to
@@ -132,6 +138,7 @@ export class TaskCloudService extends BaseCloudService implements TaskCloudServi
/** /**
* Un-claims a task. * Un-claims a task.
*
* @param appName Name of the app * @param appName Name of the app
* @param taskId ID of the task to unclaim * @param taskId ID of the task to unclaim
* @returns Details of the task that was unclaimed * @returns Details of the task that was unclaimed
@@ -154,6 +161,7 @@ export class TaskCloudService extends BaseCloudService implements TaskCloudServi
/** /**
* Gets details of a task. * Gets details of a task.
*
* @param appName Name of the app * @param appName Name of the app
* @param taskId ID of the task whose details you want * @param taskId ID of the task whose details you want
* @returns Task details * @returns Task details
@@ -173,6 +181,7 @@ export class TaskCloudService extends BaseCloudService implements TaskCloudServi
/** /**
* Creates a new standalone task. * Creates a new standalone task.
*
* @param taskDetails Details of the task to create * @param taskDetails Details of the task to create
* @returns Details of the newly created task * @returns Details of the newly created task
*/ */
@@ -188,6 +197,7 @@ export class TaskCloudService extends BaseCloudService implements TaskCloudServi
/** /**
* Updates the details (name, description, due date) for a task. * Updates the details (name, description, due date) for a task.
*
* @param appName Name of the app * @param appName Name of the app
* @param taskId ID of the task to update * @param taskId ID of the task to update
* @param payload Data to update the task * @param payload Data to update the task
@@ -209,6 +219,7 @@ export class TaskCloudService extends BaseCloudService implements TaskCloudServi
/** /**
* Gets candidate users of the task. * Gets candidate users of the task.
*
* @param appName Name of the app * @param appName Name of the app
* @param taskId ID of the task * @param taskId ID of the task
* @returns Candidate users * @returns Candidate users
@@ -225,6 +236,7 @@ export class TaskCloudService extends BaseCloudService implements TaskCloudServi
/** /**
* Gets candidate groups of the task. * Gets candidate groups of the task.
*
* @param appName Name of the app * @param appName Name of the app
* @param taskId ID of the task * @param taskId ID of the task
* @returns Candidate groups * @returns Candidate groups
@@ -241,6 +253,7 @@ export class TaskCloudService extends BaseCloudService implements TaskCloudServi
/** /**
* Gets the process definitions associated with an app. * Gets the process definitions associated with an app.
*
* @param appName Name of the target app * @param appName Name of the target app
* @returns Array of process definitions * @returns Array of process definitions
*/ */
@@ -249,9 +262,7 @@ export class TaskCloudService extends BaseCloudService implements TaskCloudServi
const url = `${this.getBasePath(appName)}/rb/v1/process-definitions`; const url = `${this.getBasePath(appName)}/rb/v1/process-definitions`;
return this.get(url).pipe( return this.get(url).pipe(
map((res: any) => { map((res: any) => res.list.entries.map((processDefs) => new ProcessDefinitionCloud(processDefs.entry)))
return res.list.entries.map((processDefs) => new ProcessDefinitionCloud(processDefs.entry));
})
); );
} else { } else {
this.logService.error('AppName is mandatory for querying task'); this.logService.error('AppName is mandatory for querying task');
@@ -261,6 +272,7 @@ export class TaskCloudService extends BaseCloudService implements TaskCloudServi
/** /**
* Updates the task assignee. * Updates the task assignee.
*
* @param appName Name of the app * @param appName Name of the app
* @param taskId ID of the task to update assignee * @param taskId ID of the task to update assignee
* @param assignee assignee to update current user task assignee * @param assignee assignee to update current user task assignee
@@ -268,13 +280,11 @@ export class TaskCloudService extends BaseCloudService implements TaskCloudServi
*/ */
assign(appName: string, taskId: string, assignee: string): Observable<TaskDetailsCloudModel> { assign(appName: string, taskId: string, assignee: string): Observable<TaskDetailsCloudModel> {
if (appName && taskId) { if (appName && taskId) {
const payLoad = { 'assignee': assignee, 'taskId': taskId, 'payloadType': 'AssignTaskPayload' }; const payLoad = { assignee, taskId, payloadType: 'AssignTaskPayload' };
const url = `${this.getBasePath(appName)}/rb/v1/tasks/${taskId}/assign`; const url = `${this.getBasePath(appName)}/rb/v1/tasks/${taskId}/assign`;
return this.post(url, payLoad).pipe( return this.post(url, payLoad).pipe(
map((res: any) => { map((res: any) => res.entry)
return res.entry;
})
); );
} else { } else {
this.logService.error('AppName and TaskId are mandatory to change/update the task assignee'); this.logService.error('AppName and TaskId are mandatory to change/update the task assignee');
@@ -42,9 +42,7 @@ describe('StartTaskCloudComponent', () => {
oauth2Auth: { oauth2Auth: {
callCustomApi: () => Promise.resolve(taskDetailsMock) callCustomApi: () => Promise.resolve(taskDetailsMock)
}, },
isEcmLoggedIn() { isEcmLoggedIn: () => false,
return false;
},
reply: jasmine.createSpy('reply') reply: jasmine.createSpy('reply')
}; };
@@ -35,6 +35,9 @@ import { StartTaskCloudRequestModel } from '../models/start-task-cloud-request.m
import { takeUntil } from 'rxjs/operators'; import { takeUntil } from 'rxjs/operators';
import { TaskPriorityOption } from '../../models/task.model'; import { TaskPriorityOption } from '../../models/task.model';
const MAX_NAME_LENGTH = 255;
const DATE_FORMAT: string = 'DD/MM/YYYY';
@Component({ @Component({
selector: 'adf-cloud-start-task', selector: 'adf-cloud-start-task',
templateUrl: './start-task-cloud.component.html', templateUrl: './start-task-cloud.component.html',
@@ -44,20 +47,14 @@ import { TaskPriorityOption } from '../../models/task.model';
{ provide: MAT_DATE_FORMATS, useValue: MOMENT_DATE_FORMATS }], { provide: MAT_DATE_FORMATS, useValue: MOMENT_DATE_FORMATS }],
encapsulation: ViewEncapsulation.None encapsulation: ViewEncapsulation.None
}) })
export class StartTaskCloudComponent implements OnInit, OnDestroy { export class StartTaskCloudComponent implements OnInit, OnDestroy {
static MAX_NAME_LENGTH = 255;
public DATE_FORMAT: string = 'DD/MM/YYYY';
/** (required) Name of the app. */ /** (required) Name of the app. */
@Input() @Input()
appName: string = ''; appName: string = '';
/** Maximum length of the task name. */ /** Maximum length of the task name. */
@Input() @Input()
maxNameLength: number = StartTaskCloudComponent.MAX_NAME_LENGTH; maxNameLength: number = MAX_NAME_LENGTH;
/** Name of the task. */ /** Name of the task. */
@Input() @Input()
@@ -140,8 +137,7 @@ export class StartTaskCloudComponent implements OnInit, OnDestroy {
} }
private getMaxNameLength(): number { private getMaxNameLength(): number {
return this.maxNameLength > StartTaskCloudComponent.MAX_NAME_LENGTH ? return this.maxNameLength > MAX_NAME_LENGTH ? MAX_NAME_LENGTH : this.maxNameLength;
StartTaskCloudComponent.MAX_NAME_LENGTH : this.maxNameLength;
} }
private loadCurrentUser() { private loadCurrentUser() {
@@ -186,7 +182,7 @@ export class StartTaskCloudComponent implements OnInit, OnDestroy {
this.dateError = false; this.dateError = false;
if (newDateValue) { if (newDateValue) {
const momentDate = moment(newDateValue, this.DATE_FORMAT, true); const momentDate = moment(newDateValue, DATE_FORMAT, true);
if (!momentDate.isValid()) { if (!momentDate.isValid()) {
this.dateError = true; this.dateError = true;
} }
@@ -209,9 +205,7 @@ export class StartTaskCloudComponent implements OnInit, OnDestroy {
onCandidateGroupRemove(candidateGroup: any) { onCandidateGroupRemove(candidateGroup: any) {
if (candidateGroup.name) { if (candidateGroup.name) {
this.candidateGroupNames = this.candidateGroupNames.filter((name: string) => { this.candidateGroupNames = this.candidateGroupNames.filter((name: string) => name !== candidateGroup.name);
return name !== candidateGroup.name;
});
} }
} }
@@ -226,7 +220,7 @@ export class StartTaskCloudComponent implements OnInit, OnDestroy {
public whitespaceValidator(control: FormControl) { public whitespaceValidator(control: FormControl) {
const isWhitespace = (control.value || '').trim().length === 0; const isWhitespace = (control.value || '').trim().length === 0;
const isValid = control.value.length === 0 || !isWhitespace; const isValid = control.value.length === 0 || !isWhitespace;
return isValid ? null : { 'whitespace': true }; return isValid ? null : { whitespace: true };
} }
get nameController(): FormControl { get nameController(): FormControl {
@@ -17,4 +17,4 @@
import { StartTaskCloudRequestModel } from '../models/start-task-cloud-request.model'; import { StartTaskCloudRequestModel } from '../models/start-task-cloud-request.model';
export let taskDetailsMock = new StartTaskCloudRequestModel({ assignee: 'fake-assigne', name: 'fake-name' }); export const taskDetailsMock = new StartTaskCloudRequestModel({ assignee: 'fake-assigne', name: 'fake-name' });
@@ -29,6 +29,8 @@ import { IdentityGroupModel, IdentityUserModel, TranslationService, UserPreferen
import { TaskFilterDialogCloudComponent } from '../task-filter-dialog/task-filter-dialog-cloud.component'; import { TaskFilterDialogCloudComponent } from '../task-filter-dialog/task-filter-dialog-cloud.component';
import { MatDialog } from '@angular/material/dialog'; import { MatDialog } from '@angular/material/dialog';
/* eslint-disable @typescript-eslint/naming-convention */
export interface DropdownOption { export interface DropdownOption {
value: string; value: string;
label: string; label: string;
@@ -202,6 +204,7 @@ export abstract class BaseEditTaskFilterCloudComponent<T> implements OnInit, OnC
/** /**
* Return filter name * Return filter name
*
* @param filterName * @param filterName
*/ */
getSanitizeFilterName(filterName: string): string { getSanitizeFilterName(filterName: string): string {
@@ -322,9 +325,7 @@ export abstract class BaseEditTaskFilterCloudComponent<T> implements OnInit, OnC
get createSortProperties(): FilterOptions[] { get createSortProperties(): FilterOptions[] {
this.checkMandatorySortProperties(); this.checkMandatorySortProperties();
return this.sortProperties.map((property: string) => { return this.sortProperties.map((property: string) => ({ label: property, value: property }));
return { label: property, value: property };
});
} }
createAndFilterActions(): TaskFilterAction[] { createAndFilterActions(): TaskFilterAction[] {
@@ -82,7 +82,7 @@ describe('EditServiceTaskFilterCloudComponent', () => {
it('should fetch task filter by taskId', () => { it('should fetch task filter by taskId', () => {
const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true);
component.ngOnChanges({ 'id': taskFilterIdChange }); component.ngOnChanges({ id: taskFilterIdChange });
fixture.detectChanges(); fixture.detectChanges();
fixture.whenStable().then(() => { fixture.whenStable().then(() => {
expect(getTaskFilterSpy).toHaveBeenCalled(); expect(getTaskFilterSpy).toHaveBeenCalled();
@@ -102,7 +102,7 @@ describe('EditServiceTaskFilterCloudComponent', () => {
component.filterProperties = ['processDefinitionName']; component.filterProperties = ['processDefinitionName'];
fixture.detectChanges(); fixture.detectChanges();
const taskFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true); const taskFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true);
component.ngOnChanges({ 'id': taskFilterIdChange }); component.ngOnChanges({ id: taskFilterIdChange });
fixture.detectChanges(); fixture.detectChanges();
const controller = component.editTaskFilterForm.get('processDefinitionName'); const controller = component.editTaskFilterForm.get('processDefinitionName');
@@ -115,7 +115,7 @@ describe('EditServiceTaskFilterCloudComponent', () => {
it('should display filter name as title', async () => { it('should display filter name as title', async () => {
const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true);
component.ngOnChanges({ 'id': taskFilterIdChange }); component.ngOnChanges({ id: taskFilterIdChange });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -129,7 +129,7 @@ describe('EditServiceTaskFilterCloudComponent', () => {
it('should not display filter name if showFilterName is false', async () => { it('should not display filter name if showFilterName is false', async () => {
const taskFilterIdChange = new SimpleChange(null, 'mock-task-filter-id', true); const taskFilterIdChange = new SimpleChange(null, 'mock-task-filter-id', true);
component.showTaskFilterName = false; component.showTaskFilterName = false;
component.ngOnChanges({ 'id': taskFilterIdChange }); component.ngOnChanges({ id: taskFilterIdChange });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -140,7 +140,7 @@ describe('EditServiceTaskFilterCloudComponent', () => {
it('should not display mat-spinner if isloading set to false', async () => { it('should not display mat-spinner if isloading set to false', async () => {
const taskFilterIdChange = new SimpleChange(null, 'mock-task-filter-id', true); const taskFilterIdChange = new SimpleChange(null, 'mock-task-filter-id', true);
component.ngOnChanges({ 'id': taskFilterIdChange }); component.ngOnChanges({ id: taskFilterIdChange });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -157,7 +157,7 @@ describe('EditServiceTaskFilterCloudComponent', () => {
it('should display mat-spinner if isloading set to true', async () => { it('should display mat-spinner if isloading set to true', async () => {
component.isLoading = true; component.isLoading = true;
const taskFilterIdChange = new SimpleChange(null, 'mock-task-filter-id', true); const taskFilterIdChange = new SimpleChange(null, 'mock-task-filter-id', true);
component.ngOnChanges({ 'id': taskFilterIdChange }); component.ngOnChanges({ id: taskFilterIdChange });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -170,7 +170,7 @@ describe('EditServiceTaskFilterCloudComponent', () => {
beforeEach(() => { beforeEach(() => {
const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true);
component.ngOnChanges({ 'id': taskFilterIdChange }); component.ngOnChanges({ id: taskFilterIdChange });
fixture.detectChanges(); fixture.detectChanges();
}); });
@@ -204,7 +204,7 @@ describe('EditServiceTaskFilterCloudComponent', () => {
})); }));
const taskFilterIdChange = new SimpleChange(null, 'filter-id', true); const taskFilterIdChange = new SimpleChange(null, 'filter-id', true);
component.ngOnChanges({ 'id': taskFilterIdChange }); component.ngOnChanges({ id: taskFilterIdChange });
fixture.detectChanges(); fixture.detectChanges();
component.toggleFilterActions = true; component.toggleFilterActions = true;
@@ -222,7 +222,7 @@ describe('EditServiceTaskFilterCloudComponent', () => {
it('should enable delete button for custom task filters', async () => { it('should enable delete button for custom task filters', async () => {
const taskFilterIdChange = new SimpleChange(null, 'mock-task-filter-id', true); const taskFilterIdChange = new SimpleChange(null, 'mock-task-filter-id', true);
component.ngOnChanges({ 'id': taskFilterIdChange }); component.ngOnChanges({ id: taskFilterIdChange });
fixture.detectChanges(); fixture.detectChanges();
component.toggleFilterActions = true; component.toggleFilterActions = true;
@@ -240,7 +240,7 @@ describe('EditServiceTaskFilterCloudComponent', () => {
it('should enable save button if the filter is changed for custom task filters', (done) => { it('should enable save button if the filter is changed for custom task filters', (done) => {
const taskFilterIdChange = new SimpleChange(null, 'mock-task-filter-id', true); const taskFilterIdChange = new SimpleChange(null, 'mock-task-filter-id', true);
component.ngOnChanges({ 'id': taskFilterIdChange }); component.ngOnChanges({ id: taskFilterIdChange });
fixture.detectChanges(); fixture.detectChanges();
component.toggleFilterActions = true; component.toggleFilterActions = true;
@@ -291,7 +291,7 @@ describe('EditServiceTaskFilterCloudComponent', () => {
})); }));
const taskFilterIdChange = new SimpleChange(null, 'filter-id', true); const taskFilterIdChange = new SimpleChange(null, 'filter-id', true);
component.ngOnChanges({ 'id': taskFilterIdChange }); component.ngOnChanges({ id: taskFilterIdChange });
fixture.detectChanges(); fixture.detectChanges();
component.toggleFilterActions = true; component.toggleFilterActions = true;
@@ -329,7 +329,7 @@ describe('EditServiceTaskFilterCloudComponent', () => {
})); }));
const taskFilterIdChange = new SimpleChange(null, 'filter-id', true); const taskFilterIdChange = new SimpleChange(null, 'filter-id', true);
component.ngOnChanges({ 'id': taskFilterIdChange }); component.ngOnChanges({ id: taskFilterIdChange });
fixture.detectChanges(); fixture.detectChanges();
component.toggleFilterActions = true; component.toggleFilterActions = true;
@@ -474,7 +474,7 @@ describe('EditServiceTaskFilterCloudComponent', () => {
it('should able to build a editTaskFilter form with default properties if input is empty', async () => { it('should able to build a editTaskFilter form with default properties if input is empty', async () => {
const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true);
component.ngOnChanges({ 'id': taskFilterIdChange }); component.ngOnChanges({ id: taskFilterIdChange });
component.filterProperties = []; component.filterProperties = [];
fixture.detectChanges(); fixture.detectChanges();
@@ -497,7 +497,7 @@ describe('EditServiceTaskFilterCloudComponent', () => {
component.filterProperties = ['appName', 'processInstanceId', 'priority']; component.filterProperties = ['appName', 'processInstanceId', 'priority'];
fixture.detectChanges(); fixture.detectChanges();
const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true);
component.ngOnChanges({ 'id': taskFilterIdChange }); component.ngOnChanges({ id: taskFilterIdChange });
const appController = component.editTaskFilterForm.get('appName'); const appController = component.editTaskFilterForm.get('appName');
fixture.detectChanges(); fixture.detectChanges();
@@ -513,7 +513,7 @@ describe('EditServiceTaskFilterCloudComponent', () => {
it('should display default sort properties', async () => { it('should display default sort properties', async () => {
const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true);
component.ngOnChanges({ 'id': taskFilterIdChange }); component.ngOnChanges({ id: taskFilterIdChange });
fixture.detectChanges(); fixture.detectChanges();
const expansionPanel = fixture.debugElement.nativeElement.querySelector('mat-expansion-panel-header'); const expansionPanel = fixture.debugElement.nativeElement.querySelector('mat-expansion-panel-header');
expansionPanel.click(); expansionPanel.click();
@@ -539,7 +539,7 @@ describe('EditServiceTaskFilterCloudComponent', () => {
})); }));
fixture.detectChanges(); fixture.detectChanges();
const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true);
component.ngOnChanges({ 'id': taskFilterIdChange }); component.ngOnChanges({ id: taskFilterIdChange });
fixture.detectChanges(); fixture.detectChanges();
const expansionPanel = fixture.debugElement.nativeElement.querySelector('mat-expansion-panel-header'); const expansionPanel = fixture.debugElement.nativeElement.querySelector('mat-expansion-panel-header');
expansionPanel.click(); expansionPanel.click();
@@ -559,7 +559,7 @@ describe('EditServiceTaskFilterCloudComponent', () => {
it('should display default sort properties if input is empty', async () => { it('should display default sort properties if input is empty', async () => {
const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true);
component.ngOnChanges({ 'id': taskFilterIdChange }); component.ngOnChanges({ id: taskFilterIdChange });
fixture.detectChanges(); fixture.detectChanges();
component.sortProperties = []; component.sortProperties = [];
fixture.detectChanges(); fixture.detectChanges();
@@ -584,7 +584,7 @@ describe('EditServiceTaskFilterCloudComponent', () => {
it('should display default filter actions', async () => { it('should display default filter actions', async () => {
component.toggleFilterActions = true; component.toggleFilterActions = true;
const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true);
component.ngOnChanges({ 'id': taskFilterIdChange }); component.ngOnChanges({ id: taskFilterIdChange });
fixture.detectChanges(); fixture.detectChanges();
const expansionPanel = fixture.debugElement.nativeElement.querySelector('mat-expansion-panel-header'); const expansionPanel = fixture.debugElement.nativeElement.querySelector('mat-expansion-panel-header');
expansionPanel.click(); expansionPanel.click();
@@ -606,7 +606,7 @@ describe('EditServiceTaskFilterCloudComponent', () => {
component.actions = ['save']; component.actions = ['save'];
fixture.detectChanges(); fixture.detectChanges();
const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true);
component.ngOnChanges({ 'id': taskFilterIdChange }); component.ngOnChanges({ id: taskFilterIdChange });
fixture.detectChanges(); fixture.detectChanges();
component.toggleFilterActions = true; component.toggleFilterActions = true;
fixture.detectChanges(); fixture.detectChanges();
@@ -631,7 +631,7 @@ describe('EditServiceTaskFilterCloudComponent', () => {
beforeEach(() => { beforeEach(() => {
const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true);
component.ngOnChanges({ 'id': taskFilterIdChange }); component.ngOnChanges({ id: taskFilterIdChange });
fixture.detectChanges(); fixture.detectChanges();
spyOn(component.action, 'emit').and.callThrough(); spyOn(component.action, 'emit').and.callThrough();
}); });
@@ -57,9 +57,7 @@ describe('EditTaskFilterCloudComponent', () => {
oauth2Auth: { oauth2Auth: {
callCustomApi: () => Promise.resolve(fakeApplicationInstance) callCustomApi: () => Promise.resolve(fakeApplicationInstance)
}, },
isEcmLoggedIn() { isEcmLoggedIn: () => false,
return false;
},
reply: jasmine.createSpy('reply') reply: jasmine.createSpy('reply')
}; };
@@ -102,7 +100,7 @@ describe('EditTaskFilterCloudComponent', () => {
it('should fetch task filter by taskId', () => { it('should fetch task filter by taskId', () => {
const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true);
component.ngOnChanges({ 'id': taskFilterIdChange }); component.ngOnChanges({ id: taskFilterIdChange });
fixture.detectChanges(); fixture.detectChanges();
fixture.whenStable().then(() => { fixture.whenStable().then(() => {
expect(getTaskFilterSpy).toHaveBeenCalled(); expect(getTaskFilterSpy).toHaveBeenCalled();
@@ -120,7 +118,7 @@ describe('EditTaskFilterCloudComponent', () => {
component.filterProperties = ['processDefinitionName']; component.filterProperties = ['processDefinitionName'];
fixture.detectChanges(); fixture.detectChanges();
const taskFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true); const taskFilterIdChange = new SimpleChange(null, 'mock-process-filter-id', true);
component.ngOnChanges({ 'id': taskFilterIdChange }); component.ngOnChanges({ id: taskFilterIdChange });
fixture.detectChanges(); fixture.detectChanges();
const controller = component.editTaskFilterForm.get('processDefinitionName'); const controller = component.editTaskFilterForm.get('processDefinitionName');
@@ -133,7 +131,7 @@ describe('EditTaskFilterCloudComponent', () => {
it('should display filter name as title', async () => { it('should display filter name as title', async () => {
const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true);
component.ngOnChanges({ 'id': taskFilterIdChange }); component.ngOnChanges({ id: taskFilterIdChange });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -147,7 +145,7 @@ describe('EditTaskFilterCloudComponent', () => {
it('should not display filter name if showFilterName is false', async () => { it('should not display filter name if showFilterName is false', async () => {
const taskFilterIdChange = new SimpleChange(null, 'mock-task-filter-id', true); const taskFilterIdChange = new SimpleChange(null, 'mock-task-filter-id', true);
component.showTaskFilterName = false; component.showTaskFilterName = false;
component.ngOnChanges({ 'id': taskFilterIdChange }); component.ngOnChanges({ id: taskFilterIdChange });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -158,7 +156,7 @@ describe('EditTaskFilterCloudComponent', () => {
it('should not display mat-spinner if isloading set to false', async () => { it('should not display mat-spinner if isloading set to false', async () => {
const taskFilterIdChange = new SimpleChange(null, 'mock-task-filter-id', true); const taskFilterIdChange = new SimpleChange(null, 'mock-task-filter-id', true);
component.ngOnChanges({ 'id': taskFilterIdChange }); component.ngOnChanges({ id: taskFilterIdChange });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -175,7 +173,7 @@ describe('EditTaskFilterCloudComponent', () => {
it('should display mat-spinner if isloading set to true', async () => { it('should display mat-spinner if isloading set to true', async () => {
component.isLoading = true; component.isLoading = true;
const taskFilterIdChange = new SimpleChange(null, 'mock-task-filter-id', true); const taskFilterIdChange = new SimpleChange(null, 'mock-task-filter-id', true);
component.ngOnChanges({ 'id': taskFilterIdChange }); component.ngOnChanges({ id: taskFilterIdChange });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -188,7 +186,7 @@ describe('EditTaskFilterCloudComponent', () => {
beforeEach(() => { beforeEach(() => {
const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true);
component.ngOnChanges({ 'id': taskFilterIdChange }); component.ngOnChanges({ id: taskFilterIdChange });
fixture.detectChanges(); fixture.detectChanges();
}); });
@@ -221,7 +219,7 @@ describe('EditTaskFilterCloudComponent', () => {
})); }));
const taskFilterIdChange = new SimpleChange(null, 'filter-id', true); const taskFilterIdChange = new SimpleChange(null, 'filter-id', true);
component.ngOnChanges({ 'id': taskFilterIdChange }); component.ngOnChanges({ id: taskFilterIdChange });
fixture.detectChanges(); fixture.detectChanges();
component.toggleFilterActions = true; component.toggleFilterActions = true;
@@ -239,7 +237,7 @@ describe('EditTaskFilterCloudComponent', () => {
it('should enable delete button for custom task filters', async () => { it('should enable delete button for custom task filters', async () => {
const taskFilterIdChange = new SimpleChange(null, 'mock-task-filter-id', true); const taskFilterIdChange = new SimpleChange(null, 'mock-task-filter-id', true);
component.ngOnChanges({ 'id': taskFilterIdChange }); component.ngOnChanges({ id: taskFilterIdChange });
fixture.detectChanges(); fixture.detectChanges();
component.toggleFilterActions = true; component.toggleFilterActions = true;
@@ -257,7 +255,7 @@ describe('EditTaskFilterCloudComponent', () => {
it('should enable save button if the filter is changed for custom task filters', (done) => { it('should enable save button if the filter is changed for custom task filters', (done) => {
const taskFilterIdChange = new SimpleChange(null, 'mock-task-filter-id', true); const taskFilterIdChange = new SimpleChange(null, 'mock-task-filter-id', true);
component.ngOnChanges({ 'id': taskFilterIdChange }); component.ngOnChanges({ id: taskFilterIdChange });
fixture.detectChanges(); fixture.detectChanges();
component.toggleFilterActions = true; component.toggleFilterActions = true;
@@ -308,7 +306,7 @@ describe('EditTaskFilterCloudComponent', () => {
})); }));
const taskFilterIdChange = new SimpleChange(null, 'filter-id', true); const taskFilterIdChange = new SimpleChange(null, 'filter-id', true);
component.ngOnChanges({ 'id': taskFilterIdChange }); component.ngOnChanges({ id: taskFilterIdChange });
fixture.detectChanges(); fixture.detectChanges();
component.toggleFilterActions = true; component.toggleFilterActions = true;
@@ -346,7 +344,7 @@ describe('EditTaskFilterCloudComponent', () => {
})); }));
const taskFilterIdChange = new SimpleChange(null, 'filter-id', true); const taskFilterIdChange = new SimpleChange(null, 'filter-id', true);
component.ngOnChanges({ 'id': taskFilterIdChange }); component.ngOnChanges({ id: taskFilterIdChange });
fixture.detectChanges(); fixture.detectChanges();
component.toggleFilterActions = true; component.toggleFilterActions = true;
@@ -469,7 +467,7 @@ describe('EditTaskFilterCloudComponent', () => {
it('should able to build a editTaskFilter form with default properties if input is empty', async () => { it('should able to build a editTaskFilter form with default properties if input is empty', async () => {
const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true);
component.ngOnChanges({ 'id': taskFilterIdChange }); component.ngOnChanges({ id: taskFilterIdChange });
component.filterProperties = []; component.filterProperties = [];
fixture.detectChanges(); fixture.detectChanges();
const stateController = component.editTaskFilterForm.get('status'); const stateController = component.editTaskFilterForm.get('status');
@@ -489,7 +487,7 @@ describe('EditTaskFilterCloudComponent', () => {
component.filterProperties = ['appName', 'processInstanceId', 'priority']; component.filterProperties = ['appName', 'processInstanceId', 'priority'];
fixture.detectChanges(); fixture.detectChanges();
const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true);
component.ngOnChanges({ 'id': taskFilterIdChange }); component.ngOnChanges({ id: taskFilterIdChange });
const appController = component.editTaskFilterForm.get('appName'); const appController = component.editTaskFilterForm.get('appName');
fixture.detectChanges(); fixture.detectChanges();
@@ -504,7 +502,7 @@ describe('EditTaskFilterCloudComponent', () => {
component.filterProperties = ['appName', 'processInstanceId', 'priority', 'completedBy']; component.filterProperties = ['appName', 'processInstanceId', 'priority', 'completedBy'];
fixture.detectChanges(); fixture.detectChanges();
const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true);
component.ngOnChanges({ 'id': taskFilterIdChange }); component.ngOnChanges({ id: taskFilterIdChange });
const appController = component.editTaskFilterForm.get('completedBy'); const appController = component.editTaskFilterForm.get('completedBy');
fixture.detectChanges(); fixture.detectChanges();
@@ -521,7 +519,7 @@ describe('EditTaskFilterCloudComponent', () => {
component.filterProperties = ['appName', 'processInstanceId', 'priority', 'completedBy']; component.filterProperties = ['appName', 'processInstanceId', 'priority', 'completedBy'];
fixture.detectChanges(); fixture.detectChanges();
const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true);
component.ngOnChanges({ 'id': taskFilterIdChange }); component.ngOnChanges({ id: taskFilterIdChange });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -534,7 +532,7 @@ describe('EditTaskFilterCloudComponent', () => {
component.appName = 'fake'; component.appName = 'fake';
component.filterProperties = ['appName', 'processInstanceId', 'priority', 'completedBy']; component.filterProperties = ['appName', 'processInstanceId', 'priority', 'completedBy'];
const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true);
component.ngOnChanges({ 'id': taskFilterIdChange }); component.ngOnChanges({ id: taskFilterIdChange });
fixture.detectChanges(); fixture.detectChanges();
const mockUser: IdentityUserModel[] = [{ const mockUser: IdentityUserModel[] = [{
@@ -565,7 +563,7 @@ describe('EditTaskFilterCloudComponent', () => {
component.appName = 'fake'; component.appName = 'fake';
component.filterProperties = ['appName', 'processInstanceId', 'priority', 'dueDateRange']; component.filterProperties = ['appName', 'processInstanceId', 'priority', 'dueDateRange'];
const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true);
component.ngOnChanges({ 'id': taskFilterIdChange }); component.ngOnChanges({ id: taskFilterIdChange });
fixture.detectChanges(); fixture.detectChanges();
const startedDateTypeControl: AbstractControl = component.editTaskFilterForm.get('dueDateType'); const startedDateTypeControl: AbstractControl = component.editTaskFilterForm.get('dueDateType');
@@ -587,7 +585,7 @@ describe('EditTaskFilterCloudComponent', () => {
component.appName = 'fake'; component.appName = 'fake';
component.filterProperties = ['appName', 'processInstanceId', 'priority', 'dueDateRange']; component.filterProperties = ['appName', 'processInstanceId', 'priority', 'dueDateRange'];
const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true);
component.ngOnChanges({ 'id': taskFilterIdChange }); component.ngOnChanges({ id: taskFilterIdChange });
fixture.detectChanges(); fixture.detectChanges();
const stateElement = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-cloud-edit-process-property-dueDateRange"] .mat-select-trigger'); const stateElement = fixture.debugElement.nativeElement.querySelector('[data-automation-id="adf-cloud-edit-process-property-dueDateRange"] .mat-select-trigger');
@@ -606,7 +604,7 @@ describe('EditTaskFilterCloudComponent', () => {
component.appName = 'fake'; component.appName = 'fake';
component.filterProperties = ['appName', 'processInstanceId', 'priority', 'dueDateRange']; component.filterProperties = ['appName', 'processInstanceId', 'priority', 'dueDateRange'];
const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true);
component.ngOnChanges({ 'id': taskFilterIdChange }); component.ngOnChanges({ id: taskFilterIdChange });
fixture.detectChanges(); fixture.detectChanges();
const dateFilter = { const dateFilter = {
@@ -643,7 +641,7 @@ describe('EditTaskFilterCloudComponent', () => {
component.appName = 'fake'; component.appName = 'fake';
component.filterProperties = ['appName', 'processInstanceId', 'priority', 'completedDateRange']; component.filterProperties = ['appName', 'processInstanceId', 'priority', 'completedDateRange'];
const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true);
component.ngOnChanges({ 'id': taskFilterIdChange }); component.ngOnChanges({ id: taskFilterIdChange });
fixture.detectChanges(); fixture.detectChanges();
const startedDateTypeControl: AbstractControl = component.editTaskFilterForm.get('completedDateType'); const startedDateTypeControl: AbstractControl = component.editTaskFilterForm.get('completedDateType');
@@ -665,7 +663,7 @@ describe('EditTaskFilterCloudComponent', () => {
component.appName = 'fake'; component.appName = 'fake';
component.filterProperties = ['appName', 'processInstanceId', 'priority', 'completedDateRange']; component.filterProperties = ['appName', 'processInstanceId', 'priority', 'completedDateRange'];
const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true);
component.ngOnChanges({ 'id': taskFilterIdChange }); component.ngOnChanges({ id: taskFilterIdChange });
fixture.detectChanges(); fixture.detectChanges();
const dateFilter = { const dateFilter = {
@@ -701,7 +699,7 @@ describe('EditTaskFilterCloudComponent', () => {
component.appName = 'fake'; component.appName = 'fake';
component.filterProperties = ['appName', 'processInstanceId', 'priority', 'createdDateRange']; component.filterProperties = ['appName', 'processInstanceId', 'priority', 'createdDateRange'];
const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true);
component.ngOnChanges({ 'id': taskFilterIdChange }); component.ngOnChanges({ id: taskFilterIdChange });
fixture.detectChanges(); fixture.detectChanges();
const startedDateTypeControl: AbstractControl = component.editTaskFilterForm.get('createdDateType'); const startedDateTypeControl: AbstractControl = component.editTaskFilterForm.get('createdDateType');
@@ -724,7 +722,7 @@ describe('EditTaskFilterCloudComponent', () => {
component.appName = 'fake'; component.appName = 'fake';
component.filterProperties = ['assignment']; component.filterProperties = ['assignment'];
const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true);
component.ngOnChanges({ 'id': taskFilterIdChange }); component.ngOnChanges({ id: taskFilterIdChange });
fixture.detectChanges(); fixture.detectChanges();
const assignmentComponent = fixture.debugElement.nativeElement.querySelector('adf-cloud-task-assignment-filter'); const assignmentComponent = fixture.debugElement.nativeElement.querySelector('adf-cloud-task-assignment-filter');
expect(assignmentComponent).toBeTruthy(); expect(assignmentComponent).toBeTruthy();
@@ -735,7 +733,7 @@ describe('EditTaskFilterCloudComponent', () => {
component.appName = 'fake'; component.appName = 'fake';
component.filterProperties = ['assignment']; component.filterProperties = ['assignment'];
const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true);
component.ngOnChanges({ 'id': taskFilterIdChange }); component.ngOnChanges({ id: taskFilterIdChange });
component.onAssignedChange(identityUserMock); component.onAssignedChange(identityUserMock);
component.filterChange.subscribe(() => { component.filterChange.subscribe(() => {
@@ -749,7 +747,7 @@ describe('EditTaskFilterCloudComponent', () => {
component.appName = 'fake'; component.appName = 'fake';
component.filterProperties = ['appName', 'processInstanceId', 'priority', 'createdDateRange']; component.filterProperties = ['appName', 'processInstanceId', 'priority', 'createdDateRange'];
const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true);
component.ngOnChanges({ 'id': taskFilterIdChange }); component.ngOnChanges({ id: taskFilterIdChange });
fixture.detectChanges(); fixture.detectChanges();
const dateFilter = { const dateFilter = {
@@ -790,7 +788,7 @@ describe('EditTaskFilterCloudComponent', () => {
component.appName = 'fake'; component.appName = 'fake';
component.filterProperties = ['assignment']; component.filterProperties = ['assignment'];
const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true);
component.ngOnChanges({ 'id': taskFilterIdChange }); component.ngOnChanges({ id: taskFilterIdChange });
fixture.detectChanges(); fixture.detectChanges();
component.onAssignedGroupsChange(identityGroupsMock); component.onAssignedGroupsChange(identityGroupsMock);
@@ -806,7 +804,7 @@ describe('EditTaskFilterCloudComponent', () => {
it('should display default sort properties', async () => { it('should display default sort properties', async () => {
const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true);
component.ngOnChanges({ 'id': taskFilterIdChange }); component.ngOnChanges({ id: taskFilterIdChange });
fixture.detectChanges(); fixture.detectChanges();
const expansionPanel = fixture.debugElement.nativeElement.querySelector('mat-expansion-panel-header'); const expansionPanel = fixture.debugElement.nativeElement.querySelector('mat-expansion-panel-header');
expansionPanel.click(); expansionPanel.click();
@@ -832,7 +830,7 @@ describe('EditTaskFilterCloudComponent', () => {
})); }));
fixture.detectChanges(); fixture.detectChanges();
const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true);
component.ngOnChanges({ 'id': taskFilterIdChange }); component.ngOnChanges({ id: taskFilterIdChange });
fixture.detectChanges(); fixture.detectChanges();
const expansionPanel = fixture.debugElement.nativeElement.querySelector('mat-expansion-panel-header'); const expansionPanel = fixture.debugElement.nativeElement.querySelector('mat-expansion-panel-header');
expansionPanel.click(); expansionPanel.click();
@@ -852,7 +850,7 @@ describe('EditTaskFilterCloudComponent', () => {
it('should display default sort properties if input is empty', async () => { it('should display default sort properties if input is empty', async () => {
const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true);
component.ngOnChanges({ 'id': taskFilterIdChange }); component.ngOnChanges({ id: taskFilterIdChange });
fixture.detectChanges(); fixture.detectChanges();
component.sortProperties = []; component.sortProperties = [];
fixture.detectChanges(); fixture.detectChanges();
@@ -877,7 +875,7 @@ describe('EditTaskFilterCloudComponent', () => {
it('should display default filter actions', async () => { it('should display default filter actions', async () => {
component.toggleFilterActions = true; component.toggleFilterActions = true;
const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true);
component.ngOnChanges({ 'id': taskFilterIdChange }); component.ngOnChanges({ id: taskFilterIdChange });
fixture.detectChanges(); fixture.detectChanges();
const expansionPanel = fixture.debugElement.nativeElement.querySelector('mat-expansion-panel-header'); const expansionPanel = fixture.debugElement.nativeElement.querySelector('mat-expansion-panel-header');
expansionPanel.click(); expansionPanel.click();
@@ -899,7 +897,7 @@ describe('EditTaskFilterCloudComponent', () => {
component.actions = ['save']; component.actions = ['save'];
fixture.detectChanges(); fixture.detectChanges();
const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true);
component.ngOnChanges({ 'id': taskFilterIdChange }); component.ngOnChanges({ id: taskFilterIdChange });
fixture.detectChanges(); fixture.detectChanges();
component.toggleFilterActions = true; component.toggleFilterActions = true;
fixture.detectChanges(); fixture.detectChanges();
@@ -923,7 +921,7 @@ describe('EditTaskFilterCloudComponent', () => {
component.appName = 'fake'; component.appName = 'fake';
component.filterProperties = ['appName', 'processInstanceId', 'priority', 'lastModified']; component.filterProperties = ['appName', 'processInstanceId', 'priority', 'lastModified'];
const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true);
component.ngOnChanges({ 'id': taskFilterIdChange }); component.ngOnChanges({ id: taskFilterIdChange });
fixture.detectChanges(); fixture.detectChanges();
const lastModifiedToControl: AbstractControl = component.editTaskFilterForm.get('lastModifiedTo'); const lastModifiedToControl: AbstractControl = component.editTaskFilterForm.get('lastModifiedTo');
@@ -949,7 +947,7 @@ describe('EditTaskFilterCloudComponent', () => {
beforeEach(() => { beforeEach(() => {
const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true); const taskFilterIdChange = new SimpleChange(undefined, 'mock-task-filter-id', true);
component.ngOnChanges({ 'id': taskFilterIdChange }); component.ngOnChanges({ id: taskFilterIdChange });
fixture.detectChanges(); fixture.detectChanges();
spyOn(component.action, 'emit').and.callThrough(); spyOn(component.action, 'emit').and.callThrough();
}); });
@@ -62,7 +62,7 @@ describe('ServiceTaskFiltersCloudComponent', () => {
it('should attach specific icon for each filter if hasIcon is true', async () => { it('should attach specific icon for each filter if hasIcon is true', async () => {
const change = new SimpleChange(undefined, 'my-app-1', true); const change = new SimpleChange(undefined, 'my-app-1', true);
component.ngOnChanges({'appName': change}); component.ngOnChanges({appName: change});
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -84,7 +84,7 @@ describe('ServiceTaskFiltersCloudComponent', () => {
it('should not attach icons for each filter if hasIcon is false', async () => { it('should not attach icons for each filter if hasIcon is false', async () => {
component.showIcons = false; component.showIcons = false;
const change = new SimpleChange(undefined, 'my-app-1', true); const change = new SimpleChange(undefined, 'my-app-1', true);
component.ngOnChanges({'appName': change}); component.ngOnChanges({appName: change});
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -96,7 +96,7 @@ describe('ServiceTaskFiltersCloudComponent', () => {
it('should display the filters', async () => { it('should display the filters', async () => {
const change = new SimpleChange(undefined, 'my-app-1', true); const change = new SimpleChange(undefined, 'my-app-1', true);
component.ngOnChanges({'appName': change}); component.ngOnChanges({appName: change});
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -128,7 +128,7 @@ describe('ServiceTaskFiltersCloudComponent', () => {
done(); done();
}); });
component.ngOnChanges({'appName': change}); component.ngOnChanges({appName: change});
fixture.detectChanges(); fixture.detectChanges();
}); });
@@ -136,7 +136,7 @@ describe('ServiceTaskFiltersCloudComponent', () => {
const appName = 'my-app-1'; const appName = 'my-app-1';
const change = new SimpleChange(null, appName, true); const change = new SimpleChange(null, appName, true);
component.ngOnChanges({ 'appName': change }); component.ngOnChanges({ appName: change });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -150,7 +150,7 @@ describe('ServiceTaskFiltersCloudComponent', () => {
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
component.ngOnChanges({ 'filterParam': change }); component.ngOnChanges({ filterParam: change });
expect(component.currentFilter).toEqual(fakeGlobalServiceFilters[1]); expect(component.currentFilter).toEqual(fakeGlobalServiceFilters[1]);
expect(filterSelectedSpy).toHaveBeenCalledWith(fakeGlobalServiceFilters[1]); expect(filterSelectedSpy).toHaveBeenCalledWith(fakeGlobalServiceFilters[1]);
@@ -160,7 +160,7 @@ describe('ServiceTaskFiltersCloudComponent', () => {
const change = new SimpleChange(null, { name: 'nonexistentFilter' }, true); const change = new SimpleChange(null, { name: 'nonexistentFilter' }, true);
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
component.ngOnChanges({ 'filterParam': change }); component.ngOnChanges({ filterParam: change });
expect(component.currentFilter).toBeUndefined(); expect(component.currentFilter).toBeUndefined();
}); });
@@ -171,7 +171,7 @@ describe('ServiceTaskFiltersCloudComponent', () => {
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
component.ngOnChanges({ 'filterParam': change }); component.ngOnChanges({ filterParam: change });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -186,7 +186,7 @@ describe('ServiceTaskFiltersCloudComponent', () => {
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
component.ngOnChanges({ 'filterParam': change }); component.ngOnChanges({ filterParam: change });
expect(component.currentFilter).toEqual(fakeGlobalServiceFilters[2]); expect(component.currentFilter).toEqual(fakeGlobalServiceFilters[2]);
expect(filterSelectedSpy).toHaveBeenCalledWith(fakeGlobalServiceFilters[2]); expect(filterSelectedSpy).toHaveBeenCalledWith(fakeGlobalServiceFilters[2]);
@@ -198,7 +198,7 @@ describe('ServiceTaskFiltersCloudComponent', () => {
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
component.ngOnChanges({ 'filterParam': change }); component.ngOnChanges({ filterParam: change });
expect(component.currentFilter).toEqual(fakeGlobalServiceFilters[0]); expect(component.currentFilter).toEqual(fakeGlobalServiceFilters[0]);
expect(filterSelectedSpy).toHaveBeenCalledWith(fakeGlobalServiceFilters[0]); expect(filterSelectedSpy).toHaveBeenCalledWith(fakeGlobalServiceFilters[0]);
@@ -225,7 +225,7 @@ describe('ServiceTaskFiltersCloudComponent', () => {
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
component.ngOnChanges({ 'filterParam': change }); component.ngOnChanges({ filterParam: change });
expect(component.currentFilter).toBe(fakeGlobalServiceFilters[0]); expect(component.currentFilter).toBe(fakeGlobalServiceFilters[0]);
expect(filterClickedSpy).not.toHaveBeenCalled(); expect(filterClickedSpy).not.toHaveBeenCalled();
@@ -234,7 +234,7 @@ describe('ServiceTaskFiltersCloudComponent', () => {
it('should reset the filter when the param is undefined', () => { it('should reset the filter when the param is undefined', () => {
const change = new SimpleChange(null, undefined, false); const change = new SimpleChange(null, undefined, false);
component.currentFilter = fakeGlobalServiceFilters[0]; component.currentFilter = fakeGlobalServiceFilters[0];
component.ngOnChanges({ 'filterParam': change }); component.ngOnChanges({ filterParam: change });
expect(component.currentFilter).toBe(undefined); expect(component.currentFilter).toBe(undefined);
}); });
@@ -244,7 +244,7 @@ describe('ServiceTaskFiltersCloudComponent', () => {
const appName = 'my-app-1'; const appName = 'my-app-1';
const change = new SimpleChange(null, appName, true); const change = new SimpleChange(null, appName, true);
component.ngOnChanges({ 'appName': change }); component.ngOnChanges({ appName: change });
expect(component.getFilters).toHaveBeenCalledWith(appName); expect(component.getFilters).toHaveBeenCalledWith(appName);
}); });
@@ -254,7 +254,7 @@ describe('ServiceTaskFiltersCloudComponent', () => {
const appName = 'fake-app-name'; const appName = 'fake-app-name';
const change = new SimpleChange(null, appName, true); const change = new SimpleChange(null, appName, true);
component.ngOnChanges({ 'appName': change }); component.ngOnChanges({ appName: change });
expect(component.getFilters).toHaveBeenCalledWith(appName); expect(component.getFilters).toHaveBeenCalledWith(appName);
}); });
@@ -26,6 +26,7 @@ import { FormBuilder, FormGroup, AbstractControl, Validators } from '@angular/fo
}) })
export class TaskFilterDialogCloudComponent implements OnInit { export class TaskFilterDialogCloudComponent implements OnInit {
// eslint-disable-next-line @typescript-eslint/naming-convention
public static ACTION_SAVE = 'SAVE'; public static ACTION_SAVE = 'SAVE';
defaultIcon = 'inbox'; defaultIcon = 'inbox';
@@ -67,7 +67,7 @@ describe('TaskFiltersCloudComponent', () => {
it('should attach specific icon for each filter if hasIcon is true', async () => { it('should attach specific icon for each filter if hasIcon is true', async () => {
const change = new SimpleChange(undefined, 'my-app-1', true); const change = new SimpleChange(undefined, 'my-app-1', true);
component.ngOnChanges({ 'appName': change }); component.ngOnChanges({ appName: change });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -89,7 +89,7 @@ describe('TaskFiltersCloudComponent', () => {
it('should not attach icons for each filter if hasIcon is false', async () => { it('should not attach icons for each filter if hasIcon is false', async () => {
component.showIcons = false; component.showIcons = false;
const change = new SimpleChange(undefined, 'my-app-1', true); const change = new SimpleChange(undefined, 'my-app-1', true);
component.ngOnChanges({ 'appName': change }); component.ngOnChanges({ appName: change });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -100,7 +100,7 @@ describe('TaskFiltersCloudComponent', () => {
it('should display the filters', async () => { it('should display the filters', async () => {
const change = new SimpleChange(undefined, 'my-app-1', true); const change = new SimpleChange(undefined, 'my-app-1', true);
component.ngOnChanges({ 'appName': change }); component.ngOnChanges({ appName: change });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -133,14 +133,14 @@ describe('TaskFiltersCloudComponent', () => {
done(); done();
}); });
component.ngOnChanges({ 'appName': change }); component.ngOnChanges({ appName: change });
}); });
it('should display the task filters', async () => { it('should display the task filters', async () => {
const appName = 'my-app-1'; const appName = 'my-app-1';
const change = new SimpleChange(null, appName, true); const change = new SimpleChange(null, appName, true);
component.ngOnChanges({ 'appName': change }); component.ngOnChanges({ appName: change });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -157,7 +157,7 @@ describe('TaskFiltersCloudComponent', () => {
const appName = 'my-app-1'; const appName = 'my-app-1';
const change = new SimpleChange(null, appName, true); const change = new SimpleChange(null, appName, true);
component.ngOnChanges({ 'appName': change }); component.ngOnChanges({ appName: change });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -170,7 +170,7 @@ describe('TaskFiltersCloudComponent', () => {
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
component.ngOnChanges({ 'filterParam': change }); component.ngOnChanges({ filterParam: change });
expect(component.currentFilter).toEqual(fakeGlobalFilter[2]); expect(component.currentFilter).toEqual(fakeGlobalFilter[2]);
expect(filterSelectedSpy).toHaveBeenCalledWith(fakeGlobalFilter[2]); expect(filterSelectedSpy).toHaveBeenCalledWith(fakeGlobalFilter[2]);
@@ -180,7 +180,7 @@ describe('TaskFiltersCloudComponent', () => {
const change = new SimpleChange(null, { name: 'nonexistentFilter' }, true); const change = new SimpleChange(null, { name: 'nonexistentFilter' }, true);
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
component.ngOnChanges({ 'filterParam': change }); component.ngOnChanges({ filterParam: change });
expect(component.currentFilter).toBeUndefined(); expect(component.currentFilter).toBeUndefined();
}); });
@@ -191,7 +191,7 @@ describe('TaskFiltersCloudComponent', () => {
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
component.ngOnChanges({ 'filterParam': change }); component.ngOnChanges({ filterParam: change });
expect(component.currentFilter).toEqual(fakeGlobalFilter[2]); expect(component.currentFilter).toEqual(fakeGlobalFilter[2]);
expect(filterSelectedSpy).toHaveBeenCalledWith(fakeGlobalFilter[2]); expect(filterSelectedSpy).toHaveBeenCalledWith(fakeGlobalFilter[2]);
@@ -203,7 +203,7 @@ describe('TaskFiltersCloudComponent', () => {
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
component.ngOnChanges({ 'filterParam': change }); component.ngOnChanges({ filterParam: change });
expect(component.currentFilter).toEqual(fakeGlobalFilter[2]); expect(component.currentFilter).toEqual(fakeGlobalFilter[2]);
expect(filterSelectedSpy).toHaveBeenCalledWith(fakeGlobalFilter[2]); expect(filterSelectedSpy).toHaveBeenCalledWith(fakeGlobalFilter[2]);
@@ -215,7 +215,7 @@ describe('TaskFiltersCloudComponent', () => {
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
component.ngOnChanges({ 'filterParam': change }); component.ngOnChanges({ filterParam: change });
expect(component.currentFilter).toEqual(fakeGlobalFilter[2]); expect(component.currentFilter).toEqual(fakeGlobalFilter[2]);
expect(filterSelectedSpy).toHaveBeenCalledWith(fakeGlobalFilter[2]); expect(filterSelectedSpy).toHaveBeenCalledWith(fakeGlobalFilter[2]);
@@ -242,7 +242,7 @@ describe('TaskFiltersCloudComponent', () => {
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
component.ngOnChanges({ 'filterParam': change }); component.ngOnChanges({ filterParam: change });
expect(component.currentFilter).toBe(fakeGlobalFilter[0]); expect(component.currentFilter).toBe(fakeGlobalFilter[0]);
expect(filterClickedSpy).not.toHaveBeenCalled(); expect(filterClickedSpy).not.toHaveBeenCalled();
@@ -251,7 +251,7 @@ describe('TaskFiltersCloudComponent', () => {
it('should reset the filter when the param is undefined', () => { it('should reset the filter when the param is undefined', () => {
const change = new SimpleChange(fakeGlobalFilter[0], undefined, false); const change = new SimpleChange(fakeGlobalFilter[0], undefined, false);
component.currentFilter = fakeGlobalFilter[0]; component.currentFilter = fakeGlobalFilter[0];
component.ngOnChanges({ 'filterParam': change }); component.ngOnChanges({ filterParam: change });
expect(component.currentFilter).toEqual(undefined); expect(component.currentFilter).toEqual(undefined);
}); });
@@ -261,14 +261,14 @@ describe('TaskFiltersCloudComponent', () => {
const appName = 'my-app-1'; const appName = 'my-app-1';
const change = new SimpleChange(null, appName, true); const change = new SimpleChange(null, appName, true);
component.ngOnChanges({ 'appName': change }); component.ngOnChanges({ appName: change });
expect(component.getFilters).toHaveBeenCalledWith(appName); expect(component.getFilters).toHaveBeenCalledWith(appName);
}); });
it('should display filter counter if property set to true', async () => { it('should display filter counter if property set to true', async () => {
const change = new SimpleChange(undefined, 'my-app-1', true); const change = new SimpleChange(undefined, 'my-app-1', true);
component.ngOnChanges({ 'appName': change }); component.ngOnChanges({ appName: change });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -331,7 +331,7 @@ describe('TaskFiltersCloudComponent', () => {
component.currentFilter = null; component.currentFilter = null;
change = new SimpleChange(null, { key: fakeGlobalFilter[0].key }, true); change = new SimpleChange(null, { key: fakeGlobalFilter[0].key }, true);
component.ngOnChanges({ 'filterParam': change }); component.ngOnChanges({ filterParam: change });
fixture.detectChanges(); fixture.detectChanges();
fixture.whenStable().then(() => { fixture.whenStable().then(() => {
fixture.detectChanges(); fixture.detectChanges();
@@ -363,22 +363,22 @@ describe('TaskFiltersCloudComponent', () => {
const queuedTasksFilterKey = defaultTaskFiltersMock[0].key; const queuedTasksFilterKey = defaultTaskFiltersMock[0].key;
const completedTasksFilterKey = defaultTaskFiltersMock[2].key; const completedTasksFilterKey = defaultTaskFiltersMock[2].key;
function getActiveFilterElement(filterKey: string): Element { const getActiveFilterElement = (filterKey: string): Element => {
const activeFilter = fixture.debugElement.query(By.css(`.adf-active`)); const activeFilter = fixture.debugElement.query(By.css(`.adf-active`));
return activeFilter.nativeElement.querySelector(`[data-automation-id="${filterKey}_filter"]`); return activeFilter.nativeElement.querySelector(`[data-automation-id="${filterKey}_filter"]`);
} };
async function clickOnFilter(filterKey: string) { const clickOnFilter = async (filterKey: string) => {
fixture.debugElement.nativeElement.querySelector(`[data-automation-id="${filterKey}_filter"]`).click(); fixture.debugElement.nativeElement.querySelector(`[data-automation-id="${filterKey}_filter"]`).click();
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
} };
it('Should highlight task filter on filter click', async () => { it('Should highlight task filter on filter click', async () => {
getTaskListFiltersSpy.and.returnValue(of(defaultTaskFiltersMock)); getTaskListFiltersSpy.and.returnValue(of(defaultTaskFiltersMock));
component.appName = 'mock-app-name'; component.appName = 'mock-app-name';
const appNameChange = new SimpleChange(null, 'mock-app-name', true); const appNameChange = new SimpleChange(null, 'mock-app-name', true);
component.ngOnChanges({ 'appName': appNameChange }); component.ngOnChanges({ appName: appNameChange });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -405,7 +405,7 @@ describe('TaskFiltersCloudComponent', () => {
getTaskListFiltersSpy.and.returnValue(of(defaultTaskFiltersMock)); getTaskListFiltersSpy.and.returnValue(of(defaultTaskFiltersMock));
fixture.detectChanges(); fixture.detectChanges();
component.ngOnChanges({ 'filterParam': new SimpleChange(null, { key: assignedTasksFilterKey }, true) }); component.ngOnChanges({ filterParam: new SimpleChange(null, { key: assignedTasksFilterKey }, true) });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -413,7 +413,7 @@ describe('TaskFiltersCloudComponent', () => {
expect(getActiveFilterElement(queuedTasksFilterKey)).toBeNull(); expect(getActiveFilterElement(queuedTasksFilterKey)).toBeNull();
expect(getActiveFilterElement(completedTasksFilterKey)).toBeNull(); expect(getActiveFilterElement(completedTasksFilterKey)).toBeNull();
component.ngOnChanges({ 'filterParam': new SimpleChange(null, { key: queuedTasksFilterKey }, true) }); component.ngOnChanges({ filterParam: new SimpleChange(null, { key: queuedTasksFilterKey }, true) });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -421,7 +421,7 @@ describe('TaskFiltersCloudComponent', () => {
expect(getActiveFilterElement(queuedTasksFilterKey)).toBeDefined(); expect(getActiveFilterElement(queuedTasksFilterKey)).toBeDefined();
expect(getActiveFilterElement(completedTasksFilterKey)).toBeNull(); expect(getActiveFilterElement(completedTasksFilterKey)).toBeNull();
component.ngOnChanges({ 'filterParam': new SimpleChange(null, { key: completedTasksFilterKey }, true) }); component.ngOnChanges({ filterParam: new SimpleChange(null, { key: completedTasksFilterKey }, true) });
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -15,6 +15,10 @@
* limitations under the License. * limitations under the License.
*/ */
/* eslint-disable no-underscore-dangle */
/* eslint-disable no-shadow */
/* eslint-disable @typescript-eslint/naming-convention */
import { DateCloudFilterType } from '../../../models/date-cloud-filter.model'; import { DateCloudFilterType } from '../../../models/date-cloud-filter.model';
import { DateRangeFilterService } from '../../../common/date-range-filter/date-range-filter.service'; import { DateRangeFilterService } from '../../../common/date-range-filter/date-range-filter.service';
import { ComponentSelectionMode } from '../../../types'; import { ComponentSelectionMode } from '../../../types';
@@ -41,6 +41,7 @@ export class ServiceTaskFilterCloudService {
/** /**
* Creates and returns the default task filters for an app. * Creates and returns the default task filters for an app.
*
* @param appName Name of the target app * @param appName Name of the target app
* @returns Observable of default filters task filters just created or created filters * @returns Observable of default filters task filters just created or created filters
*/ */
@@ -62,6 +63,7 @@ export class ServiceTaskFilterCloudService {
/** /**
* Checks user preference are empty or not * Checks user preference are empty or not
*
* @param preferences User preferences of the target app * @param preferences User preferences of the target app
* @returns Boolean value if the preferences are not empty * @returns Boolean value if the preferences are not empty
*/ */
@@ -71,6 +73,7 @@ export class ServiceTaskFilterCloudService {
/** /**
* Checks for task filters in given user preferences * Checks for task filters in given user preferences
*
* @param preferences User preferences of the target app * @param preferences User preferences of the target app
* @param key Key of the task filters * @param key Key of the task filters
* @param filters Details of create filter * @param filters Details of create filter
@@ -83,6 +86,7 @@ export class ServiceTaskFilterCloudService {
/** /**
* Calls create preference api to create task filters * Calls create preference api to create task filters
*
* @param appName Name of the target app * @param appName Name of the target app
* @param key Key of the task instance filters * @param key Key of the task instance filters
* @param filters Details of new task filter * @param filters Details of new task filter
@@ -94,6 +98,7 @@ export class ServiceTaskFilterCloudService {
/** /**
* Calls get preference api to get task filter by preference key * Calls get preference api to get task filter by preference key
*
* @param appName Name of the target app * @param appName Name of the target app
* @param key Key of the task filters * @param key Key of the task filters
* @returns Observable of task filters * @returns Observable of task filters
@@ -104,6 +109,7 @@ export class ServiceTaskFilterCloudService {
/** /**
* Gets all task filters for a task app. * Gets all task filters for a task app.
*
* @param appName Name of the target app * @param appName Name of the target app
* @returns Observable of task filter details * @returns Observable of task filter details
*/ */
@@ -114,6 +120,7 @@ export class ServiceTaskFilterCloudService {
/** /**
* Gets a task filter. * Gets a task filter.
*
* @param appName Name of the target app * @param appName Name of the target app
* @param id ID of the task * @param id ID of the task
* @returns Details of the task filter * @returns Details of the task filter
@@ -128,16 +135,13 @@ export class ServiceTaskFilterCloudService {
return of(filters); return of(filters);
} }
}), }),
map((filters: any) => { map((filters: any) => filters.filter((filter: ServiceTaskFilterCloudModel) => filter.id === id)[0])
return filters.filter((filter: ServiceTaskFilterCloudModel) => {
return filter.id === id;
})[0];
})
); );
} }
/** /**
* Adds a new task filter. * Adds a new task filter.
*
* @param filter The new filter to add * @param filter The new filter to add
* @returns Observable of task instance filters with newly added filter * @returns Observable of task instance filters with newly added filter
*/ */
@@ -146,7 +150,7 @@ export class ServiceTaskFilterCloudService {
return this.getTaskFiltersByKey(newFilter.appName, key).pipe( return this.getTaskFiltersByKey(newFilter.appName, key).pipe(
switchMap((filters: ServiceTaskFilterCloudModel[]) => { switchMap((filters: ServiceTaskFilterCloudModel[]) => {
if (filters && filters.length === 0) { if (filters && filters.length === 0) {
return this.createTaskFilters(newFilter.appName, key, <ServiceTaskFilterCloudModel[]> [newFilter]); return this.createTaskFilters(newFilter.appName, key, [newFilter]);
} else { } else {
filters.push(newFilter); filters.push(newFilter);
return this.preferenceService.updatePreference(newFilter.appName, key, filters); return this.preferenceService.updatePreference(newFilter.appName, key, filters);
@@ -165,6 +169,7 @@ export class ServiceTaskFilterCloudService {
/** /**
* Updates a task filter. * Updates a task filter.
*
* @param filter The filter to update * @param filter The filter to update
* @returns Observable of task instance filters with updated filter * @returns Observable of task instance filters with updated filter
*/ */
@@ -173,7 +178,7 @@ export class ServiceTaskFilterCloudService {
return this.getTaskFiltersByKey(updatedFilter.appName, key).pipe( return this.getTaskFiltersByKey(updatedFilter.appName, key).pipe(
switchMap((filters: ServiceTaskFilterCloudModel[]) => { switchMap((filters: ServiceTaskFilterCloudModel[]) => {
if (filters && filters.length === 0) { if (filters && filters.length === 0) {
return this.createTaskFilters(updatedFilter.appName, key, <ServiceTaskFilterCloudModel[]> [updatedFilter]); return this.createTaskFilters(updatedFilter.appName, key, [updatedFilter]);
} else { } else {
const itemIndex = filters.findIndex((filter: ServiceTaskFilterCloudModel) => filter.id === updatedFilter.id); const itemIndex = filters.findIndex((filter: ServiceTaskFilterCloudModel) => filter.id === updatedFilter.id);
filters[itemIndex] = updatedFilter; filters[itemIndex] = updatedFilter;
@@ -189,6 +194,7 @@ export class ServiceTaskFilterCloudService {
/** /**
* Deletes a task filter * Deletes a task filter
*
* @param filter The filter to delete * @param filter The filter to delete
* @returns Observable of task instance filters without deleted filter * @returns Observable of task instance filters without deleted filter
*/ */
@@ -211,6 +217,7 @@ export class ServiceTaskFilterCloudService {
/** /**
* Checks if given filter is a default filter * Checks if given filter is a default filter
*
* @param filterName Name of the target task filter * @param filterName Name of the target task filter
* @returns Boolean value for whether the filter is a default filter * @returns Boolean value for whether the filter is a default filter
*/ */
@@ -221,6 +228,7 @@ export class ServiceTaskFilterCloudService {
/** /**
* Calls update preference api to update task filter * Calls update preference api to update task filter
*
* @param appName Name of the target app * @param appName Name of the target app
* @param key Key of the task filters * @param key Key of the task filters
* @param filters Details of update filter * @param filters Details of update filter
@@ -232,6 +240,7 @@ export class ServiceTaskFilterCloudService {
/** /**
* Creates a uniq key with appName and username * Creates a uniq key with appName and username
*
* @param appName Name of the target app * @param appName Name of the target app
* @returns String of task filters preference key * @returns String of task filters preference key
*/ */
@@ -241,6 +250,7 @@ export class ServiceTaskFilterCloudService {
/** /**
* Finds and returns the task filters from preferences * Finds and returns the task filters from preferences
*
* @param appName Name of the target app * @param appName Name of the target app
* @returns Array of TaskFilterCloudModel * @returns Array of TaskFilterCloudModel
*/ */
@@ -251,6 +261,7 @@ export class ServiceTaskFilterCloudService {
/** /**
* Creates and returns the default filters for a task app. * Creates and returns the default filters for a task app.
*
* @param appName Name of the target app * @param appName Name of the target app
* @returns Array of TaskFilterCloudModel * @returns Array of TaskFilterCloudModel
*/ */
@@ -64,6 +64,7 @@ export class TaskFilterCloudService extends BaseCloudService {
/** /**
* Creates and returns the default task filters for an app. * Creates and returns the default task filters for an app.
*
* @param appName Name of the target app * @param appName Name of the target app
* @returns Observable of default filters task filters just created or created filters * @returns Observable of default filters task filters just created or created filters
*/ */
@@ -85,6 +86,7 @@ export class TaskFilterCloudService extends BaseCloudService {
/** /**
* Checks user preference are empty or not * Checks user preference are empty or not
*
* @param preferences User preferences of the target app * @param preferences User preferences of the target app
* @returns Boolean value if the preferences are not empty * @returns Boolean value if the preferences are not empty
*/ */
@@ -94,6 +96,7 @@ export class TaskFilterCloudService extends BaseCloudService {
/** /**
* Checks for task filters in given user preferences * Checks for task filters in given user preferences
*
* @param preferences User preferences of the target app * @param preferences User preferences of the target app
* @param key Key of the task filters * @param key Key of the task filters
* @param filters Details of create filter * @param filters Details of create filter
@@ -106,6 +109,7 @@ export class TaskFilterCloudService extends BaseCloudService {
/** /**
* Calls create preference api to create task filters * Calls create preference api to create task filters
*
* @param appName Name of the target app * @param appName Name of the target app
* @param key Key of the task instance filters * @param key Key of the task instance filters
* @param filters Details of new task filter * @param filters Details of new task filter
@@ -117,6 +121,7 @@ export class TaskFilterCloudService extends BaseCloudService {
/** /**
* Calls get preference api to get task filter by preference key * Calls get preference api to get task filter by preference key
*
* @param appName Name of the target app * @param appName Name of the target app
* @param key Key of the task filters * @param key Key of the task filters
* @returns Observable of task filters * @returns Observable of task filters
@@ -127,6 +132,7 @@ export class TaskFilterCloudService extends BaseCloudService {
/** /**
* Gets all task filters for a task app. * Gets all task filters for a task app.
*
* @param appName Name of the target app * @param appName Name of the target app
* @returns Observable of task filter details * @returns Observable of task filter details
*/ */
@@ -137,6 +143,7 @@ export class TaskFilterCloudService extends BaseCloudService {
/** /**
* Gets a task filter. * Gets a task filter.
*
* @param appName Name of the target app * @param appName Name of the target app
* @param id ID of the task * @param id ID of the task
* @returns Details of the task filter * @returns Details of the task filter
@@ -151,16 +158,13 @@ export class TaskFilterCloudService extends BaseCloudService {
return of(filters); return of(filters);
} }
}), }),
map((filters: any) => { map((filters: any) => filters.filter((filter: TaskFilterCloudModel) => filter.id === id)[0])
return filters.filter((filter: TaskFilterCloudModel) => {
return filter.id === id;
})[0];
})
); );
} }
/** /**
* Adds a new task filter. * Adds a new task filter.
*
* @param filter The new filter to add * @param filter The new filter to add
* @returns Observable of task instance filters with newly added filter * @returns Observable of task instance filters with newly added filter
*/ */
@@ -169,7 +173,7 @@ export class TaskFilterCloudService extends BaseCloudService {
return this.getTaskFiltersByKey(newFilter.appName, key).pipe( return this.getTaskFiltersByKey(newFilter.appName, key).pipe(
switchMap((filters: any) => { switchMap((filters: any) => {
if (filters && filters.length === 0) { if (filters && filters.length === 0) {
return this.createTaskFilters(newFilter.appName, key, <TaskFilterCloudModel[]> [newFilter]); return this.createTaskFilters(newFilter.appName, key, [newFilter]);
} else { } else {
filters.push(newFilter); filters.push(newFilter);
return this.preferenceService.updatePreference(newFilter.appName, key, filters); return this.preferenceService.updatePreference(newFilter.appName, key, filters);
@@ -188,6 +192,7 @@ export class TaskFilterCloudService extends BaseCloudService {
/** /**
* Updates a task filter. * Updates a task filter.
*
* @param filter The filter to update * @param filter The filter to update
* @returns Observable of task instance filters with updated filter * @returns Observable of task instance filters with updated filter
*/ */
@@ -196,7 +201,7 @@ export class TaskFilterCloudService extends BaseCloudService {
return this.getTaskFiltersByKey(updatedFilter.appName, key).pipe( return this.getTaskFiltersByKey(updatedFilter.appName, key).pipe(
switchMap((filters: TaskFilterCloudModel[]) => { switchMap((filters: TaskFilterCloudModel[]) => {
if (filters && filters.length === 0) { if (filters && filters.length === 0) {
return this.createTaskFilters(updatedFilter.appName, key, <TaskFilterCloudModel[]> [updatedFilter]); return this.createTaskFilters(updatedFilter.appName, key, [updatedFilter]);
} else { } else {
const itemIndex = filters.findIndex((filter: TaskFilterCloudModel) => filter.id === updatedFilter.id); const itemIndex = filters.findIndex((filter: TaskFilterCloudModel) => filter.id === updatedFilter.id);
filters[itemIndex] = updatedFilter; filters[itemIndex] = updatedFilter;
@@ -212,6 +217,7 @@ export class TaskFilterCloudService extends BaseCloudService {
/** /**
* Deletes a task filter * Deletes a task filter
*
* @param filter The filter to delete * @param filter The filter to delete
* @returns Observable of task instance filters without deleted filter * @returns Observable of task instance filters without deleted filter
*/ */
@@ -234,6 +240,7 @@ export class TaskFilterCloudService extends BaseCloudService {
/** /**
* Checks if given filter is a default filter * Checks if given filter is a default filter
*
* @param filterName Name of the target task filter * @param filterName Name of the target task filter
* @returns Boolean value for whether the filter is a default filter * @returns Boolean value for whether the filter is a default filter
*/ */
@@ -244,6 +251,7 @@ export class TaskFilterCloudService extends BaseCloudService {
/** /**
* Finds a task using an object with optional query properties. * Finds a task using an object with optional query properties.
*
* @param requestNode Query object * @param requestNode Query object
* @returns Task information * @returns Task information
*/ */
@@ -266,6 +274,7 @@ export class TaskFilterCloudService extends BaseCloudService {
/** /**
* Calls update preference api to update task filter * Calls update preference api to update task filter
*
* @param appName Name of the target app * @param appName Name of the target app
* @param key Key of the task filters * @param key Key of the task filters
* @param filters Details of update filter * @param filters Details of update filter
@@ -277,6 +286,7 @@ export class TaskFilterCloudService extends BaseCloudService {
/** /**
* Creates a uniq key with appName and username * Creates a uniq key with appName and username
*
* @param appName Name of the target app * @param appName Name of the target app
* @returns String of task filters preference key * @returns String of task filters preference key
*/ */
@@ -286,6 +296,7 @@ export class TaskFilterCloudService extends BaseCloudService {
/** /**
* Finds and returns the task filters from preferences * Finds and returns the task filters from preferences
*
* @param appName Name of the target app * @param appName Name of the target app
* @returns Array of TaskFilterCloudModel * @returns Array of TaskFilterCloudModel
*/ */
@@ -296,6 +307,7 @@ export class TaskFilterCloudService extends BaseCloudService {
/** /**
* Creates and returns the default filters for a task app. * Creates and returns the default filters for a task app.
*
* @param appName Name of the target app * @param appName Name of the target app
* @returns Array of TaskFilterCloudModel * @returns Array of TaskFilterCloudModel
*/ */
@@ -19,7 +19,7 @@ import { TaskHeaderCloudComponent } from './task-header-cloud.component';
import { of, throwError } from 'rxjs'; import { of, throwError } from 'rxjs';
import { By } from '@angular/platform-browser'; import { By } from '@angular/platform-browser';
import { ComponentFixture, TestBed, fakeAsync } from '@angular/core/testing'; import { ComponentFixture, TestBed, fakeAsync } from '@angular/core/testing';
import { setupTestBed, AppConfigService, AlfrescoApiService, CardViewArrayItem } from '@alfresco/adf-core'; import { setupTestBed, AppConfigService, AlfrescoApiService } from '@alfresco/adf-core';
import { ProcessServiceCloudTestingModule } from '../../../testing/process-service-cloud.testing.module'; import { ProcessServiceCloudTestingModule } from '../../../testing/process-service-cloud.testing.module';
import { TaskCloudService } from '../../services/task-cloud.service'; import { TaskCloudService } from '../../services/task-cloud.service';
import { TaskHeaderCloudModule } from '../task-header-cloud.module'; import { TaskHeaderCloudModule } from '../task-header-cloud.module';
@@ -53,9 +53,7 @@ describe('TaskHeaderCloudComponent', () => {
oauth2Auth: { oauth2Auth: {
callCustomApi: () => Promise.resolve({}) callCustomApi: () => Promise.resolve({})
}, },
isEcmLoggedIn() { isEcmLoggedIn: () => false,
return false;
},
reply: jasmine.createSpy('reply') reply: jasmine.createSpy('reply')
}; };
@@ -292,7 +290,7 @@ describe('TaskHeaderCloudComponent', () => {
}); });
it('should not render defined edit icon for assignee property if the task in assigned state and shared among candidate groups', async () => { it('should not render defined edit icon for assignee property if the task in assigned state and shared among candidate groups', async () => {
component.candidateGroups = <CardViewArrayItem[]> [{ value: 'mock-group-1', icon: 'edit' }, { value: 'mock-group-2', icon: 'edit' }]; component.candidateGroups = [{ value: 'mock-group-1', icon: 'edit' }, { value: 'mock-group-2', icon: 'edit' }];
component.candidateUsers = []; component.candidateUsers = [];
fixture.detectChanges(); fixture.detectChanges();
await fixture.whenStable(); await fixture.whenStable();
@@ -303,7 +301,7 @@ describe('TaskHeaderCloudComponent', () => {
it('should not render defined edit icon for assignee property if the task in created state and shared among condidate groups', async () => { it('should not render defined edit icon for assignee property if the task in created state and shared among condidate groups', async () => {
getTaskByIdSpy.and.returnValue(of(createdTaskDetailsCloudMock)); getTaskByIdSpy.and.returnValue(of(createdTaskDetailsCloudMock));
component.candidateGroups = <CardViewArrayItem[]> [{ value: 'mock-group-1', icon: 'edit' }, { value: 'mock-group-2', icon: 'edit' }]; component.candidateGroups = [{ value: 'mock-group-1', icon: 'edit' }, { value: 'mock-group-2', icon: 'edit' }];
component.candidateUsers = []; component.candidateUsers = [];
component.ngOnChanges(); component.ngOnChanges();
fixture.detectChanges(); fixture.detectChanges();
@@ -127,8 +127,8 @@ export class TaskHeaderCloudComponent implements OnInit, OnDestroy, OnChanges {
finalize(() => (this.isLoading = false)) finalize(() => (this.isLoading = false))
).subscribe(([taskDetails, candidateUsers, candidateGroups]) => { ).subscribe(([taskDetails, candidateUsers, candidateGroups]) => {
this.taskDetails = taskDetails; this.taskDetails = taskDetails;
this.candidateGroups = candidateGroups.map((user) => <CardViewArrayItem> { icon: 'group', value: user }); this.candidateGroups = candidateGroups.map((user) => ({ icon: 'group', value: user } as CardViewArrayItem));
this.candidateUsers = candidateUsers.map((group) => <CardViewArrayItem> { icon: 'person', value: group }); this.candidateUsers = candidateUsers.map((group) => ({ icon: 'person', value: group } as CardViewArrayItem));
if (this.taskDetails.parentTaskId) { if (this.taskDetails.parentTaskId) {
this.loadParentName(`${this.taskDetails.parentTaskId}`); this.loadParentName(`${this.taskDetails.parentTaskId}`);
} else { } else {
@@ -16,16 +16,16 @@
*/ */
export const taskClaimCloudMock: any = { export const taskClaimCloudMock: any = {
'entry': { entry: {
'appName': 'simple-app', appName: 'simple-app',
'appVersion': '', appVersion: '',
'serviceName': 'simple-app', serviceName: 'simple-app',
'serviceFullName': 'simple-app', serviceFullName: 'simple-app',
'serviceType': 'runtime-bundle', serviceType: 'runtime-bundle',
'serviceVersion': '', serviceVersion: '',
'id': '68d54a8f', id: '68d54a8f',
'name': 'NXltAGmT', name: 'NXltAGmT',
'priority': 0, priority: 0,
'status': 'COMPLETED' status: 'COMPLETED'
} }
}; };
@@ -16,16 +16,16 @@
*/ */
export const taskCompleteCloudMock: any = { export const taskCompleteCloudMock: any = {
'entry': { entry: {
'appName': 'simple-app', appName: 'simple-app',
'appVersion': '', appVersion: '',
'serviceName': 'simple-app', serviceName: 'simple-app',
'serviceFullName': 'simple-app', serviceFullName: 'simple-app',
'serviceType': 'runtime-bundle', serviceType: 'runtime-bundle',
'serviceVersion': '', serviceVersion: '',
'id': '68d54a8f', id: '68d54a8f',
'name': 'NXltAGmT', name: 'NXltAGmT',
'priority': 0, priority: 0,
'status': 'COMPLETED' status: 'COMPLETED'
} }
}; };
@@ -16,27 +16,27 @@
*/ */
export const fakeTaskDetailsCloud = { export const fakeTaskDetailsCloud = {
'entry': { entry: {
'appName': 'task-app', appName: 'task-app',
'appVersion': '', appVersion: '',
'id': '68d54a8f', id: '68d54a8f',
'assignee': 'Phil Woods', assignee: 'Phil Woods',
'name': 'This is a new task', name: 'This is a new task',
'description': 'This is the description ', description: 'This is the description ',
'createdDate': 1545048055900, createdDate: 1545048055900,
'dueDate': 1545091200000, dueDate: 1545091200000,
'claimedDate': 1545140162601, claimedDate: 1545140162601,
'priority': 0, priority: 0,
'category': null, category: null,
'processDefinitionId': null, processDefinitionId: null,
'processInstanceId': null, processInstanceId: null,
'status': 'ASSIGNED', status: 'ASSIGNED',
'owner': 'Phil Woods', owner: 'Phil Woods',
'parentTaskId': null, parentTaskId: null,
'formKey': null, formKey: null,
'lastModified': 1545140162601, lastModified: 1545140162601,
'lastModifiedTo': null, lastModifiedTo: null,
'lastModifiedFrom': null, lastModifiedFrom: null,
'standalone': true standalone: true
} }
}; };
@@ -18,263 +18,263 @@
import { TaskDetailsCloudModel } from '../../start-task/models/task-details-cloud.model'; import { TaskDetailsCloudModel } from '../../start-task/models/task-details-cloud.model';
export const taskDetailsWithParentTaskIdMock: TaskDetailsCloudModel = { export const taskDetailsWithParentTaskIdMock: TaskDetailsCloudModel = {
'appName': 'task-app', appName: 'task-app',
'appVersion': 1, appVersion: 1,
'id': '68d54a8f-01f3-11e9-8e36-0a58646002ad', id: '68d54a8f-01f3-11e9-8e36-0a58646002ad',
'assignee': 'AssignedTaskUser', assignee: 'AssignedTaskUser',
'name': 'This is a parent task name ', name: 'This is a parent task name ',
'description': 'This is the description ', description: 'This is the description ',
'createdDate': new Date(1545048055900), createdDate: new Date(1545048055900),
'dueDate': new Date(), dueDate: new Date(),
'claimedDate': null, claimedDate: null,
'priority': 5, priority: 5,
'category': null, category: null,
'processDefinitionId': null, processDefinitionId: null,
'processInstanceId': null, processInstanceId: null,
'status': 'ASSIGNED', status: 'ASSIGNED',
'owner': 'ownerUser', owner: 'ownerUser',
'parentTaskId': 'mock-parent-task-id', parentTaskId: 'mock-parent-task-id',
'formKey': null, formKey: null,
'lastModified': new Date(1545048055900), lastModified: new Date(1545048055900),
'lastModifiedTo': null, lastModifiedTo: null,
'lastModifiedFrom': null, lastModifiedFrom: null,
'standalone': true standalone: true
}; };
export const assignedTaskDetailsCloudMock: TaskDetailsCloudModel = { export const assignedTaskDetailsCloudMock: TaskDetailsCloudModel = {
'appName': 'task-app', appName: 'task-app',
'appVersion': 1, appVersion: 1,
'id': '68d54a8f-01f3-11e9-8e36-0a58646002ad', id: '68d54a8f-01f3-11e9-8e36-0a58646002ad',
'assignee': 'AssignedTaskUser', assignee: 'AssignedTaskUser',
'name': 'This is a new task', name: 'This is a new task',
'description': 'This is the description ', description: 'This is the description ',
'createdDate': new Date(1545048055900), createdDate: new Date(1545048055900),
'dueDate': new Date(), dueDate: new Date(),
'claimedDate': null, claimedDate: null,
'priority': 1, priority: 1,
'category': null, category: null,
'processDefinitionId': null, processDefinitionId: null,
'processInstanceId': null, processInstanceId: null,
'status': 'ASSIGNED', status: 'ASSIGNED',
'owner': 'ownerUser', owner: 'ownerUser',
'parentTaskId': null, parentTaskId: null,
'formKey': null, formKey: null,
'lastModified': new Date(1545048055900), lastModified: new Date(1545048055900),
'lastModifiedTo': null, lastModifiedTo: null,
'lastModifiedFrom': null, lastModifiedFrom: null,
'standalone': true standalone: true
}; };
export const createdTaskDetailsCloudMock: TaskDetailsCloudModel = { export const createdTaskDetailsCloudMock: TaskDetailsCloudModel = {
'appName': 'task-app', appName: 'task-app',
'appVersion': 1, appVersion: 1,
'id': '68d54a8f-01f3-11e9-8e36-0a58646002ad', id: '68d54a8f-01f3-11e9-8e36-0a58646002ad',
'assignee': 'CreatedTaskUser', assignee: 'CreatedTaskUser',
'name': 'This is a new task', name: 'This is a new task',
'description': 'This is the description ', description: 'This is the description ',
'createdDate': new Date(1545048055900), createdDate: new Date(1545048055900),
'dueDate': new Date(1545091200000), dueDate: new Date(1545091200000),
'claimedDate': null, claimedDate: null,
'priority': 5, priority: 5,
'category': null, category: null,
'processDefinitionId': null, processDefinitionId: null,
'processInstanceId': null, processInstanceId: null,
'status': 'CREATED', status: 'CREATED',
'owner': 'ownerUser', owner: 'ownerUser',
'parentTaskId': null, parentTaskId: null,
'formKey': null, formKey: null,
'lastModified': new Date(1545048055900), lastModified: new Date(1545048055900),
'lastModifiedTo': null, lastModifiedTo: null,
'lastModifiedFrom': null, lastModifiedFrom: null,
'standalone': true standalone: true
}; };
export const emptyOwnerTaskDetailsCloudMock: TaskDetailsCloudModel = { export const emptyOwnerTaskDetailsCloudMock: TaskDetailsCloudModel = {
'appName': 'task-app', appName: 'task-app',
'appVersion': 1, appVersion: 1,
'id': '68d54a8f-01f3-11e9-8e36-0a58646002ad', id: '68d54a8f-01f3-11e9-8e36-0a58646002ad',
'assignee': 'AssignedTaskUser', assignee: 'AssignedTaskUser',
'name': 'This is a new task', name: 'This is a new task',
'description': 'This is the description ', description: 'This is the description ',
'createdDate': new Date(1545048055900), createdDate: new Date(1545048055900),
'dueDate': new Date(1545091200000), dueDate: new Date(1545091200000),
'claimedDate': null, claimedDate: null,
'priority': 5, priority: 5,
'category': null, category: null,
'processDefinitionId': null, processDefinitionId: null,
'processInstanceId': null, processInstanceId: null,
'status': 'ASSIGNED', status: 'ASSIGNED',
'owner': null, owner: null,
'parentTaskId': null, parentTaskId: null,
'formKey': null, formKey: null,
'lastModified': new Date(1545048055900), lastModified: new Date(1545048055900),
'lastModifiedTo': null, lastModifiedTo: null,
'lastModifiedFrom': null, lastModifiedFrom: null,
'standalone': true standalone: true
}; };
export const createdStateTaskDetailsCloudMock: TaskDetailsCloudModel = { export const createdStateTaskDetailsCloudMock: TaskDetailsCloudModel = {
'appName': 'mock-app-name', appName: 'mock-app-name',
'appVersion': 1, appVersion: 1,
'id': 'mock-task-id', id: 'mock-task-id',
'assignee': '', assignee: '',
'name': 'This is a new task', name: 'This is a new task',
'description': 'This is the description ', description: 'This is the description ',
'createdDate': new Date(1545048055900), createdDate: new Date(1545048055900),
'dueDate': new Date(1545091200000), dueDate: new Date(1545091200000),
'claimedDate': null, claimedDate: null,
'priority': 5, priority: 5,
'category': null, category: null,
'processDefinitionId': null, processDefinitionId: null,
'processInstanceId': null, processInstanceId: null,
'status': 'CREATED', status: 'CREATED',
'owner': 'ownerUser', owner: 'ownerUser',
'parentTaskId': null, parentTaskId: null,
'formKey': null, formKey: null,
'lastModified': new Date(1545048055900), lastModified: new Date(1545048055900),
'lastModifiedTo': null, lastModifiedTo: null,
'lastModifiedFrom': null, lastModifiedFrom: null,
'standalone': false standalone: false
}; };
export const completedTaskDetailsCloudMock: TaskDetailsCloudModel = { export const completedTaskDetailsCloudMock: TaskDetailsCloudModel = {
'appName': 'mock-app-name', appName: 'mock-app-name',
'appVersion': 1, appVersion: 1,
'id': 'mock-task-id', id: 'mock-task-id',
'assignee': 'CompletedTaskAssignee', assignee: 'CompletedTaskAssignee',
'name': 'This is a new task', name: 'This is a new task',
'description': 'This is the description ', description: 'This is the description ',
'createdDate': new Date(1545048055900), createdDate: new Date(1545048055900),
'dueDate': new Date(1545091200000), dueDate: new Date(1545091200000),
'completedDate': new Date(1546091200000), completedDate: new Date(1546091200000),
'claimedDate': null, claimedDate: null,
'priority': 5, priority: 5,
'category': null, category: null,
'processDefinitionId': null, processDefinitionId: null,
'processInstanceId': null, processInstanceId: null,
'status': 'COMPLETED', status: 'COMPLETED',
'owner': 'ownerUser', owner: 'ownerUser',
'parentTaskId': null, parentTaskId: null,
'formKey': null, formKey: null,
'lastModified': new Date(1545048055900), lastModified: new Date(1545048055900),
'lastModifiedTo': null, lastModifiedTo: null,
'lastModifiedFrom': null, lastModifiedFrom: null,
'standalone': false standalone: false
}; };
export const cancelledTaskDetailsCloudMock: TaskDetailsCloudModel = { export const cancelledTaskDetailsCloudMock: TaskDetailsCloudModel = {
'appName': 'mock-app-name', appName: 'mock-app-name',
'appVersion': 1, appVersion: 1,
'id': 'mock-task-id', id: 'mock-task-id',
'assignee': 'CancelledTaskAssignee', assignee: 'CancelledTaskAssignee',
'name': 'This is a new task', name: 'This is a new task',
'description': 'This is the description ', description: 'This is the description ',
'createdDate': new Date(1545048055900), createdDate: new Date(1545048055900),
'dueDate': new Date(1545091200000), dueDate: new Date(1545091200000),
'claimedDate': null, claimedDate: null,
'priority': 5, priority: 5,
'category': null, category: null,
'processDefinitionId': null, processDefinitionId: null,
'processInstanceId': null, processInstanceId: null,
'status': 'CANCELLED', status: 'CANCELLED',
'owner': 'ownerUser', owner: 'ownerUser',
'parentTaskId': null, parentTaskId: null,
'formKey': null, formKey: null,
'lastModified': new Date(1545048055900), lastModified: new Date(1545048055900),
'lastModifiedTo': null, lastModifiedTo: null,
'lastModifiedFrom': null, lastModifiedFrom: null,
'standalone': true standalone: true
}; };
export const suspendedTaskDetailsCloudMock: TaskDetailsCloudModel = { export const suspendedTaskDetailsCloudMock: TaskDetailsCloudModel = {
'appName': 'mock-app-name', appName: 'mock-app-name',
'appVersion': 1, appVersion: 1,
'id': 'mock-task-id', id: 'mock-task-id',
'assignee': 'SuspendedTaskAssignee', assignee: 'SuspendedTaskAssignee',
'name': 'This is a new task', name: 'This is a new task',
'description': 'This is the description ', description: 'This is the description ',
'createdDate': new Date(1545048055900), createdDate: new Date(1545048055900),
'dueDate': new Date(1545091200000), dueDate: new Date(1545091200000),
'claimedDate': null, claimedDate: null,
'priority': 5, priority: 5,
'category': null, category: null,
'processDefinitionId': null, processDefinitionId: null,
'processInstanceId': null, processInstanceId: null,
'status': 'SUSPENDED', status: 'SUSPENDED',
'owner': 'ownerUser', owner: 'ownerUser',
'parentTaskId': null, parentTaskId: null,
'formKey': null, formKey: null,
'lastModified': new Date(1545048055900), lastModified: new Date(1545048055900),
'lastModifiedTo': null, lastModifiedTo: null,
'lastModifiedFrom': null, lastModifiedFrom: null,
'standalone': true standalone: true
}; };
export const noCandidateUsersTaskDetailsCloudMock: TaskDetailsCloudModel = { export const noCandidateUsersTaskDetailsCloudMock: TaskDetailsCloudModel = {
'appName': 'mock-app-name', appName: 'mock-app-name',
'appVersion': 1, appVersion: 1,
'id': 'mock-task-id', id: 'mock-task-id',
'assignee': '', assignee: '',
'name': 'This is a new task', name: 'This is a new task',
'description': 'This is the description ', description: 'This is the description ',
'createdDate': new Date(1545048055900), createdDate: new Date(1545048055900),
'dueDate': new Date(1545091200000), dueDate: new Date(1545091200000),
'claimedDate': null, claimedDate: null,
'priority': 5, priority: 5,
'category': null, category: null,
'processDefinitionId': null, processDefinitionId: null,
'processInstanceId': null, processInstanceId: null,
'status': 'CREATED', status: 'CREATED',
'owner': 'ownerUser', owner: 'ownerUser',
'candidateUsers': null, candidateUsers: null,
'parentTaskId': null, parentTaskId: null,
'formKey': null, formKey: null,
'lastModified': new Date(1545048055900), lastModified: new Date(1545048055900),
'lastModifiedTo': null, lastModifiedTo: null,
'lastModifiedFrom': null, lastModifiedFrom: null,
'standalone': false standalone: false
}; };
export const noCandidateGroupsTaskDetailsCloudMock: TaskDetailsCloudModel = { export const noCandidateGroupsTaskDetailsCloudMock: TaskDetailsCloudModel = {
'appName': 'mock-app-name', appName: 'mock-app-name',
'appVersion': 1, appVersion: 1,
'id': 'mock-task-id', id: 'mock-task-id',
'assignee': '', assignee: '',
'name': 'This is a new task', name: 'This is a new task',
'description': 'This is the description ', description: 'This is the description ',
'createdDate': new Date(1545048055900), createdDate: new Date(1545048055900),
'dueDate': new Date(1545091200000), dueDate: new Date(1545091200000),
'claimedDate': null, claimedDate: null,
'priority': 5, priority: 5,
'category': null, category: null,
'processDefinitionId': null, processDefinitionId: null,
'processInstanceId': null, processInstanceId: null,
'status': 'CREATED', status: 'CREATED',
'owner': 'ownerUser', owner: 'ownerUser',
'candidateGroups': null, candidateGroups: null,
'parentTaskId': null, parentTaskId: null,
'formKey': null, formKey: null,
'lastModified': new Date(1545048055900), lastModified: new Date(1545048055900),
'lastModifiedTo': null, lastModifiedTo: null,
'lastModifiedFrom': null, lastModifiedFrom: null,
'standalone': false standalone: false
}; };
export const taskWithFormDetailsMock: TaskDetailsCloudModel = { export const taskWithFormDetailsMock: TaskDetailsCloudModel = {
'appName': 'mock-app-name', appName: 'mock-app-name',
'assignee': 'AssignedTaskUser', assignee: 'AssignedTaskUser',
'completedDate': null, completedDate: null,
'createdDate': new Date(1555419255340), createdDate: new Date(1555419255340),
'dueDate': new Date(1558419255340), dueDate: new Date(1558419255340),
'description': null, description: null,
'formKey': '4', formKey: '4',
'priority': 1, priority: 1,
'parentTaskId': 'bd6b1741-6046-11e9-80f0-0a586460040d', parentTaskId: 'bd6b1741-6046-11e9-80f0-0a586460040d',
'id': 'bd6b1741-6046-11e9-80f0-0a586460040d', id: 'bd6b1741-6046-11e9-80f0-0a586460040d',
'name': 'Task1', name: 'Task1',
'owner': 'fakeAdmin', owner: 'fakeAdmin',
'standalone': true, standalone: true,
'status': 'ASSIGNED' status: 'ASSIGNED'
}; };
export const taskDetailsContainer = { export const taskDetailsContainer = {
@@ -124,7 +124,7 @@ export abstract class BaseTaskListCloudComponent extends DataTableSchema impleme
super(appConfigService, presetKey, taskPresetsCloudDefaultModel); super(appConfigService, presetKey, taskPresetsCloudDefaultModel);
this.size = userPreferences.paginationSize; this.size = userPreferences.paginationSize;
this.pagination = new BehaviorSubject<PaginationModel>(<PaginationModel> { this.pagination = new BehaviorSubject<PaginationModel>({
maxItems: this.size, maxItems: this.size,
skipCount: 0, skipCount: 0,
totalItems: 0 totalItems: 0
@@ -184,6 +184,7 @@ export abstract class BaseTaskListCloudComponent extends DataTableSchema impleme
/** /**
* Resets the pagination values and * Resets the pagination values and
* Reloads the task list * Reloads the task list
*
* @param pagination Pagination values to be set * @param pagination Pagination values to be set
*/ */
updatePagination(pagination: PaginationModel) { updatePagination(pagination: PaginationModel) {
@@ -93,19 +93,19 @@ describe('ServiceTaskListCloudComponent', () => {
component = fixture.componentInstance; component = fixture.componentInstance;
appConfig.config = Object.assign(appConfig.config, { appConfig.config = Object.assign(appConfig.config, {
'adf-cloud-service-task-list': { 'adf-cloud-service-task-list': {
'presets': { presets: {
'fakeCustomSchema': [ fakeCustomSchema: [
{ {
'key': 'fakeName', key: 'fakeName',
'type': 'text', type: 'text',
'title': 'ADF_CLOUD_TASK_LIST.PROPERTIES.FAKE', title: 'ADF_CLOUD_TASK_LIST.PROPERTIES.FAKE',
'sortable': true sortable: true
}, },
{ {
'key': 'fakeTaskName', key: 'fakeTaskName',
'type': 'text', type: 'text',
'title': 'ADF_CLOUD_TASK_LIST.PROPERTIES.TASK_FAKE', title: 'ADF_CLOUD_TASK_LIST.PROPERTIES.TASK_FAKE',
'sortable': true sortable: true
} }
] ]
} }
@@ -209,7 +209,7 @@ describe('ServiceTaskListCloudComponent', () => {
done(); done();
}); });
component.appName = appName.currentValue; component.appName = appName.currentValue;
component.ngOnChanges({ 'appName': appName }); component.ngOnChanges({ appName });
fixture.detectChanges(); fixture.detectChanges();
}); });
@@ -257,7 +257,7 @@ describe('ServiceTaskListCloudComponent', () => {
component.queryParams.status = 'mock-status'; component.queryParams.status = 'mock-status';
const queryParams = new SimpleChange(undefined, { status: 'mock-status' }, true); const queryParams = new SimpleChange(undefined, { status: 'mock-status' }, true);
component.ngOnChanges({ component.ngOnChanges({
'queryParams': queryParams queryParams
}); });
fixture.detectChanges(); fixture.detectChanges();
expect(component.isListEmpty()).toBeFalsy(); expect(component.isListEmpty()).toBeFalsy();
@@ -277,7 +277,7 @@ describe('ServiceTaskListCloudComponent', () => {
]; ];
const sortChange = new SimpleChange(undefined, mockSort, true); const sortChange = new SimpleChange(undefined, mockSort, true);
component.ngOnChanges({ component.ngOnChanges({
'sorting': sortChange sorting: sortChange
}); });
fixture.detectChanges(); fixture.detectChanges();
expect(component.formatSorting).toHaveBeenCalledWith(mockSort); expect(component.formatSorting).toHaveBeenCalledWith(mockSort);
@@ -404,13 +404,13 @@ describe('ServiceTaskListCloudComponent', () => {
const appName = new SimpleChange(null, 'FAKE-APP-NAME', true); const appName = new SimpleChange(null, 'FAKE-APP-NAME', true);
copyFixture.whenStable().then(() => { copyFixture.whenStable().then(() => {
copyFixture.detectChanges(); copyFixture.detectChanges();
const spanHTMLElement = <HTMLInputElement> element.querySelector('span[title="04fdf69f-4ddd-48ab-9563-da776c9b163c"]'); const spanHTMLElement = element.querySelector<HTMLInputElement>('span[title="04fdf69f-4ddd-48ab-9563-da776c9b163c"]');
spanHTMLElement.dispatchEvent(new Event('mouseenter')); spanHTMLElement.dispatchEvent(new Event('mouseenter'));
copyFixture.detectChanges(); copyFixture.detectChanges();
expect(copyFixture.debugElement.nativeElement.querySelector('.adf-copy-tooltip')).not.toBeNull(); expect(copyFixture.debugElement.nativeElement.querySelector('.adf-copy-tooltip')).not.toBeNull();
}); });
customCopyComponent.taskList.appName = appName.currentValue; customCopyComponent.taskList.appName = appName.currentValue;
customCopyComponent.taskList.ngOnChanges({ 'appName': appName }); customCopyComponent.taskList.ngOnChanges({ appName });
copyFixture.detectChanges(); copyFixture.detectChanges();
})); }));
@@ -419,7 +419,7 @@ describe('ServiceTaskListCloudComponent', () => {
customCopyComponent.taskList.success.subscribe(() => { customCopyComponent.taskList.success.subscribe(() => {
copyFixture.whenStable().then(() => { copyFixture.whenStable().then(() => {
copyFixture.detectChanges(); copyFixture.detectChanges();
const spanHTMLElement: HTMLInputElement = <HTMLInputElement> element.querySelector('span[title="serviceTaskName"]'); const spanHTMLElement = element.querySelector<HTMLInputElement>('span[title="serviceTaskName"]');
spanHTMLElement.dispatchEvent(new Event('mouseenter')); spanHTMLElement.dispatchEvent(new Event('mouseenter'));
copyFixture.detectChanges(); copyFixture.detectChanges();
expect(copyFixture.debugElement.nativeElement.querySelector('.adf-copy-tooltip')).toBeNull(); expect(copyFixture.debugElement.nativeElement.querySelector('.adf-copy-tooltip')).toBeNull();
@@ -427,7 +427,7 @@ describe('ServiceTaskListCloudComponent', () => {
}); });
}); });
customCopyComponent.taskList.appName = appName.currentValue; customCopyComponent.taskList.appName = appName.currentValue;
customCopyComponent.taskList.ngOnChanges({ 'appName': appName }); customCopyComponent.taskList.ngOnChanges({ appName });
copyFixture.detectChanges(); copyFixture.detectChanges();
}); });
}); });
@@ -449,20 +449,20 @@ describe('ServiceTaskListCloudComponent', () => {
serviceTaskListCloudService = TestBed.inject(ServiceTaskListCloudService); serviceTaskListCloudService = TestBed.inject(ServiceTaskListCloudService);
appConfig.config = Object.assign(appConfig.config, { appConfig.config = Object.assign(appConfig.config, {
'adf-cloud-service-task-list': { 'adf-cloud-service-task-list': {
'presets': { presets: {
'fakeCustomSchema': [ fakeCustomSchema: [
{ {
'key': 'id', key: 'id',
'type': 'text', type: 'text',
'title': 'ADF_CLOUD_TASK_LIST.PROPERTIES.FAKE', title: 'ADF_CLOUD_TASK_LIST.PROPERTIES.FAKE',
'sortable': true, sortable: true,
'copyContent': true copyContent: true
}, },
{ {
'key': 'activityName', key: 'activityName',
'type': 'text', type: 'text',
'title': 'ADF_CLOUD_TASK_LIST.PROPERTIES.TASK_FAKE', title: 'ADF_CLOUD_TASK_LIST.PROPERTIES.TASK_FAKE',
'sortable': true sortable: true
} }
] ]
} }
@@ -494,7 +494,7 @@ describe('ServiceTaskListCloudComponent', () => {
component.presetColumn = 'fakeCustomSchema'; component.presetColumn = 'fakeCustomSchema';
component.appName = appName.currentValue; component.appName = appName.currentValue;
component.ngOnChanges({ 'appName': appName }); component.ngOnChanges({ appName });
component.ngAfterContentInit(); component.ngAfterContentInit();
})); }));
@@ -512,7 +512,7 @@ describe('ServiceTaskListCloudComponent', () => {
}); });
component.presetColumn = 'fakeCustomSchema'; component.presetColumn = 'fakeCustomSchema';
component.appName = appName.currentValue; component.appName = appName.currentValue;
component.ngOnChanges({ 'appName': appName }); component.ngOnChanges({ appName });
component.ngAfterContentInit(); component.ngAfterContentInit();
})); }));
}); });
@@ -24,6 +24,8 @@ import { BaseTaskListCloudComponent } from './base-task-list-cloud.component';
import { ServiceTaskListCloudService } from '../services/service-task-list-cloud.service'; import { ServiceTaskListCloudService } from '../services/service-task-list-cloud.service';
import { TaskCloudService } from '../../services/task-cloud.service'; import { TaskCloudService } from '../../services/task-cloud.service';
const PRESET_KEY = 'adf-cloud-service-task-list.presets';
@Component({ @Component({
selector: 'adf-cloud-service-task-list', selector: 'adf-cloud-service-task-list',
templateUrl: './base-task-list-cloud.component.html', templateUrl: './base-task-list-cloud.component.html',
@@ -31,9 +33,6 @@ import { TaskCloudService } from '../../services/task-cloud.service';
encapsulation: ViewEncapsulation.None encapsulation: ViewEncapsulation.None
}) })
export class ServiceTaskListCloudComponent extends BaseTaskListCloudComponent { export class ServiceTaskListCloudComponent extends BaseTaskListCloudComponent {
static PRESET_KEY = 'adf-cloud-service-task-list.presets';
@Input() @Input()
queryParams: { [key: string]: any } = {}; queryParams: { [key: string]: any } = {};
@@ -41,7 +40,7 @@ export class ServiceTaskListCloudComponent extends BaseTaskListCloudComponent {
appConfigService: AppConfigService, appConfigService: AppConfigService,
taskCloudService: TaskCloudService, taskCloudService: TaskCloudService,
userPreferences: UserPreferencesService) { userPreferences: UserPreferencesService) {
super(appConfigService, taskCloudService, userPreferences, ServiceTaskListCloudComponent.PRESET_KEY); super(appConfigService, taskCloudService, userPreferences, PRESET_KEY);
} }
load(requestNode: ServiceTaskQueryCloudRequestModel) { load(requestNode: ServiceTaskQueryCloudRequestModel) {
@@ -98,19 +98,19 @@ describe('TaskListCloudComponent', () => {
component = fixture.componentInstance; component = fixture.componentInstance;
appConfig.config = Object.assign(appConfig.config, { appConfig.config = Object.assign(appConfig.config, {
'adf-cloud-task-list': { 'adf-cloud-task-list': {
'presets': { presets: {
'fakeCustomSchema': [ fakeCustomSchema: [
{ {
'key': 'fakeName', key: 'fakeName',
'type': 'text', type: 'text',
'title': 'ADF_CLOUD_TASK_LIST.PROPERTIES.FAKE', title: 'ADF_CLOUD_TASK_LIST.PROPERTIES.FAKE',
'sortable': true sortable: true
}, },
{ {
'key': 'fakeTaskName', key: 'fakeTaskName',
'type': 'text', type: 'text',
'title': 'ADF_CLOUD_TASK_LIST.PROPERTIES.TASK_FAKE', title: 'ADF_CLOUD_TASK_LIST.PROPERTIES.TASK_FAKE',
'sortable': true sortable: true
} }
] ]
} }
@@ -221,7 +221,7 @@ describe('TaskListCloudComponent', () => {
done(); done();
}); });
component.appName = appName.currentValue; component.appName = appName.currentValue;
component.ngOnChanges({ 'appName': appName }); component.ngOnChanges({ appName });
fixture.detectChanges(); fixture.detectChanges();
}); });
@@ -275,10 +275,10 @@ describe('TaskListCloudComponent', () => {
const lastModifiedFromChange = new SimpleChange(undefined, 'mock-lastmodified-date', true); const lastModifiedFromChange = new SimpleChange(undefined, 'mock-lastmodified-date', true);
const ownerChange = new SimpleChange(undefined, 'mock-owner-name', true); const ownerChange = new SimpleChange(undefined, 'mock-owner-name', true);
component.ngOnChanges({ component.ngOnChanges({
'priority': priorityChange, priority: priorityChange,
'status': statusChange, status: statusChange,
'lastModifiedFrom': lastModifiedFromChange, lastModifiedFrom: lastModifiedFromChange,
'owner': ownerChange owner: ownerChange
}); });
fixture.detectChanges(); fixture.detectChanges();
expect(component.isListEmpty()).toBeFalsy(); expect(component.isListEmpty()).toBeFalsy();
@@ -298,7 +298,7 @@ describe('TaskListCloudComponent', () => {
]; ];
const sortChange = new SimpleChange(undefined, mockSort, true); const sortChange = new SimpleChange(undefined, mockSort, true);
component.ngOnChanges({ component.ngOnChanges({
'sorting': sortChange sorting: sortChange
}); });
fixture.detectChanges(); fixture.detectChanges();
expect(component.formatSorting).toHaveBeenCalledWith(mockSort); expect(component.formatSorting).toHaveBeenCalledWith(mockSort);
@@ -383,7 +383,7 @@ describe('TaskListCloudComponent', () => {
let fixtureCustom: ComponentFixture<CustomTaskListComponent>; let fixtureCustom: ComponentFixture<CustomTaskListComponent>;
let componentCustom: CustomTaskListComponent; let componentCustom: CustomTaskListComponent;
let customCopyComponent: CustomCopyContentTaskListComponent; let customCopyComponent: CustomCopyContentTaskListComponent;
let element: any; let element: HTMLElement;
let copyFixture: ComponentFixture<CustomCopyContentTaskListComponent>; let copyFixture: ComponentFixture<CustomCopyContentTaskListComponent>;
setupTestBed({ setupTestBed({
@@ -425,13 +425,13 @@ describe('TaskListCloudComponent', () => {
const appName = new SimpleChange(null, 'FAKE-APP-NAME', true); const appName = new SimpleChange(null, 'FAKE-APP-NAME', true);
copyFixture.whenStable().then(() => { copyFixture.whenStable().then(() => {
copyFixture.detectChanges(); copyFixture.detectChanges();
const spanHTMLElement: HTMLInputElement = <HTMLInputElement> element.querySelector('span[title="11fe013d-c263-11e8-b75b-0a5864600540"]'); const spanHTMLElement = element.querySelector<HTMLInputElement>('span[title="11fe013d-c263-11e8-b75b-0a5864600540"]');
spanHTMLElement.dispatchEvent(new Event('mouseenter')); spanHTMLElement.dispatchEvent(new Event('mouseenter'));
copyFixture.detectChanges(); copyFixture.detectChanges();
expect(copyFixture.debugElement.nativeElement.querySelector('.adf-copy-tooltip')).not.toBeNull(); expect(copyFixture.debugElement.nativeElement.querySelector('.adf-copy-tooltip')).not.toBeNull();
}); });
customCopyComponent.taskList.appName = appName.currentValue; customCopyComponent.taskList.appName = appName.currentValue;
customCopyComponent.taskList.ngOnChanges({ 'appName': appName }); customCopyComponent.taskList.ngOnChanges({ appName });
copyFixture.detectChanges(); copyFixture.detectChanges();
})); }));
@@ -440,7 +440,7 @@ describe('TaskListCloudComponent', () => {
customCopyComponent.taskList.success.subscribe(() => { customCopyComponent.taskList.success.subscribe(() => {
copyFixture.whenStable().then(() => { copyFixture.whenStable().then(() => {
copyFixture.detectChanges(); copyFixture.detectChanges();
const spanHTMLElement: HTMLInputElement = <HTMLInputElement> element.querySelector('span[title="standalone-subtask"]'); const spanHTMLElement = element.querySelector<HTMLInputElement>('span[title="standalone-subtask"]');
spanHTMLElement.dispatchEvent(new Event('mouseenter')); spanHTMLElement.dispatchEvent(new Event('mouseenter'));
copyFixture.detectChanges(); copyFixture.detectChanges();
expect(copyFixture.debugElement.nativeElement.querySelector('.adf-copy-tooltip')).toBeNull(); expect(copyFixture.debugElement.nativeElement.querySelector('.adf-copy-tooltip')).toBeNull();
@@ -448,7 +448,7 @@ describe('TaskListCloudComponent', () => {
}); });
}); });
customCopyComponent.taskList.appName = appName.currentValue; customCopyComponent.taskList.appName = appName.currentValue;
customCopyComponent.taskList.ngOnChanges({ 'appName': appName }); customCopyComponent.taskList.ngOnChanges({ appName });
copyFixture.detectChanges(); copyFixture.detectChanges();
}); });
}); });
@@ -483,7 +483,7 @@ describe('TaskListCloudComponent', () => {
describe('Copy cell content directive from app.config specifications', () => { describe('Copy cell content directive from app.config specifications', () => {
let element: any; let element: HTMLElement;
let taskSpy: jasmine.Spy; let taskSpy: jasmine.Spy;
setupTestBed({ setupTestBed({
@@ -498,26 +498,26 @@ describe('TaskListCloudComponent', () => {
taskListCloudService = TestBed.inject(TaskListCloudService); taskListCloudService = TestBed.inject(TaskListCloudService);
appConfig.config = Object.assign(appConfig.config, { appConfig.config = Object.assign(appConfig.config, {
'adf-cloud-task-list': { 'adf-cloud-task-list': {
'presets': { presets: {
'fakeCustomSchema': [ fakeCustomSchema: [
{ {
'key': 'id', key: 'id',
'type': 'text', type: 'text',
'title': 'ADF_CLOUD_TASK_LIST.PROPERTIES.FAKE', title: 'ADF_CLOUD_TASK_LIST.PROPERTIES.FAKE',
'sortable': true, sortable: true,
'copyContent': true copyContent: true
}, },
{ {
'key': 'name', key: 'name',
'type': 'text', type: 'text',
'title': 'ADF_CLOUD_TASK_LIST.PROPERTIES.TASK_FAKE', title: 'ADF_CLOUD_TASK_LIST.PROPERTIES.TASK_FAKE',
'sortable': true sortable: true
}, },
{ {
'key': 'entry.priority', key: 'entry.priority',
'type': 'text', type: 'text',
'title': 'ADF_TASK_LIST.PROPERTIES.PRIORITY', title: 'ADF_TASK_LIST.PROPERTIES.PRIORITY',
'sortable': true sortable: true
} }
] ]
} }
@@ -542,7 +542,7 @@ describe('TaskListCloudComponent', () => {
component.success.subscribe(() => { component.success.subscribe(() => {
fixture.whenStable().then(() => { fixture.whenStable().then(() => {
fixture.detectChanges(); fixture.detectChanges();
const spanHTMLElement: HTMLInputElement = <HTMLInputElement> element.querySelector('span[title="11fe013d-c263-11e8-b75b-0a5864600540"]'); const spanHTMLElement = element.querySelector<HTMLInputElement>('span[title="11fe013d-c263-11e8-b75b-0a5864600540"]');
spanHTMLElement.dispatchEvent(new Event('mouseenter')); spanHTMLElement.dispatchEvent(new Event('mouseenter'));
fixture.detectChanges(); fixture.detectChanges();
expect(fixture.debugElement.nativeElement.querySelector('.adf-copy-tooltip')).not.toBeNull(); expect(fixture.debugElement.nativeElement.querySelector('.adf-copy-tooltip')).not.toBeNull();
@@ -551,7 +551,7 @@ describe('TaskListCloudComponent', () => {
component.presetColumn = 'fakeCustomSchema'; component.presetColumn = 'fakeCustomSchema';
component.appName = appName.currentValue; component.appName = appName.currentValue;
component.ngOnChanges({ 'appName': appName }); component.ngOnChanges({ appName });
component.ngAfterContentInit(); component.ngAfterContentInit();
})); }));
@@ -22,6 +22,8 @@ import { TaskListCloudService } from '../services/task-list-cloud.service';
import { BaseTaskListCloudComponent } from './base-task-list-cloud.component'; import { BaseTaskListCloudComponent } from './base-task-list-cloud.component';
import { TaskCloudService } from '../../services/task-cloud.service'; import { TaskCloudService } from '../../services/task-cloud.service';
const PRESET_KEY = 'adf-cloud-task-list.presets';
@Component({ @Component({
selector: 'adf-cloud-task-list', selector: 'adf-cloud-task-list',
templateUrl: './base-task-list-cloud.component.html', templateUrl: './base-task-list-cloud.component.html',
@@ -29,9 +31,6 @@ import { TaskCloudService } from '../../services/task-cloud.service';
encapsulation: ViewEncapsulation.None encapsulation: ViewEncapsulation.None
}) })
export class TaskListCloudComponent extends BaseTaskListCloudComponent { export class TaskListCloudComponent extends BaseTaskListCloudComponent {
static PRESET_KEY = 'adf-cloud-task-list.presets';
/** /**
* The assignee of the process. Possible values are: "assignee" (the current user is the assignee), * The assignee of the process. Possible values are: "assignee" (the current user is the assignee),
* "candidate" (the current user is a task candidate", "group_x" (the task is assigned to a group * "candidate" (the current user is a task candidate", "group_x" (the task is assigned to a group
@@ -136,7 +135,7 @@ export class TaskListCloudComponent extends BaseTaskListCloudComponent {
appConfigService: AppConfigService, appConfigService: AppConfigService,
taskCloudService: TaskCloudService, taskCloudService: TaskCloudService,
userPreferences: UserPreferencesService) { userPreferences: UserPreferencesService) {
super(appConfigService, taskCloudService, userPreferences, TaskListCloudComponent.PRESET_KEY); super(appConfigService, taskCloudService, userPreferences, PRESET_KEY);
} }
load(requestNode: TaskQueryCloudRequestModel) { load(requestNode: TaskQueryCloudRequestModel) {
@@ -88,15 +88,15 @@ export const fakeServiceTask = {
export const fakeCustomSchema = export const fakeCustomSchema =
[ [
new ObjectDataColumn({ new ObjectDataColumn({
'key': 'fakeName', key: 'fakeName',
'type': 'text', type: 'text',
'title': 'ADF_CLOUD_TASK_LIST.PROPERTIES.FAKE', title: 'ADF_CLOUD_TASK_LIST.PROPERTIES.FAKE',
'sortable': true sortable: true
}), }),
new ObjectDataColumn({ new ObjectDataColumn({
'key': 'fakeTaskName', key: 'fakeTaskName',
'type': 'text', type: 'text',
'title': 'ADF_CLOUD_TASK_LIST.PROPERTIES.TASK_FAKE', title: 'ADF_CLOUD_TASK_LIST.PROPERTIES.TASK_FAKE',
'sortable': true sortable: true
}) })
]; ];
@@ -16,57 +16,57 @@
*/ */
export const taskPresetsCloudDefaultModel = { export const taskPresetsCloudDefaultModel = {
'default': [ default: [
{ {
'key': 'name', key: 'name',
'type': 'text', type: 'text',
'title': 'ADF_CLOUD_TASK_LIST.PROPERTIES.NAME', title: 'ADF_CLOUD_TASK_LIST.PROPERTIES.NAME',
'sortable': true sortable: true
}, },
{ {
'key': 'created', key: 'created',
'type': 'text', type: 'text',
'title': 'ADF_CLOUD_TASK_LIST.PROPERTIES.CREATED', title: 'ADF_CLOUD_TASK_LIST.PROPERTIES.CREATED',
'cssClass': 'hidden', cssClass: 'hidden',
'sortable': true sortable: true
}, },
{ {
'key': 'assignee', key: 'assignee',
'type': 'text', type: 'text',
'title': 'ADF_CLOUD_TASK_LIST.PROPERTIES.ASSIGNEE', title: 'ADF_CLOUD_TASK_LIST.PROPERTIES.ASSIGNEE',
'cssClass': 'hidden', cssClass: 'hidden',
'sortable': true sortable: true
} }
] ]
}; };
export const serviceTaskPresetsCloudDefaultModel = { export const serviceTaskPresetsCloudDefaultModel = {
'default': [ default: [
{ {
'key': 'activityName', key: 'activityName',
'type': 'text', type: 'text',
'title': 'ADF_CLOUD_SERVICE_TASK_LIST.PROPERTIES.ACTIVITY_NAME', title: 'ADF_CLOUD_SERVICE_TASK_LIST.PROPERTIES.ACTIVITY_NAME',
'sortable': true sortable: true
}, },
{ {
'key': 'status', key: 'status',
'type': 'text', type: 'text',
'title': 'ADF_CLOUD_SERVICE_TASK_LIST.PROPERTIES.STATUS', title: 'ADF_CLOUD_SERVICE_TASK_LIST.PROPERTIES.STATUS',
'sortable': true sortable: true
}, },
{ {
'key': 'startedDate', key: 'startedDate',
'type': 'text', type: 'text',
'title': 'ADF_CLOUD_SERVICE_TASK_LIST.PROPERTIES.STARTED_DATE', title: 'ADF_CLOUD_SERVICE_TASK_LIST.PROPERTIES.STARTED_DATE',
'cssClass': 'hidden', cssClass: 'hidden',
'sortable': true sortable: true
}, },
{ {
'key': 'completedDate', key: 'completedDate',
'type': 'text', type: 'text',
'title': 'ADF_CLOUD_SERVICE_TASK_LIST.PROPERTIES.COMPLETED_DATE', title: 'ADF_CLOUD_SERVICE_TASK_LIST.PROPERTIES.COMPLETED_DATE',
'cssClass': 'hidden', cssClass: 'hidden',
'sortable': true sortable: true
} }
] ]
}; };
@@ -26,32 +26,20 @@ describe('Activiti ServiceTaskList Cloud Service', () => {
let service: ServiceTaskListCloudService; let service: ServiceTaskListCloudService;
let alfrescoApiService: AlfrescoApiService; let alfrescoApiService: AlfrescoApiService;
function returnCallQueryParameters(): any { const returnCallQueryParameters = (): any => ({
return {
oauth2Auth: { oauth2Auth: {
callCustomApi: (_queryUrl, _operation, _context, queryParams) => { callCustomApi: (_queryUrl, _operation, _context, queryParams) => Promise.resolve(queryParams)
return Promise.resolve(queryParams);
}
},
isEcmLoggedIn() {
return false;
}, },
isEcmLoggedIn: () => false,
reply: jasmine.createSpy('reply') reply: jasmine.createSpy('reply')
}; });
}
function returnCallUrl(): any { const returnCallUrl = (): any => ({
return {
oauth2Auth: { oauth2Auth: {
callCustomApi: (queryUrl) => { callCustomApi: (queryUrl) => Promise.resolve(queryUrl)
return Promise.resolve(queryUrl);
}
}, },
isEcmLoggedIn() { isEcmLoggedIn: () => false
return false; });
}
};
}
setupTestBed({ setupTestBed({
imports: [ imports: [
@@ -65,7 +53,7 @@ describe('Activiti ServiceTaskList Cloud Service', () => {
}); });
it('should append to the call all the parameters', (done) => { it('should append to the call all the parameters', (done) => {
const taskRequest: ServiceTaskQueryCloudRequestModel = <ServiceTaskQueryCloudRequestModel> { appName: 'fakeName', skipCount: 0, maxItems: 20, service: 'fake-service' }; const taskRequest = { appName: 'fakeName', skipCount: 0, maxItems: 20, service: 'fake-service' } as ServiceTaskQueryCloudRequestModel;
spyOn(alfrescoApiService, 'getInstance').and.callFake(returnCallQueryParameters); spyOn(alfrescoApiService, 'getInstance').and.callFake(returnCallQueryParameters);
service.getServiceTaskByRequest(taskRequest).subscribe((res) => { service.getServiceTaskByRequest(taskRequest).subscribe((res) => {
expect(res).toBeDefined(); expect(res).toBeDefined();
@@ -78,7 +66,7 @@ describe('Activiti ServiceTaskList Cloud Service', () => {
}); });
it('should concat the app name to the request url', (done) => { it('should concat the app name to the request url', (done) => {
const taskRequest: ServiceTaskQueryCloudRequestModel = <ServiceTaskQueryCloudRequestModel> { appName: 'fakeName', skipCount: 0, maxItems: 20, service: 'fake-service' }; const taskRequest = { appName: 'fakeName', skipCount: 0, maxItems: 20, service: 'fake-service' } as ServiceTaskQueryCloudRequestModel;
spyOn(alfrescoApiService, 'getInstance').and.callFake(returnCallUrl); spyOn(alfrescoApiService, 'getInstance').and.callFake(returnCallUrl);
service.getServiceTaskByRequest(taskRequest).subscribe((requestUrl) => { service.getServiceTaskByRequest(taskRequest).subscribe((requestUrl) => {
expect(requestUrl).toBeDefined(); expect(requestUrl).toBeDefined();
@@ -89,10 +77,10 @@ describe('Activiti ServiceTaskList Cloud Service', () => {
}); });
it('should concat the sorting to append as parameters', (done) => { it('should concat the sorting to append as parameters', (done) => {
const taskRequest: ServiceTaskQueryCloudRequestModel = <ServiceTaskQueryCloudRequestModel> { const taskRequest = {
appName: 'fakeName', skipCount: 0, maxItems: 20, service: 'fake-service', appName: 'fakeName', skipCount: 0, maxItems: 20, service: 'fake-service',
sorting: [{ orderBy: 'NAME', direction: 'DESC' }, { orderBy: 'TITLE', direction: 'ASC' }] sorting: [{ orderBy: 'NAME', direction: 'DESC' }, { orderBy: 'TITLE', direction: 'ASC' }]
}; } as ServiceTaskQueryCloudRequestModel;
spyOn(alfrescoApiService, 'getInstance').and.callFake(returnCallQueryParameters); spyOn(alfrescoApiService, 'getInstance').and.callFake(returnCallQueryParameters);
service.getServiceTaskByRequest(taskRequest).subscribe((res) => { service.getServiceTaskByRequest(taskRequest).subscribe((res) => {
expect(res).toBeDefined(); expect(res).toBeDefined();
@@ -103,7 +91,7 @@ describe('Activiti ServiceTaskList Cloud Service', () => {
}); });
it('should return an error when app name is not specified', (done) => { it('should return an error when app name is not specified', (done) => {
const taskRequest: ServiceTaskQueryCloudRequestModel = <ServiceTaskQueryCloudRequestModel> { appName: null }; const taskRequest = { appName: null } as ServiceTaskQueryCloudRequestModel;
spyOn(alfrescoApiService, 'getInstance').and.callFake(returnCallUrl); spyOn(alfrescoApiService, 'getInstance').and.callFake(returnCallUrl);
service.getServiceTaskByRequest(taskRequest).subscribe( service.getServiceTaskByRequest(taskRequest).subscribe(
() => { }, () => { },
@@ -27,32 +27,20 @@ describe('TaskListCloudService', () => {
let service: TaskListCloudService; let service: TaskListCloudService;
let alfrescoApiService: AlfrescoApiService; let alfrescoApiService: AlfrescoApiService;
function returnCallQueryParameters(): any { const returnCallQueryParameters = (): any => ({
return {
oauth2Auth: { oauth2Auth: {
callCustomApi : (_queryUrl, _operation, _context, queryParams) => { callCustomApi : (_queryUrl, _operation, _context, queryParams) => Promise.resolve(queryParams)
return Promise.resolve(queryParams);
}
},
isEcmLoggedIn() {
return false;
}, },
isEcmLoggedIn: () => false,
reply: jasmine.createSpy('reply') reply: jasmine.createSpy('reply')
}; });
}
function returnCallUrl(): any { const returnCallUrl = (): any => ({
return {
oauth2Auth: { oauth2Auth: {
callCustomApi : (queryUrl) => { callCustomApi : (queryUrl) => Promise.resolve(queryUrl)
return Promise.resolve(queryUrl);
}
}, },
isEcmLoggedIn() { isEcmLoggedIn: () => false
return false; });
}
};
}
setupTestBed({ setupTestBed({
imports: [ imports: [
@@ -67,7 +55,7 @@ describe('TaskListCloudService', () => {
}); });
it('should append to the call all the parameters', (done) => { it('should append to the call all the parameters', (done) => {
const taskRequest: TaskQueryCloudRequestModel = <TaskQueryCloudRequestModel> { appName: 'fakeName', skipCount: 0, maxItems: 20, service: 'fake-service' }; const taskRequest = { appName: 'fakeName', skipCount: 0, maxItems: 20, service: 'fake-service' } as TaskQueryCloudRequestModel;
spyOn(alfrescoApiService, 'getInstance').and.callFake(returnCallQueryParameters); spyOn(alfrescoApiService, 'getInstance').and.callFake(returnCallQueryParameters);
service.getTaskByRequest(taskRequest).subscribe((res) => { service.getTaskByRequest(taskRequest).subscribe((res) => {
expect(res).toBeDefined(); expect(res).toBeDefined();
@@ -80,7 +68,7 @@ describe('TaskListCloudService', () => {
}); });
it('should concat the app name to the request url', (done) => { it('should concat the app name to the request url', (done) => {
const taskRequest: TaskQueryCloudRequestModel = <TaskQueryCloudRequestModel> { appName: 'fakeName', skipCount: 0, maxItems: 20, service: 'fake-service' }; const taskRequest = { appName: 'fakeName', skipCount: 0, maxItems: 20, service: 'fake-service' } as TaskQueryCloudRequestModel;
spyOn(alfrescoApiService, 'getInstance').and.callFake(returnCallUrl); spyOn(alfrescoApiService, 'getInstance').and.callFake(returnCallUrl);
service.getTaskByRequest(taskRequest).subscribe((requestUrl) => { service.getTaskByRequest(taskRequest).subscribe((requestUrl) => {
expect(requestUrl).toBeDefined(); expect(requestUrl).toBeDefined();
@@ -91,8 +79,8 @@ describe('TaskListCloudService', () => {
}); });
it('should concat the sorting to append as parameters', (done) => { it('should concat the sorting to append as parameters', (done) => {
const taskRequest: TaskQueryCloudRequestModel = <TaskQueryCloudRequestModel> { appName: 'fakeName', skipCount: 0, maxItems: 20, service: 'fake-service', const taskRequest = { appName: 'fakeName', skipCount: 0, maxItems: 20, service: 'fake-service',
sorting: [{ orderBy: 'NAME', direction: 'DESC'}, { orderBy: 'TITLE', direction: 'ASC'}] }; sorting: [{ orderBy: 'NAME', direction: 'DESC'}, { orderBy: 'TITLE', direction: 'ASC'}] } as TaskQueryCloudRequestModel;
spyOn(alfrescoApiService, 'getInstance').and.callFake(returnCallQueryParameters); spyOn(alfrescoApiService, 'getInstance').and.callFake(returnCallQueryParameters);
service.getTaskByRequest(taskRequest).subscribe((res) => { service.getTaskByRequest(taskRequest).subscribe((res) => {
expect(res).toBeDefined(); expect(res).toBeDefined();
@@ -103,7 +91,7 @@ describe('TaskListCloudService', () => {
}); });
it('should return an error when app name is not specified', (done) => { it('should return an error when app name is not specified', (done) => {
const taskRequest: TaskQueryCloudRequestModel = <TaskQueryCloudRequestModel> { appName: null }; const taskRequest = { appName: null } as TaskQueryCloudRequestModel;
spyOn(alfrescoApiService, 'getInstance').and.callFake(returnCallUrl); spyOn(alfrescoApiService, 'getInstance').and.callFake(returnCallUrl);
service.getTaskByRequest(taskRequest).subscribe( service.getTaskByRequest(taskRequest).subscribe(
() => { }, () => { },