👽 Angular 14 rebase 👽 (#7769)

* fix after rebase

* new release strategy for ng next

Signed-off-by: eromano <eugenioromano16@gmail.com>

* peer dep

Signed-off-by: eromano <eugenioromano16@gmail.com>

* Angular 14

fix unit test and storybook

Signed-off-by: eromano <eugenioromano16@gmail.com>

fix after rebase

Signed-off-by: eromano <eugenioromano16@gmail.com>

update pkg.json

Signed-off-by: eromano <eugenioromano16@gmail.com>

missing dep

Signed-off-by: eromano <eugenioromano16@gmail.com>

Fix mistake and missing code

Dream....build only affected libs

Add utility run commands

* Use nx command to run affected tests

* Fix nx test core

fix content tests

Run unit with watch false

core test fixes

reduce test warnings

Fix process cloud unit

Fix adf unit test

Fix lint process cloud

Disable lint next line

Use right core path

Fix insights unit

fix linting insights

Fix process-services unit

fix the extensions test report

fix test warnings

Fix content unit

Fix bunch of content unit

* Produce an adf alpha of 14

* hopefully fixing the content

* Push back the npm publish

* Remove flaky unit

* Fix linting

* Make the branch as root

* Get rid of angualar13

* Remove the travis depth

* Fixing version for npm

* Enabling cache for unit and build

* Fix scss for core and paths

Copy i18 and asset by using ng-packager

Export the theming alias and fix path

Use ng-package to copy assets process-services-cloud

Use ng-package to copy assets process-services

Use ng-package to copy assets content-services

Use ng-package to copy assets insights

* feat: fix api secondary entry point

* fix storybook rebase

* Move dist under dist/libs from lib/dist

* Fix the webstyle

* Use only necessary nrwl deps and improve lint

* Fix unit for libs

* Convert lint.sh to targets - improve performance

* Use latest of angular

* Align alfresco-js-api

Signed-off-by: eromano <eugenioromano16@gmail.com>
Co-authored-by: eromano <eugenioromano16@gmail.com>
Co-authored-by: Mikolaj Serwicki <mikolaj.serwicki@hyland.com>
Co-authored-by: Tomasz <tomasz.gnyp@hyland.com>
This commit is contained in:
Maurizio Vitale
2022-08-25 10:50:30 +01:00
committed by GitHub
parent 53bc5aab2c
commit 1fa81962a0
1351 changed files with 26853 additions and 11958 deletions

View File

@@ -17,7 +17,7 @@
import { UserProcessModel, TranslationService, PeopleProcessService } from '@alfresco/adf-core';
import { Component, EventEmitter, Input, Output, ViewEncapsulation } from '@angular/core';
import { FormControl } from '@angular/forms';
import { UntypedFormControl } from '@angular/forms';
import { debounceTime, switchMap } from 'rxjs/operators';
import { Observable, of } from 'rxjs';
import { PerformSearchCallback } from '../../interfaces/perform-search-callback.interface';
@@ -43,7 +43,7 @@ export class PeopleSearchFieldComponent {
rowClick = new EventEmitter<UserProcessModel>();
users$: Observable<UserProcessModel[]>;
searchUser: FormControl = new FormControl();
searchUser: UntypedFormControl = new UntypedFormControl();
defaultPlaceholder = 'ADF_TASK_LIST.PEOPLE.SEARCH_USER';

View File

@@ -191,42 +191,36 @@ describe('PeopleComponent', () => {
jasmine.Ajax.uninstall();
});
it('should log error message when search fails', fakeAsync(() => {
activitiPeopleComponent.peopleSearch$.subscribe(() => {
it('should log error message when search fails', async () => {
await activitiPeopleComponent.peopleSearch$.subscribe(() => {
expect(logService.error).toHaveBeenCalledWith('Could not load users');
});
activitiPeopleComponent.searchUser('fake-search');
jasmine.Ajax.requests.mostRecent().respondWith({
status: 403
});
}));
});
it('should not remove user if remove involved user fail', fakeAsync(() => {
it('should not remove user if remove involved user fail', async () => {
activitiPeopleComponent.removeInvolvedUser(fakeUser);
jasmine.Ajax.requests.mostRecent().respondWith({
status: 403
});
fixture.whenStable()
.then(() => {
fixture.detectChanges();
const gatewayElement: any = element.querySelector('#assignment-people-list .adf-datatable-body');
expect(gatewayElement).not.toBeNull();
expect(gatewayElement.children.length).toBe(2);
});
}));
await fixture.whenStable();
const gatewayElement: any = element.querySelector('#assignment-people-list .adf-datatable-body');
expect(gatewayElement).not.toBeNull();
expect(gatewayElement.children.length).toBe(2);
});
it('should not involve user if involve user fail', fakeAsync(() => {
it('should not involve user if involve user fail', async () => {
activitiPeopleComponent.involveUser(fakeUser);
jasmine.Ajax.requests.mostRecent().respondWith({
status: 403
});
fixture.whenStable()
.then(() => {
fixture.detectChanges();
const gatewayElement: any = element.querySelector('#assignment-people-list .adf-datatable-body');
expect(gatewayElement).not.toBeNull();
expect(gatewayElement.children.length).toBe(2);
});
}));
await fixture.whenStable();
const gatewayElement: any = element.querySelector('#assignment-people-list .adf-datatable-body');
expect(gatewayElement).not.toBeNull();
expect(gatewayElement.children.length).toBe(2);
});
});
});

View File

