From e066a3ad10e0b57c588f3d5bae3530f1f7db6f51 Mon Sep 17 00:00:00 2001 From: VitoAlbano Date: Mon, 3 Jun 2024 23:31:09 +0100 Subject: [PATCH] Fixed process unit test after huge rebase --- .../file-viewer/file-viewer.widget.spec.ts | 24 +++++++--- .../radio-buttons.widget.spec.ts | 4 +- .../src/lib/material.module.ts | 0 .../start-process.component.spec.ts | 47 ++++++++++++------- .../process-user-info.module.ts | 0 .../task-list/task-list.component.spec.ts | 16 +++++-- 6 files changed, 61 insertions(+), 30 deletions(-) delete mode 100644 lib/process-services/src/lib/material.module.ts delete mode 100644 lib/process-services/src/lib/process-user-info/process-user-info.module.ts diff --git a/lib/process-services/src/lib/form/widgets/file-viewer/file-viewer.widget.spec.ts b/lib/process-services/src/lib/form/widgets/file-viewer/file-viewer.widget.spec.ts index b1b3b45e04a..d09b482ac54 100644 --- a/lib/process-services/src/lib/form/widgets/file-viewer/file-viewer.widget.spec.ts +++ b/lib/process-services/src/lib/form/widgets/file-viewer/file-viewer.widget.spec.ts @@ -17,9 +17,19 @@ import { FileViewerWidgetComponent } from './file-viewer.widget'; import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { FormModel, FormService, FormFieldModel } from '@alfresco/adf-core'; +import { + FormModel, + FormService, + FormFieldModel, + TranslationService, + TranslationMock, + AuthenticationService, + RedirectAuthService +} from '@alfresco/adf-core'; import { TranslateModule } from '@ngx-translate/core'; import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { EMPTY } from 'rxjs'; describe('FileViewerWidgetComponent', () => { const fakeForm = new FormModel(); @@ -44,13 +54,15 @@ describe('FileViewerWidgetComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ - imports: [ - TranslateModule.forRoot() + imports: [TranslateModule.forRoot(), FileViewerWidgetComponent, HttpClientTestingModule], + providers: [ + { provide: FormService, useValue: formServiceStub }, + { provide: TranslationService, useClass: TranslationMock }, + AuthenticationService, + { provide: RedirectAuthService, useValue: { onLogin: EMPTY } } ], - declarations: [ FileViewerWidgetComponent ], - providers: [ { provide: FormService, useValue: formServiceStub } ], schemas: [CUSTOM_ELEMENTS_SCHEMA] - }); + }); formServiceStub = TestBed.inject(FormService); fixture = TestBed.createComponent(FileViewerWidgetComponent); diff --git a/lib/process-services/src/lib/form/widgets/radio-buttons/radio-buttons.widget.spec.ts b/lib/process-services/src/lib/form/widgets/radio-buttons/radio-buttons.widget.spec.ts index 8f38b6a4787..75ba7602072 100644 --- a/lib/process-services/src/lib/form/widgets/radio-buttons/radio-buttons.widget.spec.ts +++ b/lib/process-services/src/lib/form/widgets/radio-buttons/radio-buttons.widget.spec.ts @@ -63,9 +63,9 @@ describe('RadioButtonsWidgetComponent', () => { FormsModule, HttpClientTestingModule, MatIconModule, - ErrorWidgetComponent + ErrorWidgetComponent, + RadioButtonsWidgetComponent ], - declarations: [RadioButtonsWidgetComponent], providers: [ { provide: TranslationService, useClass: TranslationMock }, { provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock }, diff --git a/lib/process-services/src/lib/material.module.ts b/lib/process-services/src/lib/material.module.ts deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/lib/process-services/src/lib/process-list/components/start-process/start-process.component.spec.ts b/lib/process-services/src/lib/process-list/components/start-process/start-process.component.spec.ts index c6c7f4b3500..8f4866cbc2f 100644 --- a/lib/process-services/src/lib/process-list/components/start-process/start-process.component.spec.ts +++ b/lib/process-services/src/lib/process-list/components/start-process/start-process.component.spec.ts @@ -16,22 +16,27 @@ */ import { SimpleChange } from '@angular/core'; -import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { AppConfigService, AppConfigServiceMock, LocalizedDatePipe, TemplateModule, TranslationMock, TranslationService } from '@alfresco/adf-core'; -import { AppsProcessService } from '../../app-list/services/apps-process.service'; +import { ComponentFixture, getTestBed } from '@angular/core/testing'; +import { + AppConfigService, + AppConfigServiceMock, + FormRenderingService, + LocalizedDatePipe, + PipeModule, + TemplateModule, + TranslationMock, + TranslationService +} from '@alfresco/adf-core'; import { of, throwError } from 'rxjs'; -import { MatSelectChange } from '@angular/material/select'; +import { MatSelectChange, MatSelectModule } from '@angular/material/select'; import { ProcessService } from '../../services/process.service'; import { newProcess, taskFormMock, testProcessDef, testMultipleProcessDefs, testProcessDefWithForm, testProcessDefinitions } from '../../../mock'; import { StartProcessInstanceComponent } from './start-process.component'; import { TranslateModule } from '@ngx-translate/core'; -import { deployedApps } from '../../mock/apps-list.mock'; -import { ActivitiContentService } from '../../form/services/activiti-alfresco.service'; import { HarnessLoader } from '@angular/cdk/testing'; import { MatFormFieldHarness } from '@angular/material/form-field/testing'; import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed'; import { MatAutocompleteHarness } from '@angular/material/autocomplete/testing'; -import { FormModule } from '../../form'; import { NoopAnimationsModule } from '@angular/platform-browser/animations'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { HttpClientTestingModule } from '@angular/common/http/testing'; @@ -39,6 +44,11 @@ import { MatInputModule } from '@angular/material/input'; import { MatIconModule } from '@angular/material/icon'; import { MatAutocompleteModule } from '@angular/material/autocomplete'; import { RestVariable } from '@alfresco/js-api'; +import { ActivitiContentService } from '../../../form/services/activiti-alfresco.service'; +import { AppsProcessService } from '../../../services/apps-process.service'; +import { deployedApps } from '../../../mock/apps-list.mock'; +import { ProcessFormRenderingService } from '../../../form'; +import { FORM_FIELD_MODEL_RENDER_MIDDLEWARE } from 'lib/core/src/lib/form/components/middlewares/middleware'; describe('StartProcessComponent', () => { let appConfig: AppConfigService; @@ -55,11 +65,10 @@ describe('StartProcessComponent', () => { let getDeployedApplicationsSpy: jasmine.Spy; beforeEach(() => { - TestBed.configureTestingModule({ + getTestBed().configureTestingModule({ imports: [ TranslateModule.forRoot(), TemplateModule, - FormModule, NoopAnimationsModule, ReactiveFormsModule, FormsModule, @@ -67,16 +76,20 @@ describe('StartProcessComponent', () => { MatInputModule, MatIconModule, MatSelectModule, - MatAutocompleteModule + MatAutocompleteModule, + PipeModule, + StartProcessInstanceComponent ], - declarations: [StartProcessInstanceComponent], providers: [ LocalizedDatePipe, ActivitiContentService, ProcessService, AppsProcessService, + FormRenderingService, + { provide: FormRenderingService, useClass: ProcessFormRenderingService }, { provide: AppConfigService, useClass: AppConfigServiceMock }, - { provide: TranslationService, useClass: TranslationMock } + { provide: TranslationService, useClass: TranslationMock }, + { provide: FORM_FIELD_MODEL_RENDER_MIDDLEWARE, useValue: [] } ] }); }); @@ -102,13 +115,13 @@ describe('StartProcessComponent', () => { } beforeEach(() => { - appConfig = TestBed.inject(AppConfigService); - activitiContentService = TestBed.inject(ActivitiContentService); - fixture = TestBed.createComponent(StartProcessInstanceComponent); + appConfig = getTestBed().inject(AppConfigService); + activitiContentService = getTestBed().inject(ActivitiContentService); + fixture = getTestBed().createComponent(StartProcessInstanceComponent); component = fixture.componentInstance; loader = TestbedHarnessEnvironment.loader(fixture); - processService = TestBed.inject(ProcessService); - appsProcessService = TestBed.inject(AppsProcessService); + processService = getTestBed().inject(ProcessService); + appsProcessService = getTestBed().inject(AppsProcessService); getDefinitionsSpy = spyOn(processService, 'getProcessDefinitions').and.returnValue(of(testMultipleProcessDefs)); startProcessSpy = spyOn(processService, 'startProcess').and.returnValue(of(newProcess)); diff --git a/lib/process-services/src/lib/process-user-info/process-user-info.module.ts b/lib/process-services/src/lib/process-user-info/process-user-info.module.ts deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/lib/process-services/src/lib/task-list/components/task-list/task-list.component.spec.ts b/lib/process-services/src/lib/task-list/components/task-list/task-list.component.spec.ts index 8362b026263..0cb30f4b957 100644 --- a/lib/process-services/src/lib/task-list/components/task-list/task-list.component.spec.ts +++ b/lib/process-services/src/lib/task-list/components/task-list/task-list.component.spec.ts @@ -29,10 +29,10 @@ import { AlfrescoApiServiceMock, AlfrescoApiService } from '@alfresco/adf-core'; -import { TaskListService } from '../services/tasklist.service'; +import { TaskListService } from '../../services/tasklist.service'; import { TaskListComponent } from './task-list.component'; -import { ProcessTestingModule } from '../../testing/process.testing.module'; -import { fakeGlobalTask, fakeEmptyTask, paginatedTask, fakeColumnSchema, fakeCustomSchema } from '../../mock'; +import { ProcessTestingModule } from '../../../testing/process.testing.module'; +import { fakeGlobalTask, fakeEmptyTask, paginatedTask, fakeColumnSchema, fakeCustomSchema } from '../../../mock'; import { TranslateService, TranslateModule } from '@ngx-translate/core'; import { of, Subject } from 'rxjs'; import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed'; @@ -106,8 +106,14 @@ describe('TaskListComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ - imports: [TranslateModule.forRoot(), DataTableModule, NoopAnimationsModule, MatProgressSpinnerModule, HttpClientTestingModule, TaskListComponent], - declarations: [TaskListComponent], + imports: [ + TranslateModule.forRoot(), + DataTableModule, + NoopAnimationsModule, + MatProgressSpinnerModule, + HttpClientTestingModule, + TaskListComponent + ], providers: [ TaskListService, { provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock },