From b16e326ac34b72d8b55f46ded412881529856298 Mon Sep 17 00:00:00 2001 From: Denys Vuika Date: Wed, 13 Aug 2025 08:01:09 -0400 Subject: [PATCH] AAE-36664 additional linting rules, cleanup (#11084) --- .eslintrc.js | 6 + .../common/services/content.service.spec.ts | 2 - .../lib/common/services/rendition.service.ts | 8 +- .../sites-dropdown.component.spec.ts | 8 +- .../site-dropdown/sites-dropdown.component.ts | 4 + .../src/lib/dialogs/folder/folder.dialog.ts | 2 +- .../directives/node-delete.directive.spec.ts | 10 +- .../directives/node-restore.directive.spec.ts | 8 +- .../document-list.component.spec.ts | 6 +- .../components/document-list.component.ts | 4 +- .../models/content-action.model.ts | 14 - .../services/folder-actions.service.spec.ts | 10 +- .../search-check-list.component.spec.ts | 6 +- .../tag-actions/tag-actions.component.spec.ts | 12 +- .../alfresco-viewer.component.spec.ts | 2 +- .../components/alfresco-viewer.component.ts | 8 +- .../api/src/lib/adf-http-client.service.ts | 2 +- .../components/flags/flags.component.spec.ts | 6 +- .../lib/components/flags/flags.component.ts | 4 +- .../app-config/debug-app-config.service.ts | 37 - lib/core/src/lib/app-config/public-api.ts | 1 - .../src/lib/auth/mock/identity-group.mock.ts | 14 - .../auth/mock/identity-group.service.mock.ts | 142 -- .../src/lib/auth/mock/oauth2.service.mock.ts | 133 -- .../src/lib/auth/oidc/oidc-auth.guard.spec.ts | 5 +- .../auth/oidc/redirect-auth.service.spec.ts | 4 +- .../lib/common/services/storage.service.ts | 2 +- .../form/components/mock/cloud-form.mock.ts | 1330 ----------------- .../mock/form-renderer.component.mock.ts | 31 - .../src/lib/form/components/mock/form.mock.ts | 1046 ------------- .../widgets/core/form-field.model.ts | 2 +- .../lib/form/models/form-rules.model.spec.ts | 16 +- lib/core/src/lib/mock/data-column.mock.ts | 23 - .../form/widget-visibility.service.mock.ts | 6 - lib/core/src/lib/mock/public-api.ts | 4 - .../src/lib/testing/unit-testing-utils.ts | 47 +- .../translation/translate-loader.service.ts | 20 +- .../img-viewer/img-viewer.component.ts | 28 +- .../pdf-viewer/pdf-viewer.component.spec.ts | 4 +- .../components/viewer.component.spec.ts | 4 +- .../lib/viewer/components/viewer.component.ts | 2 +- .../directives/viewer-extension.directive.ts | 2 +- .../services/rendering-queue.services.ts | 21 +- .../lib/viewer/services/view-util.service.ts | 18 +- lib/core/test.ts | 4 +- lib/insights/src/lib/insights.module.ts | 10 +- .../app-list-cloud.component.spec.ts | 2 +- .../services/apps-process-cloud.service.ts | 16 +- .../form/components/form-cloud.component.ts | 26 +- .../group/components/group-cloud.component.ts | 2 +- .../components/people-cloud.component.ts | 2 +- .../src/lib/process-services-cloud.module.ts | 3 +- .../process-list-cloud.component.spec.ts | 2 +- .../process-list-datatable-adapter.spec.ts | 3 +- .../mock/start-process.component.mock.ts | 11 - .../services/variable-mapper.sevice.spec.ts | 4 +- .../task-list-datatable-adapter.spec.ts | 3 +- .../src/lib/testing/data-column.mock.ts} | 26 +- .../lib/app-list/apps-list.component.spec.ts | 2 +- .../form/form-definition-readonly.mock.ts | 0 .../form/form-definition-visibility.mock.ts | 0 .../src/lib}/form/form-definition.mock.ts | 0 .../src/lib}/form/form.component.mock.ts | 0 .../src/lib/form/form.component.spec.ts | 2 +- .../form/form.component.visibility.spec.ts | 13 +- .../editors/row-editor/row.editor.ts | 10 +- .../lib/form/widgets/people/people.widget.ts | 7 +- .../process-list/services/process.service.ts | 2 +- .../src/lib/process.module.ts | 11 + .../task-form/task-form.component.spec.ts | 2 +- .../task-header/task-header.component.spec.ts | 2 +- 71 files changed, 235 insertions(+), 2994 deletions(-) delete mode 100644 lib/core/src/lib/app-config/debug-app-config.service.ts delete mode 100644 lib/core/src/lib/auth/mock/identity-group.service.mock.ts delete mode 100644 lib/core/src/lib/auth/mock/oauth2.service.mock.ts delete mode 100644 lib/core/src/lib/form/components/mock/cloud-form.mock.ts rename lib/{content-services/src/lib/testing/mat-icon-registry-mock.ts => process-services-cloud/src/lib/testing/data-column.mock.ts} (53%) rename lib/{core/src/lib/mock => process-services/src/lib}/form/form-definition-readonly.mock.ts (100%) rename lib/{core/src/lib/mock => process-services/src/lib}/form/form-definition-visibility.mock.ts (100%) rename lib/{core/src/lib/mock => process-services/src/lib}/form/form-definition.mock.ts (100%) rename lib/{core/src/lib/mock => process-services/src/lib}/form/form.component.mock.ts (100%) diff --git a/.eslintrc.js b/.eslintrc.js index abf782033b..44c7f82106 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -28,6 +28,11 @@ module.exports = { 'plugin:@angular-eslint/recommended', 'plugin:@angular-eslint/template/process-inline-templates', 'plugin:jsdoc/recommended-typescript-error' + // Uncomment this once all linting issues are fixed + // Note to developers: + // you can uncomment the full ruleset locally when fixing issues, and then comment + // that will allow splitting the work into smaller chunks + // 'plugin:unicorn/recommended' ], plugins: [ 'eslint-plugin-unicorn', @@ -152,6 +157,7 @@ module.exports = { 'rxjs/no-subject-value': 'error', 'rxjs/no-unsafe-takeuntil': 'error', 'unicorn/filename-case': 'error', + 'unicorn/prefer-optional-catch-binding': 'error', '@typescript-eslint/no-unused-expressions': [ 'error', { diff --git a/lib/content-services/src/lib/common/services/content.service.spec.ts b/lib/content-services/src/lib/common/services/content.service.spec.ts index 295bb7a24a..cd4cfc71cf 100644 --- a/lib/content-services/src/lib/common/services/content.service.spec.ts +++ b/lib/content-services/src/lib/common/services/content.service.spec.ts @@ -20,7 +20,6 @@ import { ContentService } from './content.service'; import { AppConfigService, AuthenticationService, RedirectAuthService, StorageService } from '@alfresco/adf-core'; import { Node, PermissionsInfo } from '@alfresco/js-api'; import { EMPTY, of } from 'rxjs'; -import { HttpClientTestingModule } from '@angular/common/http/testing'; describe('ContentService', () => { let contentService: ContentService; @@ -29,7 +28,6 @@ describe('ContentService', () => { beforeEach(() => { TestBed.configureTestingModule({ - imports: [HttpClientTestingModule], providers: [ContentService, AuthenticationService, { provide: RedirectAuthService, useValue: { onLogin: EMPTY, onTokenReceived: of() } }] }); authService = TestBed.inject(AuthenticationService); diff --git a/lib/content-services/src/lib/common/services/rendition.service.ts b/lib/content-services/src/lib/common/services/rendition.service.ts index 0169515a83..f4e6a615a2 100644 --- a/lib/content-services/src/lib/common/services/rendition.service.ts +++ b/lib/content-services/src/lib/common/services/rendition.service.ts @@ -73,7 +73,11 @@ export class RenditionService { return this._versionsApi; } - constructor(private apiService: AlfrescoApiService, private translateService: TranslationService, private viewUtilsService: ViewUtilService) {} + constructor( + private readonly apiService: AlfrescoApiService, + private readonly translateService: TranslationService, + private readonly viewUtilsService: ViewUtilService + ) {} getRenditionUrl(nodeId: string, type: string, renditionExists: boolean): string { return renditionExists && type !== RenditionService.ContentGroup.IMAGE @@ -167,7 +171,7 @@ export class RenditionService { } try { return versionId ? await this.waitNodeRendition(nodeId, renditionId, versionId) : await this.waitNodeRendition(nodeId, renditionId); - } catch (e) { + } catch { return null; } } catch { diff --git a/lib/content-services/src/lib/content-node-selector/site-dropdown/sites-dropdown.component.spec.ts b/lib/content-services/src/lib/content-node-selector/site-dropdown/sites-dropdown.component.spec.ts index 4a792b20d6..d488e1c4fd 100644 --- a/lib/content-services/src/lib/content-node-selector/site-dropdown/sites-dropdown.component.spec.ts +++ b/lib/content-services/src/lib/content-node-selector/site-dropdown/sites-dropdown.component.spec.ts @@ -54,7 +54,7 @@ const customSiteList = { describe('DropdownSitesComponent', () => { let loader: HarnessLoader; - let component: any; + let component: DropdownSitesComponent; let fixture: ComponentFixture; let element: HTMLElement; let siteService: SitesService; @@ -167,7 +167,7 @@ describe('DropdownSitesComponent', () => { }); it('should load custom sites when the "siteList" input property is given a value', async () => { - component.siteList = customSiteList; + component.siteList = customSiteList as any; fixture.detectChanges(); await fixture.whenStable(); @@ -246,7 +246,7 @@ describe('DropdownSitesComponent', () => { fixture.whenStable().then(() => { expect(component.selected).toBeUndefined(); - expect(component.loading).toBeFalsy(); + expect(component.isLoading).toBeFalsy(); done(); }); }); @@ -290,7 +290,7 @@ describe('DropdownSitesComponent', () => { describe('No relations', () => { beforeEach(() => { - component.relations = []; + component.relations = ''; authService = TestBed.inject(AuthenticationService); }); diff --git a/lib/content-services/src/lib/content-node-selector/site-dropdown/sites-dropdown.component.ts b/lib/content-services/src/lib/content-node-selector/site-dropdown/sites-dropdown.component.ts index 8754428afb..17fe4d0386 100644 --- a/lib/content-services/src/lib/content-node-selector/site-dropdown/sites-dropdown.component.ts +++ b/lib/content-services/src/lib/content-node-selector/site-dropdown/sites-dropdown.component.ts @@ -89,6 +89,10 @@ export class DropdownSitesComponent implements OnInit { selected: SiteEntry = null; MY_FILES_VALUE = '-my-'; + get isLoading(): boolean { + return this.loading; + } + constructor( private authService: AuthenticationService, private sitesService: SitesService, diff --git a/lib/content-services/src/lib/dialogs/folder/folder.dialog.ts b/lib/content-services/src/lib/dialogs/folder/folder.dialog.ts index 17d68495c4..21fd4de484 100644 --- a/lib/content-services/src/lib/dialogs/folder/folder.dialog.ts +++ b/lib/content-services/src/lib/dialogs/folder/folder.dialog.ts @@ -161,7 +161,7 @@ export class FolderDialogComponent implements OnInit { if (statusCode === 409) { errorMessage = 'CORE.MESSAGES.ERRORS.EXISTENT_FOLDER'; } - } catch (err) { + } catch { /* Do nothing, keep the original message */ } diff --git a/lib/content-services/src/lib/directives/node-delete.directive.spec.ts b/lib/content-services/src/lib/directives/node-delete.directive.spec.ts index 80a3751479..bbfd136bf2 100644 --- a/lib/content-services/src/lib/directives/node-delete.directive.spec.ts +++ b/lib/content-services/src/lib/directives/node-delete.directive.spec.ts @@ -20,7 +20,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { By } from '@angular/platform-browser'; import { NodeDeleteDirective } from './node-delete.directive'; import { RedirectAuthService } from '@alfresco/adf-core'; -import { EMPTY, of } from 'rxjs'; +import { EMPTY, of, Subscription } from 'rxjs'; import { CheckAllowableOperationDirective } from './check-allowable-operation.directive'; @Component({ @@ -73,10 +73,10 @@ describe('NodeDeleteDirective', () => { let elementWithPermanentDelete: DebugElement; let component: TestComponent; let componentWithPermanentDelete: TestDeletePermanentComponent; - let deleteNodeSpy: any; - let disposableDelete: any; - let deleteNodePermanentSpy: any; - let purgeDeletedNodePermanentSpy: any; + let deleteNodeSpy: jasmine.Spy; + let disposableDelete: Subscription; + let deleteNodePermanentSpy: jasmine.Spy; + let purgeDeletedNodePermanentSpy: jasmine.Spy; beforeEach(() => { TestBed.configureTestingModule({ diff --git a/lib/content-services/src/lib/directives/node-restore.directive.spec.ts b/lib/content-services/src/lib/directives/node-restore.directive.spec.ts index 16a4b87ee7..421ec4f580 100644 --- a/lib/content-services/src/lib/directives/node-restore.directive.spec.ts +++ b/lib/content-services/src/lib/directives/node-restore.directive.spec.ts @@ -38,7 +38,7 @@ describe('NodeRestoreDirective', () => { let component: TestComponent; let trashcanApi: TrashcanApi; let directiveInstance: NodeRestoreDirective; - let restoreNodeSpy: any; + let restoreNodeSpy: jasmine.Spy; let translationService: TranslationService; beforeEach(() => { @@ -131,7 +131,7 @@ describe('NodeRestoreDirective', () => { it('should notify on multiple fails', (done) => { const error = { message: '{ "error": {} }' }; - directiveInstance.restore.subscribe((event: any) => { + directiveInstance.restore.subscribe((event) => { expect(event.message).toEqual('CORE.RESTORE_NODE.PARTIAL_PLURAL'); done(); }); @@ -193,7 +193,7 @@ describe('NodeRestoreDirective', () => { restoreNodeSpy.and.returnValue(Promise.reject(error)); - directiveInstance.restore.subscribe((event: any) => { + directiveInstance.restore.subscribe((event) => { expect(event.message).toEqual('CORE.RESTORE_NODE.LOCATION_MISSING'); done(); }); @@ -205,7 +205,7 @@ describe('NodeRestoreDirective', () => { }); it('should notify success when restore multiple nodes', (done) => { - directiveInstance.restore.subscribe((event: any) => { + directiveInstance.restore.subscribe((event) => { expect(event.message).toEqual('CORE.RESTORE_NODE.PLURAL'); done(); diff --git a/lib/content-services/src/lib/document-list/components/document-list.component.spec.ts b/lib/content-services/src/lib/document-list/components/document-list.component.spec.ts index 338be67215..859a4d68ea 100644 --- a/lib/content-services/src/lib/document-list/components/document-list.component.spec.ts +++ b/lib/content-services/src/lib/document-list/components/document-list.component.spec.ts @@ -52,7 +52,6 @@ import { } from '../../mock'; import { ContentTestingModule } from '../../testing/content.testing.module'; import { domSanitizerMock } from '../../testing/dom-sanitizer-mock'; -import { matIconRegistryMock } from '../../testing/mat-icon-registry-mock'; import { ImageResolver } from '../data/image-resolver.model'; import { RowFilter } from '../data/row-filter.model'; import { ShareDataRow } from '../data/share-data-row.model'; @@ -64,11 +63,16 @@ import { FileAutoDownloadComponent } from './file-auto-download/file-auto-downlo import { DocumentListComponent } from './document-list.component'; import { CustomResourcesService, DocumentListService } from '../public-api'; import { CommonModule } from '@angular/common'; +import { MatIconRegistry } from '@angular/material/icon'; const mockDialog = { open: jasmine.createSpy('open') }; +export const matIconRegistryMock = { + addSvgIconInNamespace: () => {} +} as any as MatIconRegistry; + describe('DocumentList', () => { let loader: HarnessLoader; let documentList: DocumentListComponent; diff --git a/lib/content-services/src/lib/document-list/components/document-list.component.ts b/lib/content-services/src/lib/document-list/components/document-list.component.ts index 6230cd976d..8901fb6d23 100644 --- a/lib/content-services/src/lib/document-list/components/document-list.component.ts +++ b/lib/content-services/src/lib/document-list/components/document-list.component.ts @@ -430,7 +430,7 @@ export class DocumentListComponent extends DataTableSchema implements OnInit, On dataTable: DataTableComponent; actions: ContentActionModel[] = []; - contextActionHandler: Subject = new Subject(); + contextActionHandler = new Subject(); data: ShareDataTableAdapter; noPermission: boolean = false; selection = new Array(); @@ -1051,7 +1051,7 @@ export class DocumentListComponent extends DataTableSchema implements OnInit, On if (JSON.parse(err.message).error.statusCode === 403) { this.noPermission = true; } - } catch (error) { + } catch { /* empty */ } } diff --git a/lib/content-services/src/lib/document-list/models/content-action.model.ts b/lib/content-services/src/lib/document-list/models/content-action.model.ts index 55206aac09..5e5320ba98 100644 --- a/lib/content-services/src/lib/document-list/models/content-action.model.ts +++ b/lib/content-services/src/lib/document-list/models/content-action.model.ts @@ -57,17 +57,3 @@ export enum ContentActionTarget { } export type ContentActionHandler = (obj: any, target?: any, permission?: string) => any; - -export class DocumentActionModel extends ContentActionModel { - constructor(json?: any) { - super(json); - this.target = 'document'; - } -} - -export class FolderActionModel extends ContentActionModel { - constructor(json?: any) { - super(json); - this.target = 'folder'; - } -} diff --git a/lib/content-services/src/lib/document-list/services/folder-actions.service.spec.ts b/lib/content-services/src/lib/document-list/services/folder-actions.service.spec.ts index 2bfb0663d4..e53bc0b514 100644 --- a/lib/content-services/src/lib/document-list/services/folder-actions.service.spec.ts +++ b/lib/content-services/src/lib/document-list/services/folder-actions.service.spec.ts @@ -95,7 +95,7 @@ describe('FolderActionsService', () => { it('should delete the folder node if there is the delete permission', () => { spyOn(documentListService, 'deleteNode').and.callFake( () => - new Observable((observer) => { + new Observable((observer) => { observer.next(undefined); observer.complete(); }) @@ -156,7 +156,7 @@ describe('FolderActionsService', () => { it('should delete the folder node if there is the delete and others permission ', () => { spyOn(documentListService, 'deleteNode').and.callFake( () => - new Observable((observer) => { + new Observable((observer) => { observer.next(undefined); observer.complete(); }) @@ -174,7 +174,7 @@ describe('FolderActionsService', () => { it('should support deletion only folder node', () => { spyOn(documentListService, 'deleteNode').and.callFake( () => - new Observable((observer) => { + new Observable((observer) => { observer.next(undefined); observer.complete(); }) @@ -195,7 +195,7 @@ describe('FolderActionsService', () => { it('should require node id to delete', () => { spyOn(documentListService, 'deleteNode').and.callFake( () => - new Observable((observer) => { + new Observable((observer) => { observer.next(undefined); observer.complete(); }) @@ -211,7 +211,7 @@ describe('FolderActionsService', () => { it('should reload target upon node deletion', async () => { spyOn(documentListService, 'deleteNode').and.callFake( () => - new Observable((observer) => { + new Observable((observer) => { observer.next(undefined); observer.complete(); }) diff --git a/lib/content-services/src/lib/search/components/search-check-list/search-check-list.component.spec.ts b/lib/content-services/src/lib/search/components/search-check-list/search-check-list.component.spec.ts index eeca281688..950d03d648 100644 --- a/lib/content-services/src/lib/search/components/search-check-list/search-check-list.component.spec.ts +++ b/lib/content-services/src/lib/search/components/search-check-list/search-check-list.component.spec.ts @@ -25,14 +25,13 @@ import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed'; import { MatCheckboxHarness } from '@angular/material/checkbox/testing'; import { MatButtonHarness } from '@angular/material/button/testing'; import { ReplaySubject } from 'rxjs'; -import { UnitTestingUtils } from '@alfresco/adf-core'; import { MatCheckbox } from '@angular/material/checkbox'; +import { By } from '@angular/platform-browser'; describe('SearchCheckListComponent', () => { let loader: HarnessLoader; let fixture: ComponentFixture; let component: SearchCheckListComponent; - let unitTestingUtils: UnitTestingUtils; beforeEach(() => { TestBed.configureTestingModule({ @@ -41,7 +40,6 @@ describe('SearchCheckListComponent', () => { fixture = TestBed.createComponent(SearchCheckListComponent); component = fixture.componentInstance; loader = TestbedHarnessEnvironment.loader(fixture); - unitTestingUtils = new UnitTestingUtils(fixture.debugElement); component.context = { queryFragments: {}, @@ -149,7 +147,7 @@ describe('SearchCheckListComponent', () => { ]); fixture.detectChanges(); - const checkboxes = unitTestingUtils.getAllByDirective(MatCheckbox); + const checkboxes = fixture.debugElement.queryAll(By.directive(MatCheckbox)); expect(checkboxes.length).toBe(2); expect(checkboxes.every((checkbox) => checkbox.componentInstance.labelPosition === 'after')).toBeTrue(); }); diff --git a/lib/content-services/src/lib/tag/tag-actions/tag-actions.component.spec.ts b/lib/content-services/src/lib/tag/tag-actions/tag-actions.component.spec.ts index 244ff23479..9f8924dbc0 100644 --- a/lib/content-services/src/lib/tag/tag-actions/tag-actions.component.spec.ts +++ b/lib/content-services/src/lib/tag/tag-actions/tag-actions.component.spec.ts @@ -43,7 +43,7 @@ describe('TagActionsComponent', () => { } }; - let component: any; + let component: TagActionsComponent; let fixture: ComponentFixture; let element: HTMLElement; let tagService: TagService; @@ -90,7 +90,7 @@ describe('TagActionsComponent', () => { fixture.detectChanges(); await fixture.whenStable(); - const deleteButton: any = element.querySelector('#tag_delete_test1'); + const deleteButton = element.querySelector('#tag_delete_test1'); deleteButton.click(); expect(tagService.removeTag).toHaveBeenCalledWith('fake-node-id', '0ee933fa-57fc-4587-8a77-b787e814f1d2'); }); @@ -102,7 +102,7 @@ describe('TagActionsComponent', () => { fixture.detectChanges(); await fixture.whenStable(); - const addButton: any = element.querySelector('#add-tag'); + const addButton = element.querySelector('#add-tag'); expect(addButton.disabled).toEqual(true); }); @@ -110,7 +110,7 @@ describe('TagActionsComponent', () => { component.nodeId = 'fake-node-id'; component.newTagName = 'test1'; - await component.error.subscribe((res) => { + component.error.subscribe((res) => { expect(res).toEqual('TAG.MESSAGES.EXIST'); }); @@ -118,7 +118,7 @@ describe('TagActionsComponent', () => { fixture.detectChanges(); await fixture.whenStable(); - const addButton: any = element.querySelector('#add-tag'); + const addButton = element.querySelector('#add-tag'); addButton.click(); }); @@ -130,7 +130,7 @@ describe('TagActionsComponent', () => { fixture.detectChanges(); await fixture.whenStable(); - const addButton: any = element.querySelector('#add-tag'); + const addButton = element.querySelector('#add-tag'); expect(addButton.disabled).toEqual(false); }); }); diff --git a/lib/content-services/src/lib/viewer/components/alfresco-viewer.component.spec.ts b/lib/content-services/src/lib/viewer/components/alfresco-viewer.component.spec.ts index caa02cebf5..95bb7e14ff 100644 --- a/lib/content-services/src/lib/viewer/components/alfresco-viewer.component.spec.ts +++ b/lib/content-services/src/lib/viewer/components/alfresco-viewer.component.spec.ts @@ -790,7 +790,7 @@ describe('AlfrescoViewerComponent', () => { }); it('should Click on close button hide the viewer', (done) => { - const closeButton: any = element.querySelector('.adf-viewer-close-button'); + const closeButton = element.querySelector('.adf-viewer-close-button'); closeButton.click(); fixture.detectChanges(); diff --git a/lib/content-services/src/lib/viewer/components/alfresco-viewer.component.ts b/lib/content-services/src/lib/viewer/components/alfresco-viewer.component.ts index b5f51d7522..7ed4ae126b 100644 --- a/lib/content-services/src/lib/viewer/components/alfresco-viewer.component.ts +++ b/lib/content-services/src/lib/viewer/components/alfresco-viewer.component.ts @@ -300,7 +300,7 @@ export class AlfrescoViewerComponent implements OnChanges, OnInit { try { const sharedLinkEntry = await this.sharedLinksApi.getSharedLink(this.sharedLinkId); await this.setUpSharedLinkFile(sharedLinkEntry); - } catch (error) { + } catch { this.invalidSharedLink.next(undefined); this.mimeType = 'invalid-link'; this.urlFileContent = 'invalid-file'; @@ -317,7 +317,7 @@ export class AlfrescoViewerComponent implements OnChanges, OnInit { await this.setUpNodeFile(this.nodeEntry.entry); this.cdr.detectChanges(); } - } catch (error) { + } catch { this.urlFileContent = 'invalid-node'; } } @@ -392,14 +392,14 @@ export class AlfrescoViewerComponent implements OnChanges, OnInit { const urlFileContent = this.contentApi.getSharedLinkRenditionUrl(sharedId, 'pdf'); return { url: urlFileContent, mimeType: 'application/pdf' }; } - } catch (error) { + } catch { try { const rendition: RenditionEntry = await this.sharedLinksApi.getSharedLinkRendition(sharedId, 'imgpreview'); if (rendition.entry.status.toString() === 'CREATED') { const urlFileContent = this.contentApi.getSharedLinkRenditionUrl(sharedId, 'imgpreview'); return { url: urlFileContent, mimeType: 'image/png' }; } - } catch (renditionError) { + } catch { return null; } } diff --git a/lib/core/api/src/lib/adf-http-client.service.ts b/lib/core/api/src/lib/adf-http-client.service.ts index 0450625249..6fa5006e61 100644 --- a/lib/core/api/src/lib/adf-http-client.service.ts +++ b/lib/core/api/src/lib/adf-http-client.service.ts @@ -313,7 +313,7 @@ export class AdfHttpClient implements ee.Emitter, JsApiHttpClient { try { document.cookie = 'CSRF-TOKEN=' + token + ';path=/'; - } catch (err) { + } catch { /* continue regardless of error */ } } diff --git a/lib/core/feature-flags/src/lib/components/flags/flags.component.spec.ts b/lib/core/feature-flags/src/lib/components/flags/flags.component.spec.ts index 820c86e26f..d83eb2250e 100644 --- a/lib/core/feature-flags/src/lib/components/flags/flags.component.spec.ts +++ b/lib/core/feature-flags/src/lib/components/flags/flags.component.spec.ts @@ -58,7 +58,7 @@ describe('FlagsComponent', () => { }); it('should update inputValue$ when onInputChange is called', (done) => { - (component as any).onInputChange('test'); + component.onInputChange('test'); component.inputValue$.subscribe((value) => { expect(value).toBe('test'); done(); @@ -67,12 +67,12 @@ describe('FlagsComponent', () => { it('should clear inputValue when onClearInput is called', () => { component.inputValue = 'test'; - (component as any).onClearInput(); + component.onClearInput(); expect(component.inputValue).toBe(''); }); it('should filter flags when when onClearInput is called', (done) => { - (component as any).onInputChange('feature1'); + component.onInputChange('feature1'); component.flags$.subscribe((flags) => { expect(flags).toEqual([{ fictive: false, flag: 'feature1', value: true }]); done(); diff --git a/lib/core/feature-flags/src/lib/components/flags/flags.component.ts b/lib/core/feature-flags/src/lib/components/flags/flags.component.ts index 48937012fe..c22f5ce300 100644 --- a/lib/core/feature-flags/src/lib/components/flags/flags.component.ts +++ b/lib/core/feature-flags/src/lib/components/flags/flags.component.ts @@ -123,11 +123,11 @@ export class FlagsComponent { this.featuresService.enable(value); } - protected onInputChange(text: string) { + onInputChange(text: string) { this.inputValue$.next(text); } - protected onClearInput() { + onClearInput() { this.inputValue = ''; this.inputValue$.next(''); } diff --git a/lib/core/src/lib/app-config/debug-app-config.service.ts b/lib/core/src/lib/app-config/debug-app-config.service.ts deleted file mode 100644 index c82c423401..0000000000 --- a/lib/core/src/lib/app-config/debug-app-config.service.ts +++ /dev/null @@ -1,37 +0,0 @@ -/*! - * @license - * Copyright © 2005-2025 Hyland Software, Inc. and its affiliates. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { Injectable } from '@angular/core'; -import { StorageService } from '../common/services/storage.service'; -import { AppConfigService, AppConfigValues } from './app-config.service'; - -@Injectable() -export class DebugAppConfigService extends AppConfigService { - constructor(private storage: StorageService) { - super(); - } - - get(key: string, defaultValue?: T): T { - if (key === AppConfigValues.OAUTHCONFIG) { - return JSON.parse(this.storage.getItem(key)) || super.get(key, defaultValue); - } else if (key === AppConfigValues.APPLICATION) { - return undefined; - } else { - return (this.storage.getItem(key) as any) || super.get(key, defaultValue); - } - } -} diff --git a/lib/core/src/lib/app-config/public-api.ts b/lib/core/src/lib/app-config/public-api.ts index fa74bc032f..4aef9eb43e 100644 --- a/lib/core/src/lib/app-config/public-api.ts +++ b/lib/core/src/lib/app-config/public-api.ts @@ -16,7 +16,6 @@ */ export * from './app-config.service'; -export * from './debug-app-config.service'; export * from './app-config.pipe'; export * from './app-config-storage-prefix.factory'; diff --git a/lib/core/src/lib/auth/mock/identity-group.mock.ts b/lib/core/src/lib/auth/mock/identity-group.mock.ts index f7014b3a63..e419c1ca8c 100644 --- a/lib/core/src/lib/auth/mock/identity-group.mock.ts +++ b/lib/core/src/lib/auth/mock/identity-group.mock.ts @@ -76,20 +76,6 @@ export const clientRoles: IdentityRoleModel[] = [ export const mockJoinGroupRequest: IdentityJoinGroupRequestModel = { userId: 'mock-hser-id', groupId: 'mock-group-id', realm: 'mock-realm-name' }; -export const mockGroup1 = { - id: 'mock-group-id-1', - name: 'Mock Group 1', - path: '/mock', - subGroups: [] -} as IdentityGroupModel; - -export const mockGroup2 = { - id: 'mock-group-id-2', - name: 'Mock Group 2', - path: '', - subGroups: [] -} as IdentityGroupModel; - export const mockGroups = [ { id: 'mock-group-id-1', name: 'Mock Group 1', path: '/mock', subGroups: [] } as IdentityGroupModel, { id: 'mock-group-id-2', name: 'Mock Group 2', path: '', subGroups: [] } as IdentityGroupModel diff --git a/lib/core/src/lib/auth/mock/identity-group.service.mock.ts b/lib/core/src/lib/auth/mock/identity-group.service.mock.ts deleted file mode 100644 index 1ef11828bd..0000000000 --- a/lib/core/src/lib/auth/mock/identity-group.service.mock.ts +++ /dev/null @@ -1,142 +0,0 @@ -/*! - * @license - * Copyright © 2005-2025 Hyland Software, Inc. and its affiliates. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { Injectable } from '@angular/core'; -import { mockIdentityGroups, mockIdentityGroupsCount, mockIdentityRoles } from './identity-group.mock'; -import { Observable, of } from 'rxjs'; -import { map } from 'rxjs/operators'; -import { IdentityGroupServiceInterface } from '../interfaces/identity-group.interface'; -import { - IdentityGroupModel, - IdentityGroupQueryResponse, - IdentityGroupQueryCloudRequestModel, - IdentityGroupSearchParam, - IdentityGroupCountModel -} from '../models/identity-group.model'; -import { IdentityRoleModel } from '../models/identity-role.model'; - -Injectable({ providedIn: 'root' }); -export class IdentityGroupServiceMock implements IdentityGroupServiceInterface { - getGroups(): Observable { - return of(mockIdentityGroups); - } - - getAvailableRoles(_groupId: string): Observable { - return of(mockIdentityRoles); - } - - getAssignedRoles(_groupId: string): Observable { - return of(mockIdentityRoles); - } - - assignRoles(_groupId: string, _roles: IdentityRoleModel[]): Observable { - return of(); - } - - removeRoles(_groupId: string, _roles: IdentityRoleModel[]): Observable { - return of(); - } - - getEffectiveRoles(_groupId: string): Observable { - return of(mockIdentityRoles); - } - - queryGroups(_requestQuery: IdentityGroupQueryCloudRequestModel): Observable { - return of(); - } - - getTotalGroupsCount(): Observable { - return of(mockIdentityGroupsCount); - } - - createGroup(_newGroup: IdentityGroupModel): Observable { - return of(); - } - - updateGroup(_groupId: string, _updatedGroup: IdentityGroupModel): Observable { - return of(); - } - - deleteGroup(_groupId: string): Observable { - return of(); - } - - findGroupsByName(searchParams: IdentityGroupSearchParam): Observable { - if (searchParams.name === '') { - return of([]); - } - - return of(mockIdentityGroups.filter((group) => group.name.toUpperCase().includes(searchParams.name.toUpperCase()))); - } - - getGroupRoles(_groupId: string): Observable { - return of(mockIdentityRoles); - } - - checkGroupHasRole(groupId: string, roleNames: string[]): Observable { - return this.getGroupRoles(groupId).pipe( - map((groupRoles) => { - let hasRole = false; - if (groupRoles?.length > 0) { - roleNames.forEach((roleName: string) => { - const role = groupRoles.find(({ name }) => roleName === name); - if (role) { - hasRole = true; - return; - } - }); - } - return hasRole; - }) - ); - } - - getClientIdByApplicationName(_applicationName: string): Observable { - return of('fake-client-id'); - } - - getClientRoles(groupId: string, _clientId: string): Observable { - if (['mock-group-id-1', 'mock-group-id-2'].includes(groupId)) { - return of([{ id: 'mock-role-id', name: 'MOCK-ADMIN-ROLE' }]); - } - - return of([{ id: 'mock-role-id', name: 'MOCK-USER-ROLE' }]); - } - - checkGroupHasClientApp(groupId: string, clientId: string): Observable { - return this.getClientRoles(groupId, clientId).pipe(map((response) => response && response.length > 0)); - } - - checkGroupHasAnyClientAppRole(groupId: string, clientId: string, roleNames: string[]): Observable { - return this.getClientRoles(groupId, clientId).pipe( - map((clientRoles: any[]) => { - let hasRole = false; - if (clientRoles.length > 0) { - roleNames.forEach((roleName) => { - const role = clientRoles.find(({ name }) => name === roleName); - - if (role) { - hasRole = true; - return; - } - }); - } - return hasRole; - }) - ); - } -} diff --git a/lib/core/src/lib/auth/mock/oauth2.service.mock.ts b/lib/core/src/lib/auth/mock/oauth2.service.mock.ts deleted file mode 100644 index 41f20e83ae..0000000000 --- a/lib/core/src/lib/auth/mock/oauth2.service.mock.ts +++ /dev/null @@ -1,133 +0,0 @@ -/*! - * @license - * Copyright © 2005-2025 Hyland Software, Inc. and its affiliates. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { mockGroups, mockIdentityGroups, roleMappingMock } from './identity-group.mock'; -import { mockAssignedRoles, mockAvailableRoles, mockEffectiveRoles, mockIdentityUsers } from './identity-user.mock'; - -export const queryUsersMockApi: any = { - oauth2Auth: { - callCustomApi: () => Promise.resolve(mockIdentityUsers) - } -}; - -export const createUserMockApi: any = { - oauth2Auth: { - callCustomApi: () => Promise.resolve() - } -}; - -export const updateUserMockApi: any = { - oauth2Auth: { - callCustomApi: () => Promise.resolve() - } -}; - -export const deleteUserMockApi: any = { - oauth2Auth: { - callCustomApi: () => Promise.resolve() - } -}; - -export const getInvolvedGroupsMockApi: any = { - oauth2Auth: { - callCustomApi: () => Promise.resolve(mockGroups) - } -}; - -export const joinGroupMockApi: any = { - oauth2Auth: { - callCustomApi: () => Promise.resolve() - } -}; - -export const leaveGroupMockApi: any = { - oauth2Auth: { - callCustomApi: () => Promise.resolve() - } -}; - -export const getAvailableRolesMockApi: any = { - oauth2Auth: { - callCustomApi: () => Promise.resolve(mockAvailableRoles) - } -}; - -export const getAssignedRolesMockApi: any = { - oauth2Auth: { - callCustomApi: () => Promise.resolve(mockAssignedRoles) - } -}; - -export const getEffectiveRolesMockApi: any = { - oauth2Auth: { - callCustomApi: () => Promise.resolve(mockEffectiveRoles) - } -}; - -export const assignRolesMockApi: any = { - oauth2Auth: { - callCustomApi: () => Promise.resolve() - } -}; - -export const removeRolesMockApi: any = { - oauth2Auth: { - callCustomApi: () => Promise.resolve() - } -}; - -export const roleMappingApi: any = { - oauth2Auth: { - callCustomApi: () => Promise.resolve(roleMappingMock) - } -}; - -export const noRoleMappingApi: any = { - oauth2Auth: { - callCustomApi: () => Promise.resolve([]) - } -}; - -export const groupsMockApi: any = { - oauth2Auth: { - callCustomApi: () => Promise.resolve(mockIdentityGroups) - } -}; - -export const createGroupMappingApi: any = { - oauth2Auth: { - callCustomApi: () => Promise.resolve() - } -}; - -export const updateGroupMappingApi: any = { - oauth2Auth: { - callCustomApi: () => Promise.resolve() - } -}; - -export const deleteGroupMappingApi: any = { - oauth2Auth: { - callCustomApi: () => Promise.resolve() - } -}; - -export const applicationDetailsMockApi: any = { - oauth2Auth: { - callCustomApi: () => Promise.resolve([{ id: 'mock-app-id', name: 'mock-app-name' }]) - } -}; diff --git a/lib/core/src/lib/auth/oidc/oidc-auth.guard.spec.ts b/lib/core/src/lib/auth/oidc/oidc-auth.guard.spec.ts index 2b3bd34d9a..cb9a0d99ee 100644 --- a/lib/core/src/lib/auth/oidc/oidc-auth.guard.spec.ts +++ b/lib/core/src/lib/auth/oidc/oidc-auth.guard.spec.ts @@ -60,10 +60,9 @@ describe('OidcAuthGuard', () => { try { await TestBed.runInInjectionContext(() => OidcAuthGuard(route, state)); expect(routerSpy.navigateByUrl).toHaveBeenCalledWith('/', { replaceUrl: true }); - } catch (error) { + } catch { fail('Expected no error to be thrown'); } - }); it('should throw an error if loginCallback fails and logout event is emitted', async () => { @@ -89,7 +88,7 @@ describe('OidcAuthGuard', () => { fakeLogoutSubject.next(); await runInInjectionContext; expect(routerSpy.navigateByUrl).toHaveBeenCalledWith('/test-route', { replaceUrl: true }); - } catch (error) { + } catch { fail('Expected no error to be thrown'); } }); diff --git a/lib/core/src/lib/auth/oidc/redirect-auth.service.spec.ts b/lib/core/src/lib/auth/oidc/redirect-auth.service.spec.ts index 44f1183807..ad8dfede7b 100644 --- a/lib/core/src/lib/auth/oidc/redirect-auth.service.spec.ts +++ b/lib/core/src/lib/auth/oidc/redirect-auth.service.spec.ts @@ -211,7 +211,7 @@ describe('RedirectAuthService', () => { try { await service.loginCallback(); fail('Expected to throw an error'); - } catch (error) { + } catch { expect(oauthServiceSpy.logOut).toHaveBeenCalledTimes(1); } }); @@ -281,7 +281,7 @@ describe('RedirectAuthService', () => { try { await service.loginCallback(); expect(oauthServiceSpy.logOut).not.toHaveBeenCalled(); - } catch (error) { + } catch { fail('Expected not to throw an error'); } }); diff --git a/lib/core/src/lib/common/services/storage.service.ts b/lib/core/src/lib/common/services/storage.service.ts index 1f174004fc..cefaee220d 100644 --- a/lib/core/src/lib/common/services/storage.service.ts +++ b/lib/core/src/lib/common/services/storage.service.ts @@ -135,7 +135,7 @@ export class StorageService { storage.setItem(key, key); storage.removeItem(key, key); return true; - } catch (e) { + } catch { return false; } } diff --git a/lib/core/src/lib/form/components/mock/cloud-form.mock.ts b/lib/core/src/lib/form/components/mock/cloud-form.mock.ts deleted file mode 100644 index 111c7d7a4f..0000000000 --- a/lib/core/src/lib/form/components/mock/cloud-form.mock.ts +++ /dev/null @@ -1,1330 +0,0 @@ -/*! - * @license - * Copyright © 2005-2025 Hyland Software, Inc. and its affiliates. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -export const cloudFormMock = { - id: 'form-b661635a-dc3e-4557-914a-3498ed47189c', - name: 'form-with-all-fields', - description: '', - version: 0, - tabs: [], - fields: [ - { - fieldType: 'ContainerRepresentation', - id: '26b10e64-0403-4686-a75b-0d45279ce3a8', - name: 'Label', - type: 'container', - tab: null, - numberOfColumns: 2, - fields: { - '1': [ - { - fieldType: 'FormFieldRepresentation', - id: 'text1', - name: 'Text1', - type: 'text', - value: null, - required: false, - readOnly: true, - overrideId: false, - colspan: 1, - placeholder: null, - minLength: 0, - maxLength: 0, - minValue: null, - maxValue: null, - regexPattern: null, - visibilityCondition: null, - params: { - existingColspan: 1, - maxColspan: 2 - } - } - ], - '2': [ - { - fieldType: 'FormFieldRepresentation', - id: 'text2', - name: 'Text2', - type: 'text', - value: null, - required: false, - readOnly: true, - overrideId: false, - colspan: 1, - placeholder: null, - minLength: 0, - maxLength: 0, - minValue: null, - maxValue: null, - regexPattern: null, - visibilityCondition: null, - params: { - existingColspan: 1, - maxColspan: 2 - } - } - ] - } - }, - { - fieldType: 'ContainerRepresentation', - id: '69c1390a-8d8d-423c-8efb-8e43401efa42', - name: 'Label', - type: 'container', - tab: null, - numberOfColumns: 2, - fields: { - '1': [ - { - fieldType: 'FormFieldRepresentation', - id: 'multilinetext1', - name: 'Multiline text1', - type: 'multi-line-text', - overrideId: false, - colspan: 1, - placeholder: null, - minLength: 0, - maxLength: 0, - regexPattern: null, - required: false, - readOnly: true, - visibilityCondition: null, - params: { - existingColspan: 1, - maxColspan: 2 - } - } - ], - '2': [ - { - fieldType: 'FormFieldRepresentation', - id: 'multilinetext2', - name: 'Multiline text2', - type: 'multi-line-text', - overrideId: false, - colspan: 1, - placeholder: null, - minLength: 0, - maxLength: 0, - regexPattern: null, - required: false, - readOnly: true, - visibilityCondition: null, - params: { - existingColspan: 1, - maxColspan: 2 - } - } - ] - } - }, - { - fieldType: 'ContainerRepresentation', - id: 'df046463-2d65-4388-9ee1-0e1517985215', - name: 'Label', - type: 'container', - tab: null, - numberOfColumns: 2, - fields: { - '1': [ - { - fieldType: 'FormFieldRepresentation', - id: 'number1', - overrideId: false, - name: 'Number1', - type: 'integer', - colspan: 1, - placeholder: null, - readOnly: true, - minValue: null, - maxValue: null, - required: false, - visibilityCondition: null, - params: { - existingColspan: 1, - maxColspan: 2 - } - } - ], - '2': [ - { - fieldType: 'FormFieldRepresentation', - id: 'number2', - overrideId: false, - name: 'Number2', - type: 'integer', - colspan: 1, - placeholder: null, - readOnly: true, - minValue: null, - maxValue: null, - required: false, - visibilityCondition: null, - params: { - existingColspan: 1, - maxColspan: 2 - } - } - ] - } - }, - { - fieldType: 'ContainerRepresentation', - id: '9672cc7b-1959-49c9-96be-3816e57bdfc1', - name: 'Label', - type: 'container', - tab: null, - numberOfColumns: 2, - fields: { - '1': [ - { - fieldType: 'FormFieldRepresentation', - id: 'checkbox1', - name: 'Checkbox1', - type: 'boolean', - required: false, - readOnly: true, - colspan: 1, - overrideId: false, - visibilityCondition: null, - params: { - existingColspan: 1, - maxColspan: 2 - } - } - ], - '2': [ - { - fieldType: 'FormFieldRepresentation', - id: 'checkbox2', - name: 'Checkbox2', - type: 'boolean', - required: false, - readOnly: true, - colspan: 1, - overrideId: false, - visibilityCondition: null, - params: { - existingColspan: 1, - maxColspan: 2 - } - } - ] - } - }, - { - fieldType: 'ContainerRepresentation', - id: '054d193e-a899-4494-9a3e-b489315b7d57', - name: 'Label', - type: 'container', - tab: null, - numberOfColumns: 2, - fields: { - '1': [ - { - fieldType: 'FormFieldRepresentation', - id: 'dropdown1', - name: 'Dropdown1', - type: 'dropdown', - value: null, - required: false, - readOnly: true, - overrideId: false, - colspan: 1, - placeholder: null, - optionType: 'manual', - options: [], - endpoint: null, - requestHeaders: null, - restUrl: null, - restResponsePath: null, - restIdProperty: null, - restLabelProperty: null, - visibilityCondition: null, - params: { - existingColspan: 1, - maxColspan: 2 - } - } - ], - '2': [ - { - fieldType: 'FormFieldRepresentation', - id: 'dropdown2', - name: 'Dropdown2', - type: 'dropdown', - value: null, - required: false, - readOnly: true, - overrideId: false, - colspan: 1, - placeholder: null, - optionType: 'manual', - options: [], - endpoint: null, - requestHeaders: null, - restUrl: null, - restResponsePath: null, - restIdProperty: null, - restLabelProperty: null, - visibilityCondition: null, - params: { - existingColspan: 1, - maxColspan: 2 - } - } - ] - } - }, - { - fieldType: 'ContainerRepresentation', - id: '1f8f0b66-e022-4667-91b4-bbbf2ddc36fb', - name: 'Label', - type: 'container', - tab: null, - numberOfColumns: 2, - fields: { - '1': [ - { - fieldType: 'FormFieldRepresentation', - id: 'amount1', - name: 'Amount1', - type: 'amount', - value: null, - required: false, - readOnly: true, - overrideId: false, - colspan: 1, - placeholder: '123', - minValue: null, - maxValue: null, - visibilityCondition: null, - params: { - existingColspan: 1, - maxColspan: 2 - }, - enableFractions: false, - currency: '$' - } - ], - '2': [ - { - fieldType: 'FormFieldRepresentation', - id: 'amount2', - name: 'Amount2', - type: 'amount', - value: null, - required: false, - readOnly: true, - overrideId: false, - colspan: 1, - placeholder: '123', - minValue: null, - maxValue: null, - visibilityCondition: null, - params: { - existingColspan: 1, - maxColspan: 2 - }, - enableFractions: false, - currency: '$' - } - ] - } - }, - { - fieldType: 'ContainerRepresentation', - id: '541a368b-67ee-4a7c-ae7e-232c050b9e24', - name: 'Label', - type: 'container', - tab: null, - numberOfColumns: 2, - fields: { - '1': [ - { - fieldType: 'FormFieldRepresentation', - id: 'date1', - name: 'Date1', - type: 'date', - overrideId: false, - required: false, - readOnly: true, - colspan: 1, - placeholder: null, - minValue: null, - maxValue: null, - visibilityCondition: null, - params: { - existingColspan: 1, - maxColspan: 2 - }, - dateDisplayFormat: 'D-M-YYYY' - } - ], - '2': [ - { - fieldType: 'FormFieldRepresentation', - id: 'date2', - name: 'Date2', - type: 'date', - overrideId: false, - required: false, - readOnly: true, - colspan: 1, - placeholder: null, - minValue: null, - maxValue: null, - visibilityCondition: null, - params: { - existingColspan: 1, - maxColspan: 2 - }, - dateDisplayFormat: 'D-M-YYYY' - } - ] - } - }, - { - fieldType: 'ContainerRepresentation', - id: 'e79cb7e2-3dc1-4c79-8158-28662c28a9f3', - name: 'Label', - type: 'container', - tab: null, - numberOfColumns: 2, - fields: { - '1': [ - { - fieldType: 'FormFieldRepresentation', - id: 'radiobuttons1', - name: 'Radio buttons1', - type: 'radio-buttons', - value: null, - required: false, - readOnly: true, - overrideId: false, - colspan: 1, - placeholder: null, - optionType: 'manual', - options: [ - { - id: 'option_1', - name: 'Option 1' - }, - { - id: 'option_2', - name: 'Option 2' - } - ], - endpoint: null, - requestHeaders: null, - restUrl: null, - restResponsePath: null, - restIdProperty: null, - restLabelProperty: null, - visibilityCondition: null, - params: { - existingColspan: 1, - maxColspan: 2 - } - } - ], - '2': [ - { - fieldType: 'FormFieldRepresentation', - id: 'radiobuttons2', - name: 'Radio buttons2', - type: 'radio-buttons', - value: null, - required: false, - readOnly: true, - overrideId: false, - colspan: 1, - placeholder: null, - optionType: 'manual', - options: [ - { - id: 'option_1', - name: 'Option 1' - }, - { - id: 'option_2', - name: 'Option 2' - } - ], - endpoint: null, - requestHeaders: null, - restUrl: null, - restResponsePath: null, - restIdProperty: null, - restLabelProperty: null, - visibilityCondition: null, - params: { - existingColspan: 1, - maxColspan: 2 - } - } - ] - } - }, - { - fieldType: 'ContainerRepresentation', - id: '7c01ed35-be86-4be7-9c28-ed640a5a2ae1', - name: 'Label', - type: 'container', - tab: null, - numberOfColumns: 2, - fields: { - '1': [ - { - fieldType: 'AttachFileFieldRepresentation', - id: 'attachfile1', - name: 'Attach file1', - type: 'upload', - value: null, - required: false, - readOnly: true, - overrideId: false, - colspan: 1, - placeholder: null, - visibilityCondition: null, - params: { - existingColspan: 1, - maxColspan: 2, - fileSource: { - serviceId: 'all-file-sources', - name: 'All file sources' - }, - multiple: false, - link: false - } - } - ], - '2': [ - { - fieldType: 'AttachFileFieldRepresentation', - id: 'attachfile2', - name: 'Attach file2', - type: 'upload', - value: null, - required: false, - readOnly: true, - overrideId: false, - colspan: 1, - placeholder: null, - visibilityCondition: null, - params: { - existingColspan: 1, - maxColspan: 2, - fileSource: { - serviceId: 'all-file-sources', - name: 'All file sources' - }, - multiple: false, - link: false - } - } - ] - } - }, - { - fieldType: 'ContainerRepresentation', - id: '07b13b96-d469-4a1e-8a9a-9bb957c68869', - name: 'Label', - type: 'container', - tab: null, - numberOfColumns: 2, - fields: { - '1': [ - { - fieldType: 'FormFieldRepresentation', - id: 'displayvalue1', - name: 'Display value1', - type: 'readonly', - value: 'No field selected', - readOnly: true, - required: false, - overrideId: false, - colspan: 1, - visibilityCondition: null, - params: { - existingColspan: 1, - maxColspan: 2, - field: { - id: 'displayvalue', - name: 'Display value', - type: 'text', - responseVariable: true - } - } - } - ], - '2': [ - { - fieldType: 'FormFieldRepresentation', - id: 'displayvalue2', - name: 'Display value2', - type: 'readonly', - value: 'No field selected', - readOnly: true, - required: false, - overrideId: false, - colspan: 1, - visibilityCondition: null, - params: { - existingColspan: 1, - maxColspan: 2, - field: { - id: 'displayvalue', - name: 'Display value', - type: 'text', - responseVariable: true - } - } - } - ] - } - }, - { - fieldType: 'ContainerRepresentation', - id: '1576ef25-c842-494c-ab84-265a1e3bf68d', - name: 'Label', - type: 'container', - tab: null, - numberOfColumns: 2, - fields: { - '1': [ - { - fieldType: 'FormFieldRepresentation', - id: 'displaytext1', - name: 'Display text1', - type: 'readonly-text', - value: 'Display text as part of the form', - readOnly: true, - required: false, - overrideId: false, - colspan: 1, - visibilityCondition: null, - params: { - existingColspan: 1, - maxColspan: 2 - } - } - ], - '2': [ - { - fieldType: 'FormFieldRepresentation', - id: 'displaytext2', - name: 'Display text2', - type: 'readonly-text', - value: 'Display text as part of the form', - readOnly: true, - required: false, - overrideId: false, - colspan: 1, - visibilityCondition: null, - params: { - existingColspan: 1, - maxColspan: 2 - } - } - ] - } - } - ], - outcomes: [], - metadata: {}, - variables: [ - { - name: 'FormVarStr', - type: 'string', - value: '' - }, - { - name: 'FormVarInt', - type: 'integer', - value: '' - }, - { - name: 'FormVarBool', - type: 'boolean', - value: '' - }, - { - name: 'FormVarDate', - type: 'date', - value: '' - }, - { - name: 'NewVar', - type: 'string', - value: '' - } - ] -}; - -export const fakeCloudForm = { - formRepresentation: { - id: 'form-de8895be-d0d7-4434-beef-559b15305d72', - name: 'StartEventForm', - description: '', - version: 0, - formDefinition: { - tabs: [], - fields: [ - { - type: 'container', - id: '5a6b24c1-db2b-45e9-9aff-142395433d23', - name: 'Label', - tab: null, - fields: { - '1': [ - { - type: 'text', - id: 'firstName', - name: 'firstName', - colspan: 1, - params: { - existingColspan: 1, - maxColspan: 2 - }, - visibilityCondition: null, - placeholder: null, - value: null, - required: false, - minLength: 0, - maxLength: 0, - regexPattern: null - } - ], - '2': [ - { - type: 'text', - id: 'lastName', - name: 'lastName', - colspan: 1, - params: { - existingColspan: 1, - maxColspan: 2 - }, - visibilityCondition: null, - placeholder: null, - value: null, - required: false, - minLength: 0, - maxLength: 0, - regexPattern: null - } - ] - }, - numberOfColumns: 2 - } - ], - outcomes: [], - metadata: {}, - variables: [] - } - } -}; - -export const emptyFormRepresentationJSON = { - description: '', - fields: [], - id: 'form-3de070b6-63df-4058-8028-ac82283d64fa', - metadata: {}, - name: 'form', - outcomes: [], - length: 0, - processDefinitionId: 'ed4a6233-0ad8-11ea-8616-e6267bbdb057', - processInstanceId: 'ec921948-0ad9-11ea-8616-e6267bbdb057', - processVariables: [], - tabs: [], - taskId: 'ec92194b-0ad9-11ea-8616-e6267bbdb057', - taskName: null, - variables: [], - version: 0 -}; - -export const conditionalUploadWidgetsMock: any = { - formRepresentation: { - id: 'form-fb7858f7-5cf6-4afe-b462-c15a5dc0c34c', - name: 'AttachVisibility', - description: '', - version: 0, - formDefinition: { - tabs: [], - fields: [ - { - id: '1dc63387-aa9d-4f06-adfa-37817e8fd394', - name: 'Label', - type: 'container', - tab: null, - numberOfColumns: 2, - fields: { - '1': [ - { - id: 'Text0xlk8n', - name: 'Text', - type: 'text', - required: false, - colspan: 1, - placeholder: null, - minLength: 0, - maxLength: 0, - regexPattern: null, - visibilityCondition: null, - params: { - existingColspan: 1, - maxColspan: 2 - } - } - ], - '2': [ - { - id: 'Attachfile0h9fr1', - name: 'Attach file', - type: 'upload', - required: false, - colspan: 1, - visibilityCondition: { - leftFormFieldId: 'Text0xlk8n', - leftRestResponseId: '', - operator: '==', - rightValue: 'Attach', - rightType: null, - rightFormFieldId: '', - rightRestResponseId: '', - nextConditionOperator: '', - nextCondition: null - }, - params: { - existingColspan: 1, - maxColspan: 2, - fileSource: { - serviceId: 'alfresco-content', - name: 'Alfresco Content' - }, - multiple: false, - link: false - } - } - ] - } - } - ], - outcomes: [ - { - id: '5f2f1c2d-5a79-4ed1-a262-4fef190d41eb', - name: 'Custom Outcome', - visibilityCondition: { - leftType: 'field', - leftValue: 'Text0xlk8n', - operator: '==', - rightValue: 'hi', - rightType: 'value', - nextConditionOperator: '', - nextCondition: null - } - } - ], - metadata: {}, - variables: [] - } - } -}; - -export const multilingualForm: any = { - formRepresentation: { - id: 'form-2aaaf20e-43d3-46bf-89be-859d5f512dd2', - name: 'multilingualform', - description: '', - version: 0, - formDefinition: { - tabs: [], - fields: [ - { - id: '451e2235-3310-4c2d-9b4a-08b53ae1640c', - name: 'Label', - type: 'container', - tab: null, - numberOfColumns: 2, - fields: { - '1': [ - { - id: 'textField', - name: 'TEXT_FIELD.TITLE', - type: 'text', - required: false, - colspan: 1, - placeholder: null, - minLength: 0, - maxLength: 0, - regexPattern: null, - visibilityCondition: null, - params: { - existingColspan: 1, - maxColspan: 2 - } - } - ], - '2': [] - } - }, - { - id: '1c87df6c-514e-45a7-96bc-508562683bb3', - name: 'Label', - type: 'container', - tab: null, - numberOfColumns: 2, - fields: { - '1': [ - { - id: 'fildUploadField', - name: 'FILE_UPLOAD_FIELD.TITLE', - type: 'multi-line-text', - colspan: 1, - placeholder: null, - minLength: 0, - maxLength: 0, - regexPattern: null, - required: false, - visibilityCondition: null, - params: { - existingColspan: 1, - maxColspan: 2 - } - } - ], - '2': [ - { - id: 'amountField', - name: 'AMOUNT_FIELD.TITLE', - type: 'amount', - required: false, - colspan: 1, - placeholder: '123', - minValue: null, - maxValue: null, - visibilityCondition: null, - params: { - existingColspan: 1, - maxColspan: 2 - }, - enableFractions: false, - currency: '$' - } - ] - } - }, - { - id: '33138eea-130f-4bba-b5a5-29ea60f31786', - name: 'Label', - type: 'container', - tab: null, - numberOfColumns: 2, - fields: { - '1': [ - { - id: 'dateField', - name: 'DATE_FIELD.TITLE', - type: 'date', - required: false, - colspan: 1, - placeholder: null, - minValue: null, - maxValue: null, - visibilityCondition: null, - params: { - existingColspan: 1, - maxColspan: 2 - }, - dateDisplayFormat: 'D-M-YYYY' - } - ], - '2': [] - } - } - ], - outcomes: [], - metadata: {}, - variables: [] - } - } -}; - -export const fakeMetadataForm = { - id: 'form-de8895be-d0d7-4434-beef-559b15305d72', - name: 'StartEventForm', - description: '', - version: 0, - formDefinition: { - tabs: [], - fields: [ - { - type: 'container', - id: '5a6b24c1-db2b-45e9-9aff-142395433d23', - name: 'Label', - tab: null, - fields: { - '1': [ - { - type: 'text', - id: 'pfx_property_one', - name: 'pfx_property_one', - colspan: 1, - params: { - existingColspan: 1, - maxColspan: 2 - }, - visibilityCondition: null, - placeholder: null, - value: null, - required: false, - minLength: 0, - maxLength: 0, - regexPattern: null - } - ], - '2': [ - { - type: 'boolean', - id: 'pfx_property_two', - name: 'pfx_property_two', - colspan: 1, - params: { - existingColspan: 1, - maxColspan: 2 - }, - visibilityCondition: null, - placeholder: null, - value: null, - required: false, - minLength: 0, - maxLength: 0, - regexPattern: null - } - ], - '3': [ - { - id: 'content_form_nodes', - name: 'Nodes', - type: 'upload', - readOnly: false, - required: true, - colspan: 1, - visibilityCondition: null, - params: { - existingColspan: 1, - maxColspan: 2, - fileSource: { - serviceId: 'alfresco-content', - name: 'Alfresco Content', - metadataAllowed: true - }, - multiple: true, - menuOptions: { - show: true, - download: true, - retrieveMetadata: true, - remove: true - }, - link: false - } - } - ], - '4': [ - { - id: 'pfx_property_three', - name: 'pfx_property_three', - required: false, - readOnly: false, - colspan: 1, - params: { - existingColspan: 1, - maxColspan: 2 - }, - visibilityCondition: null, - type: 'dropdown', - optionType: 'manual', - options: [ - { - id: 'empty', - name: 'Choose one...' - }, - { - id: 'opt_1', - name: 'Option 1' - }, - { - id: 'opt_2', - name: 'Option 2' - } - ], - value: 'empty', - restUrl: null, - restResponsePath: null, - restIdProperty: null, - restLabelProperty: null - } - ], - '5': [ - { - id: 'pfx_property_four', - name: 'pfx_property_four', - required: false, - readOnly: false, - colspan: 1, - params: { - existingColspan: 1, - maxColspan: 2 - }, - visibilityCondition: null, - type: 'dropdown', - optionType: 'manual', - options: [ - { - id: 'empty', - name: 'Choose one...' - }, - { - id: 'option_1', - name: 'Option: 1' - }, - { - id: 'option_2', - name: 'Option: 2' - } - ], - value: 'empty', - restUrl: null, - restResponsePath: null, - restIdProperty: null, - restLabelProperty: null - } - ], - '6': [ - { - id: 'pfx_property_five', - name: 'pfx_property_five', - required: false, - readOnly: false, - colspan: 1, - params: { - existingColspan: 1, - maxColspan: 2 - }, - visibilityCondition: null, - type: 'dropdown', - optionType: 'manual', - options: [ - { - id: 'empty', - name: 'Choose one...' - }, - { - id: 'green', - name: 'Colour green' - }, - { - id: 'orange', - name: 'Colour orange' - } - ], - value: 'empty', - restUrl: null, - restResponsePath: null, - restIdProperty: null, - restLabelProperty: null - } - ], - '7': [ - { - id: 'cmfb85b2a7295ba41209750bca176ccaf9a', - name: 'File viewer', - type: 'file-viewer', - readOnly: false, - required: false, - colspan: 1, - visibilityCondition: null, - params: { - existingColspan: 1, - maxColspan: 2, - uploadWidget: 'content_form_nodes' - } - } - ], - '8': [ - { - type: 'text', - id: 'pfx_property_six', - name: 'pfx_property_six', - colspan: 1, - params: { - existingColspan: 1, - maxColspan: 2 - }, - visibilityCondition: null, - placeholder: null, - value: null, - required: false, - minLength: 0, - maxLength: 0, - regexPattern: null - } - ], - '9': [ - { - type: 'text', - id: 'pfx_property_seven', - name: 'pfx_property_seven', - colspan: 1, - params: { - existingColspan: 1, - maxColspan: 2 - }, - visibilityCondition: null, - placeholder: null, - value: null, - required: false, - minLength: 0, - maxLength: 0, - regexPattern: null - } - ], - '10': [ - { - type: 'text', - id: 'pfx_property_eight', - name: 'pfx_property_eight', - colspan: 1, - params: { - existingColspan: 1, - maxColspan: 2 - }, - visibilityCondition: null, - placeholder: null, - value: null, - required: false, - minLength: 0, - maxLength: 0, - regexPattern: null - } - ] - }, - numberOfColumns: 2 - } - ], - outcomes: [], - metadata: {}, - variables: [] - } -}; - -export const fakeViewerForm = { - id: 'form-de8895be-d0d7-4434-beef-559b15305d72', - name: 'StartEventForm', - description: '', - version: 0, - formDefinition: { - tabs: [], - fields: [ - { - type: 'container', - id: '5a6b24c1-db2b-45e9-9aff-142395433d23', - name: 'Label', - tab: null, - fields: { - '1': [ - { - id: 'content_form_nodes', - name: 'Nodes', - type: 'upload', - readOnly: false, - required: true, - colspan: 1, - visibilityCondition: null, - params: { - existingColspan: 1, - maxColspan: 2, - fileSource: { - serviceId: 'alfresco-content', - name: 'Alfresco Content', - metadataAllowed: true - }, - multiple: true, - menuOptions: { - show: true, - download: true, - retrieveMetadata: true, - remove: true - }, - link: false - } - } - ], - '2': [ - { - id: 'upload_widget', - name: 'Nodes', - type: 'upload', - readOnly: false, - required: true, - colspan: 1, - visibilityCondition: null, - params: { - existingColspan: 1, - maxColspan: 2, - fileSource: { - serviceId: 'alfresco-content', - name: 'Alfresco Content', - metadataAllowed: true - }, - multiple: true, - menuOptions: { - show: true, - download: true, - retrieveMetadata: true, - remove: true - }, - link: false - } - } - ], - '3': [ - { - id: 'cmfb85b2a7295ba41209750bca176ccaf9a', - name: 'File viewer', - type: 'file-viewer', - readOnly: false, - required: false, - colspan: 1, - visibilityCondition: null, - params: { - existingColspan: 1, - maxColspan: 2, - uploadWidget: 'content_form_nodes' - } - } - ] - }, - numberOfColumns: 2 - } - ], - outcomes: [], - metadata: {}, - variables: [] - } -}; diff --git a/lib/core/src/lib/form/components/mock/form-renderer.component.mock.ts b/lib/core/src/lib/form/components/mock/form-renderer.component.mock.ts index 7928a1b949..9e9f3bce41 100644 --- a/lib/core/src/lib/form/components/mock/form-renderer.component.mock.ts +++ b/lib/core/src/lib/form/components/mock/form-renderer.component.mock.ts @@ -2188,37 +2188,6 @@ export const mockSectionWithFields = { colspan: 1 }; -export const mockFormWithSimpleSection = { - id: 'form-363114eb-35f6-40d0-9908-8bbbe776c3e6', - name: 'simplest section', - key: 'simplest-section-uzvc7', - description: '', - version: 0, - formDefinition: { - tabs: [], - fields: [ - { - id: 'Group0wuwv7', - name: 'Group', - type: 'group', - tab: null, - params: { - hideHeader: false, - allowCollapse: false, - collapseByDefault: false - }, - numberOfColumns: 1, - fields: { - 1: [mockSectionWithFields] - } - } - ], - outcomes: [], - metadata: {}, - variables: [] - } -}; - export const mockSectionVisibilityForm = { id: 'form-65e9f07c-44d9-4469-8f5d-74aba3bd7326', name: 'section visibility', diff --git a/lib/core/src/lib/form/components/mock/form.mock.ts b/lib/core/src/lib/form/components/mock/form.mock.ts index e8d4aa8a92..c46d7b8897 100644 --- a/lib/core/src/lib/form/components/mock/form.mock.ts +++ b/lib/core/src/lib/form/components/mock/form.mock.ts @@ -15,956 +15,6 @@ * limitations under the License. */ -export const cloudFormMock = { - id: 'form-b661635a-dc3e-4557-914a-3498ed47189c', - name: 'form-with-all-fields', - description: '', - version: 0, - tabs: [], - fields: [ - { - fieldType: 'ContainerRepresentation', - id: '26b10e64-0403-4686-a75b-0d45279ce3a8', - name: 'Label', - type: 'container', - tab: null, - numberOfColumns: 2, - fields: { - '1': [ - { - fieldType: 'FormFieldRepresentation', - id: 'text1', - name: 'Text1', - type: 'text', - value: null, - required: false, - readOnly: true, - overrideId: false, - colspan: 1, - placeholder: null, - minLength: 0, - maxLength: 0, - minValue: null, - maxValue: null, - regexPattern: null, - visibilityCondition: null, - params: { - existingColspan: 1, - maxColspan: 2 - } - } - ], - '2': [ - { - fieldType: 'FormFieldRepresentation', - id: 'text2', - name: 'Text2', - type: 'text', - value: null, - required: false, - readOnly: true, - overrideId: false, - colspan: 1, - placeholder: null, - minLength: 0, - maxLength: 0, - minValue: null, - maxValue: null, - regexPattern: null, - visibilityCondition: null, - params: { - existingColspan: 1, - maxColspan: 2 - } - } - ] - } - }, - { - fieldType: 'ContainerRepresentation', - id: '69c1390a-8d8d-423c-8efb-8e43401efa42', - name: 'Label', - type: 'container', - tab: null, - numberOfColumns: 2, - fields: { - '1': [ - { - fieldType: 'FormFieldRepresentation', - id: 'multilinetext1', - name: 'Multiline text1', - type: 'multi-line-text', - overrideId: false, - colspan: 1, - placeholder: null, - minLength: 0, - maxLength: 0, - regexPattern: null, - required: false, - readOnly: true, - visibilityCondition: null, - params: { - existingColspan: 1, - maxColspan: 2 - } - } - ], - '2': [ - { - fieldType: 'FormFieldRepresentation', - id: 'multilinetext2', - name: 'Multiline text2', - type: 'multi-line-text', - overrideId: false, - colspan: 1, - placeholder: null, - minLength: 0, - maxLength: 0, - regexPattern: null, - required: false, - readOnly: true, - visibilityCondition: null, - params: { - existingColspan: 1, - maxColspan: 2 - } - } - ] - } - }, - { - fieldType: 'ContainerRepresentation', - id: 'df046463-2d65-4388-9ee1-0e1517985215', - name: 'Label', - type: 'container', - tab: null, - numberOfColumns: 2, - fields: { - '1': [ - { - fieldType: 'FormFieldRepresentation', - id: 'number1', - overrideId: false, - name: 'Number1', - type: 'integer', - colspan: 1, - placeholder: null, - readOnly: true, - minValue: null, - maxValue: null, - required: false, - visibilityCondition: null, - params: { - existingColspan: 1, - maxColspan: 2 - } - } - ], - '2': [ - { - fieldType: 'FormFieldRepresentation', - id: 'number2', - overrideId: false, - name: 'Number2', - type: 'integer', - colspan: 1, - placeholder: null, - readOnly: true, - minValue: null, - maxValue: null, - required: false, - visibilityCondition: null, - params: { - existingColspan: 1, - maxColspan: 2 - } - } - ] - } - }, - { - fieldType: 'ContainerRepresentation', - id: '9672cc7b-1959-49c9-96be-3816e57bdfc1', - name: 'Label', - type: 'container', - tab: null, - numberOfColumns: 2, - fields: { - '1': [ - { - fieldType: 'FormFieldRepresentation', - id: 'checkbox1', - name: 'Checkbox1', - type: 'boolean', - required: false, - readOnly: true, - colspan: 1, - overrideId: false, - visibilityCondition: null, - params: { - existingColspan: 1, - maxColspan: 2 - } - } - ], - '2': [ - { - fieldType: 'FormFieldRepresentation', - id: 'checkbox2', - name: 'Checkbox2', - type: 'boolean', - required: false, - readOnly: true, - colspan: 1, - overrideId: false, - visibilityCondition: null, - params: { - existingColspan: 1, - maxColspan: 2 - } - } - ] - } - }, - { - fieldType: 'ContainerRepresentation', - id: '054d193e-a899-4494-9a3e-b489315b7d57', - name: 'Label', - type: 'container', - tab: null, - numberOfColumns: 2, - fields: { - '1': [ - { - fieldType: 'FormFieldRepresentation', - id: 'dropdown1', - name: 'Dropdown1', - type: 'dropdown', - value: null, - required: false, - readOnly: true, - overrideId: false, - colspan: 1, - placeholder: null, - optionType: 'manual', - options: [], - endpoint: null, - requestHeaders: null, - restUrl: null, - restResponsePath: null, - restIdProperty: null, - restLabelProperty: null, - visibilityCondition: null, - params: { - existingColspan: 1, - maxColspan: 2 - } - } - ], - '2': [ - { - fieldType: 'FormFieldRepresentation', - id: 'dropdown2', - name: 'Dropdown2', - type: 'dropdown', - value: null, - required: false, - readOnly: true, - overrideId: false, - colspan: 1, - placeholder: null, - optionType: 'manual', - options: [], - endpoint: null, - requestHeaders: null, - restUrl: null, - restResponsePath: null, - restIdProperty: null, - restLabelProperty: null, - visibilityCondition: null, - params: { - existingColspan: 1, - maxColspan: 2 - } - } - ] - } - }, - { - fieldType: 'ContainerRepresentation', - id: '1f8f0b66-e022-4667-91b4-bbbf2ddc36fb', - name: 'Label', - type: 'container', - tab: null, - numberOfColumns: 2, - fields: { - '1': [ - { - fieldType: 'FormFieldRepresentation', - id: 'amount1', - name: 'Amount1', - type: 'amount', - value: null, - required: false, - readOnly: true, - overrideId: false, - colspan: 1, - placeholder: '123', - minValue: null, - maxValue: null, - visibilityCondition: null, - params: { - existingColspan: 1, - maxColspan: 2 - }, - enableFractions: false, - currency: '$' - } - ], - '2': [ - { - fieldType: 'FormFieldRepresentation', - id: 'amount2', - name: 'Amount2', - type: 'amount', - value: null, - required: false, - readOnly: true, - overrideId: false, - colspan: 1, - placeholder: '123', - minValue: null, - maxValue: null, - visibilityCondition: null, - params: { - existingColspan: 1, - maxColspan: 2 - }, - enableFractions: false, - currency: '$' - } - ] - } - }, - { - fieldType: 'ContainerRepresentation', - id: '541a368b-67ee-4a7c-ae7e-232c050b9e24', - name: 'Label', - type: 'container', - tab: null, - numberOfColumns: 2, - fields: { - '1': [ - { - fieldType: 'FormFieldRepresentation', - id: 'date1', - name: 'Date1', - type: 'date', - overrideId: false, - required: false, - readOnly: true, - colspan: 1, - placeholder: null, - minValue: null, - maxValue: null, - visibilityCondition: null, - params: { - existingColspan: 1, - maxColspan: 2 - }, - dateDisplayFormat: 'D-M-YYYY' - } - ], - '2': [ - { - fieldType: 'FormFieldRepresentation', - id: 'date2', - name: 'Date2', - type: 'date', - overrideId: false, - required: false, - readOnly: true, - colspan: 1, - placeholder: null, - minValue: null, - maxValue: null, - visibilityCondition: null, - params: { - existingColspan: 1, - maxColspan: 2 - }, - dateDisplayFormat: 'D-M-YYYY' - } - ] - } - }, - { - fieldType: 'ContainerRepresentation', - id: 'e79cb7e2-3dc1-4c79-8158-28662c28a9f3', - name: 'Label', - type: 'container', - tab: null, - numberOfColumns: 2, - fields: { - '1': [ - { - fieldType: 'FormFieldRepresentation', - id: 'radiobuttons1', - name: 'Radio buttons1', - type: 'radio-buttons', - value: null, - required: false, - readOnly: true, - overrideId: false, - colspan: 1, - placeholder: null, - optionType: 'manual', - options: [ - { - id: 'option_1', - name: 'Option 1' - }, - { - id: 'option_2', - name: 'Option 2' - } - ], - endpoint: null, - requestHeaders: null, - restUrl: null, - restResponsePath: null, - restIdProperty: null, - restLabelProperty: null, - visibilityCondition: null, - params: { - existingColspan: 1, - maxColspan: 2 - } - } - ], - '2': [ - { - fieldType: 'FormFieldRepresentation', - id: 'radiobuttons2', - name: 'Radio buttons2', - type: 'radio-buttons', - value: null, - required: false, - readOnly: true, - overrideId: false, - colspan: 1, - placeholder: null, - optionType: 'manual', - options: [ - { - id: 'option_1', - name: 'Option 1' - }, - { - id: 'option_2', - name: 'Option 2' - } - ], - endpoint: null, - requestHeaders: null, - restUrl: null, - restResponsePath: null, - restIdProperty: null, - restLabelProperty: null, - visibilityCondition: null, - params: { - existingColspan: 1, - maxColspan: 2 - } - } - ] - } - }, - { - fieldType: 'ContainerRepresentation', - id: '7c01ed35-be86-4be7-9c28-ed640a5a2ae1', - name: 'Label', - type: 'container', - tab: null, - numberOfColumns: 2, - fields: { - '1': [ - { - fieldType: 'AttachFileFieldRepresentation', - id: 'attachfile1', - name: 'Attach file1', - type: 'upload', - value: null, - required: false, - readOnly: true, - overrideId: false, - colspan: 1, - placeholder: null, - visibilityCondition: null, - params: { - existingColspan: 1, - maxColspan: 2, - fileSource: { - serviceId: 'all-file-sources', - name: 'All file sources' - }, - multiple: false, - link: false - } - } - ], - '2': [ - { - fieldType: 'AttachFileFieldRepresentation', - id: 'attachfile2', - name: 'Attach file2', - type: 'upload', - value: null, - required: false, - readOnly: true, - overrideId: false, - colspan: 1, - placeholder: null, - visibilityCondition: null, - params: { - existingColspan: 1, - maxColspan: 2, - fileSource: { - serviceId: 'all-file-sources', - name: 'All file sources' - }, - multiple: false, - link: false - } - } - ] - } - }, - { - fieldType: 'ContainerRepresentation', - id: '07b13b96-d469-4a1e-8a9a-9bb957c68869', - name: 'Label', - type: 'container', - tab: null, - numberOfColumns: 2, - fields: { - '1': [ - { - fieldType: 'FormFieldRepresentation', - id: 'displayvalue1', - name: 'Display value1', - type: 'readonly', - value: 'No field selected', - readOnly: true, - required: false, - overrideId: false, - colspan: 1, - visibilityCondition: null, - params: { - existingColspan: 1, - maxColspan: 2, - field: { - id: 'displayvalue', - name: 'Display value', - type: 'text', - responseVariable: true - } - } - } - ], - '2': [ - { - fieldType: 'FormFieldRepresentation', - id: 'displayvalue2', - name: 'Display value2', - type: 'readonly', - value: 'No field selected', - readOnly: true, - required: false, - overrideId: false, - colspan: 1, - visibilityCondition: null, - params: { - existingColspan: 1, - maxColspan: 2, - field: { - id: 'displayvalue', - name: 'Display value', - type: 'text', - responseVariable: true - } - } - } - ] - } - }, - { - fieldType: 'ContainerRepresentation', - id: '1576ef25-c842-494c-ab84-265a1e3bf68d', - name: 'Label', - type: 'container', - tab: null, - numberOfColumns: 2, - fields: { - '1': [ - { - fieldType: 'FormFieldRepresentation', - id: 'displaytext1', - name: 'Display text1', - type: 'readonly-text', - value: 'Display text as part of the form', - readOnly: true, - required: false, - overrideId: false, - colspan: 1, - visibilityCondition: null, - params: { - existingColspan: 1, - maxColspan: 2 - } - } - ], - '2': [ - { - fieldType: 'FormFieldRepresentation', - id: 'displaytext2', - name: 'Display text2', - type: 'readonly-text', - value: 'Display text as part of the form', - readOnly: true, - required: false, - overrideId: false, - colspan: 1, - visibilityCondition: null, - params: { - existingColspan: 1, - maxColspan: 2 - } - } - ] - } - } - ], - outcomes: [], - metadata: {}, - variables: [ - { - name: 'FormVarStr', - type: 'string', - value: '' - }, - { - name: 'FormVarInt', - type: 'integer', - value: '' - }, - { - name: 'FormVarBool', - type: 'boolean', - value: '' - }, - { - name: 'FormVarDate', - type: 'date', - value: '' - }, - { - name: 'NewVar', - type: 'string', - value: '' - } - ] -}; - -export const fakeCloudForm = { - formRepresentation: { - id: 'form-de8895be-d0d7-4434-beef-559b15305d72', - name: 'StartEventForm', - description: '', - version: 0, - formDefinition: { - tabs: [], - fields: [ - { - type: 'container', - id: '5a6b24c1-db2b-45e9-9aff-142395433d23', - name: 'Label', - tab: null, - fields: { - '1': [ - { - type: 'text', - id: 'firstName', - name: 'firstName', - colspan: 1, - params: { - existingColspan: 1, - maxColspan: 2 - }, - visibilityCondition: null, - placeholder: null, - value: null, - required: false, - minLength: 0, - maxLength: 0, - regexPattern: null - } - ], - '2': [ - { - type: 'text', - id: 'lastName', - name: 'lastName', - colspan: 1, - params: { - existingColspan: 1, - maxColspan: 2 - }, - visibilityCondition: null, - placeholder: null, - value: null, - required: false, - minLength: 0, - maxLength: 0, - regexPattern: null - } - ] - }, - numberOfColumns: 2 - } - ], - outcomes: [], - metadata: {}, - variables: [] - } - } -}; - -export const emptyFormRepresentationJSON = { - description: '', - fields: [], - id: 'form-3de070b6-63df-4058-8028-ac82283d64fa', - metadata: {}, - name: 'form', - outcomes: [], - length: 0, - processDefinitionId: 'ed4a6233-0ad8-11ea-8616-e6267bbdb057', - processInstanceId: 'ec921948-0ad9-11ea-8616-e6267bbdb057', - processVariables: [], - tabs: [], - taskId: 'ec92194b-0ad9-11ea-8616-e6267bbdb057', - taskName: null, - variables: [], - version: 0 -}; - -export const conditionalUploadWidgetsMock: any = { - formRepresentation: { - id: 'form-fb7858f7-5cf6-4afe-b462-c15a5dc0c34c', - name: 'AttachVisibility', - description: '', - version: 0, - formDefinition: { - tabs: [], - fields: [ - { - id: '1dc63387-aa9d-4f06-adfa-37817e8fd394', - name: 'Label', - type: 'container', - tab: null, - numberOfColumns: 2, - fields: { - '1': [ - { - id: 'Text0xlk8n', - name: 'Text', - type: 'text', - required: false, - colspan: 1, - placeholder: null, - minLength: 0, - maxLength: 0, - regexPattern: null, - visibilityCondition: null, - params: { - existingColspan: 1, - maxColspan: 2 - } - } - ], - '2': [ - { - id: 'Attachfile0h9fr1', - name: 'Attach file', - type: 'upload', - required: false, - colspan: 1, - visibilityCondition: { - leftFormFieldId: 'Text0xlk8n', - leftRestResponseId: '', - operator: '==', - rightValue: 'Attach', - rightType: null, - rightFormFieldId: '', - rightRestResponseId: '', - nextConditionOperator: '', - nextCondition: null - }, - params: { - existingColspan: 1, - maxColspan: 2, - fileSource: { - serviceId: 'alfresco-content', - name: 'Alfresco Content' - }, - multiple: false, - link: false - } - } - ] - } - } - ], - outcomes: [ - { - id: '5f2f1c2d-5a79-4ed1-a262-4fef190d41eb', - name: 'Custom Outcome', - visibilityCondition: { - leftType: 'field', - leftValue: 'Text0xlk8n', - operator: '==', - rightValue: 'hi', - rightType: 'value', - nextConditionOperator: '', - nextCondition: null - } - } - ], - metadata: {}, - variables: [] - } - } -}; - -export const multilingualForm: any = { - formRepresentation: { - id: 'form-2aaaf20e-43d3-46bf-89be-859d5f512dd2', - name: 'multilingualform', - description: '', - version: 0, - formDefinition: { - tabs: [], - fields: [ - { - id: '451e2235-3310-4c2d-9b4a-08b53ae1640c', - name: 'Label', - type: 'container', - tab: null, - numberOfColumns: 2, - fields: { - '1': [ - { - id: 'textField', - name: 'TEXT_FIELD.TITLE', - type: 'text', - required: false, - colspan: 1, - placeholder: null, - minLength: 0, - maxLength: 0, - regexPattern: null, - visibilityCondition: null, - params: { - existingColspan: 1, - maxColspan: 2 - } - } - ], - '2': [] - } - }, - { - id: '1c87df6c-514e-45a7-96bc-508562683bb3', - name: 'Label', - type: 'container', - tab: null, - numberOfColumns: 2, - fields: { - '1': [ - { - id: 'fildUploadField', - name: 'FILE_UPLOAD_FIELD.TITLE', - type: 'multi-line-text', - colspan: 1, - placeholder: null, - minLength: 0, - maxLength: 0, - regexPattern: null, - required: false, - visibilityCondition: null, - params: { - existingColspan: 1, - maxColspan: 2 - } - } - ], - '2': [ - { - id: 'amountField', - name: 'AMOUNT_FIELD.TITLE', - type: 'amount', - required: false, - colspan: 1, - placeholder: '123', - minValue: null, - maxValue: null, - visibilityCondition: null, - params: { - existingColspan: 1, - maxColspan: 2 - }, - enableFractions: false, - currency: '$' - } - ] - } - }, - { - id: '33138eea-130f-4bba-b5a5-29ea60f31786', - name: 'Label', - type: 'container', - tab: null, - numberOfColumns: 2, - fields: { - '1': [ - { - id: 'dateField', - name: 'DATE_FIELD.TITLE', - type: 'date', - required: false, - colspan: 1, - placeholder: null, - minValue: null, - maxValue: null, - visibilityCondition: null, - params: { - existingColspan: 1, - maxColspan: 2 - }, - dateDisplayFormat: 'D-M-YYYY' - } - ], - '2': [] - } - } - ], - outcomes: [], - metadata: {}, - variables: [] - } - } -}; - export const fakeMetadataForm = { id: 'form-de8895be-d0d7-4434-beef-559b15305d72', name: 'StartEventForm', @@ -1310,102 +360,6 @@ export const mockDisplayExternalPropertyForm = { ] }; -export const fakeViewerForm = { - id: 'form-de8895be-d0d7-4434-beef-559b15305d72', - name: 'StartEventForm', - description: '', - version: 0, - formDefinition: { - tabs: [], - fields: [ - { - type: 'container', - id: '5a6b24c1-db2b-45e9-9aff-142395433d23', - name: 'Label', - tab: null, - fields: { - '1': [ - { - id: 'content_form_nodes', - name: 'Nodes', - type: 'upload', - readOnly: false, - required: true, - colspan: 1, - visibilityCondition: null, - params: { - existingColspan: 1, - maxColspan: 2, - fileSource: { - serviceId: 'alfresco-content', - name: 'Alfresco Content', - metadataAllowed: true - }, - multiple: true, - menuOptions: { - show: true, - download: true, - retrieveMetadata: true, - remove: true - }, - link: false - } - } - ], - '2': [ - { - id: 'upload_widget', - name: 'Nodes', - type: 'upload', - readOnly: false, - required: true, - colspan: 1, - visibilityCondition: null, - params: { - existingColspan: 1, - maxColspan: 2, - fileSource: { - serviceId: 'alfresco-content', - name: 'Alfresco Content', - metadataAllowed: true - }, - multiple: true, - menuOptions: { - show: true, - download: true, - retrieveMetadata: true, - remove: true - }, - link: false - } - } - ], - '3': [ - { - id: 'cmfb85b2a7295ba41209750bca176ccaf9a', - name: 'File viewer', - type: 'file-viewer', - readOnly: false, - required: false, - colspan: 1, - visibilityCondition: null, - params: { - existingColspan: 1, - maxColspan: 2, - uploadWidget: 'content_form_nodes' - } - } - ] - }, - numberOfColumns: 2 - } - ], - outcomes: [], - metadata: {}, - variables: [] - } -}; - export const mockFormWithSections = { id: 'form-970ddfcf-6d5d-4cbb-ae81-958ade65062c', name: 'simple section', diff --git a/lib/core/src/lib/form/components/widgets/core/form-field.model.ts b/lib/core/src/lib/form/components/widgets/core/form-field.model.ts index d3a7f60aec..13ccf57911 100644 --- a/lib/core/src/lib/form/components/widgets/core/form-field.model.ts +++ b/lib/core/src/lib/form/components/widgets/core/form-field.model.ts @@ -488,7 +488,7 @@ export class FormFieldModel extends FormWidgetModel { let dateValue; try { dateValue = DateFnsUtils.parseDate(this.value, this.dateDisplayFormat); - } catch (e) { + } catch { dateValue = new Date('error'); } diff --git a/lib/core/src/lib/form/models/form-rules.model.spec.ts b/lib/core/src/lib/form/models/form-rules.model.spec.ts index 2c4d626748..e574af5006 100644 --- a/lib/core/src/lib/form/models/form-rules.model.spec.ts +++ b/lib/core/src/lib/form/models/form-rules.model.spec.ts @@ -24,11 +24,11 @@ import { FormService } from '../services/form.service'; import { ByPassFormRuleManager, FORM_RULES_MANAGER, FormRulesManager, formRulesManagerFactory } from './form-rules.model'; class CustomRuleManager extends FormRulesManager { - protected getRules() { + getRules(): any { return null; } - protected handleRuleEvent(): void { + handleRuleEvent(): void { return; } } @@ -67,8 +67,8 @@ describe('Form Rules', () => { it('should send the form loaded event when initialized', () => { const rulesManager = new CustomRuleManager(formService); - const getRulesSpy = spyOn(rulesManager, 'getRules').and.returnValue({}); - const handleRuleEventSpy = spyOn(rulesManager, 'handleRuleEvent'); + const getRulesSpy = spyOn(rulesManager, 'getRules').and.returnValue({}); + const handleRuleEventSpy = spyOn(rulesManager, 'handleRuleEvent'); const formModel = new FormModel({ id: 'mock' }, {}, false); const formEvent = new FormEvent(formModel); const event = new FormRulesEvent('formLoaded', formEvent); @@ -82,8 +82,8 @@ describe('Form Rules', () => { it('should not receive the form event when event has no form', () => { const rulesManager = new CustomRuleManager(formService); - spyOn(rulesManager, 'getRules').and.returnValue({}); - const handleRuleEventSpy = spyOn(rulesManager, 'handleRuleEvent'); + spyOn(rulesManager, 'getRules').and.returnValue({}); + const handleRuleEventSpy = spyOn(rulesManager, 'handleRuleEvent'); const formModel = new FormModel({ id: 'mock' }, {}, false); const formEvent = new FormEvent(new FormModel(null)); const event = new FormRulesEvent('formLoaded', formEvent); @@ -105,8 +105,8 @@ describe('Form Rules', () => { beforeEach(() => { injector = TestBed.inject(Injector); - rulesManager = formRulesManagerFactory(injector); - getRulesSpy = spyOn(rulesManager, 'getRules'); + rulesManager = formRulesManagerFactory(injector); + getRulesSpy = spyOn(rulesManager as any, 'getRules'); }); it('factory function should return bypass service', () => { diff --git a/lib/core/src/lib/mock/data-column.mock.ts b/lib/core/src/lib/mock/data-column.mock.ts index c2375a262d..d29b0f775c 100644 --- a/lib/core/src/lib/mock/data-column.mock.ts +++ b/lib/core/src/lib/mock/data-column.mock.ts @@ -15,31 +15,8 @@ * limitations under the License. */ -import { DataColumn } from '../datatable/data/data-column.model'; import { mockPathInfos } from '../datatable/components/mocks/datatable.mock'; -export const getDataColumnMock = (column: Partial> = {}): DataColumn => ({ - id: 'columnId', - key: 'key', - type: 'text', - format: 'format', - sortable: false, - title: 'title', - srTitle: 'srTitle', - cssClass: 'cssClass', - template: undefined, - copyContent: false, - editable: false, - focus: false, - sortingKey: 'sortingKey', - header: undefined, - draggable: false, - resizable: true, - isHidden: false, - customData: undefined, - ...column -}); - export const textColumnRows = [{ firstname: 'John' }, { firstname: 'Henry' }, { firstname: 'David' }, { firstname: 'Thomas' }]; export const dateColumnRows = [ diff --git a/lib/core/src/lib/mock/form/widget-visibility.service.mock.ts b/lib/core/src/lib/mock/form/widget-visibility.service.mock.ts index fd85e1fd08..0688d4c5ee 100644 --- a/lib/core/src/lib/mock/form/widget-visibility.service.mock.ts +++ b/lib/core/src/lib/mock/form/widget-visibility.service.mock.ts @@ -19,12 +19,6 @@ import { FormModel, FormValues } from '../../form/components/widgets/core'; export const formTest = new FormModel({}); -export const fakeTaskProcessVariableModels = [ - { id: 'TEST_VAR_1', type: 'string', value: 'test_value_1' }, - { id: 'TEST_VAR_2', type: 'string', value: 'test_value_2' }, - { id: 'TEST_VAR_3', type: 'string', value: 'test_value_3' } -]; - export const formValues: FormValues = { test_1: 'value_1', test_2: 'value_2', diff --git a/lib/core/src/lib/mock/public-api.ts b/lib/core/src/lib/mock/public-api.ts index 693197bb5f..77dd1202f0 100644 --- a/lib/core/src/lib/mock/public-api.ts +++ b/lib/core/src/lib/mock/public-api.ts @@ -19,10 +19,6 @@ export * from './cookie.service.mock'; export * from './event.mock'; export * from './translation.service.mock'; -export * from './form/form.component.mock'; -export * from './form/form-definition.mock'; -export * from './form/form-definition-readonly.mock'; -export * from './form/form-definition-visibility.mock'; export * from './form/form.service.mock'; export * from './form/widget-visibility.service.mock'; diff --git a/lib/core/src/lib/testing/unit-testing-utils.ts b/lib/core/src/lib/testing/unit-testing-utils.ts index f12cb502d8..2b9c3d358a 100644 --- a/lib/core/src/lib/testing/unit-testing-utils.ts +++ b/lib/core/src/lib/testing/unit-testing-utils.ts @@ -24,7 +24,7 @@ import { MatChipGridHarness, MatChipHarness, MatChipListboxHarness } from '@angu import { MatButtonHarness } from '@angular/material/button/testing'; import { MatIconHarness } from '@angular/material/icon/testing'; import { MatCheckboxHarness } from '@angular/material/checkbox/testing'; -import { MatErrorHarness, MatFormFieldHarness } from '@angular/material/form-field/testing'; +import { MatFormFieldHarness } from '@angular/material/form-field/testing'; import { MatInputHarness } from '@angular/material/input/testing'; import { MatAutocompleteHarness } from '@angular/material/autocomplete/testing'; import { ComponentFixture } from '@angular/core/testing'; @@ -34,7 +34,10 @@ import { MatSnackBarHarness } from '@angular/material/snack-bar/testing'; import { MatProgressBarHarness } from '@angular/material/progress-bar/testing'; export class UnitTestingUtils { - constructor(private debugElement?: DebugElement, private loader?: HarnessLoader) { + constructor( + private debugElement?: DebugElement, + private loader?: HarnessLoader + ) { this.debugElement = debugElement; this.loader = loader; } @@ -75,10 +78,6 @@ export class UnitTestingUtils { return this.debugElement.query(By.directive(directive)); } - getAllByDirective(directive: Type): DebugElement[] { - return this.debugElement.queryAll(By.directive(directive)); - } - /** Perform actions */ clickByCSS(selector: string): void { @@ -243,10 +242,6 @@ export class UnitTestingUtils { return this.loader.getHarness(MatIconHarness.with({ ancestor: selector })); } - async getMatIconWithAncestorByCSSAndName(selector: string, name: string): Promise { - return this.loader.getHarness(MatIconHarness.with({ ancestor: selector, name })); - } - async checkIfMatIconExistsWithAncestorByDataAutomationId(dataAutomationId: string): Promise { return this.loader.hasHarness(MatIconHarness.with({ ancestor: `[data-automation-id="${dataAutomationId}"]` })); } @@ -339,10 +334,6 @@ export class UnitTestingUtils { return this.loader.getHarness(MatInputHarness); } - async getMatInputByCSS(selector: string): Promise { - return this.loader.getHarness(MatInputHarness.with({ selector })); - } - async getMatInputByDataAutomationId(dataAutomationId: string): Promise { return this.loader.getHarness(MatInputHarness.with({ selector: `[data-automation-id="${dataAutomationId}"]` })); } @@ -360,14 +351,6 @@ export class UnitTestingUtils { return this.loader.hasHarness(MatInputHarness); } - async checkIfMatInputExistsWithCSS(selector: string): Promise { - return this.loader.hasHarness(MatInputHarness.with({ selector })); - } - - async checkIfMatInputExistsWithDataAutomationId(dataAutomationId: string): Promise { - return this.loader.hasHarness(MatInputHarness.with({ selector: `[data-automation-id="${dataAutomationId}"]` })); - } - async checkIfMatInputExistsWithPlaceholder(placeholder: string): Promise { return this.loader.hasHarness(MatInputHarness.with({ placeholder })); } @@ -383,11 +366,6 @@ export class UnitTestingUtils { await input.setValue(value); } - async fillMatInputByCSS(selector: string, value: string): Promise { - const input = await this.getMatInputByCSS(selector); - await input.setValue(value); - } - async fillMatInputByDataAutomationId(dataAutomationId: string, value: string): Promise { const input = await this.getMatInputByDataAutomationId(dataAutomationId); await input.setValue(value); @@ -409,11 +387,6 @@ export class UnitTestingUtils { return input.getValue(); } - async getMatInputValueByDataAutomationId(dataAutomationId: string): Promise { - const input = await this.getMatInputByDataAutomationId(dataAutomationId); - return input.getValue(); - } - async sendKeysToMatInput(keys: (string | TestKey)[]): Promise { const input = await this.getMatInput(); const host = await input.host(); @@ -430,16 +403,6 @@ export class UnitTestingUtils { return autocomplete.getOptions(); } - /** MatError related methods */ - - async getMatErrorByCSS(selector: string): Promise { - return this.loader.getHarness(MatErrorHarness.with({ selector })); - } - - async getMatErrorByDataAutomationId(dataAutomationId: string): Promise { - return this.loader.getHarness(MatErrorHarness.with({ selector: `[data-automation-id="${dataAutomationId}"]` })); - } - /** MatTabGroup related methods */ async getSelectedTabFromMatTabGroup(): Promise { diff --git a/lib/core/src/lib/translation/translate-loader.service.ts b/lib/core/src/lib/translation/translate-loader.service.ts index 50fd91a4b0..37c6bc787e 100644 --- a/lib/core/src/lib/translation/translate-loader.service.ts +++ b/lib/core/src/lib/translation/translate-loader.service.ts @@ -54,7 +54,7 @@ export class TranslateLoaderService implements TranslateLoader { } providerRegistered(name: string): boolean { - return !!this.providers.find((x) => x.name === name); + return this.providers.some((x) => x.name === name); } fetchLanguageFile(lang: string, component: ComponentTranslationModel, fallbackUrl?: string): Observable { @@ -75,7 +75,7 @@ export class TranslateLoaderService implements TranslateLoader { return this.fetchLanguageFile(lang, component, url); } } - return throwError(`Failed to load ${translationUrl}`); + return throwError(() => new Error(`Failed to load ${translationUrl}`)); }) ); } @@ -85,13 +85,13 @@ export class TranslateLoaderService implements TranslateLoader { if (!this.queue[lang]) { this.queue[lang] = []; } - this.providers.forEach((component) => { + for (const component of this.providers) { if (!this.isComponentInQueue(lang, component.name)) { this.queue[lang].push(component.name); observableBatch.push(this.fetchLanguageFile(lang, component)); } - }); + } return observableBatch; } @@ -102,8 +102,8 @@ export class TranslateLoaderService implements TranslateLoader { } } - isComponentInQueue(lang: string, name: string) { - return !!(this.queue[lang] || []).find((x) => x === name); + isComponentInQueue(lang: string, name: string): boolean { + return (this.queue[lang] || []).some((x) => x === name); } getFullTranslationJSON(lang: string): any { @@ -144,8 +144,8 @@ export class TranslateLoaderService implements TranslateLoader { return new Observable((observer) => { if (batch.length > 0) { - forkJoin(batch).subscribe( - () => { + forkJoin(batch).subscribe({ + next: () => { const fullTranslation = this.getFullTranslationJSON(lang); if (fullTranslation) { observer.next(fullTranslation); @@ -156,10 +156,10 @@ export class TranslateLoaderService implements TranslateLoader { observer.complete(); } }, - () => { + error: () => { observer.error('Failed to load some resources'); } - ); + }); } else { const fullTranslation = this.getFullTranslationJSON(lang); if (fullTranslation) { diff --git a/lib/core/src/lib/viewer/components/img-viewer/img-viewer.component.ts b/lib/core/src/lib/viewer/components/img-viewer/img-viewer.component.ts index 6d13060d4d..29931cf242 100644 --- a/lib/core/src/lib/viewer/components/img-viewer/img-viewer.component.ts +++ b/lib/core/src/lib/viewer/components/img-viewer/img-viewer.component.ts @@ -88,31 +88,38 @@ export class ImgViewerComponent implements AfterViewInit, OnChanges, OnDestroy { @HostListener('document:keydown', ['$event']) onKeyDown(event: KeyboardEvent) { switch (event.key) { - case 'ArrowLeft': + case 'ArrowLeft': { event.preventDefault(); this.cropper.move(-3, 0); break; - case 'ArrowUp': + } + case 'ArrowUp': { event.preventDefault(); this.cropper.move(0, -3); break; - case 'ArrowRight': + } + case 'ArrowRight': { event.preventDefault(); this.cropper.move(3, 0); break; - case 'ArrowDown': + } + case 'ArrowDown': { event.preventDefault(); this.cropper.move(0, 3); break; - case 'i': + } + case 'i': { this.zoomIn(); break; - case 'o': + } + case 'o': { this.zoomOut(); break; - case 'r': + } + case 'r': { this.rotateImage(); break; + } default: } } @@ -132,7 +139,10 @@ export class ImgViewerComponent implements AfterViewInit, OnChanges, OnDestroy { return Math.round(this.scale * 100) + '%'; } - constructor(private appConfigService: AppConfigService, private urlService: UrlService) { + constructor( + private readonly appConfigService: AppConfigService, + private readonly urlService: UrlService + ) { this.initializeScaling(); } @@ -222,7 +232,7 @@ export class ImgViewerComponent implements AfterViewInit, OnChanges, OnDestroy { this.cropper.clear(); this.cropper.reset(); this.cropper.setDragMode('move'); - this.scale = 1.0; + this.scale = 1; this.updateCanvasContainer(); } diff --git a/lib/core/src/lib/viewer/components/pdf-viewer/pdf-viewer.component.spec.ts b/lib/core/src/lib/viewer/components/pdf-viewer/pdf-viewer.component.spec.ts index c993bc5c03..5df1b2833a 100644 --- a/lib/core/src/lib/viewer/components/pdf-viewer/pdf-viewer.component.spec.ts +++ b/lib/core/src/lib/viewer/components/pdf-viewer/pdf-viewer.component.spec.ts @@ -27,7 +27,7 @@ import { UnitTestingUtils, provideCoreAuthTesting } from '../../../testing'; import { RenderingQueueServices } from '../../services/rendering-queue.services'; import { PdfThumbListComponent } from '../pdf-viewer-thumbnails/pdf-viewer-thumbnails.component'; import { PDFJS_MODULE, PDFJS_VIEWER_MODULE, PdfViewerComponent } from './pdf-viewer.component'; -import pdfjsLibMock from '../mock/pdfjs-lib.mock'; +import pdfjsLibraryMock from '../mock/pdfjs-lib.mock'; declare const pdfjsLib: any; @@ -441,7 +441,7 @@ describe('Test PdfViewer - User interaction', () => { }, RenderingQueueServices, { provide: PDFJS_VIEWER_MODULE, useValue: pdfViewerSpy }, - { provide: PDFJS_MODULE, useValue: pdfjsLibMock } + { provide: PDFJS_MODULE, useValue: pdfjsLibraryMock } ] }); diff --git a/lib/core/src/lib/viewer/components/viewer.component.spec.ts b/lib/core/src/lib/viewer/components/viewer.component.spec.ts index 5a28be2da4..bf1d7f076e 100644 --- a/lib/core/src/lib/viewer/components/viewer.component.spec.ts +++ b/lib/core/src/lib/viewer/components/viewer.component.spec.ts @@ -545,9 +545,9 @@ describe('ViewerComponent', () => { keyCode: 27 } as KeyboardEventInit); - const dialogRef = dialog.open(DummyDialogComponent); + const dialogReference = dialog.open(DummyDialogComponent); - dialogRef.afterClosed().subscribe(() => { + dialogReference.afterClosed().subscribe(() => { EventMock.keyDown(27); fixture.detectChanges(); expect(testingUtils.getByCSS('.adf-viewer-content')).toBeNull(); diff --git a/lib/core/src/lib/viewer/components/viewer.component.ts b/lib/core/src/lib/viewer/components/viewer.component.ts index e8d2bf2b17..51ce7a76d3 100644 --- a/lib/core/src/lib/viewer/components/viewer.component.ts +++ b/lib/core/src/lib/viewer/components/viewer.component.ts @@ -245,7 +245,7 @@ export class ViewerComponent implements OnDestroy, OnInit, OnChanges { @Input() nodeId: string = null; - /** Original node mime type, should be provided when renditiona mime type is different. */ + /** Original node mime type, should be provided when renditions mime type is different. */ @Input() nodeMimeType: string = undefined; diff --git a/lib/core/src/lib/viewer/directives/viewer-extension.directive.ts b/lib/core/src/lib/viewer/directives/viewer-extension.directive.ts index ac372b360a..56606884a2 100644 --- a/lib/core/src/lib/viewer/directives/viewer-extension.directive.ts +++ b/lib/core/src/lib/viewer/directives/viewer-extension.directive.ts @@ -60,7 +60,7 @@ export class ViewerExtensionDirective implements AfterContentInit { isVisible(fileExtension: string): boolean { let supportedExtension: string; - if (this.supportedExtensions && this.supportedExtensions instanceof Array) { + if (Array.isArray(this.supportedExtensions)) { supportedExtension = this.supportedExtensions.find((extension) => extension.toLowerCase() === fileExtension); } diff --git a/lib/core/src/lib/viewer/services/rendering-queue.services.ts b/lib/core/src/lib/viewer/services/rendering-queue.services.ts index 7e5d6628e3..e9b8abfc2b 100644 --- a/lib/core/src/lib/viewer/services/rendering-queue.services.ts +++ b/lib/core/src/lib/viewer/services/rendering-queue.services.ts @@ -31,16 +31,16 @@ export class RenderingQueueServices { FINISHED: 3 }; - CLEANUP_TIMEOUT: number = 30000; + CLEANUP_TIMEOUT: number = 30_000; pdfViewer: any = null; pdfThumbnailViewer: any = null; onIdle: any = null; - highestPriorityPage: any = null; + highestPriorityPage: string | null = null; idleTimeout: any = null; printing: any = false; - isThumbnailViewEnabled: any = false; + isThumbnailViewEnabled = false; /** * Set the instance of the PDF Viewer @@ -81,10 +81,8 @@ export class RenderingQueueServices { return; } // No pages needed rendering so check thumbnails. - if (this.pdfThumbnailViewer && this.isThumbnailViewEnabled) { - if (this.pdfThumbnailViewer.forceRendering()) { - return; - } + if (this.pdfThumbnailViewer && this.isThumbnailViewEnabled && this.pdfThumbnailViewer.forceRendering()) { + return; } if (this.printing) { @@ -106,11 +104,11 @@ export class RenderingQueueServices { // 2 if last scrolled up page before the visible pages const visibleViews = visible.views; - const numVisible = visibleViews.length; - if (numVisible === 0) { + const numberVisible = visibleViews.length; + if (numberVisible === 0) { return false; } - for (let i = 0; i < numVisible; ++i) { + for (let i = 0; i < numberVisible; ++i) { const view = visibleViews[i].view; if (!this.isViewFinished(view)) { return view; @@ -180,8 +178,9 @@ export class RenderingQueueServices { view.draw().then(continueRendering, continueRendering); break; } - default: + default: { break; + } } return true; } diff --git a/lib/core/src/lib/viewer/services/view-util.service.ts b/lib/core/src/lib/viewer/services/view-util.service.ts index 97affa7b25..421437c26d 100644 --- a/lib/core/src/lib/viewer/services/view-util.service.ts +++ b/lib/core/src/lib/viewer/services/view-util.service.ts @@ -53,7 +53,7 @@ export class ViewUtilService { * @returns list of extensions */ get externalExtensions(): string[] { - return this.viewerExtensions.map((ext) => ext.fileExtension); + return this.viewerExtensions.map((extension) => extension.fileExtension); } constructor(private extensionService: AppExtensionService) {} @@ -85,7 +85,7 @@ export class ViewUtilService { const match = fileName.match(/\.([^./?#]+)($|\?|#)/); return match ? match[1] : null; } - return null; + return undefined; } getViewerType(extension: string, mimeType: string, extensionsSupportedByTemplates?: string[]): string { @@ -104,7 +104,7 @@ export class ViewUtilService { const editorTypes = Object.keys(this.mimeTypes); for (const type of editorTypes) { - if (this.mimeTypes[type].indexOf(mimeType) >= 0) { + if (this.mimeTypes[type].includes(mimeType)) { return type; } } @@ -125,19 +125,19 @@ export class ViewUtilService { return 'custom'; } - if (this.extensions.image.indexOf(extension) >= 0) { + if (this.extensions.image.includes(extension)) { return 'image'; } - if (this.extensions.media.indexOf(extension) >= 0) { + if (this.extensions.media.includes(extension)) { return 'media'; } - if (this.extensions.text.indexOf(extension) >= 0) { + if (this.extensions.text.includes(extension)) { return 'text'; } - if (this.extensions.pdf.indexOf(extension) >= 0) { + if (this.extensions.pdf.includes(extension)) { return 'pdf'; } @@ -145,7 +145,7 @@ export class ViewUtilService { } private isExternalViewer(): boolean { - return !!this.viewerExtensions.find((ext) => ext.fileExtension === '*'); + return this.viewerExtensions.some((extension) => extension.fileExtension === '*'); } isCustomViewerExtension(extension: string, extensionsSupportedByTemplates?: string[]): boolean { @@ -156,7 +156,7 @@ export class ViewUtilService { if (extension && extensions.length > 0) { extension = extension.toLowerCase(); - return extensions.flat().indexOf(extension) >= 0; + return extensions.flat().includes(extension); } return false; diff --git a/lib/core/test.ts b/lib/core/test.ts index 8780163215..96ffb0528a 100644 --- a/lib/core/test.ts +++ b/lib/core/test.ts @@ -19,11 +19,11 @@ import 'zone.js'; import 'zone.js/testing'; import { TestBed } from '@angular/core/testing'; import { platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing'; -import pdfjsLibMock from './src/lib/viewer/components/mock/pdfjs-lib.mock'; +import pdfjsLibraryMock from './src/lib/viewer/components/mock/pdfjs-lib.mock'; import { GlobalTestingModule } from './src/lib/testing/global-testing.module'; TestBed.initTestEnvironment(GlobalTestingModule, platformBrowserDynamicTesting(), { teardown: { destroyAfterEach: true } }); -(window as any).pdfjsLib = pdfjsLibMock; +(window as any).pdfjsLib = pdfjsLibraryMock; diff --git a/lib/insights/src/lib/insights.module.ts b/lib/insights/src/lib/insights.module.ts index a891528aae..d7a7fe5cc4 100644 --- a/lib/insights/src/lib/insights.module.ts +++ b/lib/insights/src/lib/insights.module.ts @@ -20,7 +20,15 @@ import { provideTranslations } from '@alfresco/adf-core'; import { ANALYTICS_PROCESS_DIRECTIVES } from './analytics-process/public-api'; import { DIAGRAM_DIRECTIVES } from './diagram/public-api'; -/** @deprecated This module is deprecated and will be removed in a future release. */ +/** + * @deprecated This module is deprecated and will be removed in a future release. + * Example: + * ``` + * providers: [ + * provideTranslations('adf-insights', 'assets/adf-insights') + * ] + * ``` + */ @NgModule({ imports: [...ANALYTICS_PROCESS_DIRECTIVES, ...DIAGRAM_DIRECTIVES], exports: [...ANALYTICS_PROCESS_DIRECTIVES, ...DIAGRAM_DIRECTIVES] diff --git a/lib/process-services-cloud/src/lib/app/components/app-list-cloud/app-list-cloud.component.spec.ts b/lib/process-services-cloud/src/lib/app/components/app-list-cloud/app-list-cloud.component.spec.ts index 28dfe30ee9..5a8b1685e5 100644 --- a/lib/process-services-cloud/src/lib/app/components/app-list-cloud/app-list-cloud.component.spec.ts +++ b/lib/process-services-cloud/src/lib/app/components/app-list-cloud/app-list-cloud.component.spec.ts @@ -213,7 +213,7 @@ describe('AppListCloudComponent', () => { customFixture.detectChanges(); await customFixture.whenStable(); - const title: any = customFixture.nativeElement.querySelector('#custom-id'); + const title = customFixture.nativeElement.querySelector('#custom-id'); expect(title.innerText).toBe('No Apps Found'); }); }); diff --git a/lib/process-services-cloud/src/lib/app/services/apps-process-cloud.service.ts b/lib/process-services-cloud/src/lib/app/services/apps-process-cloud.service.ts index 552ab95817..a239e5be6d 100644 --- a/lib/process-services-cloud/src/lib/app/services/apps-process-cloud.service.ts +++ b/lib/process-services-cloud/src/lib/app/services/apps-process-cloud.service.ts @@ -28,7 +28,10 @@ import { RequestOptions } from '@alfresco/js-api'; export class AppsProcessCloudService { deployedApps: ApplicationInstanceModel[]; - constructor(private adfHttpClient: AdfHttpClient, private appConfigService: AppConfigService) { + constructor( + private readonly adfHttpClient: AdfHttpClient, + private readonly appConfigService: AppConfigService + ) { this.loadApps(); } @@ -48,11 +51,12 @@ export class AppsProcessCloudService { } loadApps() { - const apps = this.appConfigService.get('alfresco-deployed-apps', []); - apps.map((app) => { - app.theme = app.theme ? app.theme : 'theme-1'; - app.icon = app.icon ? app.icon : 'favorite'; - }); + const apps = this.appConfigService.get<{ theme: string; icon: string }[]>('alfresco-deployed-apps', []); + for (const app of apps) { + app.theme = app.theme ?? 'theme-1'; + app.icon = app.icon ?? 'favorite'; + } + this.deployedApps = apps; } diff --git a/lib/process-services-cloud/src/lib/form/components/form-cloud.component.ts b/lib/process-services-cloud/src/lib/form/components/form-cloud.component.ts index f437c4c427..d9f407a914 100644 --- a/lib/process-services-cloud/src/lib/form/components/form-cloud.component.ts +++ b/lib/process-services-cloud/src/lib/form/components/form-cloud.component.ts @@ -363,8 +363,8 @@ export class FormCloudComponent extends FormBaseComponent implements OnChanges, }), takeUntilDestroyed(this.destroyRef) ) - .subscribe( - (form) => { + .subscribe({ + next: (form) => { this.formCloudRepresentationJSON = form; this.formCloudRepresentationJSON.processVariables = this.data || []; const parsedForm = this.parseForm(form); @@ -374,10 +374,10 @@ export class FormCloudComponent extends FormBaseComponent implements OnChanges, this.form.nodeId = '-my-'; this.onFormLoaded(this.form); }, - (error) => { + error: (error) => { this.handleError(error); } - ); + }); } saveTaskForm() { @@ -385,12 +385,12 @@ export class FormCloudComponent extends FormBaseComponent implements OnChanges, this.formCloudService .saveTaskForm(this.appName, this.taskId, this.processInstanceId, `${this.form.id}`, this.form.values) .pipe(takeUntilDestroyed(this.destroyRef)) - .subscribe( - () => { + .subscribe({ + next: () => { this.onTaskSaved(this.form); }, - (error) => this.onTaskSavedError(error) - ); + error: (error) => this.onTaskSavedError(error) + }); this.displayModeService.onSaveTask(this.id, this.displayMode, this.displayModeConfigurations); } } @@ -420,12 +420,12 @@ export class FormCloudComponent extends FormBaseComponent implements OnChanges, this.formCloudService .completeTaskForm(this.appName, this.taskId, this.processInstanceId, `${this.form.id}`, this.form.values, outcome, this.appVersion) .pipe(takeUntilDestroyed(this.destroyRef)) - .subscribe( - () => { + .subscribe({ + next: () => { this.onTaskCompleted(this.form); }, - (error) => this.onTaskCompletedError(error) - ); + error: (error) => this.onTaskCompletedError(error) + }); } } @@ -531,7 +531,7 @@ export class FormCloudComponent extends FormBaseComponent implements OnChanges, } loadInjectedFieldValidators(injectedFieldValidators: FormFieldValidator[]): void { - if (injectedFieldValidators && injectedFieldValidators?.length) { + if (Array.isArray(injectedFieldValidators) && injectedFieldValidators.length) { this.fieldValidators = [...this.fieldValidators, ...injectedFieldValidators]; } } diff --git a/lib/process-services-cloud/src/lib/group/components/group-cloud.component.ts b/lib/process-services-cloud/src/lib/group/components/group-cloud.component.ts index e9ba41d6dc..6f014d2204 100644 --- a/lib/process-services-cloud/src/lib/group/components/group-cloud.component.ts +++ b/lib/process-services-cloud/src/lib/group/components/group-cloud.component.ts @@ -268,7 +268,7 @@ export class GroupCloudComponent implements OnInit, OnChanges { if (this.isPreselectedGroupInvalid(group, validationResult)) { this.invalidGroups.push(group); } - } catch (error) { + } catch { this.invalidGroups.push(group); } } diff --git a/lib/process-services-cloud/src/lib/people/components/people-cloud.component.ts b/lib/process-services-cloud/src/lib/people/components/people-cloud.component.ts index 13f7e0c7d1..b4c6aa3a0c 100644 --- a/lib/process-services-cloud/src/lib/people/components/people-cloud.component.ts +++ b/lib/process-services-cloud/src/lib/people/components/people-cloud.component.ts @@ -376,7 +376,7 @@ export class PeopleCloudComponent implements OnInit, OnChanges, AfterViewInit { if (!this.equalsUsers(user, validationResult)) { this.invalidUsers.push(user); } - } catch (error) { + } catch { this.invalidUsers.push(user); } } diff --git a/lib/process-services-cloud/src/lib/process-services-cloud.module.ts b/lib/process-services-cloud/src/lib/process-services-cloud.module.ts index 9dee489f7b..65b812c7a9 100644 --- a/lib/process-services-cloud/src/lib/process-services-cloud.module.ts +++ b/lib/process-services-cloud/src/lib/process-services-cloud.module.ts @@ -39,13 +39,14 @@ export const PROCESS_SERVICES_CLOUD_DIRECTIVES = [ * @deprecated this module is deprecated and will be removed in the future versions * * Instead, import the standalone components directly, or use the following provider API to replicate the behaviour: - * + * ``` * providers: [ * provideTranslations('adf-process-services-cloud', 'assets/adf-process-services-cloud') * provideCloudPreferences() * provideCloudFormRenderer(), * { provide: TASK_LIST_CLOUD_TOKEN, useClass: TaskListCloudService } * ] + * ``` */ @NgModule({ imports: [ProcessCloudModule, TaskCloudModule, GroupCloudComponent, ...PROCESS_SERVICES_CLOUD_DIRECTIVES], diff --git a/lib/process-services-cloud/src/lib/process/process-list/components/process-list-cloud.component.spec.ts b/lib/process-services-cloud/src/lib/process/process-list/components/process-list-cloud.component.spec.ts index 126105193b..0f3c5445c8 100644 --- a/lib/process-services-cloud/src/lib/process/process-list/components/process-list-cloud.component.spec.ts +++ b/lib/process-services-cloud/src/lib/process/process-list/components/process-list-cloud.component.spec.ts @@ -26,7 +26,6 @@ import { DataColumnComponent, DataColumnListComponent, DataRowEvent, - getDataColumnMock, ObjectDataColumn, ObjectDataRow, User, @@ -46,6 +45,7 @@ import { HarnessLoader } from '@angular/cdk/testing'; import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed'; import { MatProgressSpinnerHarness } from '@angular/material/progress-spinner/testing'; import { provideCloudPreferences } from '../../../providers'; +import { getDataColumnMock } from '../../../testing/data-column.mock'; const fakeCustomSchema = [ new ObjectDataColumn({ diff --git a/lib/process-services-cloud/src/lib/process/process-list/datatable/process-list-datatable-adapter.spec.ts b/lib/process-services-cloud/src/lib/process/process-list/datatable/process-list-datatable-adapter.spec.ts index c83bd2b758..e7a49d5f03 100644 --- a/lib/process-services-cloud/src/lib/process/process-list/datatable/process-list-datatable-adapter.spec.ts +++ b/lib/process-services-cloud/src/lib/process/process-list/datatable/process-list-datatable-adapter.spec.ts @@ -15,11 +15,12 @@ * limitations under the License. */ -import { DataColumn, DataRow, getDataColumnMock } from '@alfresco/adf-core'; +import { DataColumn, DataRow } from '@alfresco/adf-core'; import { getProcessInstanceVariableMock } from '../../../mock/process-instance-variable.mock'; import { ProcessListDataColumnCustomData, PROCESS_LIST_CUSTOM_VARIABLE_COLUMN } from '../../../models/data-column-custom-data'; import { ProcessInstanceCloudListViewModel } from '../models/perocess-instance-cloud-view.model'; import { ProcessListDatatableAdapter } from './process-list-datatable-adapter'; +import { getDataColumnMock } from '../../../testing/data-column.mock'; describe('ProcessListDatatableAdapter', () => { it('should get proepr type for column', () => { diff --git a/lib/process-services-cloud/src/lib/process/start-process/mock/start-process.component.mock.ts b/lib/process-services-cloud/src/lib/process/start-process/mock/start-process.component.mock.ts index da37b1427f..2d27a08d56 100755 --- a/lib/process-services-cloud/src/lib/process/start-process/mock/start-process.component.mock.ts +++ b/lib/process-services-cloud/src/lib/process/start-process/mock/start-process.component.mock.ts @@ -15,21 +15,10 @@ * limitations under the License. */ -import { FormFieldModel, FormFieldValidator } from '@alfresco/adf-core'; import { ProcessDefinitionCloud } from '../../../models/process-definition-cloud.model'; import { ProcessInstanceCloud } from '../models/process-instance-cloud.model'; import { ProcessPayloadCloud } from '../models/process-payload-cloud.model'; -export class MockFormFieldValidator implements FormFieldValidator { - isSupported(_field: FormFieldModel): boolean { - return true; - } - - validate(_field: FormFieldModel): boolean { - return true; - } -} - export const fakeProcessInstance: ProcessInstanceCloud = { appName: 'simple-app', appVersion: '1', diff --git a/lib/process-services-cloud/src/lib/services/variable-mapper.sevice.spec.ts b/lib/process-services-cloud/src/lib/services/variable-mapper.sevice.spec.ts index ee411e738a..fe687ce39a 100644 --- a/lib/process-services-cloud/src/lib/services/variable-mapper.sevice.spec.ts +++ b/lib/process-services-cloud/src/lib/services/variable-mapper.sevice.spec.ts @@ -16,11 +16,11 @@ */ import { getProcessInstanceVariableMock } from '../mock/process-instance-variable.mock'; - import { ProcessListDataColumnCustomData } from '../models/data-column-custom-data'; import { ProcessInstanceVariable } from '../models/process-instance-variable.model'; import { VariableMapperService } from './variable-mapper.sevice'; -import { DataColumn, getDataColumnMock } from '@alfresco/adf-core'; +import { DataColumn } from '@alfresco/adf-core'; +import { getDataColumnMock } from '../testing/data-column.mock'; describe('VariableMapperService', () => { let service: VariableMapperService; diff --git a/lib/process-services-cloud/src/lib/task/task-list/components/task-list/datatable/task-list-datatable-adapter.spec.ts b/lib/process-services-cloud/src/lib/task/task-list/components/task-list/datatable/task-list-datatable-adapter.spec.ts index 3c50ba86bf..20149e7c76 100644 --- a/lib/process-services-cloud/src/lib/task/task-list/components/task-list/datatable/task-list-datatable-adapter.spec.ts +++ b/lib/process-services-cloud/src/lib/task/task-list/components/task-list/datatable/task-list-datatable-adapter.spec.ts @@ -15,7 +15,8 @@ * limitations under the License. */ -import { DataColumn, DataRow, getDataColumnMock } from '@alfresco/adf-core'; +import { DataColumn, DataRow } from '@alfresco/adf-core'; +import { getDataColumnMock } from '../../../../../testing/data-column.mock'; import { ProcessListDataColumnCustomData, PROCESS_LIST_CUSTOM_VARIABLE_COLUMN } from '../../../../../models/data-column-custom-data'; import { TasksListDatatableAdapter } from './task-list-datatable-adapter'; import { TaskInstanceCloudListViewModel } from '../../../models/task-cloud-view.model'; diff --git a/lib/content-services/src/lib/testing/mat-icon-registry-mock.ts b/lib/process-services-cloud/src/lib/testing/data-column.mock.ts similarity index 53% rename from lib/content-services/src/lib/testing/mat-icon-registry-mock.ts rename to lib/process-services-cloud/src/lib/testing/data-column.mock.ts index e1a0c2a21e..310c8ab03a 100644 --- a/lib/content-services/src/lib/testing/mat-icon-registry-mock.ts +++ b/lib/process-services-cloud/src/lib/testing/data-column.mock.ts @@ -15,8 +15,26 @@ * limitations under the License. */ -import { MatIconRegistry } from '@angular/material/icon'; +import { DataColumn } from '@alfresco/adf-core'; -export const matIconRegistryMock = { - addSvgIconInNamespace: () => {} -} as any as MatIconRegistry; +export const getDataColumnMock = (column: Partial> = {}): DataColumn => ({ + id: 'columnId', + key: 'key', + type: 'text', + format: 'format', + sortable: false, + title: 'title', + srTitle: 'srTitle', + cssClass: 'cssClass', + template: undefined, + copyContent: false, + editable: false, + focus: false, + sortingKey: 'sortingKey', + header: undefined, + draggable: false, + resizable: true, + isHidden: false, + customData: undefined, + ...column +}); diff --git a/lib/process-services/src/lib/app-list/apps-list.component.spec.ts b/lib/process-services/src/lib/app-list/apps-list.component.spec.ts index abb6d4c2ac..80a481a129 100644 --- a/lib/process-services/src/lib/app-list/apps-list.component.spec.ts +++ b/lib/process-services/src/lib/app-list/apps-list.component.spec.ts @@ -269,7 +269,7 @@ describe('AppsListComponent', () => { customFixture.detectChanges(); await customFixture.whenStable(); - const title: any = customFixture.debugElement.queryAll(By.css('#custom-id')); + const title = customFixture.debugElement.queryAll(By.css('#custom-id')); expect(title.length).toBe(1); expect(title[0].nativeElement.innerText).toBe('No Apps'); }); diff --git a/lib/core/src/lib/mock/form/form-definition-readonly.mock.ts b/lib/process-services/src/lib/form/form-definition-readonly.mock.ts similarity index 100% rename from lib/core/src/lib/mock/form/form-definition-readonly.mock.ts rename to lib/process-services/src/lib/form/form-definition-readonly.mock.ts diff --git a/lib/core/src/lib/mock/form/form-definition-visibility.mock.ts b/lib/process-services/src/lib/form/form-definition-visibility.mock.ts similarity index 100% rename from lib/core/src/lib/mock/form/form-definition-visibility.mock.ts rename to lib/process-services/src/lib/form/form-definition-visibility.mock.ts diff --git a/lib/core/src/lib/mock/form/form-definition.mock.ts b/lib/process-services/src/lib/form/form-definition.mock.ts similarity index 100% rename from lib/core/src/lib/mock/form/form-definition.mock.ts rename to lib/process-services/src/lib/form/form-definition.mock.ts diff --git a/lib/core/src/lib/mock/form/form.component.mock.ts b/lib/process-services/src/lib/form/form.component.mock.ts similarity index 100% rename from lib/core/src/lib/mock/form/form.component.mock.ts rename to lib/process-services/src/lib/form/form.component.mock.ts diff --git a/lib/process-services/src/lib/form/form.component.spec.ts b/lib/process-services/src/lib/form/form.component.spec.ts index 05396fe8c9..0fdfba3e30 100644 --- a/lib/process-services/src/lib/form/form.component.spec.ts +++ b/lib/process-services/src/lib/form/form.component.spec.ts @@ -29,9 +29,9 @@ import { FormService, WidgetVisibilityService, ContainerModel, - fakeForm, NoopAuthModule } from '@alfresco/adf-core'; +import { fakeForm } from './form.component.mock'; import { NodeMetadata, NodesApiService } from '@alfresco/adf-content-services'; import { FormComponent } from './form.component'; import { ProcessFormRenderingService } from './process-form-rendering.service'; diff --git a/lib/process-services/src/lib/form/form.component.visibility.spec.ts b/lib/process-services/src/lib/form/form.component.visibility.spec.ts index 9d11f3c65c..84bcfa3baf 100644 --- a/lib/process-services/src/lib/form/form.component.visibility.spec.ts +++ b/lib/process-services/src/lib/form/form.component.visibility.spec.ts @@ -19,15 +19,10 @@ import { SimpleChange } from '@angular/core'; import { of } from 'rxjs'; import { ComponentFixture, TestBed } from '@angular/core/testing'; import { By } from '@angular/platform-browser'; -import { - formDefinitionDropdownField, - formDefinitionTwoTextFields, - formDefinitionRequiredField, - formDefVisibilityFieldDependsOnNextOne, - formDefVisibilitiFieldDependsOnPreviousOne, - formReadonlyTwoTextFields, - FormRenderingService -} from '@alfresco/adf-core'; +import { formDefinitionDropdownField, formDefinitionTwoTextFields, formDefinitionRequiredField } from './form-definition.mock'; +import { formDefVisibilityFieldDependsOnNextOne, formDefVisibilitiFieldDependsOnPreviousOne } from './form-definition-visibility.mock'; +import { formReadonlyTwoTextFields } from './form-definition-readonly.mock'; +import { FormRenderingService } from '@alfresco/adf-core'; import { FormComponent } from './form.component'; import { TaskService } from './services/task.service'; import { TaskFormService } from './services/task-form.service'; diff --git a/lib/process-services/src/lib/form/widgets/dynamic-table/editors/row-editor/row.editor.ts b/lib/process-services/src/lib/form/widgets/dynamic-table/editors/row-editor/row.editor.ts index 726a1d6032..c2bd62066a 100644 --- a/lib/process-services/src/lib/form/widgets/dynamic-table/editors/row-editor/row.editor.ts +++ b/lib/process-services/src/lib/form/widgets/dynamic-table/editors/row-editor/row.editor.ts @@ -32,6 +32,12 @@ import { TextEditorComponent } from '../text/text.editor'; import { ErrorWidgetComponent } from '@alfresco/adf-core'; import { MatButtonModule } from '@angular/material/button'; +export interface RowEditorReturnType { + table: DynamicTableModel; + row: DynamicTableRow; + column: DynamicTableColumn; +} + @Component({ selector: 'row-editor', imports: [ @@ -59,10 +65,10 @@ export class RowEditorComponent { column: DynamicTableColumn; @Output() - save: EventEmitter = new EventEmitter(); + save = new EventEmitter(); @Output() - cancel: EventEmitter = new EventEmitter(); + cancel = new EventEmitter(); validationSummary: DynamicRowValidationSummary; diff --git a/lib/process-services/src/lib/form/widgets/people/people.widget.ts b/lib/process-services/src/lib/form/widgets/people/people.widget.ts index 2181e7acf3..e8e6cf9498 100644 --- a/lib/process-services/src/lib/form/widgets/people/people.widget.ts +++ b/lib/process-services/src/lib/form/widgets/people/people.widget.ts @@ -74,7 +74,7 @@ export class PeopleWidgetComponent extends WidgetComponent implements OnInit { groupId: number; searchTerm = new UntypedFormControl(); - searchTerms$: Observable = this.searchTerm.valueChanges; + searchTerms$ = this.searchTerm.valueChanges; users$: Observable = this.searchTerms$.pipe( distinctUntilChanged(), @@ -92,7 +92,10 @@ export class PeopleWidgetComponent extends WidgetComponent implements OnInit { }) ); - constructor(public formService: FormService, public peopleProcessService: PeopleProcessService) { + constructor( + public formService: FormService, + public peopleProcessService: PeopleProcessService + ) { super(formService); } diff --git a/lib/process-services/src/lib/process-list/services/process.service.ts b/lib/process-services/src/lib/process-list/services/process.service.ts index 56a08b580c..0ea28f43cd 100644 --- a/lib/process-services/src/lib/process-list/services/process.service.ts +++ b/lib/process-services/src/lib/process-list/services/process.service.ts @@ -307,7 +307,7 @@ export class ProcessService { try { return datePipe.transform(value, dateFormat); - } catch (err) { + } catch { return ''; } } diff --git a/lib/process-services/src/lib/process.module.ts b/lib/process-services/src/lib/process.module.ts index 35420fce60..b4125c0f65 100644 --- a/lib/process-services/src/lib/process.module.ts +++ b/lib/process-services/src/lib/process.module.ts @@ -28,6 +28,17 @@ import { FORM_DIRECTIVES } from './form'; import { TASK_COMMENTS_DIRECTIVES } from './task-comments'; import { MAT_FORM_FIELD_DEFAULT_OPTIONS } from '@angular/material/form-field'; +/** + * @deprecated use provider api instead, for example: + * ``` + * providers: [ + * provideTranslations('adf-process-services', 'assets/adf-process-services'), + * { provide: MAT_FORM_FIELD_DEFAULT_OPTIONS, useValue: { floatLabel: 'never' } } + * FormRenderingService, + * { provide: FormRenderingService, useClass: ProcessFormRenderingService } + * ] + * ``` + */ @NgModule({ imports: [ ...PROCESS_COMMENTS_DIRECTIVES, diff --git a/lib/process-services/src/lib/task-list/components/task-form/task-form.component.spec.ts b/lib/process-services/src/lib/task-list/components/task-form/task-form.component.spec.ts index d5794b5865..a875af89d9 100644 --- a/lib/process-services/src/lib/task-list/components/task-form/task-form.component.spec.ts +++ b/lib/process-services/src/lib/task-list/components/task-form/task-form.component.spec.ts @@ -759,7 +759,7 @@ describe('TaskFormComponent', () => { component.taskId = 'mock-task-id'; - component.error.subscribe((error: any) => { + component.error.subscribe((error) => { expect(error).toEqual(mockError); done(); }); diff --git a/lib/process-services/src/lib/task-list/components/task-header/task-header.component.spec.ts b/lib/process-services/src/lib/task-list/components/task-header/task-header.component.spec.ts index fd2e4c60b5..ce2a7d5bb0 100644 --- a/lib/process-services/src/lib/task-list/components/task-header/task-header.component.spec.ts +++ b/lib/process-services/src/lib/task-list/components/task-header/task-header.component.spec.ts @@ -184,7 +184,7 @@ describe('TaskHeaderComponent', () => { await fixture.whenStable(); const datePicker = fixture.debugElement.query(By.css(`[data-automation-id="datepicker-dueDate"]`)); - expect(datePicker).toBeNull('Datepicker should NOT be in DOM'); + expect(datePicker).toBeNull(); }); it('should set editable to true if the task has not completed yet', async () => {