👽 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

@@ -1,23 +1,12 @@
{
"extends": "../../.eslintrc.json",
"ignorePatterns": [
"!**/*"
],
"extends": ["../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": [
"*.ts"
],
"parserOptions": {
"project": [
"lib/process-services-cloud/tsconfig.lib.json",
"lib/process-services-cloud/tsconfig.spec.json"
],
"createDefaultProgram": true
},
"plugins": [
"eslint-plugin-unicorn",
"eslint-plugin-rxjs"
"files": ["*.ts"],
"extends": [
"plugin:@nrwl/nx/angular",
"plugin:@angular-eslint/template/process-inline-templates"
],
"rules": {
"jsdoc/newline-after-description": "warn",
@@ -90,9 +79,8 @@
}
},
{
"files": [
"*.html"
],
"files": ["*.html"],
"extends": ["plugin:@nrwl/nx/angular-template"],
"rules": {
"@angular-eslint/template/no-autofocus": "error",
"@angular-eslint/template/no-positive-tabindex": "error"

View File

@@ -9,7 +9,7 @@ module.exports = {
],
staticDirs: [
...rootMain.staticDirs,
{ from: '../../core/i18n', to: 'assets/adf-core/i18n' },
{ from: '../../core/src/lib/i18n', to: 'assets/adf-core/i18n' },
{ from: __dirname + '/../src/lib/i18n', to: 'assets/adf-process-services-cloud/i18n' }
],
addons: [...rootMain.addons ]

View File

@@ -21,7 +21,7 @@ module.exports = function (config) {
watched: false
},
{ pattern: 'node_modules/moment/min/moment.min.js', included: true, watched: false },
{ pattern: 'lib/core/i18n/**/en.json', included: false, served: true, watched: false },
{ pattern: 'lib/core/src/lib/i18n/**/en.json', included: false, served: true, watched: false },
{ pattern: 'lib/process-services-cloud/src/lib/i18n/*.json', included: false, served: true, watched: false },
{ pattern: 'lib/process-services-cloud/src/lib/mock/*.json', included: false, served: true, watched: false },
{ pattern: 'lib/process-services-cloud/**/*.ts', included: false, served: true, watched: false },
@@ -29,18 +29,15 @@ module.exports = function (config) {
],
frameworks: ['jasmine-ajax', 'jasmine', '@angular-devkit/build-angular'],
proxies: {
'/assets/': '/base/lib/process-services-cloud/assets/',
'/assets/': '/base/lib/process-services-cloud/src/lib/assets/',
'/resources/i18n/en.json': '/base/lib/process-services-cloud/src/lib/mock/en.json',
'/resources/i18n/fr.json': '/base/lib/process-services-cloud/src/lib/mock/fr.json',
'/base/assets/': '/base/lib/process-services/assets/',
'/assets/adf-core/i18n/en.json': '/base/lib/core/i18n/en.json',
'/assets/adf-core/i18n/en-GB.json': '/base/lib/core/i18n/en.json',
'/assets/adf-core/i18n/en.json': '/base/lib/core/src/lib/i18n/en.json',
'/assets/adf-core/i18n/en-GB.json': '/base/lib/core/src/lib/i18n/en.json',
'/assets/adf-process-services-cloud/i18n/en.json': '/base/lib/process-services-cloud/lib/i18n/en.json',
'/assets/adf-process-services-cloud/i18n/en-GB.json': '/base/lib/process-services-cloud/lib/i18n/en.json',
'/app.config.json': '/base/lib/config/app.config.json',
'/base/lib/process-services-cloud/assets/images/ft_ic_raster_image.svg': '/base/lib/process-services-cloud/assets/images/ft_ic_raster_image.svg',
'/base/lib/process-services-cloud/assets/images/ft_ic_miscellaneous.svg': '/base/lib/process-services-cloud/assets/images/ft_ic_miscellaneous.svg',
'/base/lib/process-services-cloud/assets/images/ft_ic_pdf.svg': '/base/lib/process-services-cloud/assets/images/ft_ic_pdf.svg',
},
plugins: [
require('karma-jasmine-ajax'),
@@ -85,7 +82,7 @@ module.exports = function (config) {
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false
singleRun: true
});
process.env.TZ = 'UTC';
};

View File

@@ -1,11 +1,24 @@
{
"$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
"dest": "../dist/process-services-cloud",
"dest": "../../dist/libs/process-services-cloud",
"assets": [
"./src/lib/styles/**/*.scss",
"./theming/**/*.scss",
"./src/**/*.theme.scss"
{
"glob": "assets/**/*",
"input": "./src/lib",
"output": "/bundles/"
},
{
"glob": "i18n/*.json",
"input": "./src/lib",
"output": "/bundles/assets/adf-process-services-cloud/"
},
{
"glob": "**/*.scss",
"input": "./src/lib",
"output": "/lib"
}
],
"lib": {
"entryFile": "src/public-api.ts",
"flatModuleFile": "adf-process-services-cloud"

View File

@@ -1,7 +1,7 @@
{
"name": "@alfresco/adf-process-services-cloud",
"description": "Alfresco ADF process services cloud",
"version": "5.0.0-angular.13.2",
"version": "5.0.0-angular.14.0",
"author": "Alfresco Software, Ltd.",
"repository": {
"type": "git",
@@ -11,21 +11,21 @@
"url": "https://github.com/Alfresco/alfresco-ng2-components/issues"
},
"peerDependencies": {
"@angular/animations": ">=13.3.11",
"@angular/animations": ">=14.0.5",
"@angular/cdk": ">=13.3.9",
"@angular/common": ">=13.3.11",
"@angular/compiler": ">=13.3.11",
"@angular/core": ">=13.3.11",
"@angular/common": ">=14.0.5",
"@angular/compiler": ">=14.0.5",
"@angular/core": ">=14.0.5",
"@angular/flex-layout": ">=13.0.0-beta.38",
"@angular/forms": ">=13.3.11",
"@angular/forms": ">=14.0.5",
"@angular/material": ">=13.3.9",
"@angular/material-moment-adapter": ">=13.3.9",
"@angular/platform-browser": ">=13.3.11",
"@angular/platform-browser-dynamic": ">=13.3.11",
"@angular/router": ">=13.3.11",
"@angular/platform-browser": ">=14.0.5",
"@angular/platform-browser-dynamic": ">=14.0.5",
"@angular/router": ">=14.0.5",
"@alfresco/js-api": "4.12.0-244",
"@alfresco/adf-core": "5.0.0-angular.13.2",
"@alfresco/adf-content-services": "5.0.0-angular.13.2",
"@alfresco/adf-core": "5.0.0-angular.14.0",
"@alfresco/adf-content-services": "5.0.0-angular.14.0",
"@apollo/client": "^3.3.7",
"@ngx-translate/core": ">=13.0.0",
"apollo-angular": "^2.2.0",

View File

@@ -18,7 +18,7 @@
import { Component, Input, EventEmitter, Output, OnInit } from '@angular/core';
import { MatSelectChange } from '@angular/material/select';
import { ProcessFilterProperties, ProcessFilterOptions } from '../../process/process-filters/models/process-filter-cloud.model';
import { FormGroup, FormControl } from '@angular/forms';
import { UntypedFormGroup, UntypedFormControl } from '@angular/forms';
import { DateRangeFilter, DateCloudFilterType } from '../../models/date-cloud-filter.model';
import moment from 'moment';
@@ -43,9 +43,9 @@ import moment from 'moment';
type: DateCloudFilterType;
filteredProperties: ProcessFilterOptions[] = [];
dateRangeForm = new FormGroup({
from: new FormControl(),
to: new FormControl()
dateRangeForm = new UntypedFormGroup({
from: new UntypedFormControl(),
to: new UntypedFormControl()
});
ngOnInit() {

View File

@@ -66,7 +66,35 @@ import { By } from '@angular/platform-browser';
import { of, throwError } from 'rxjs';
import { FormCloudModule } from '../../../form-cloud.module';
import { TranslateModule } from '@ngx-translate/core';
import { mockNode } from 'content-services/src/lib/mock';
const mockNodeToBeVersioned: any = ({
isFile: true,
createdByUser: { id: 'admin', displayName: 'Administrator' },
modifiedAt: '2017-05-24T15:08:55.640Z',
nodeType: 'cm:content',
content: {
mimeType: 'application/rtf',
mimeTypeName: 'Rich Text Format',
sizeInBytes: 14530,
encoding: 'UTF-8'
},
parentId: 'd124de26-6ba0-4f40-8d98-4907da2d337a',
createdAt: '2017-05-24T15:08:55.640Z',
path: {
name: '/Company Home/Guest Home',
isComplete: true,
elements: [{
id: '94acfc73-7014-4475-9bd9-93a2162f0f8c',
name: 'Company Home'
}, { id: 'd124de26-6ba0-4f40-8d98-4907da2d337a', name: 'Guest Home' }]
},
isFolder: false,
modifiedByUser: { id: 'admin', displayName: 'Administrator' },
name: 'b_txt_file.rtf',
id: '70e1cc6a-6918-468a-b84a-1048093b06fd',
properties: { 'cm:versionLabel': '1.0', 'cm:versionType': 'MAJOR' },
allowableOperations: ['delete', 'update']
});
describe('AttachFileCloudWidgetComponent', () => {
let widget: AttachFileCloudWidgetComponent;
@@ -563,12 +591,11 @@ describe('AttachFileCloudWidgetComponent', () => {
});
});
it('should preview file when show is clicked', (done) => {
it('should preview file when show is clicked', async() => {
spyOn(processCloudContentService, 'getRawContentNode').and.returnValue(of(new Blob()));
formService.formContentClicked.subscribe(
await formService.formContentClicked.subscribe(
(fileClicked: any) => {
expect(fileClicked.nodeId).toBe('fake-properties');
done();
}
);
@@ -580,7 +607,7 @@ describe('AttachFileCloudWidgetComponent', () => {
showOption.click();
});
it('should request form to be updated with metadata when retrieve is clicked', (done) => {
it('should request form to be updated with metadata when retrieve is clicked', async() => {
updateFormSpy = spyOn(formService.updateFormValuesRequested, 'next');
widget.field.value = [fakeNodeWithProperties];
fixture.detectChanges();
@@ -594,10 +621,8 @@ describe('AttachFileCloudWidgetComponent', () => {
expect(apiServiceSpy).toHaveBeenCalledWith(fakeNodeWithProperties.id);
fixture.detectChanges();
fixture.whenStable().then(() => {
expect(updateFormSpy).toHaveBeenCalledWith(expectedValues);
done();
});
await fixture.whenStable();
expect(updateFormSpy).toHaveBeenCalledWith(expectedValues);
});
it('should display the default menu options if no options are provided', () => {
@@ -646,71 +671,59 @@ describe('AttachFileCloudWidgetComponent', () => {
await fixture.whenStable();
});
it('should not be called onInit when widget has no value', (done) => {
it('should not be called onInit when widget has no value', async() => {
widget.ngOnInit();
fixture.detectChanges();
fixture.whenStable().then(() => {
expect(contentModelFormFileHandlerSpy).not.toHaveBeenCalled();
done();
});
await fixture.whenStable();
expect(contentModelFormFileHandlerSpy).not.toHaveBeenCalled();
});
it('should have been called onInit when widget only one file', (done) => {
it('should have been called onInit when widget only one file', async() => {
widget.field.value = [fakeNodeWithProperties];
widget.ngOnInit();
fixture.detectChanges();
fixture.whenStable().then(() => {
expect(contentModelFormFileHandlerSpy).toHaveBeenCalledWith(fakeNodeWithProperties);
expect(updateFormSpy).toHaveBeenCalledWith(expectedValues);
expect(contentClickedSpy).toHaveBeenCalledWith(new UploadWidgetContentLinkModel(fakeNodeWithProperties, widget.field.id));
done();
});
await fixture.whenStable();
expect(contentModelFormFileHandlerSpy).toHaveBeenCalledWith(fakeNodeWithProperties);
expect(updateFormSpy).toHaveBeenCalledWith(expectedValues);
expect(contentClickedSpy).toHaveBeenCalledWith(new UploadWidgetContentLinkModel(fakeNodeWithProperties, widget.field.id));
});
it('should not be called onInit when widget has more than one file', (done) => {
it('should not be called onInit when widget has more than one file', async() => {
widget.field.value = [fakeNodeWithProperties, fakeMinimalNode];
widget.ngOnInit();
fixture.detectChanges();
fixture.whenStable().then(() => {
expect(contentModelFormFileHandlerSpy).not.toHaveBeenCalled();
done();
});
await fixture.whenStable();
expect(contentModelFormFileHandlerSpy).not.toHaveBeenCalled();
});
it('should not be called on remove node if node removed is not the selected one', (done) => {
it('should not be called on remove node if node removed is not the selected one', async() => {
widget.field.value = [fakeNodeWithProperties, fakeMinimalNode];
widget.selectedNode = fakeNodeWithProperties;
widget.ngOnInit();
fixture.detectChanges();
widget.onRemoveAttachFile(fakeMinimalNode);
fixture.whenStable().then(() => {
expect(contentModelFormFileHandlerSpy).not.toHaveBeenCalled();
done();
});
await fixture.whenStable();
expect(contentModelFormFileHandlerSpy).not.toHaveBeenCalled();
});
it('should have been called on remove node if node removed is the selected one', (done) => {
it('should have been called on remove node if node removed is the selected one', async() => {
widget.field.value = [fakeNodeWithProperties, fakeMinimalNode];
widget.selectedNode = fakeNodeWithProperties;
widget.ngOnInit();
fixture.detectChanges();
widget.onRemoveAttachFile(fakeNodeWithProperties);
fixture.whenStable().then(() => {
expect(contentModelFormFileHandlerSpy).toHaveBeenCalled();
expect(updateFormSpy).not.toHaveBeenCalled();
expect(contentClickedSpy).toHaveBeenCalledWith(new UploadWidgetContentLinkModel(undefined, widget.field.id));
done();
});
await fixture.whenStable();
expect(contentModelFormFileHandlerSpy).toHaveBeenCalled();
expect(updateFormSpy).not.toHaveBeenCalled();
expect(contentClickedSpy).toHaveBeenCalledWith(new UploadWidgetContentLinkModel(undefined, widget.field.id));
});
it('should have been called on attach file when value was empty', async () => {
it('should have been called on attach file when value was empty', async() => {
clickOnAttachFileWidget('attach-file-alfresco');
fixture.detectChanges();
await fixture.whenStable();
@@ -720,12 +733,8 @@ describe('AttachFileCloudWidgetComponent', () => {
expect(contentClickedSpy).toHaveBeenCalledWith(new UploadWidgetContentLinkModel(fakeNodeWithProperties, widget.field.id));
});
it('should not be called on attach file when has a file previously', async () => {
widget.field.value = [fakeNodeWithProperties, fakeMinimalNode];
widget.field.params['multiple'] = true;
widget.ngOnInit();
await fixture.whenStable();
fixture.detectChanges();
it('should not be called on attach file when has a file previously', async() => {
widget.field.value = [fakeMinimalNode];
clickOnAttachFileWidget('attach-file-alfresco');
fixture.detectChanges();
@@ -737,12 +746,10 @@ describe('AttachFileCloudWidgetComponent', () => {
it('should be called when selecting a row if no previous row was selected', async () => {
widget.field.value = [fakeNodeWithProperties, fakeMinimalNode];
widget.selectedNode = null;
widget.ngOnInit();
await fixture.whenStable();
fixture.detectChanges();
widget.onRowClicked(fakeNodeWithProperties);
fixture.detectChanges();
await fixture.whenStable();
expect(widget.selectedNode).toEqual(fakeNodeWithProperties);
@@ -754,12 +761,10 @@ describe('AttachFileCloudWidgetComponent', () => {
it('should be called when selecting a row and previous row was selected', async () => {
widget.field.value = [fakeNodeWithProperties, fakeMinimalNode];
widget.selectedNode = fakeMinimalNode;
widget.ngOnInit();
await fixture.whenStable();
fixture.detectChanges();
widget.onRowClicked(fakeNodeWithProperties);
fixture.detectChanges();
await fixture.whenStable();
expect(widget.selectedNode).toEqual(fakeNodeWithProperties);
@@ -771,12 +776,10 @@ describe('AttachFileCloudWidgetComponent', () => {
it('should be called when deselecting a row', async () => {
widget.field.value = [fakeNodeWithProperties, fakeMinimalNode];
widget.selectedNode = fakeNodeWithProperties;
widget.ngOnInit();
await fixture.whenStable();
fixture.detectChanges();
widget.onRowClicked(fakeNodeWithProperties);
fixture.detectChanges();
await fixture.whenStable();
expect(widget.selectedNode).toBeNull();
@@ -862,20 +865,20 @@ describe('AttachFileCloudWidgetComponent', () => {
it('Should open new version uploader dialog', async () => {
await fixture.whenStable();
widget.onUploadNewFileVersion(mockNode);
expect(spyOnOpenUploadNewVersionDialog).toHaveBeenCalledWith(mockNode);
widget.onUploadNewFileVersion(mockNodeToBeVersioned);
expect(spyOnOpenUploadNewVersionDialog).toHaveBeenCalledWith(mockNodeToBeVersioned);
});
it('Should not replace old file version with the new one if dialog returned action is not upload', async () => {
await fixture.whenStable();
widget.onUploadNewFileVersion(mockNode);
widget.onUploadNewFileVersion(mockNodeToBeVersioned);
expect(spyOnReplaceOldFileVersionWithNew).not.toHaveBeenCalled();
});
it('Should replace old file version with the new one if dialog returned action is upload', async () => {
spyOnOpenUploadNewVersionDialog.and.returnValue(of({ action: NewVersionUploaderDataAction.upload }));
await fixture.whenStable();
widget.onUploadNewFileVersion(mockNode);
widget.onUploadNewFileVersion(mockNodeToBeVersioned);
expect(spyOnReplaceOldFileVersionWithNew).toHaveBeenCalledTimes(1);
});
@@ -883,7 +886,7 @@ describe('AttachFileCloudWidgetComponent', () => {
const mockError = {value: 'Upload error'};
spyOnOpenUploadNewVersionDialog.and.returnValue(throwError(mockError));
await fixture.whenStable();
widget.onUploadNewFileVersion(mockNode);
widget.onUploadNewFileVersion(mockNodeToBeVersioned);
expect(spyOnReplaceOldFileVersionWithNew).not.toHaveBeenCalled();
expect(spyOnShowError).toHaveBeenCalledWith(mockError.value);
});

View File

@@ -17,7 +17,7 @@
import { Component, OnDestroy, OnInit, ViewEncapsulation } from '@angular/core';
import { WidgetComponent, FormService } from '@alfresco/adf-core';
import { FormControl } from '@angular/forms';
import { UntypedFormControl } from '@angular/forms';
import { filter, takeUntil } from 'rxjs/operators';
import { Subject } from 'rxjs';
import { ComponentSelectionMode } from '../../../../types';
@@ -50,7 +50,7 @@ export class GroupCloudWidgetComponent extends WidgetComponent implements OnInit
mode: ComponentSelectionMode;
title: string;
preSelectGroup: IdentityGroupModel[];
search: FormControl;
search: UntypedFormControl;
validate = false;
constructor(formService: FormService) {
@@ -66,7 +66,7 @@ export class GroupCloudWidgetComponent extends WidgetComponent implements OnInit
this.validate = this.field.readOnly ? false : true;
}
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
this.search = new FormControl({value: '', disabled: this.field.readOnly}, []),
this.search = new UntypedFormControl({value: '', disabled: this.field.readOnly}, []),
this.search.statusChanges
.pipe(

View File

@@ -17,7 +17,7 @@
import { Component, OnDestroy, OnInit, ViewEncapsulation } from '@angular/core';
import { WidgetComponent, FormService } from '@alfresco/adf-core';
import { FormControl } from '@angular/forms';
import { UntypedFormControl } from '@angular/forms';
import { filter, takeUntil } from 'rxjs/operators';
import { Subject } from 'rxjs';
import { ComponentSelectionMode } from '../../../../types';
@@ -52,7 +52,7 @@ export class PeopleCloudWidgetComponent extends WidgetComponent implements OnIni
mode: ComponentSelectionMode;
title: string;
preSelectUsers: IdentityUserModel[];
search: FormControl;
search: UntypedFormControl;
groupsRestriction: string[];
validate = false;
@@ -70,7 +70,7 @@ export class PeopleCloudWidgetComponent extends WidgetComponent implements OnIni
this.validate = this.field.readOnly ? false : true;
}
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
this.search = new FormControl({value: '', disabled: this.field.readOnly}, []),
this.search = new UntypedFormControl({value: '', disabled: this.field.readOnly}, []),
this.search.statusChanges
.pipe(

View File

@@ -29,7 +29,7 @@ import {
OnDestroy,
Inject
} from '@angular/core';
import { FormControl } from '@angular/forms';
import { UntypedFormControl } from '@angular/forms';
import { trigger, state, style, transition, animate } from '@angular/animations';
import { BehaviorSubject, Observable, Subject } from 'rxjs';
import { distinctUntilChanged, switchMap, mergeMap, filter, tap, takeUntil, debounceTime } from 'rxjs/operators';
@@ -91,11 +91,11 @@ export class GroupCloudComponent implements OnInit, OnChanges, OnDestroy {
/** FormControl to list of group */
@Input()
groupChipsCtrl = new FormControl({ value: '', disabled: false });
groupChipsCtrl = new UntypedFormControl({ value: '', disabled: false });
/** FormControl to search the group */
@Input()
searchGroupsControl = new FormControl({ value: '', disabled: false });
searchGroupsControl = new UntypedFormControl({ value: '', disabled: false });
/** Role names of the groups to be listed. */
@Input()

View File

@@ -15,7 +15,7 @@
* limitations under the License.
*/
import { FormControl } from '@angular/forms';
import { UntypedFormControl } from '@angular/forms';
import {
Component,
OnInit,
@@ -112,11 +112,11 @@ export class PeopleCloudComponent implements OnInit, OnChanges, OnDestroy {
/** FormControl to list of users */
@Input()
userChipsCtrl: FormControl = new FormControl({ value: '', disabled: false });
userChipsCtrl: UntypedFormControl = new UntypedFormControl({ value: '', disabled: false });
/** FormControl to search the user */
@Input()
searchUserCtrl = new FormControl({ value: '', disabled: false });
searchUserCtrl = new UntypedFormControl({ value: '', disabled: false });
/** Placeholder translation key
*/

View File

@@ -56,7 +56,7 @@ describe('IdentityUserService', () => {
const store = {};
spyOn(localStorage, 'getItem').and.callFake((key: string): string => store[key] || null);
spyOn(localStorage, 'setItem').and.callFake((key: string, value: string): string => store[key] = value);
spyOn(localStorage, 'setItem').and.callFake((key: string, value: string): string => store[key] = value);
});
it('should fetch identity user info from Jwt id token', () => {
@@ -100,7 +100,7 @@ describe('IdentityUserService', () => {
});
it('should not fetch users if error occurred', (done) => {
spyOn(alfrescoApiService, 'getInstance').and.returnValue(oAuthMockApiWithError);
spyOn(alfrescoApiService, 'getInstance').and.returnValue(oAuthMockApiWithError as any);
const searchSpy = spyOn(service, 'search').and.callThrough();

View File

@@ -16,7 +16,7 @@
*/
import { Component, Input, Output, EventEmitter, OnInit, OnChanges, SimpleChanges, OnDestroy, ViewEncapsulation } from '@angular/core';
import { FormGroup, FormBuilder, AbstractControl } from '@angular/forms';
import { UntypedFormGroup, UntypedFormBuilder, AbstractControl } from '@angular/forms';
import { DateAdapter } from '@angular/material/core';
import { MatDialog } from '@angular/material/dialog';
import { debounceTime, filter, takeUntil, finalize, switchMap, tap } from 'rxjs/operators';
@@ -148,7 +148,7 @@ export class EditProcessFilterCloudComponent implements OnInit, OnChanges, OnDes
value: ''
};
processDefinitionNames: any[] = [];
editProcessFilterForm: FormGroup;
editProcessFilterForm: UntypedFormGroup;
processFilterProperties: ProcessFilterProperties[] = [];
processFilterActions: ProcessFilterAction[] = [];
toggleFilterActions: boolean = false;
@@ -160,7 +160,7 @@ export class EditProcessFilterCloudComponent implements OnInit, OnChanges, OnDes
private filterChangeSub: Subscription;
constructor(
private formBuilder: FormBuilder,
private formBuilder: UntypedFormBuilder,
public dialog: MatDialog,
private dateAdapter: DateAdapter<Moment>,
private userPreferencesService: UserPreferencesService,

View File

@@ -17,7 +17,7 @@
import { Component, Inject, OnInit } from '@angular/core';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import { FormBuilder, FormGroup, AbstractControl, Validators } from '@angular/forms';
import { UntypedFormBuilder, UntypedFormGroup, AbstractControl, Validators } from '@angular/forms';
@Component({
selector: 'adf-cloud-process-filter-dialog-cloud',
@@ -30,10 +30,10 @@ export class ProcessFilterDialogCloudComponent implements OnInit {
public static ACTION_SAVE = 'SAVE';
defaultIcon = 'inbox';
filterForm: FormGroup;
filterForm: UntypedFormGroup;
constructor(
private fb: FormBuilder,
private fb: UntypedFormBuilder,
public dialogRef: MatDialogRef<ProcessFilterDialogCloudComponent>,
@Inject(MAT_DIALOG_DATA) public data) {
}

View File

@@ -110,7 +110,7 @@ describe('ProcessFiltersCloudComponent', () => {
expect(filters[2].nativeElement.innerText).toContain('FakeCompletedProcesses');
});
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'
};
@@ -119,9 +119,8 @@ describe('ProcessFiltersCloudComponent', () => {
const appName = 'my-app-1';
const change = new SimpleChange(null, appName, true);
component.error.subscribe((err) => {
await component.error.subscribe((err) => {
expect(err).toBeDefined();
done();
});
component.ngOnChanges({appName: change});

View File

@@ -65,17 +65,16 @@ describe('ProcessFilterCloudService', () => {
getCurrentUserInfoSpy = spyOn(identityUserService, 'getCurrentUserInfo').and.returnValue(identityUserMock);
});
it('should create processfilter key by using appName and the username', (done) => {
service.getProcessFilters('mock-appName').subscribe((res: any) => {
it('should create processfilter key by using appName and the username', async() => {
await service.getProcessFilters('mock-appName').subscribe((res: any) => {
expect(res).toBeDefined();
expect(getCurrentUserInfoSpy).toHaveBeenCalled();
done();
});
});
it('should create default process filters', (done) => {
it('should create default process filters', async() => {
getPreferencesSpy.and.returnValue(of(fakeEmptyProcessCloudFilterEntries));
service.getProcessFilters('mock-appName').subscribe((res: any) => {
await service.getProcessFilters('mock-appName').subscribe((res: any) => {
expect(res).toBeDefined();
expect(res).not.toBeNull();
expect(res.length).toBe(3);
@@ -94,13 +93,12 @@ describe('ProcessFilterCloudService', () => {
expect(res[2].id).toBe('3');
expect(res[2].name).toBe('MOCK_PROCESS_NAME_3');
expect(res[2].status).toBe('MOCK-COMPLETED');
done();
});
expect(createPreferenceSpy).toHaveBeenCalled();
});
it('should fetch the process filters if filters are available', (done) => {
service.getProcessFilters('mock-appName').subscribe((res: any) => {
it('should fetch the process filters if filters are available', async() => {
await service.getProcessFilters('mock-appName').subscribe((res: any) => {
expect(res).toBeDefined();
expect(res).not.toBeNull();
expect(res.length).toBe(3);
@@ -119,14 +117,13 @@ describe('ProcessFilterCloudService', () => {
expect(res[2].id).toBe('3');
expect(res[2].name).toBe('MOCK_PROCESS_NAME_3');
expect(res[2].status).toBe('MOCK-COMPLETED');
done();
});
expect(getPreferencesSpy).toHaveBeenCalled();
});
it('should create the process filters in case the filters are not exist in the user preferences', (done) => {
it('should create the process filters in case the filters are not exist in the user preferences', async() => {
getPreferencesSpy.and.returnValue(of(fakeProcessCloudFilterWithDifferentEntries));
service.getProcessFilters('mock-appName').subscribe((res: any) => {
await service.getProcessFilters('mock-appName').subscribe((res: any) => {
expect(res).toBeDefined();
expect(res).not.toBeNull();
expect(res.length).toBe(3);
@@ -145,68 +142,62 @@ describe('ProcessFilterCloudService', () => {
expect(res[2].id).toBe('3');
expect(res[2].name).toBe('MOCK_PROCESS_NAME_3');
expect(res[2].status).toBe('MOCK-COMPLETED');
done();
});
expect(getPreferencesSpy).toHaveBeenCalled();
expect(createPreferenceSpy).toHaveBeenCalled();
});
it('should return filter by process filter id', (done) => {
service.getFilterById('mock-appName', '2').subscribe((res: any) => {
it('should return filter by process filter id', async() => {
await service.getFilterById('mock-appName', '2').subscribe((res: any) => {
expect(res).toBeDefined();
expect(res).not.toBeNull();
expect(res.appName).toBe('mock-appName');
expect(res.id).toBe('2');
expect(res.name).toBe('MOCK_PROCESS_NAME_2');
expect(res.status).toBe('MOCK-RUNNING');
done();
});
expect(getPreferenceByKeySpy).toHaveBeenCalled();
});
it('should add process filter if filter is not exist in the filters', (done) => {
it('should add process filter if filter is not exist in the filters', async() => {
getPreferenceByKeySpy.and.returnValue(of([]));
service.getFilterById('mock-appName', '2').subscribe((res: any) => {
await service.getFilterById('mock-appName', '2').subscribe((res: any) => {
expect(res).toBeDefined();
expect(res).not.toBeNull();
expect(res.appName).toBe('mock-appName');
expect(res.id).toBe('2');
expect(res.name).toBe('MOCK_PROCESS_NAME_2');
expect(res.status).toBe('MOCK-RUNNING');
done();
});
});
it('should update filter', (done) => {
service.updateFilter(fakeProcessFilter).subscribe((res: any) => {
it('should update filter', async() => {
await service.updateFilter(fakeProcessFilter).subscribe((res: any) => {
expect(res).toBeDefined();
expect(res).not.toBeNull();
expect(res.length).toBe(3);
expect(res[0].appName).toBe('mock-appName');
expect(res[1].appName).toBe('mock-appName');
expect(res[2].appName).toBe('mock-appName');
done();
});
});
it('should create process filter when trying to update in case filter is not exist in the filters', (done) => {
it('should create process filter when trying to update in case filter is not exist in the filters', async() => {
getPreferenceByKeySpy.and.returnValue(of([]));
service.updateFilter(fakeProcessFilter).subscribe((res: any) => {
await service.updateFilter(fakeProcessFilter).subscribe((res: any) => {
expect(res).toBeDefined();
expect(res).not.toBeNull();
expect(res.length).toBe(3);
expect(res[0].appName).toBe('mock-appName');
expect(res[1].appName).toBe('mock-appName');
expect(res[2].appName).toBe('mock-appName');
done();
});
expect(createPreferenceSpy).toHaveBeenCalled();
});
it('should delete filter', (done) => {
service.deleteFilter(fakeProcessFilter).subscribe((res: any) => {
it('should delete filter', async() => {
await service.deleteFilter(fakeProcessFilter).subscribe((res: any) => {
expect(res).toBeDefined();
done();
});
expect(updatePreferenceSpy).toHaveBeenCalled();
});

View File

@@ -436,7 +436,7 @@ describe('ProcessListCloudComponent', () => {
expect(getProcessByRequestSpy).toHaveBeenCalled();
});
it('should reset pagination when resetPaginationValues is called', async (done) => {
it('should reset pagination when resetPaginationValues is called', (done) => {
spyOn(processListCloudService, 'getProcessByRequest').and.returnValue(of(fakeProcessCloudList));
const appName = new SimpleChange(null, 'FAKE-APP-NAME', true);
@@ -460,8 +460,9 @@ describe('ProcessListCloudComponent', () => {
skipCount: 200
};
component.updatePagination(pagination);
await fixture.whenStable();
component.resetPagination();
fixture.whenStable().then( () => {
component.resetPagination();
});
});
it('should set pagination and reload when updatePagination is called', (done) => {

View File

@@ -44,7 +44,7 @@ import { TranslateModule } from '@ngx-translate/core';
import { ProcessNameCloudPipe } from '../../../pipes/process-name-cloud.pipe';
import { ProcessInstanceCloud } from '../models/process-instance-cloud.model';
import { ESCAPE } from '@angular/cdk/keycodes';
import { ProcessDefinitionCloud, TaskVariableCloud } from 'process-services-cloud';
import { ProcessDefinitionCloud, TaskVariableCloud } from '@alfresco/adf-process-services-cloud';
describe('StartProcessCloudComponent', () => {

View File

@@ -22,7 +22,7 @@ import {
import { ProcessInstanceCloud } from '../models/process-instance-cloud.model';
import { StartProcessCloudService } from '../services/start-process-cloud.service';
import { FormControl, Validators, FormGroup, AbstractControl, FormBuilder, ValidatorFn } from '@angular/forms';
import { UntypedFormControl, Validators, UntypedFormGroup, AbstractControl, UntypedFormBuilder, ValidatorFn } from '@angular/forms';
import { FormModel, ContentLinkModel } from '@alfresco/adf-core';
import { MatAutocompleteTrigger } from '@angular/material/autocomplete';
import { ProcessPayloadCloud } from '../models/process-payload-cloud.model';
@@ -101,7 +101,7 @@ export class StartProcessCloudComponent implements OnChanges, OnInit, OnDestroy
processDefinitionList: ProcessDefinitionCloud[] = [];
processDefinitionCurrent: ProcessDefinitionCloud;
errorMessageId: string = '';
processForm: FormGroup;
processForm: UntypedFormGroup;
processPayloadCloud = new ProcessPayloadCloud();
filteredProcesses: ProcessDefinitionCloud[] = [];
isLoading = false;
@@ -116,14 +116,14 @@ export class StartProcessCloudComponent implements OnChanges, OnInit, OnDestroy
processDefinitionLoaded = false;
constructor(private startProcessCloudService: StartProcessCloudService,
private formBuilder: FormBuilder,
private formBuilder: UntypedFormBuilder,
private processNameCloudPipe: ProcessNameCloudPipe) {
}
ngOnInit() {
this.processForm = this.formBuilder.group({
processInstanceName: new FormControl('', [Validators.required, Validators.maxLength(this.getMaxNameLength()), Validators.pattern('^[^\\s]+(\\s+[^\\s]+)*$')]),
processDefinition: new FormControl(this.processDefinitionName, [Validators.required, this.processDefinitionNameValidator()])
processInstanceName: new UntypedFormControl('', [Validators.required, Validators.maxLength(this.getMaxNameLength()), Validators.pattern('^[^\\s]+(\\s+[^\\s]+)*$')]),
processDefinition: new UntypedFormControl(this.processDefinitionName, [Validators.required, this.processDefinitionNameValidator()])
});
this.processDefinition.valueChanges
@@ -388,8 +388,8 @@ export class StartProcessCloudComponent implements OnChanges, OnInit, OnDestroy
return !!process.name ? process.name : process.key;
}
get processInstanceName(): FormControl {
return this.processForm.get('processInstanceName') as FormControl;
get processInstanceName(): UntypedFormControl {
return this.processForm.get('processInstanceName') as UntypedFormControl;
}
get processDefinition(): AbstractControl {

View File

@@ -18,7 +18,7 @@ import { Component, EventEmitter, Input, OnInit, Output, ViewEncapsulation, OnDe
import { DateAdapter, MAT_DATE_FORMATS } from '@angular/material/core';
import moment, { Moment } from 'moment';
import { Observable, Subject } from 'rxjs';
import { FormBuilder, Validators, FormGroup, FormControl } from '@angular/forms';
import { UntypedFormBuilder, Validators, UntypedFormGroup, UntypedFormControl } from '@angular/forms';
import {
MOMENT_DATE_FORMATS, MomentDateAdapter,
LogService,
@@ -91,7 +91,7 @@ export class StartTaskCloudComponent implements OnInit, OnDestroy {
dateError: boolean;
taskForm: FormGroup;
taskForm: UntypedFormGroup;
currentUser: IdentityUserModel;
@@ -99,14 +99,14 @@ export class StartTaskCloudComponent implements OnInit, OnDestroy {
priorities: TaskPriorityOption[];
private assigneeForm = new FormControl('');
private groupForm = new FormControl('');
private assigneeForm = new UntypedFormControl('');
private groupForm = new UntypedFormControl('');
private onDestroy$ = new Subject<boolean>();
constructor(private taskService: TaskCloudService,
private dateAdapter: DateAdapter<Moment>,
private userPreferencesService: UserPreferencesService,
private formBuilder: FormBuilder,
private formBuilder: UntypedFormBuilder,
private identityUserService: IdentityUserService,
private logService: LogService) {
}
@@ -128,10 +128,10 @@ export class StartTaskCloudComponent implements OnInit, OnDestroy {
buildForm() {
this.taskForm = this.formBuilder.group({
name: new FormControl(this.name, [Validators.required, Validators.maxLength(this.getMaxNameLength()), this.whitespaceValidator]),
priority: new FormControl(''),
description: new FormControl('', [this.whitespaceValidator]),
formKey: new FormControl()
name: new UntypedFormControl(this.name, [Validators.required, Validators.maxLength(this.getMaxNameLength()), this.whitespaceValidator]),
priority: new UntypedFormControl(''),
description: new UntypedFormControl('', [this.whitespaceValidator]),
formKey: new UntypedFormControl()
});
}
@@ -216,25 +216,25 @@ export class StartTaskCloudComponent implements OnInit, OnDestroy {
this.candidateGroups.hasError());
}
public whitespaceValidator(control: FormControl) {
public whitespaceValidator(control: UntypedFormControl) {
const isWhitespace = (control.value || '').trim().length === 0;
const isValid = control.value.length === 0 || !isWhitespace;
return isValid ? null : { whitespace: true };
}
get nameController(): FormControl {
return this.taskForm.get('name') as FormControl;
get nameController(): UntypedFormControl {
return this.taskForm.get('name') as UntypedFormControl;
}
get priorityController(): FormControl {
return this.taskForm.get('priority') as FormControl;
get priorityController(): UntypedFormControl {
return this.taskForm.get('priority') as UntypedFormControl;
}
get assigneeFormControl(): FormControl {
get assigneeFormControl(): UntypedFormControl {
return this.assigneeForm;
}
get candidateUserFormControl(): FormControl {
get candidateUserFormControl(): UntypedFormControl {
return this.groupForm;
}

View File

@@ -21,7 +21,7 @@ import { TaskCloudService } from './../../../services/task-cloud.service';
import { AppsProcessCloudService } from './../../../../app/services/apps-process-cloud.service';
import { DateCloudFilterType, DateRangeFilter } from '../../../../models/date-cloud-filter.model';
import moment, { Moment } from 'moment';
import { AbstractControl, FormBuilder, FormGroup } from '@angular/forms';
import { AbstractControl, UntypedFormBuilder, UntypedFormGroup } from '@angular/forms';
import { debounceTime, filter, finalize, switchMap, takeUntil } from 'rxjs/operators';
import { Observable, Subject } from 'rxjs';
import { DateAdapter } from '@angular/material/core';
@@ -102,7 +102,7 @@ export abstract class BaseEditTaskFilterCloudComponent<T> implements OnInit, OnC
protected processDefinitionNames: DropdownOption[] = [];
protected formHasBeenChanged = false;
editTaskFilterForm: FormGroup;
editTaskFilterForm: UntypedFormGroup;
taskFilterProperties: TaskFilterProperties[] = [];
taskFilterActions: TaskFilterAction[] = [];
toggleFilterActions: boolean = false;
@@ -126,7 +126,7 @@ export abstract class BaseEditTaskFilterCloudComponent<T> implements OnInit, OnC
isLoading: boolean = false;
constructor(
protected formBuilder: FormBuilder,
protected formBuilder: UntypedFormBuilder,
protected dateAdapter: DateAdapter<Moment>,
protected userPreferencesService: UserPreferencesService,
protected appsProcessCloudService: AppsProcessCloudService,

View File

@@ -16,7 +16,7 @@
*/
import { Component, ViewEncapsulation } from '@angular/core';
import { FormBuilder } from '@angular/forms';
import { UntypedFormBuilder } from '@angular/forms';
import { DateAdapter } from '@angular/material/core';
import { MatDialog } from '@angular/material/dialog';
import { takeUntil } from 'rxjs/operators';
@@ -38,7 +38,7 @@ import { BaseEditTaskFilterCloudComponent, DropdownOption } from './base-edit-ta
})
export class EditServiceTaskFilterCloudComponent extends BaseEditTaskFilterCloudComponent<ServiceTaskFilterCloudModel> {
constructor(
formBuilder: FormBuilder,
formBuilder: UntypedFormBuilder,
dialog: MatDialog,
translateService: TranslationService,
private serviceTaskFilterCloudService: ServiceTaskFilterCloudService,

View File

@@ -16,7 +16,7 @@
*/
import { Component, ViewEncapsulation } from '@angular/core';
import { FormBuilder } from '@angular/forms';
import { UntypedFormBuilder } from '@angular/forms';
import { DateAdapter } from '@angular/material/core';
import { MatDialog } from '@angular/material/dialog';
import { takeUntil, map } from 'rxjs/operators';
@@ -39,7 +39,7 @@ import { BaseEditTaskFilterCloudComponent, DropdownOption } from './base-edit-ta
})
export class EditTaskFilterCloudComponent extends BaseEditTaskFilterCloudComponent<TaskFilterCloudModel> {
constructor(
formBuilder: FormBuilder,
formBuilder: UntypedFormBuilder,
dialog: MatDialog,
translateService: TranslationService,
private taskFilterCloudService: TaskFilterCloudService,

View File

@@ -114,7 +114,7 @@ describe('ServiceTaskFiltersCloudComponent', () => {
expect(filters[2].nativeElement.innerText).toContain('FakeMyServiceTasks2');
});
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'
};
@@ -123,9 +123,8 @@ describe('ServiceTaskFiltersCloudComponent', () => {
const appName = 'my-app-1';
const change = new SimpleChange(null, appName, true);
component.error.subscribe((err) => {
await component.error.subscribe((err) => {
expect(err).toBeDefined();
done();
});
component.ngOnChanges({appName: change});

View File

@@ -16,7 +16,7 @@
*/
import { Component, Input, Output, EventEmitter, OnInit } from '@angular/core';
import { FormControl } from '@angular/forms';
import { UntypedFormControl } from '@angular/forms';
import { AssignmentType, TaskFilterProperties } from '../../models/filter-cloud.model';
import { IdentityUserModel } from '../../../../people/models/identity-user.model';
import { IdentityUserService } from '../../../../people/services/identity-user.service';
@@ -39,7 +39,7 @@ export class TaskAssignmentFilterCloudComponent implements OnInit {
assignmentType: AssignmentType;
candidateGroups: IdentityGroupModel[] = [];
groupForm = new FormControl('');
groupForm = new UntypedFormControl('');
assignmentTypeList = {
unassigned: AssignmentType.UNASSIGNED,
currentUser: AssignmentType.CURRENT_USER,

View File

@@ -17,7 +17,7 @@
import { Component, Inject, OnInit } from '@angular/core';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import { FormBuilder, FormGroup, AbstractControl, Validators } from '@angular/forms';
import { UntypedFormBuilder, UntypedFormGroup, AbstractControl, Validators } from '@angular/forms';
@Component({
selector: 'adf-cloud-task-filter-dialog',
@@ -30,10 +30,10 @@ export class TaskFilterDialogCloudComponent implements OnInit {
public static ACTION_SAVE = 'SAVE';
defaultIcon = 'inbox';
filterForm: FormGroup;
filterForm: UntypedFormGroup;
constructor(
private fb: FormBuilder,
private fb: UntypedFormBuilder,
public dialogRef: MatDialogRef<TaskFilterDialogCloudComponent>,
@Inject(MAT_DIALOG_DATA) public data) {
}

View File

@@ -45,7 +45,6 @@ describe('TaskFilterCloudService', () => {
let getPreferencesSpy: jasmine.Spy;
let getPreferenceByKeySpy: jasmine.Spy;
let createPreferenceSpy: jasmine.Spy;
let updatePreferenceSpy: jasmine.Spy;
let getCurrentUserInfoSpy: jasmine.Spy;
const identityUserMock = { username: 'fakeusername', firstName: 'fake-identity-first-name', lastName: 'fake-identity-last-name', email: 'fakeIdentity@email.com' };
@@ -66,7 +65,6 @@ describe('TaskFilterCloudService', () => {
const preferenceCloudService = service.preferenceService;
createPreferenceSpy = spyOn(preferenceCloudService, 'createPreference').and.returnValue(of(fakeTaskCloudFilters));
updatePreferenceSpy = spyOn(preferenceCloudService, 'updatePreference').and.returnValue(of(fakeTaskCloudFilters));
getPreferencesSpy = spyOn(preferenceCloudService, 'getPreferences').and.returnValue(of(fakeTaskCloudPreferenceList));
getPreferenceByKeySpy = spyOn(preferenceCloudService, 'getPreferenceByKey').and.returnValue(of(fakeTaskCloudFilters));
@@ -74,17 +72,16 @@ describe('TaskFilterCloudService', () => {
getCurrentUserInfoSpy = spyOn(identityUserService, 'getCurrentUserInfo').and.returnValue(identityUserMock);
});
it('should create task filter key by using appName and the username', (done) => {
service.getTaskListFilters('fakeAppName').subscribe((res: any) => {
it('should create task filter key by using appName and the username', async() => {
await service.getTaskListFilters('fakeAppName').subscribe((res: any) => {
expect(res).toBeDefined();
expect(getCurrentUserInfoSpy).toHaveBeenCalled();
done();
});
});
it('should create default task filters if there are no task filter preferences', (done) => {
it('should create default task filters if there are no task filter preferences', async() => {
getPreferencesSpy.and.returnValue(of(fakeEmptyTaskCloudPreferenceList));
service.getTaskListFilters('fakeAppName').subscribe((res: any) => {
await service.getTaskListFilters('fakeAppName').subscribe((res: any) => {
expect(res).toBeDefined();
expect(res).not.toBeNull();
expect(res.length).toBe(3);
@@ -103,13 +100,12 @@ describe('TaskFilterCloudService', () => {
expect(res[2].id).toBe('3');
expect(res[2].name).toBe('FAKE_TASK_3');
expect(res[2].status).toBe('COMPLETED');
done();
});
expect(createPreferenceSpy).toHaveBeenCalled();
});
it('should return the task filters if filters available', (done) => {
service.getTaskListFilters('fakeAppName').subscribe((res: any) => {
it('should return the task filters if filters available', async() => {
await service.getTaskListFilters('fakeAppName').subscribe((res: any) => {
expect(res).toBeDefined();
expect(res).not.toBeNull();
expect(res.length).toBe(3);
@@ -128,14 +124,14 @@ describe('TaskFilterCloudService', () => {
expect(res[2].id).toBe('3');
expect(res[2].name).toBe('FAKE_TASK_3');
expect(res[2].status).toBe('COMPLETED');
done();
});
expect(getPreferencesSpy).toHaveBeenCalled();
});
it('should create the task filters if the user preference does not have task filters', (done) => {
it('should create the task filters if the user preference does not have task filters', async() => {
getPreferencesSpy.and.returnValue(of(fakePreferenceWithNoTaskFilterPreference));
service.getTaskListFilters('fakeAppName').subscribe((res: any) => {
await service.getTaskListFilters('fakeAppName').subscribe( (res) => {
expect(res).toBeDefined();
expect(res).not.toBeNull();
expect(res.length).toBe(3);
@@ -154,73 +150,59 @@ describe('TaskFilterCloudService', () => {
expect(res[2].id).toBe('3');
expect(res[2].name).toBe('FAKE_TASK_3');
expect(res[2].status).toBe('COMPLETED');
done();
});
expect(getPreferencesSpy).toHaveBeenCalled();
expect(createPreferenceSpy).toHaveBeenCalled();
});
it('should return filter by task filter id', (done) => {
service.getTaskFilterById('fakeAppName', '2').subscribe((res: any) => {
it('should return filter by task filter id', async() => {
await service.getTaskFilterById('fakeAppName', '2').subscribe((res: any) => {
expect(res).toBeDefined();
expect(res).not.toBeNull();
expect(res.appName).toBe('fakeAppName');
expect(res.id).toBe('2');
expect(res.name).toBe('FAKE_TASK_2');
expect(res.status).toBe('RUNNING');
done();
});
expect(getPreferenceByKeySpy).toHaveBeenCalled();
});
it('should add task filter if filter is not exist in the filters', (done) => {
it('should add task filter if filter is not exist in the filters', async() => {
getPreferenceByKeySpy.and.returnValue(of([]));
service.getTaskFilterById('fakeAppName', '2').subscribe((res: any) => {
await service.getTaskFilterById('fakeAppName', '2').subscribe((res: any) => {
expect(res).toBeDefined();
expect(res).not.toBeNull();
expect(res.appName).toBe('fakeAppName');
expect(res.id).toBe('2');
expect(res.name).toBe('FAKE_TASK_2');
expect(res.status).toBe('RUNNING');
done();
});
});
it('should update filter', (done) => {
it('should update filter', async() => {
createPreferenceSpy.and.returnValue(of(fakeTaskCloudFilters));
service.updateFilter(fakeTaskFilter).subscribe((res: any) => {
await service.updateFilter(fakeTaskFilter).subscribe((res: any) => {
expect(res).toBeDefined();
expect(res).not.toBeNull();
expect(res.length).toBe(3);
expect(res[0].appName).toBe('fakeAppName');
expect(res[1].appName).toBe('fakeAppName');
expect(res[2].appName).toBe('fakeAppName');
done();
});
});
it('should create task filter when trying to update in case filter is not exist in the filters', (done) => {
it('should create task filter when trying to update in case filter is not exist in the filters', async() => {
getPreferenceByKeySpy.and.returnValue(of([]));
service.updateFilter(fakeTaskFilter).subscribe((res: any) => {
await service.updateFilter(fakeTaskFilter).subscribe((res: any) => {
expect(res).toBeDefined();
expect(res).not.toBeNull();
expect(res.length).toBe(3);
expect(res[0].appName).toBe('fakeAppName');
expect(res[1].appName).toBe('fakeAppName');
expect(res[2].appName).toBe('fakeAppName');
done();
});
expect(createPreferenceSpy).toHaveBeenCalled();
});
it('should delete filter', (done) => {
service.deleteFilter(fakeTaskFilter).subscribe((res: any) => {
expect(res).toBeDefined();
done();
});
expect(updatePreferenceSpy).toHaveBeenCalled();
});
it('should check if given filter is a default filter', () => {
const fakeFilterName = 'fake-task-filter';
const defaultFilterName = 'ADF_CLOUD_TASK_FILTERS.MY_TASKS';
@@ -229,14 +211,13 @@ describe('TaskFilterCloudService', () => {
expect(service.isDefaultFilter(fakeFilterName)).toBe(false);
});
it('should return engine event task subscription', (done) => {
it('should return engine event task subscription', async() => {
spyOn(notificationCloudService, 'makeGQLQuery').and.returnValue(of(taskCloudEngineEventsMock));
service.getTaskNotificationSubscription('myAppName').subscribe((res: TaskCloudEngineEvent[]) => {
await service.getTaskNotificationSubscription('myAppName').subscribe((res: TaskCloudEngineEvent[]) => {
expect(res.length).toBe(1);
expect(res[0].eventType).toBe('TASK_ASSIGNED');
expect(res[0].entity.name).toBe('This is a new task');
done();
});
});
});
@@ -264,9 +245,9 @@ describe('Inject [LocalPreferenceCloudService] into the TaskFilterCloudService',
spyOn(identityUserService, 'getCurrentUserInfo').and.returnValue(identityUserMock);
});
it('should create default task filters if there are no task filter preferences', (done) => {
it('should create default task filters if there are no task filter preferences', async() => {
const appName = 'fakeAppName';
service.getTaskListFilters(appName).subscribe((res: TaskFilterCloudModel[]) => {
await service.getTaskListFilters(appName).subscribe((res: TaskFilterCloudModel[]) => {
expect(res.length).toEqual(3);
expect(res[0].name).toEqual('ADF_CLOUD_TASK_FILTERS.MY_TASKS');
@@ -287,8 +268,6 @@ describe('Inject [LocalPreferenceCloudService] into the TaskFilterCloudService',
expect(res[2].appName).toEqual(appName);
expect(res[2].icon).toEqual('done');
expect(res[2].status).toEqual('COMPLETED');
done();
});
expect(getPreferencesSpy).toHaveBeenCalled();

View File

@@ -197,7 +197,7 @@ describe('TaskHeaderCloudComponent', () => {
expect(valueEl.nativeElement.value).toEqual('ADF_CLOUD_TASK_HEADER.PROPERTIES.PARENT_NAME_DEFAULT');
});
it('should be able to call update service on updating task description', async (done) => {
it('should be able to call update service on updating task description', async () => {
spyOn(taskCloudService, 'updateTask').and.returnValue(of(assignedTaskDetailsCloudMock));
fixture.detectChanges();
await fixture.whenStable();
@@ -209,7 +209,6 @@ describe('TaskHeaderCloudComponent', () => {
await fixture.whenStable();
fixture.detectChanges();
expect(taskCloudService.updateTask).toHaveBeenCalled();
done();
});
it('should roll back task description on error', fakeAsync(() => {
@@ -579,20 +578,13 @@ describe('TaskHeaderCloudComponent', () => {
});
it('should emit an error when app name and/or task id are not provided', (done) => {
component.error.subscribe((error) => {
expect(error).toEqual('App Name and Task Id are mandatory');
component.error.subscribe( (err) => {
expect(err).toEqual('App Name and Task Id are mandatory');
done();
});
component.appName = '';
component.taskId = '';
component.ngOnChanges();
component.appName = 'app';
component.ngOnChanges();
component.appName = '';
component.taskId = 'taskId';
component.taskId = undefined;
component.ngOnChanges();
});

View File

@@ -307,7 +307,7 @@ describe('ServiceTaskListCloudComponent', () => {
expect(getServiceTaskByRequestSpy).toHaveBeenCalled();
});
it('should reset pagination when resetPaginationValues is called', async (done) => {
it('should reset pagination when resetPaginationValues is called', (done) => {
spyOn(serviceTaskListCloudService, 'getServiceTaskByRequest').and.returnValue(of(fakeServiceTask));
const appName = new SimpleChange(null, 'FAKE-APP-NAME', true);
@@ -331,8 +331,9 @@ describe('ServiceTaskListCloudComponent', () => {
skipCount: 200
};
component.updatePagination(pagination);
await fixture.whenStable();
component.resetPagination();
fixture.whenStable().then( () => {
component.resetPagination();
});
});
it('should set pagination and reload when updatePagination is called', (done) => {

View File

@@ -363,7 +363,7 @@ describe('TaskListCloudComponent', () => {
expect(getTaskByRequestSpy).toHaveBeenCalled();
});
it('should reset pagination when resetPaginationValues is called', async (done) => {
it('should reset pagination when resetPaginationValues is called', (done) => {
spyOn(taskListCloudService, 'getTaskByRequest').and.returnValue(of(fakeGlobalTasks));
const appName = new SimpleChange(null, 'FAKE-APP-NAME', true);
@@ -387,8 +387,9 @@ describe('TaskListCloudComponent', () => {
skipCount: 200
};
component.updatePagination(pagination);
await fixture.whenStable();
component.resetPagination();
fixture.whenStable().then( () => {
component.resetPagination();
});
});
it('should set pagination and reload when updatePagination is called', (done) => {

View File

@@ -0,0 +1,26 @@
{
"extends": "../../tsconfig.json",
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.lib.json"
},
{
"path": "./tsconfig.lib.prod.json"
},
{
"path": "./tsconfig.spec.json"
}
],
"compilerOptions": {
"baseUrl": "src",
"target": "es2020"
},
"angularCompilerOptions": {
"skipTemplateCodegen": true,
"strictMetadataEmit": true,
"enableResourceInlining": true,
"strictTemplates": true
}
}

View File

@@ -1,23 +1,16 @@
{
"extends": "../tsconfig.json",
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../dist/process-services-cloud/",
"outDir": "../../dist/out-tsc",
"declarationMap": true,
"baseUrl": "src",
"resolveJsonModule": true,
"paths": {
"@alfresco/adf-extensions": ["../../dist/extensions"],
"@alfresco/adf-extensions/*": ["../../dist/extensions/*"],
"@alfresco/adf-core": ["../../dist/core"],
"@alfresco/adf-core/*": ["../../dist/core/*"],
"@alfresco/adf-content-services": ["../../dist/content-services"],
"@alfresco/adf-content-services/*": ["../../dist/content-services/*"]
"@alfresco/adf-extensions": ["../../../dist/libs/extensions"],
"@alfresco/adf-extensions/*": ["../../../dist/libs/extensions/*"],
"@alfresco/adf-core": ["../../../dist/libs/core"],
"@alfresco/adf-core/*": ["../../../dist/libs/core/*"],
"@alfresco/adf-content-services": ["../../../dist/libs/content-services"],
"@alfresco/adf-content-services/*": ["../../../dist/libs/content-services/*"]
}
},
"angularCompilerOptions": {
"skipTemplateCodegen": true,
"strictMetadataEmit": true,
"enableResourceInlining": true,
"strictTemplates": true
}
}

View File

@@ -1,6 +1,8 @@
{
"extends": "../tsconfig.spec.json",
"files": [
"src/test.ts"
]
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc"
},
"files": ["src/test.ts"],
"include": ["**/*.spec.ts", "**/*.test.ts", "**/*.d.ts"]
}