From b4b255540e976319cefe2aaf22166055f06a2299 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 ++++++++++++------- .../task-list/task-list.component.spec.ts | 12 +++-- 5 files changed, 59 insertions(+), 28 deletions(-) delete mode 100644 lib/process-services/src/lib/material.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 532b7865c9e..810debdde26 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 4766519c550..d61f2fb8695 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,11 +16,19 @@ */ 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, @@ -32,13 +40,10 @@ import { } from '../../../testing/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'; @@ -46,6 +51,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; @@ -62,11 +72,10 @@ describe('StartProcessComponent', () => { let getDeployedApplicationsSpy: jasmine.Spy; beforeEach(() => { - TestBed.configureTestingModule({ + getTestBed().configureTestingModule({ imports: [ TranslateModule.forRoot(), TemplateModule, - FormModule, NoopAnimationsModule, ReactiveFormsModule, FormsModule, @@ -74,16 +83,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: [] } ] }); }); @@ -109,13 +122,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/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 fa4d448f29a..c7b4edd89ce 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,7 +29,7 @@ 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 '../../../testing/mock'; @@ -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 },