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 Jun 10, 2024
1 parent dc603be commit e066a3a
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 30 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,29 +16,39 @@
*/

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';
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 @@ -55,28 +65,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 @@ -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));
Expand Down
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -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';
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 e066a3a

Please sign in to comment.