Skip to content

Commit

Permalink
Fixed process unit test after huge rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
VitoAlbano committed Jul 9, 2024
1 parent 56920a6 commit 987ad94
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ describe('RadioButtonsWidgetComponent', () => {
FormsModule,
HttpClientTestingModule,
MatIconModule,
ErrorWidgetComponent
ErrorWidgetComponent,
RadioButtonsWidgetComponent
],
declarations: [RadioButtonsWidgetComponent],
providers: [
{ provide: TranslationService, useClass: TranslationMock },
{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock },
Expand Down
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -32,20 +40,22 @@ 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';
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;
Expand All @@ -62,28 +72,31 @@ describe('StartProcessComponent', () => {
let getDeployedApplicationsSpy: jasmine.Spy;

beforeEach(() => {
TestBed.configureTestingModule({
getTestBed().configureTestingModule({
imports: [
TranslateModule.forRoot(),
TemplateModule,
FormModule,
NoopAnimationsModule,
ReactiveFormsModule,
FormsModule,
HttpClientTestingModule,
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: [] }
]
});
});
Expand All @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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 },
Expand Down

0 comments on commit 987ad94

Please sign in to comment.