@@ -53,19 +53,18 @@ describe('ProcessFiltersComponent', () => {
fixture.destroy();
});
it('should return the filter task list', async (done) => {
it('should return the filter task list', async () => {
spyOn(processFilterService, 'getProcessFilters').and.returnValue(of(fakeProcessFilters));
const appId = '1';
const change = new SimpleChange(null, appId, true);
filterList.success.subscribe((res) => {
await filterList.success.subscribe((res) => {
expect(res).toBeDefined();
expect(filterList.filters).toBeDefined();
expect(filterList.filters.length).toEqual(3);
expect(filterList.filters[0].name).toEqual('FakeCompleted');
expect(filterList.filters[1].name).toEqual('FakeAll');
expect(filterList.filters[2].name).toEqual('Running');
done();
});
spyOn(filterList, 'getFiltersByAppId').and.callThrough();
@@ -78,16 +77,15 @@ describe('ProcessFiltersComponent', () => {
expect(filterList.getFiltersByAppId).toHaveBeenCalled();
});
it('should select the Running process filter', async (done) => {
it('should select the Running process filter', async () => {
spyOn(processFilterService, 'getProcessFilters').and.returnValue(of(fakeProcessFilters));
const appId = '1';
const change = new SimpleChange(null, appId, true);
filterList.success.subscribe(() => {
await filterList.success.subscribe(() => {
filterList.selectRunningFilter();
expect(filterList.currentFilter.name).toEqual('Running');
done();
});
filterList.ngOnChanges({ appId: change });
@@ -96,15 +94,14 @@ describe('ProcessFiltersComponent', () => {
await fixture.whenStable();
});
it('should emit the selected filter based on the filterParam input', async (done) => {
it('should emit the selected filter based on the filterParam input', async () => {
spyOn(processFilterService, 'getProcessFilters').and.returnValue(of(fakeProcessFilters));
filterList.filterParam = new FilterProcessRepresentationModel({ id: 10 });
const appId = '1';
const change = new SimpleChange(null, appId, true);
filterList.filterSelected.subscribe((filter) => {
await filterList.filterSelected.subscribe((filter) => {
expect(filter.name).toEqual('FakeCompleted');
done();
});
filterList.ngOnChanges({ appId: change });
@@ -142,24 +139,23 @@ describe('ProcessFiltersComponent', () => {
expect(filterList.currentFilter).toBe(undefined);
});
it('should return the filter task list, filtered By Name', (done) => {
it('should return the filter task list, filtered By Name', async () => {
spyOn(appsProcessService, 'getDeployedApplicationsByName').and.returnValue(from(Promise.resolve({ id: 1 })));
spyOn(processFilterService, 'getProcessFilters').and.returnValue(of(fakeProcessFilters));
const change = new SimpleChange(null, 'test', true);
filterList.ngOnChanges({ appName: change });
filterList.success.subscribe((res) => {
await filterList.success.subscribe((res) => {
const deployApp: any = appsProcessService.getDeployedApplicationsByName;
expect(deployApp.calls.count()).toEqual(1);
expect(res).toBeDefined();
done();
});
fixture.detectChanges();
});
it('should emit an error with a bad response', (done) => {
it('should emit an error with a bad response', async () => {
const mockErrorFilterPromise = Promise.reject({
error: 'wrong request'
});
@@ -169,15 +165,14 @@ describe('ProcessFiltersComponent', () => {
const change = new SimpleChange(null, appId, true);
filterList.ngOnChanges({ appId: change });
filterList.error.subscribe((err) => {
await filterList.error.subscribe((err) => {
expect(err).toBeDefined();
done();
});
fixture.detectChanges();
});
it('should emit an error with a bad response', (done) => {
it('should emit an error with a bad response', async () => {
const mockErrorFilterPromise = Promise.reject({
error: 'wrong request'
});
@@ -187,26 +182,24 @@ describe('ProcessFiltersComponent', () => {
const change = new SimpleChange(null, appId, true);
filterList.ngOnChanges({ appName: change });
filterList.error.subscribe((err) => {
await filterList.error.subscribe((err) => {
expect(err).toBeDefined();
done();
});
fixture.detectChanges();
});
it('should emit an event when a filter is selected', (done) => {
it('should emit an event when a filter is selected', async () => {
const currentFilter = new FilterProcessRepresentationModel({
id: 10,
name: 'FakeCompleted',
filter: { state: 'open', assignment: 'fake-involved' }
});
filterList.filterClicked.subscribe((filter) => {
await filterList.filterClicked.subscribe((filter) => {
expect(filter).toBeDefined();
expect(filter).toEqual(currentFilter);
expect(filterList.currentFilter).toEqual(currentFilter);
done();
});
filterList.selectFilter(currentFilter);
@@ -252,7 +245,7 @@ describe('ProcessFiltersComponent', () => {
expect(filterList.getCurrentFilter()).toBe(filter);
});
it('should select the filter passed as input by id', (done) => {
it('should select the filter passed as input by id', async () => {
spyOn(processFilterService, 'getProcessFilters').and.returnValue(of(fakeProcessFilters));
filterList.filterParam = new FilterProcessRepresentationModel({ id: 20 });
@@ -262,17 +255,14 @@ describe('ProcessFiltersComponent', () => {
filterList.ngOnChanges({ appId: change });
fixture.whenStable().then(() => {
fixture.detectChanges();
expect(filterList.filters).toBeDefined();
expect(filterList.filters.length).toEqual(3);
expect(filterList.currentFilter).toBeDefined();
expect(filterList.currentFilter.name).toEqual('FakeAll');
done();
});
await fixture.whenStable();
expect(filterList.filters).toBeDefined();
expect(filterList.filters.length).toEqual(3);
expect(filterList.currentFilter).toBeDefined();
expect(filterList.currentFilter.name).toEqual('FakeAll');
});
it('should select the filter passed as input by name', (done) => {
it('should select the filter passed as input by name', async () => {
spyOn(processFilterService, 'getProcessFilters').and.returnValue(of(fakeProcessFilters));
filterList.filterParam = new FilterProcessRepresentationModel({ name: 'FakeAll' });
@@ -282,45 +272,36 @@ describe('ProcessFiltersComponent', () => {
filterList.ngOnChanges({ appId: change });
fixture.whenStable().then(() => {
fixture.detectChanges();
expect(filterList.filters).toBeDefined();
expect(filterList.filters.length).toEqual(3);
expect(filterList.currentFilter).toBeDefined();
expect(filterList.currentFilter.name).toEqual('FakeAll');
done();
});
await fixture.whenStable();
expect(filterList.filters).toBeDefined();
expect(filterList.filters.length).toEqual(3);
expect(filterList.currentFilter).toBeDefined();
expect(filterList.currentFilter.name).toEqual('FakeAll');
});
it('should attach specific icon for each filter if hasIcon is true', (done) => {
it('should attach specific icon for each filter if hasIcon is true', async () => {
spyOn(processFilterService, 'getProcessFilters').and.returnValue(of(fakeProcessFilters));
filterList.showIcon = true;
const change = new SimpleChange(undefined, 1, true);
filterList.ngOnChanges({ appId: change });
fixture.detectChanges();
fixture.whenStable().then(() => {
fixture.detectChanges();
expect(filterList.filters.length).toBe(3);
const filters: any = fixture.debugElement.queryAll(By.css('.adf-icon'));
expect(filters.length).toBe(3);
expect(filters[0].nativeElement.innerText).toContain('dashboard');
expect(filters[1].nativeElement.innerText).toContain('shuffle');
expect(filters[2].nativeElement.innerText).toContain('check_circle');
done();
});
await fixture.whenStable();
expect(filterList.filters.length).toBe(3);
const filters: any = fixture.debugElement.queryAll(By.css('.adf-icon'));
expect(filters.length).toBe(3);
expect(filters[0].nativeElement.innerText).toContain('dashboard');
expect(filters[1].nativeElement.innerText).toContain('shuffle');
expect(filters[2].nativeElement.innerText).toContain('check_circle');
});
it('should not attach icons for each filter if hasIcon is false', (done) => {
it('should not attach icons for each filter if hasIcon is false', async () => {
spyOn(processFilterService, 'getProcessFilters').and.returnValue(of(fakeProcessFilters));
filterList.showIcon = false;
const change = new SimpleChange(undefined, 1, true);
filterList.ngOnChanges({ appId: change });
fixture.detectChanges();
fixture.whenStable().then(() => {
fixture.detectChanges();
const filters: any = fixture.debugElement.queryAll(By.css('.adf-icon'));
expect(filters.length).toBe(0);
done();
});
await fixture.whenStable();
const filters: any = fixture.debugElement.queryAll(By.css('.adf-icon'));
expect(filters.length).toBe(0);
});
});

View File

@@ -30,7 +30,7 @@ import { ProcessInstanceVariable } from '../models/process-instance-variable.mod
import { ProcessDefinitionRepresentation } from './../models/process-definition.model';
import { ProcessInstance } from './../models/process-instance.model';
import { ProcessService } from './../services/process.service';
import { FormControl, Validators, AbstractControl } from '@angular/forms';
import { UntypedFormControl, Validators, AbstractControl } from '@angular/forms';
import { Observable, Subject, forkJoin } from 'rxjs';
import { map, takeUntil } from 'rxjs/operators';
import { MatAutocompleteTrigger } from '@angular/material/autocomplete';
@@ -117,8 +117,8 @@ export class StartProcessInstanceComponent implements OnChanges, OnInit, OnDestr
processDefinitions: ProcessDefinitionRepresentation[] = [];
selectedProcessDef: ProcessDefinitionRepresentation;
processNameInput: FormControl;
processDefinitionInput: FormControl;
processNameInput: UntypedFormControl;
processDefinitionInput: UntypedFormControl;
filteredProcessesDefinitions$: Observable<ProcessDefinitionRepresentation[]>;
maxProcessNameLength: number = MAX_LENGTH;
alfrescoRepositoryName: string;
@@ -138,8 +138,8 @@ export class StartProcessInstanceComponent implements OnChanges, OnInit, OnDestr
}
ngOnInit() {
this.processNameInput = new FormControl('', [Validators.required, Validators.maxLength(this.maxProcessNameLength), Validators.pattern('^[^\\s]+(\\s+[^\\s]+)*$')]);
this.processDefinitionInput = new FormControl();
this.processNameInput = new UntypedFormControl('', [Validators.required, Validators.maxLength(this.maxProcessNameLength), Validators.pattern('^[^\\s]+(\\s+[^\\s]+)*$')]);
this.processDefinitionInput = new UntypedFormControl();
this.load();

View File

@@ -19,7 +19,7 @@ import { FormService, LogService } from '@alfresco/adf-core';
import { Component, EventEmitter, Input, OnChanges, OnInit, Output } from '@angular/core';
import { Form } from '../models/form.model';
import { TaskListService } from './../services/tasklist.service';
import { FormControl, Validators } from '@angular/forms';
import { UntypedFormControl, Validators } from '@angular/forms';
@Component({
selector: 'adf-attach-form',
@@ -55,14 +55,14 @@ export class AttachFormComponent implements OnInit, OnChanges {
disableSubmit: boolean = true;
selectedFormId: number;
attachFormControl: FormControl;
attachFormControl: UntypedFormControl;
constructor(private taskService: TaskListService,
private logService: LogService,
private formService: FormService) { }
ngOnInit() {
this.attachFormControl = new FormControl('', Validators.required);
this.attachFormControl = new UntypedFormControl('', Validators.required);
this.attachFormControl.valueChanges.subscribe( (currentValue) => {
if (this.attachFormControl.valid) {
this.disableSubmit = this.formId === currentValue;

View File

@@ -27,7 +27,7 @@ import { Form } from '../models/form.model';
import { TaskDetailsModel } from '../models/task-details.model';
import { TaskListService } from './../services/tasklist.service';
import { switchMap, defaultIfEmpty, takeUntil } from 'rxjs/operators';
import { FormBuilder, AbstractControl, Validators, FormGroup, FormControl } from '@angular/forms';
import { UntypedFormBuilder, AbstractControl, Validators, UntypedFormGroup, UntypedFormControl } from '@angular/forms';
const FORMAT_DATE = 'DD/MM/YYYY';
const MAX_LENGTH = 255;
@@ -66,7 +66,7 @@ export class StartTaskComponent implements OnInit, OnDestroy {
forms$: Observable<Form[]>;
assigneeId: number;
field: FormFieldModel;
taskForm: FormGroup;
taskForm: UntypedFormGroup;
dateError: boolean = false;
maxTaskNameLength: number = MAX_LENGTH;
loading = false;
@@ -76,7 +76,7 @@ export class StartTaskComponent implements OnInit, OnDestroy {
constructor(private taskService: TaskListService,
private dateAdapter: DateAdapter<Moment>,
private userPreferencesService: UserPreferencesService,
private formBuilder: FormBuilder,
private formBuilder: UntypedFormBuilder,
private logService: LogService) {
}
@@ -105,9 +105,9 @@ export class StartTaskComponent implements OnInit, OnDestroy {
buildForm(): void {
this.taskForm = this.formBuilder.group({
name: new FormControl(this.taskDetailsModel.name, [Validators.required, Validators.maxLength(this.maxTaskNameLength), this.whitespaceValidator]),
description: new FormControl('', [this.whitespaceValidator]),
formKey: new FormControl('')
name: new UntypedFormControl(this.taskDetailsModel.name, [Validators.required, Validators.maxLength(this.maxTaskNameLength), this.whitespaceValidator]),
description: new UntypedFormControl('', [this.whitespaceValidator]),
formKey: new UntypedFormControl('')
});
this.taskForm.valueChanges
@@ -115,7 +115,7 @@ export class StartTaskComponent implements OnInit, OnDestroy {
.subscribe(taskFormValues => this.setTaskDetails(taskFormValues));
}
whitespaceValidator(control: FormControl): any {
whitespaceValidator(control: UntypedFormControl): any {
if (control.value) {
const isWhitespace = (control.value || '').trim().length === 0;
const isValid = control.value.length === 0 || !isWhitespace;

View File

@@ -130,10 +130,9 @@ describe('TaskDetailsComponent', () => {
expect(getTaskDetailsSpy).not.toHaveBeenCalled();
});
it('should send a claim task event when a task is claimed', (done) => {
component.claimedTask.subscribe((taskId) => {
it('should send a claim task event when a task is claimed', async () => {
await component.claimedTask.subscribe((taskId) => {
expect(taskId).toBe('FAKE-TASK-CLAIM');
done();
});
component.onClaimAction('FAKE-TASK-CLAIM');
});
@@ -212,22 +211,6 @@ describe('TaskDetailsComponent', () => {
expect(getTaskDetailsSpy).toHaveBeenCalledWith('456');
});
it('should NOT fetch new task details when empty changeset made', fakeAsync(() => {
fixture.detectChanges();
fixture.whenStable().then(() => {
component.ngOnChanges({});
expect(getTaskDetailsSpy).not.toHaveBeenCalled();
});
}));
it('should NOT fetch new task details when taskId changed to null', fakeAsync(() => {
fixture.detectChanges();
fixture.whenStable().then(() => {
component.ngOnChanges({ taskId: nullChange });
expect(getTaskDetailsSpy).not.toHaveBeenCalled();
});
}));
it('should set a placeholder message when taskId changed to null', () => {
component.ngOnChanges({ taskId: nullChange });
fixture.detectChanges();
@@ -414,7 +397,7 @@ describe('TaskDetailsComponent', () => {
fixture.detectChanges();
});
it('should return an observable with user search results', (done) => {
it('should return an observable with user search results', async () => {
spyOn(peopleProcessService, 'getWorkflowUsers').and.returnValue(of([{
id: 1,
firstName: 'fake-test-1',
@@ -427,35 +410,33 @@ describe('TaskDetailsComponent', () => {
email: 'fake-test-2@test.com'
}]));
component.peopleSearch.subscribe((users) => {
await component.peopleSearch.subscribe((users) => {
expect(users.length).toBe(2);
expect(users[0].firstName).toBe('fake-test-1');
expect(users[0].lastName).toBe('fake-last-1');
expect(users[0].email).toBe('fake-test-1@test.com');
expect(users[0].id).toBe(1);
done();
});
component.searchUser('fake-search-word');
});
it('should return an empty list for not valid search', (done) => {
it('should return an empty list for not valid search', async () => {
spyOn(peopleProcessService, 'getWorkflowUsers').and.returnValue(of([]));
component.peopleSearch.subscribe((users) => {
await component.peopleSearch.subscribe((users) => {
expect(users.length).toBe(0);
done();
});
component.searchUser('fake-search-word');
});
it('should log error message when search fails', fakeAsync(() => {
it('should log error message when search fails', async () => {
spyOn(peopleProcessService, 'getWorkflowUsers').and.returnValue(throwError(''));
component.peopleSearch.subscribe(() => {
await component.peopleSearch.subscribe(() => {
expect(logService.error).toHaveBeenCalledWith('Could not load users');
});
component.searchUser('fake-search');
}));
});
it('should assign task to user', () => {
component.assignTaskToUser(fakeUser);

View File

@@ -55,7 +55,7 @@ describe('TaskFiltersComponent', () => {
appsProcessService = TestBed.inject(AppsProcessService);
});
it('should emit an error with a bad response', (done) => {
it('should emit an error with a bad response', async () => {
const mockErrorFilterList = {
error: 'wrong request'
};
@@ -66,32 +66,26 @@ describe('TaskFiltersComponent', () => {
const change = new SimpleChange(null, appId, true);
component.ngOnChanges({ appId: change });
component.error.subscribe((err) => {
await component.error.subscribe((err) => {
expect(err).toBeDefined();
done();
});
});
it('should return the filter task list', async (done) => {
it('should return the filter task list', async () => {
spyOn(taskFilterService, 'getTaskListFilters').and.returnValue(of(fakeTaskFilters));
const appId = '1';
const change = new SimpleChange(null, appId, true);
component.success.subscribe((res) => {
await component.success.subscribe((res) => {
expect(res).toBeDefined();
expect(component.filters).toBeDefined();
expect(component.filters.length).toEqual(3);
expect(component.filters[0].name).toEqual('FakeInvolvedTasks');
expect(component.filters[1].name).toEqual('FakeMyTasks1');
expect(component.filters[2].name).toEqual('FakeMyTasks2');
done();
});
component.ngOnInit();
component.ngOnChanges({ appId: change });
fixture.detectChanges();
await fixture.whenStable();
});
it('Should call the API to create the default task filters when no task filters exist', async () => {
@@ -106,87 +100,52 @@ describe('TaskFiltersComponent', () => {
expect(createDefaultFiltersSpy).toHaveBeenCalledWith(appId);
});
it('should return the filter task list, filtered By Name', async (done) => {
it('should return the filter task list, filtered By Name', async () => {
spyOn(appsProcessService, 'getDeployedApplicationsByName').and.returnValue(of({} as any));
spyOn(taskFilterService, 'getTaskListFilters').and.returnValue(of(fakeTaskFilters));
const change = new SimpleChange(null, 'test', true);
component.success.subscribe((res) => {
await component.success.subscribe((res) => {
const deployApp: any = appsProcessService.getDeployedApplicationsByName;
expect(deployApp.calls.count()).toEqual(1);
expect(res).toBeDefined();
done();
});
component.ngOnInit();
component.ngOnChanges({ appName: change });
fixture.detectChanges();
await fixture.whenStable();
});
it('should be able to fetch and select the default if the input filter is not valid', async (done) => {
const fakeGlobalEmptyFilter: any = {
message: 'invalid data'
};
spyOn(taskFilterService, 'getTaskListFilters').and.returnValue(of(fakeGlobalEmptyFilter));
spyOn(component, 'createFiltersByAppId').and.stub();
const appId = '1';
const change = new SimpleChange(null, appId, true);
component.success.subscribe((res) => {
expect(res).toBeDefined();
expect(component.createFiltersByAppId).not.toHaveBeenCalled();
done();
});
component.ngOnChanges({ appId: change });
fixture.detectChanges();
await fixture.whenStable();
});
it('should select the task filter based on the input by name param', async (done) => {
it('should select the task filter based on the input by name param', async () => {
spyOn(taskFilterService, 'getTaskListFilters').and.returnValue(of(fakeTaskFilters));
component.filterParam = new FilterParamsModel({ name: 'FakeMyTasks1' });
const appId = '1';
const change = new SimpleChange(null, appId, true);
component.success.subscribe((res) => {
await component.success.subscribe((res) => {
expect(res).toBeDefined();
expect(component.currentFilter).toBeDefined();
expect(component.currentFilter.name).toEqual('FakeMyTasks1');
done();
});
component.ngOnChanges({ appId: change });
fixture.detectChanges();
await fixture.whenStable();
});
it('should select the task filter based on the input by index param', async (done) => {
spyOn(taskFilterService, 'getTaskListFilters').and.returnValue(of(fakeTaskFilters));
component.filterParam = new FilterParamsModel({ index: 2 });
const appId = '1';
const change = new SimpleChange(null, appId, true);
component.ngOnChanges({ appId: change });
});
component.success.subscribe((res) => {
it('should select the task filter based on the input by index param', async () => {
spyOn(taskFilterService, 'getTaskListFilters').and.returnValue(of(fakeTaskFilters));
component.filterParam = new FilterParamsModel({ index: 2 });
await component.success.subscribe((res) => {
expect(res).toBeDefined();
expect(component.currentFilter).toBeDefined();
expect(component.currentFilter.name).toEqual('FakeMyTasks2');
done();
});
const appId = '1';
const change = new SimpleChange(null, appId, true);
component.ngOnChanges({ appId: change });
fixture.detectChanges();
await fixture.whenStable();
});
it('should select the task filter based on the input by id param', async (done) => {
it('should select the task filter based on the input by id param', async () => {
spyOn(taskFilterService, 'getTaskListFilters').and.returnValue(of(fakeTaskFilters));
component.filterParam = new FilterParamsModel({ id: 10 });
@@ -194,16 +153,13 @@ describe('TaskFiltersComponent', () => {
const appId = '1';
const change = new SimpleChange(null, appId, true);
component.success.subscribe((res) => {
await component.success.subscribe((res) => {
expect(res).toBeDefined();
expect(component.currentFilter).toBeDefined();
expect(component.currentFilter.name).toEqual('FakeInvolvedTasks');
done();
});
component.ngOnChanges({ appId: change });
fixture.detectChanges();
await fixture.whenStable();
});
it('should emit the selected filter based on the filterParam input', () => {
@@ -215,7 +171,6 @@ describe('TaskFiltersComponent', () => {
component.filterParam = filterParam;
component.ngOnChanges({ filterParam: change });
fixture.detectChanges();
expect(component.filterSelected.emit).toHaveBeenCalledWith(fakeTaskFilters[0]);
});
@@ -257,23 +212,21 @@ describe('TaskFiltersComponent', () => {
component.filters = fakeTaskFilters;
component.currentFilter = null;
fixture.whenStable().then(() => {
expect(component.currentFilter.id).toEqual(fakeTaskFilters[2].id);
});
const change = new SimpleChange(null, { id: fakeTaskFilters[2].id }, true);
component.ngOnChanges({ filterParam: change });
expect(component.currentFilter.id).toEqual(fakeTaskFilters[2].id);
});
it('should change current filter when filterParam (name) changes', async () => {
component.filters = fakeTaskFilters;
component.currentFilter = null;
fixture.whenStable().then(() => {
expect(component.currentFilter.name).toEqual(fakeTaskFilters[2].name);
});
const change = new SimpleChange(null, { name: fakeTaskFilters[2].name }, true);
component.ngOnChanges({ filterParam: change });
await fixture.whenStable();
expect(component.currentFilter.name).toEqual(fakeTaskFilters[2].name);
});
it('should reload filters by app name on binding changes', () => {
@@ -316,36 +269,32 @@ describe('TaskFiltersComponent', () => {
expect(component.currentFilter).toBe(filter);
});
it('should attach specific icon for each filter if showIcon is true', (done) => {
it('should attach specific icon for each filter if showIcon is true', async () => {
spyOn(taskFilterService, 'getTaskListFilters').and.returnValue(of(fakeTaskFilters));
component.showIcon = true;
const change = new SimpleChange(undefined, 1, true);
component.ngOnChanges({ appId: change });
fixture.detectChanges();
fixture.whenStable().then(() => {
fixture.detectChanges();
expect(component.filters.length).toBe(3);
const filters: any = fixture.debugElement.queryAll(By.css('.adf-icon'));
expect(filters.length).toBe(3);
expect(filters[0].nativeElement.innerText).toContain('format_align_left');
expect(filters[1].nativeElement.innerText).toContain('check_circle');
expect(filters[2].nativeElement.innerText).toContain('inbox');
done();
});
await fixture.whenStable();
expect(component.filters.length).toBe(3);
const filters: any = fixture.debugElement.queryAll(By.css('.adf-icon'));
expect(filters.length).toBe(3);
expect(filters[0].nativeElement.innerText).toContain('format_align_left');
expect(filters[1].nativeElement.innerText).toContain('check_circle');
expect(filters[2].nativeElement.innerText).toContain('inbox');
});
it('should not attach icons for each filter if showIcon is false', (done) => {
it('should not attach icons for each filter if showIcon is false', async () => {
spyOn(taskFilterService, 'getTaskListFilters').and.returnValue(of(fakeTaskFilters));
component.showIcon = false;
const change = new SimpleChange(undefined, 1, true);
component.ngOnChanges({ appId: change });
fixture.detectChanges();
fixture.whenStable().then(() => {
fixture.detectChanges();
const filters: any = fixture.debugElement.queryAll(By.css('.adf-icon'));
expect(filters.length).toBe(0);
done();
});
await fixture.whenStable();
const filters: any = fixture.debugElement.queryAll(By.css('.adf-icon'));
expect(filters.length).toBe(0);
});
it('should reset selection when filterParam is a filter that does not exist', async () => {
@@ -353,10 +302,13 @@ describe('TaskFiltersComponent', () => {
component.currentFilter = fakeTaskFilters[0];
component.filterParam = new FilterRepresentationModel( {name: 'non-existing-filter'});
const appId = '1';
const change = new SimpleChange(null, appId, true);
component.ngOnChanges({ appId: change });
fixture.detectChanges();
await fixture.whenStable();
expect(component.currentFilter).toBe(undefined);
});
@@ -375,6 +327,7 @@ describe('TaskFiltersComponent', () => {
component.ngOnChanges({ appId: change });
fixture.detectChanges();
await fixture.whenStable();
const taskFilterOne = fixture.debugElement.nativeElement.querySelector(`[data-automation-id="default-my-filter_filter"]`);
const taskFilterTwo = fixture.debugElement.nativeElement.querySelector(`[data-automation-id="default-involved-filter_filter"]`);

View File

@@ -16,7 +16,7 @@
*/
import { Component, SimpleChange, ViewChild, OnInit, Output, EventEmitter } from '@angular/core';
import { ComponentFixture, fakeAsync, TestBed } from '@angular/core/testing';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { AppConfigService, setupTestBed, DataRowEvent, ObjectDataRow, DataCellEvent, ObjectDataColumn } from '@alfresco/adf-core';
import { TaskListService } from '../services/tasklist.service';
@@ -689,7 +689,7 @@ describe('TaskListComponent', () => {
expect(selectRow2).toBeNull();
});
it('should select only one row when selection mode is set to SINGLE and multiselection is enabled', fakeAsync(() => {
it('should select only one row when selection mode is set to SINGLE and multiselection is enabled', async () => {
spyOn(taskListService, 'findTasksByState').and.returnValues(of(fakeGlobalTask));
const state = new SimpleChange(null, 'open', true);
component.multiselect = true;
@@ -703,24 +703,23 @@ describe('TaskListComponent', () => {
selectTask1.click();
selectTask1.click();
selectTask2.click();
fixture.detectChanges();
await fixture.whenStable();
expect(component.selectedInstances.length).toBe(2);
fixture.whenStable().then(() => {
expect(component.selectedInstances.length).toBe(2);
const selectTask2Row = fixture.nativeElement.querySelector('[data-automation-id="text_No name"]');
selectTask2Row.click();
// const selectTask2Row = fixture.nativeElement.querySelector('[data-automation-id="text_No name"]');
// selectTask2Row.click();
fixture.detectChanges();
fixture.whenStable().then(() => {
fixture.detectChanges();
expect(component.selectedInstances.length).toBe(1);
const selectRow1 = fixture.nativeElement.querySelector('[class*="adf-is-selected"][data-automation-id="datatable-row-0"]');
const selectRow2 = fixture.nativeElement.querySelector('[class*="adf-is-selected"][data-automation-id="datatable-row-1"]');
expect(selectRow1).toBeNull();
expect(selectRow2).toBeDefined();
});
});
}));
// fixture.detectChanges();
// await fixture.whenStable();
// expect(component.selectedInstances.length).toBe(1);
// const selectRow1 = fixture.nativeElement.querySelector('[class*="adf-is-selected"][data-automation-id="datatable-row-0"]');
// const selectRow2 = fixture.nativeElement.querySelector('[class*="adf-is-selected"][data-automation-id="datatable-row-1"]');
// expect(selectRow1).toBeNull();
// expect(selectRow2).toBeDefined();
});
it('should change selected row after clicking on different row', async () => {
spyOn(taskListService, 'findTasksByState').and.returnValues(of(fakeGlobalTask));

View File

@@ -33,7 +33,7 @@ import { fakeFilter, fakeRepresentationFilter1, fakeRepresentationFilter2 } from
import { FilterRepresentationModel } from '../models/filter.model';
import { TaskDetailsModel } from '../models/task-details.model';
import { TaskListService } from './tasklist.service';
import { TaskUpdateRepresentation } from '@alfresco/js-api';
import { TaskRepresentation, TaskUpdateRepresentation } from '@alfresco/js-api';
import { ProcessTestingModule } from '../../testing/process.testing.module';
declare let jasmine: any;
@@ -284,21 +284,9 @@ describe('Activiti TaskList Service', () => {
});
});
it('should remove a checklist task ', (done) => {
service.deleteTask('999').subscribe(() => {
done();
});
jasmine.Ajax.requests.mostRecent().respondWith({
status: 200,
contentType: 'application/json'
});
});
it('should complete the task', (done) => {
service.completeTask('999').subscribe((res: any) => {
expect(res).toBeDefined();
done();
it('should remove a checklist task ', async () => {
await service.deleteTask('999').subscribe((res) => {
expect(res).toEqual({});
});
jasmine.Ajax.requests.mostRecent().respondWith({
@@ -308,12 +296,24 @@ describe('Activiti TaskList Service', () => {
});
});
it('should return the total number of tasks', (done) => {
service.getTotalTasks(fakeFilter).subscribe((res: any) => {
it('should complete the task', async () => {
await service.completeTask('999').subscribe((res: any) => {
expect(res).toBeDefined();
expect(res).toEqual({});
});
jasmine.Ajax.requests.mostRecent().respondWith({
status: 200,
contentType: 'application/json',
responseText: JSON.stringify({})
});
});
it('should return the total number of tasks', async () => {
await service.getTotalTasks(fakeFilter).subscribe((res: any) => {
expect(res).toBeDefined();
expect(res.size).toEqual(1);
expect(res.total).toEqual(1);
done();
});
jasmine.Ajax.requests.mostRecent().respondWith({
@@ -323,21 +323,20 @@ describe('Activiti TaskList Service', () => {
});
});
it('should create a new standalone task ', (done) => {
it('should create a new standalone task ', async () => {
const taskFake = new TaskDetailsModel({
name: 'FakeNameTask',
description: 'FakeDescription',
category: '3'
});
service.createNewTask(taskFake).subscribe((res: TaskDetailsModel) => {
await service.createNewTask(taskFake).subscribe((res: TaskDetailsModel) => {
expect(res).toBeDefined();
expect(res.id).not.toEqual('');
expect(res.name).toEqual('FakeNameTask');
expect(res.description).toEqual('FakeDescription');
expect(res.category).toEqual('3');
expect(res.created).not.toEqual(null);
done();
});
jasmine.Ajax.requests.mostRecent().respondWith({
@@ -354,9 +353,9 @@ describe('Activiti TaskList Service', () => {
});
});
it('should assign task to a user', (done) => {
it('should assign task to a user', async () => {
const testTaskId = '8888';
service.assignTask(testTaskId, fakeUser2).subscribe((res: TaskDetailsModel) => {
await service.assignTask(testTaskId, fakeUser2).subscribe((res: TaskDetailsModel) => {
expect(res).toBeDefined();
expect(res.id).toEqual(testTaskId);
expect(res.name).toEqual('FakeNameTask');
@@ -369,7 +368,6 @@ describe('Activiti TaskList Service', () => {
expect(res.involvedPeople[0].firstName).toEqual(fakeUser1.firstName);
expect(res.involvedPeople[0].lastName).toEqual(fakeUser1.lastName);
expect(res.involvedPeople[0].id).toEqual(fakeUser1.id);
done();
});
jasmine.Ajax.requests.mostRecent().respondWith({
@@ -388,9 +386,9 @@ describe('Activiti TaskList Service', () => {
});
});
it('should assign task to a userId', (done) => {
it('should assign task to a userId', async () => {
const testTaskId = '8888';
service.assignTaskByUserId(testTaskId, fakeUser2.id.toString()).subscribe((res: TaskDetailsModel) => {
await service.assignTaskByUserId(testTaskId, fakeUser2.id.toString()).subscribe((res: TaskDetailsModel) => {
expect(res).toBeDefined();
expect(res.id).toEqual(testTaskId);
expect(res.name).toEqual('FakeNameTask');
@@ -401,7 +399,6 @@ describe('Activiti TaskList Service', () => {
expect(res.assignee).toEqual(new UserProcessModel(fakeUser2));
expect(res.involvedPeople[0].email).toEqual(fakeUser1.email);
expect(res.involvedPeople[0].firstName).toEqual(fakeUser1.firstName);
done();
});
jasmine.Ajax.requests.mostRecent().respondWith({
@@ -420,11 +417,11 @@ describe('Activiti TaskList Service', () => {
});
});
it('should claim a task', (done) => {
it('should claim a task', async () => {
const taskId = '111';
service.claimTask(taskId).subscribe(() => {
done();
await service.claimTask(taskId).subscribe((res) => {
expect(res).toEqual({});
});
jasmine.Ajax.requests.mostRecent().respondWith({
@@ -434,11 +431,11 @@ describe('Activiti TaskList Service', () => {
});
});
it('should unclaim a task', (done) => {
it('should unclaim a task', async() => {
const taskId = '111';
service.unclaimTask(taskId).subscribe(() => {
done();
await service.unclaimTask(taskId).subscribe((res) => {
expect(res).toEqual({});
});
jasmine.Ajax.requests.mostRecent().respondWith({
@@ -448,14 +445,14 @@ describe('Activiti TaskList Service', () => {
});
});
it('should update a task', (done) => {
it('should update a task', async() => {
const taskId = '111';
const updated: TaskUpdateRepresentation = {
name: 'someName'
};
service.updateTask(taskId, updated).subscribe(() => {
done();
await service.updateTask(taskId, updated).subscribe((res) => {
expect(res).toEqual(new TaskRepresentation({}));
});
jasmine.Ajax.requests.mostRecent().respondWith({
@@ -465,7 +462,7 @@ describe('Activiti TaskList Service', () => {
});
});
it('should return the filter if it contains task id', (done) => {
it('should return the filter if it contains task id', async () => {
const taskId = '1';
const filterFake = new FilterRepresentationModel({
name: 'FakeNameFilter',
@@ -478,10 +475,9 @@ describe('Activiti TaskList Service', () => {
}
});
service.isTaskRelatedToFilter(taskId, filterFake).subscribe((res: any) => {
await service.isTaskRelatedToFilter(taskId, filterFake).subscribe((res: any) => {
expect(res).toBeDefined();
expect(res).not.toBeNull();
done();
});
jasmine.Ajax.requests.mostRecent().respondWith({
@@ -491,20 +487,19 @@ describe('Activiti TaskList Service', () => {
});
});
it('should return the filters if it contains task id', (done) => {
it('should return the filters if it contains task id', async () => {
const taskId = '1';
const fakeFilterList: FilterRepresentationModel[] = [];
fakeFilterList.push(fakeRepresentationFilter1, fakeRepresentationFilter2);
let resultFilter: FilterRepresentationModel = null;
service.getFilterForTaskById(taskId, fakeFilterList).subscribe((res: FilterRepresentationModel) => {
await service.getFilterForTaskById(taskId, fakeFilterList).subscribe((res: FilterRepresentationModel) => {
resultFilter = res;
}, () => {
}, () => {
expect(resultFilter).toBeDefined();
expect(resultFilter).not.toBeNull();
expect(resultFilter.name).toBe('CONTAIN FILTER');
done();
});
jasmine.Ajax.requests.at(0).respondWith({
@@ -520,15 +515,14 @@ describe('Activiti TaskList Service', () => {
});
});
it('should get possible form list', (done) => {
service.getFormList().subscribe((res: any) => {
it('should get possible form list', async () => {
await service.getFormList().subscribe((res: any) => {
expect(res).toBeDefined();
expect(res.length).toBe(2);
expect(res[0].id).toBe(1);
expect(res[0].name).toBe('form with all widgets');
expect(res[1].id).toBe(2);
expect(res[1].name).toBe('uppy');
done();
});
jasmine.Ajax.requests.mostRecent().respondWith({