From d417eca035309695412efbe10af659a41287d6c7 Mon Sep 17 00:00:00 2001 From: Tiago Melo Date: Mon, 8 Jun 2020 20:15:13 +0000 Subject: [PATCH] mgr/dashboard: Remove entryComponents entryComponents is no longer required in Angular 9. Fixes: https://tracker.ceph.com/issues/45325 Signed-off-by: Tiago Melo --- .../src/app/ceph/block/block.module.ts | 12 ----- .../iscsi-target-form.component.spec.ts | 38 +++++++++------- .../ceph/block/mirroring/mirroring.module.ts | 8 ---- .../src/app/ceph/cluster/cluster.module.ts | 14 ------ .../host-form/host-form.component.spec.ts | 26 ++++++----- .../mgr-module-form.component.spec.ts | 26 ++++++----- .../telemetry/telemetry.component.spec.ts | 26 ++++++----- .../nfs/nfs-form/nfs-form.component.spec.ts | 44 ++++++++++--------- .../frontend/src/app/ceph/pool/pool.module.ts | 3 +- .../frontend/src/app/ceph/rgw/rgw.module.ts | 9 ---- .../role-form/role-form.component.spec.ts | 26 ++++++----- .../user-form/user-form.component.spec.ts | 32 ++++++++------ .../app/core/navigation/navigation.module.ts | 1 - .../shared/components/components.module.ts | 6 --- .../confirmation-modal.component.spec.ts | 4 +- ...tical-confirmation-modal.component.spec.ts | 4 +- .../shared/directives/directives.module.ts | 6 +-- .../directives/form-loading.directive.spec.ts | 15 ++++--- .../frontend/src/testing/unit-test-helper.ts | 15 ++++++- 19 files changed, 150 insertions(+), 165 deletions(-) diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/block.module.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/block.module.ts index c1357864d5dce..f3ea0daab318f 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/block.module.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/block.module.ts @@ -41,18 +41,6 @@ import { RbdTrashPurgeModalComponent } from './rbd-trash-purge-modal/rbd-trash-p import { RbdTrashRestoreModalComponent } from './rbd-trash-restore-modal/rbd-trash-restore-modal.component'; @NgModule({ - entryComponents: [ - RbdDetailsComponent, - RbdNamespaceFormModalComponent, - RbdSnapshotFormModalComponent, - RbdTrashMoveModalComponent, - RbdTrashRestoreModalComponent, - RbdTrashPurgeModalComponent, - IscsiTargetDetailsComponent, - IscsiTargetImageSettingsModalComponent, - IscsiTargetIqnSettingsModalComponent, - IscsiTargetDiscoveryModalComponent - ], imports: [ CommonModule, MirroringModule, diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-form/iscsi-target-form.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-form/iscsi-target-form.component.spec.ts index 1e99f242d781a..299cefd7f207a 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-form/iscsi-target-form.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/iscsi-target-form/iscsi-target-form.component.spec.ts @@ -13,6 +13,7 @@ import { i18nProviders, IscsiHelper } from '../../../../testing/unit-test-helper'; +import { LoadingPanelComponent } from '../../../shared/components/loading-panel/loading-panel.component'; import { CdFormGroup } from '../../../shared/forms/cd-form-group'; import { SharedModule } from '../../../shared/shared.module'; import { IscsiTargetFormComponent } from './iscsi-target-form.component'; @@ -141,23 +142,26 @@ describe('IscsiTargetFormComponent', () => { } ]; - configureTestBed({ - declarations: [IscsiTargetFormComponent], - imports: [ - SharedModule, - ReactiveFormsModule, - HttpClientTestingModule, - RouterTestingModule, - ToastrModule.forRoot() - ], - providers: [ - i18nProviders, - { - provide: ActivatedRoute, - useValue: new ActivatedRouteStub({ target_iqn: undefined }) - } - ] - }); + configureTestBed( + { + declarations: [IscsiTargetFormComponent], + imports: [ + SharedModule, + ReactiveFormsModule, + HttpClientTestingModule, + RouterTestingModule, + ToastrModule.forRoot() + ], + providers: [ + i18nProviders, + { + provide: ActivatedRoute, + useValue: new ActivatedRouteStub({ target_iqn: undefined }) + } + ] + }, + [LoadingPanelComponent] + ); beforeEach(() => { fixture = TestBed.createComponent(IscsiTargetFormComponent); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/mirroring/mirroring.module.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/mirroring/mirroring.module.ts index 917de076da08b..a9265d28dd76b 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/mirroring/mirroring.module.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/mirroring/mirroring.module.ts @@ -22,14 +22,6 @@ import { PoolEditPeerModalComponent } from './pool-edit-peer-modal/pool-edit-pee import { PoolListComponent } from './pool-list/pool-list.component'; @NgModule({ - entryComponents: [ - BootstrapCreateModalComponent, - BootstrapImportModalComponent, - EditSiteNameModalComponent, - OverviewComponent, - PoolEditModeModalComponent, - PoolEditPeerModalComponent - ], imports: [ CommonModule, SharedModule, diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/cluster.module.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/cluster.module.ts index f597a57ace7eb..475aa0e0dea8e 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/cluster.module.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/cluster.module.ts @@ -11,7 +11,6 @@ import { BsDropdownModule } from 'ngx-bootstrap/dropdown'; import { ModalModule } from 'ngx-bootstrap/modal'; import { TimepickerModule } from 'ngx-bootstrap/timepicker'; -import { OrchestratorDocModalComponent } from '../../shared/components/orchestrator-doc-modal/orchestrator-doc-modal.component'; import { SharedModule } from '../../shared/shared.module'; import { PerformanceCounterModule } from '../performance-counter/performance-counter.module'; import { CephSharedModule } from '../shared/ceph-shared.module'; @@ -51,19 +50,6 @@ import { ServicesComponent } from './services/services.component'; import { TelemetryComponent } from './telemetry/telemetry.component'; @NgModule({ - entryComponents: [ - OsdDetailsComponent, - OsdScrubModalComponent, - OsdFlagsModalComponent, - OsdRecvSpeedModalComponent, - OsdReweightModalComponent, - OsdPgScrubModalComponent, - OsdReweightModalComponent, - SilenceMatcherModalComponent, - OsdDevicesSelectionModalComponent, - OsdCreationPreviewModalComponent, - OrchestratorDocModalComponent - ], imports: [ CommonModule, PerformanceCounterModule, diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/host-form/host-form.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/host-form/host-form.component.spec.ts index 4ed2e3879f848..d2a4dec9c7e54 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/host-form/host-form.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/host-form/host-form.component.spec.ts @@ -6,6 +6,7 @@ import { ToastrModule } from 'ngx-toastr'; import { HttpClientTestingModule } from '@angular/common/http/testing'; import { RouterTestingModule } from '@angular/router/testing'; import { configureTestBed, i18nProviders } from '../../../../../testing/unit-test-helper'; +import { LoadingPanelComponent } from '../../../../shared/components/loading-panel/loading-panel.component'; import { SharedModule } from '../../../../shared/shared.module'; import { HostFormComponent } from './host-form.component'; @@ -13,17 +14,20 @@ describe('HostFormComponent', () => { let component: HostFormComponent; let fixture: ComponentFixture; - configureTestBed({ - imports: [ - SharedModule, - HttpClientTestingModule, - RouterTestingModule, - ReactiveFormsModule, - ToastrModule.forRoot() - ], - providers: [i18nProviders], - declarations: [HostFormComponent] - }); + configureTestBed( + { + imports: [ + SharedModule, + HttpClientTestingModule, + RouterTestingModule, + ReactiveFormsModule, + ToastrModule.forRoot() + ], + providers: [i18nProviders], + declarations: [HostFormComponent] + }, + [LoadingPanelComponent] + ); beforeEach(() => { fixture = TestBed.createComponent(HostFormComponent); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/mgr-modules/mgr-module-form/mgr-module-form.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/mgr-modules/mgr-module-form/mgr-module-form.component.spec.ts index 1832ccd8c3af5..18cbb7609bd6b 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/mgr-modules/mgr-module-form/mgr-module-form.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/mgr-modules/mgr-module-form/mgr-module-form.component.spec.ts @@ -6,6 +6,7 @@ import { RouterTestingModule } from '@angular/router/testing'; import { ToastrModule } from 'ngx-toastr'; import { configureTestBed, i18nProviders } from '../../../../../testing/unit-test-helper'; +import { LoadingPanelComponent } from '../../../../shared/components/loading-panel/loading-panel.component'; import { SharedModule } from '../../../../shared/shared.module'; import { MgrModuleFormComponent } from './mgr-module-form.component'; @@ -13,17 +14,20 @@ describe('MgrModuleFormComponent', () => { let component: MgrModuleFormComponent; let fixture: ComponentFixture; - configureTestBed({ - declarations: [MgrModuleFormComponent], - imports: [ - HttpClientTestingModule, - ReactiveFormsModule, - RouterTestingModule, - SharedModule, - ToastrModule.forRoot() - ], - providers: i18nProviders - }); + configureTestBed( + { + declarations: [MgrModuleFormComponent], + imports: [ + HttpClientTestingModule, + ReactiveFormsModule, + RouterTestingModule, + SharedModule, + ToastrModule.forRoot() + ], + providers: i18nProviders + }, + [LoadingPanelComponent] + ); beforeEach(() => { fixture = TestBed.createComponent(MgrModuleFormComponent); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/telemetry/telemetry.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/telemetry/telemetry.component.spec.ts index 2e5e95ece7527..a495c8507dcf8 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/telemetry/telemetry.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/telemetry/telemetry.component.spec.ts @@ -12,6 +12,7 @@ import { configureTestBed, i18nProviders } from '../../../../testing/unit-test-h import { MgrModuleService } from '../../../shared/api/mgr-module.service'; import { TelemetryService } from '../../../shared/api/telemetry.service'; +import { LoadingPanelComponent } from '../../../shared/components/loading-panel/loading-panel.component'; import { TextToDownloadService } from '../../../shared/services/text-to-download.service'; import { SharedModule } from '../../../shared/shared.module'; import { TelemetryComponent } from './telemetry.component'; @@ -47,17 +48,20 @@ describe('TelemetryComponent', () => { 'url' ]; - configureTestBed({ - declarations: [TelemetryComponent], - imports: [ - HttpClientTestingModule, - ReactiveFormsModule, - RouterTestingModule, - SharedModule, - ToastrModule.forRoot() - ], - providers: i18nProviders - }); + configureTestBed( + { + declarations: [TelemetryComponent], + imports: [ + HttpClientTestingModule, + ReactiveFormsModule, + RouterTestingModule, + SharedModule, + ToastrModule.forRoot() + ], + providers: i18nProviders + }, + [LoadingPanelComponent] + ); describe('configForm', () => { beforeEach(() => { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-form/nfs-form.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-form/nfs-form.component.spec.ts index ad4df81dd5eda..ee424ae51b13b 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-form/nfs-form.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-form/nfs-form.component.spec.ts @@ -10,6 +10,7 @@ import { of } from 'rxjs'; import { ActivatedRouteStub } from '../../../../testing/activated-route-stub'; import { configureTestBed, i18nProviders } from '../../../../testing/unit-test-helper'; +import { LoadingPanelComponent } from '../../../shared/components/loading-panel/loading-panel.component'; import { CephReleaseNamePipe } from '../../../shared/pipes/ceph-release-name.pipe'; import { SummaryService } from '../../../shared/services/summary.service'; import { SharedModule } from '../../../shared/shared.module'; @@ -22,26 +23,29 @@ describe('NfsFormComponent', () => { let httpTesting: HttpTestingController; let activatedRoute: ActivatedRouteStub; - configureTestBed({ - declarations: [NfsFormComponent, NfsFormClientComponent], - imports: [ - HttpClientTestingModule, - ReactiveFormsModule, - RouterTestingModule, - SharedModule, - ToastrModule.forRoot(), - NgbTypeaheadModule - ], - providers: [ - { - provide: ActivatedRoute, - useValue: new ActivatedRouteStub({ cluster_id: undefined, export_id: undefined }) - }, - i18nProviders, - SummaryService, - CephReleaseNamePipe - ] - }); + configureTestBed( + { + declarations: [NfsFormComponent, NfsFormClientComponent], + imports: [ + HttpClientTestingModule, + ReactiveFormsModule, + RouterTestingModule, + SharedModule, + ToastrModule.forRoot(), + NgbTypeaheadModule + ], + providers: [ + { + provide: ActivatedRoute, + useValue: new ActivatedRouteStub({ cluster_id: undefined, export_id: undefined }) + }, + i18nProviders, + SummaryService, + CephReleaseNamePipe + ] + }, + [LoadingPanelComponent] + ); beforeEach(() => { const summaryService = TestBed.inject(SummaryService); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool.module.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool.module.ts index 4a936bf6ee8c6..5ba3e9b1a1696 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool.module.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool.module.ts @@ -37,8 +37,7 @@ import { PoolListComponent } from './pool-list/pool-list.component'; ErasureCodeProfileFormModalComponent, CrushRuleFormModalComponent, PoolDetailsComponent - ], - entryComponents: [CrushRuleFormModalComponent, ErasureCodeProfileFormModalComponent] + ] }) export class PoolModule {} diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw.module.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw.module.ts index 970661139526d..e835faaffc9f7 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw.module.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw.module.ts @@ -27,15 +27,6 @@ import { RgwUserSubuserModalComponent } from './rgw-user-subuser-modal/rgw-user- import { RgwUserSwiftKeyModalComponent } from './rgw-user-swift-key-modal/rgw-user-swift-key-modal.component'; @NgModule({ - entryComponents: [ - RgwDaemonDetailsComponent, - RgwBucketDetailsComponent, - RgwUserDetailsComponent, - RgwUserSwiftKeyModalComponent, - RgwUserS3KeyModalComponent, - RgwUserCapabilityModalComponent, - RgwUserSubuserModalComponent - ], imports: [ CommonModule, SharedModule, diff --git a/src/pybind/mgr/dashboard/frontend/src/app/core/auth/role-form/role-form.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/core/auth/role-form/role-form.component.spec.ts index 2210cef8d226e..54786e73761b4 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/core/auth/role-form/role-form.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/core/auth/role-form/role-form.component.spec.ts @@ -11,6 +11,7 @@ import { of } from 'rxjs'; import { configureTestBed, FormHelper, i18nProviders } from '../../../../testing/unit-test-helper'; import { RoleService } from '../../../shared/api/role.service'; import { ScopeService } from '../../../shared/api/scope.service'; +import { LoadingPanelComponent } from '../../../shared/components/loading-panel/loading-panel.component'; import { CdFormGroup } from '../../../shared/forms/cd-form-group'; import { NotificationService } from '../../../shared/services/notification.service'; import { SharedModule } from '../../../shared/shared.module'; @@ -31,17 +32,20 @@ describe('RoleFormComponent', () => { const routes: Routes = [{ path: 'roles', component: FakeComponent }]; - configureTestBed({ - imports: [ - RouterTestingModule.withRoutes(routes), - HttpClientTestingModule, - ReactiveFormsModule, - ToastrModule.forRoot(), - SharedModule - ], - declarations: [RoleFormComponent, FakeComponent], - providers: i18nProviders - }); + configureTestBed( + { + imports: [ + RouterTestingModule.withRoutes(routes), + HttpClientTestingModule, + ReactiveFormsModule, + ToastrModule.forRoot(), + SharedModule + ], + declarations: [RoleFormComponent, FakeComponent], + providers: i18nProviders + }, + [LoadingPanelComponent] + ); beforeEach(() => { fixture = TestBed.createComponent(RoleFormComponent); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/core/auth/user-form/user-form.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/core/auth/user-form/user-form.component.spec.ts index abfd8f305091f..df3bc8b08d4eb 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/core/auth/user-form/user-form.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/core/auth/user-form/user-form.component.spec.ts @@ -16,6 +16,7 @@ import { RoleService } from '../../../shared/api/role.service'; import { SettingsService } from '../../../shared/api/settings.service'; import { UserService } from '../../../shared/api/user.service'; import { ComponentsModule } from '../../../shared/components/components.module'; +import { LoadingPanelComponent } from '../../../shared/components/loading-panel/loading-panel.component'; import { CdFormGroup } from '../../../shared/forms/cd-form-group'; import { AuthStorageService } from '../../../shared/services/auth-storage.service'; import { NotificationService } from '../../../shared/services/notification.service'; @@ -44,20 +45,23 @@ describe('UserFormComponent', () => { { path: 'users', component: FakeComponent } ]; - configureTestBed({ - imports: [ - RouterTestingModule.withRoutes(routes), - HttpClientTestingModule, - ReactiveFormsModule, - ComponentsModule, - ToastrModule.forRoot(), - SharedModule, - ButtonsModule.forRoot(), - BsDatepickerModule.forRoot() - ], - declarations: [UserFormComponent, FakeComponent], - providers: i18nProviders - }); + configureTestBed( + { + imports: [ + RouterTestingModule.withRoutes(routes), + HttpClientTestingModule, + ReactiveFormsModule, + ComponentsModule, + ToastrModule.forRoot(), + SharedModule, + ButtonsModule.forRoot(), + BsDatepickerModule.forRoot() + ], + declarations: [UserFormComponent, FakeComponent], + providers: i18nProviders + }, + [LoadingPanelComponent] + ); beforeEach(() => { spyOn(TestBed.inject(PasswordPolicyService), 'getHelpText').and.callFake(() => of('')); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/navigation.module.ts b/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/navigation.module.ts index bee03ba03a4ff..cce5f87d6f1d0 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/navigation.module.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/navigation.module.ts @@ -18,7 +18,6 @@ import { NavigationComponent } from './navigation/navigation.component'; import { NotificationsComponent } from './notifications/notifications.component'; @NgModule({ - entryComponents: [AboutComponent], imports: [ CommonModule, AuthModule, diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/components.module.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/components.module.ts index 2368cb1e23193..c667e7c84529c 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/components.module.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/components.module.ts @@ -105,12 +105,6 @@ import { ViewCacheComponent } from './view-cache/view-cache.component'; AlertPanelComponent, PwdExpirationNotificationComponent, OrchestratorDocPanelComponent - ], - entryComponents: [ - ModalComponent, - CriticalConfirmationModalComponent, - ConfirmationModalComponent, - FormModalComponent ] }) export class ComponentsModule {} diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/confirmation-modal/confirmation-modal.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/confirmation-modal/confirmation-modal.component.spec.ts index ba77dc88ad1f4..77c5b153e514e 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/confirmation-modal/confirmation-modal.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/confirmation-modal/confirmation-modal.component.spec.ts @@ -17,9 +17,7 @@ import { ModalComponent } from '../modal/modal.component'; import { SubmitButtonComponent } from '../submit-button/submit-button.component'; import { ConfirmationModalComponent } from './confirmation-modal.component'; -@NgModule({ - entryComponents: [ConfirmationModalComponent] -}) +@NgModule({}) export class MockModule {} @Component({ diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/critical-confirmation-modal/critical-confirmation-modal.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/critical-confirmation-modal/critical-confirmation-modal.component.spec.ts index 82db262905333..f0a7cb7c4c375 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/critical-confirmation-modal/critical-confirmation-modal.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/critical-confirmation-modal/critical-confirmation-modal.component.spec.ts @@ -12,9 +12,7 @@ import { AlertPanelComponent } from '../alert-panel/alert-panel.component'; import { LoadingPanelComponent } from '../loading-panel/loading-panel.component'; import { CriticalConfirmationModalComponent } from './critical-confirmation-modal.component'; -@NgModule({ - entryComponents: [CriticalConfirmationModalComponent] -}) +@NgModule({}) export class MockModule {} @Component({ diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/directives/directives.module.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/directives/directives.module.ts index 1fdc7a9ba076a..a72c6f6c68c9c 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/directives/directives.module.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/directives/directives.module.ts @@ -1,7 +1,5 @@ import { NgModule } from '@angular/core'; -import { AlertPanelComponent } from '../components/alert-panel/alert-panel.component'; -import { LoadingPanelComponent } from '../components/loading-panel/loading-panel.component'; import { AutofocusDirective } from './autofocus.directive'; import { Copy2ClipboardButtonDirective } from './copy2clipboard-button.directive'; import { DimlessBinaryPerSecondDirective } from './dimless-binary-per-second.directive'; @@ -35,8 +33,6 @@ import { TrimDirective } from './trim.directive'; MillisecondsDirective, IopsDirective, FormLoadingDirective - ], - providers: [], - entryComponents: [LoadingPanelComponent, AlertPanelComponent] + ] }) export class DirectivesModule {} diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/directives/form-loading.directive.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/directives/form-loading.directive.spec.ts index 8f0875a4f318e..d30233a69b9ae 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/directives/form-loading.directive.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/directives/form-loading.directive.spec.ts @@ -5,6 +5,8 @@ import { By } from '@angular/platform-browser'; import { NgbAlertModule } from '@ng-bootstrap/ng-bootstrap'; import { configureTestBed, i18nProviders } from '../../../testing/unit-test-helper'; +import { AlertPanelComponent } from '../components/alert-panel/alert-panel.component'; +import { LoadingPanelComponent } from '../components/loading-panel/loading-panel.component'; import { CdForm } from '../forms/cd-form'; import { SharedModule } from '../shared.module'; import { FormLoadingDirective } from './form-loading.directive'; @@ -26,11 +28,14 @@ describe('FormLoadingDirective', () => { expect(fixture.debugElement.queryAll(By.css('cd-loading-panel')).length).toEqual(loading); }; - configureTestBed({ - declarations: [TestComponent], - imports: [SharedModule, NgbAlertModule], - providers: [i18nProviders] - }); + configureTestBed( + { + declarations: [TestComponent], + imports: [SharedModule, NgbAlertModule], + providers: [i18nProviders] + }, + [LoadingPanelComponent, AlertPanelComponent] + ); afterEach(() => { fixture = null; diff --git a/src/pybind/mgr/dashboard/frontend/src/testing/unit-test-helper.ts b/src/pybind/mgr/dashboard/frontend/src/testing/unit-test-helper.ts index e6869c5ee193e..8045147f5b1f4 100644 --- a/src/pybind/mgr/dashboard/frontend/src/testing/unit-test-helper.ts +++ b/src/pybind/mgr/dashboard/frontend/src/testing/unit-test-helper.ts @@ -2,6 +2,7 @@ import { DebugElement, LOCALE_ID, TRANSLATIONS, TRANSLATIONS_FORMAT, Type } from import { ComponentFixture, TestBed } from '@angular/core/testing'; import { AbstractControl } from '@angular/forms'; import { By } from '@angular/platform-browser'; +import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing'; import { I18n } from '@ngx-translate/i18n-polyfill'; import { configureTestSuite } from 'ng-bullet'; @@ -23,8 +24,18 @@ import { PrometheusRule } from '../app/shared/models/prometheus-alerts'; -export function configureTestBed(configuration: any) { - configureTestSuite(() => TestBed.configureTestingModule(configuration)); +export function configureTestBed(configuration: any, entryComponents?: any) { + configureTestSuite(() => { + if (entryComponents) { + // Declare entryComponents without having to add them to a module + // This is needed since Jest doesn't yet support not declaring entryComponents + TestBed.configureTestingModule(configuration).overrideModule(BrowserDynamicTestingModule, { + set: { entryComponents: entryComponents } + }); + } else { + TestBed.configureTestingModule(configuration); + } + }); } export class PermissionHelper { -- 2.39.5