From 15d1e11bb504a6fe97ff5446ed98c415135b907f Mon Sep 17 00:00:00 2001 From: Tiago Melo Date: Mon, 13 Jul 2020 13:54:32 +0000 Subject: [PATCH] mgr/dashboard: Block the import of async from @angular/core/testing We no longer need this and it was causing unexpected results in some tests. Fixes: https://tracker.ceph.com/issues/46500 Signed-off-by: Tiago Melo --- .../frontend/src/app/app.component.spec.ts | 13 ++++++------- .../ceph/cluster/hosts/hosts.component.spec.ts | 8 ++++---- .../device-list/device-list.component.spec.ts | 16 +++++++--------- .../blank-layout/blank-layout.component.spec.ts | 13 ++++++------- .../login-layout/login-layout.component.spec.ts | 13 ++++++------- src/pybind/mgr/dashboard/frontend/tslint.json | 2 +- 6 files changed, 30 insertions(+), 35 deletions(-) diff --git a/src/pybind/mgr/dashboard/frontend/src/app/app.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/app.component.spec.ts index b7a396a5d908a..acf3a1219decf 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/app.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/app.component.spec.ts @@ -1,18 +1,17 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ComponentFixture, TestBed } from '@angular/core/testing'; import { RouterTestingModule } from '@angular/router/testing'; +import { configureTestBed } from '../testing/unit-test-helper'; import { AppComponent } from './app.component'; describe('AppComponent', () => { let component: AppComponent; let fixture: ComponentFixture; - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [AppComponent], - imports: [RouterTestingModule] - }).compileComponents(); - })); + configureTestBed({ + declarations: [AppComponent], + imports: [RouterTestingModule] + }); beforeEach(() => { fixture = TestBed.createComponent(AppComponent); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/hosts.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/hosts.component.spec.ts index b4ba5643fb808..18e9fd5f1ef58 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/hosts.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/hosts.component.spec.ts @@ -1,5 +1,5 @@ import { HttpClientTestingModule } from '@angular/common/http/testing'; -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ComponentFixture, TestBed } from '@angular/core/testing'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { RouterTestingModule } from '@angular/router/testing'; @@ -53,7 +53,7 @@ describe('HostsComponent', () => { expect(component).toBeTruthy(); }); - it('should render hosts list even with not permission mapped services', async(() => { + it('should render hosts list even with not permission mapped services', () => { const hostname = 'ceph.dev'; const payload = [ { @@ -79,7 +79,7 @@ describe('HostsComponent', () => { hostListSpy.and.callFake(() => of(payload)); - fixture.whenStable().then(() => { + return fixture.whenStable().then(() => { fixture.detectChanges(); const spans = fixture.debugElement.nativeElement.querySelectorAll( @@ -87,7 +87,7 @@ describe('HostsComponent', () => { ); expect(spans[0].textContent).toBe(hostname); }); - })); + }); describe('getEditDisableDesc', () => { it('should return message (not managed by Orchestrator)', () => { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/shared/device-list/device-list.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/shared/device-list/device-list.component.spec.ts index ff3156d8a36e2..2d136e799f9ba 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/shared/device-list/device-list.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/shared/device-list/device-list.component.spec.ts @@ -1,7 +1,7 @@ import { HttpClientTestingModule } from '@angular/common/http/testing'; -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { i18nProviders } from '../../../../testing/unit-test-helper'; +import { configureTestBed, i18nProviders } from '../../../../testing/unit-test-helper'; import { SharedModule } from '../../../shared/shared.module'; import { DeviceListComponent } from './device-list.component'; @@ -9,13 +9,11 @@ describe('DeviceListComponent', () => { let component: DeviceListComponent; let fixture: ComponentFixture; - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [DeviceListComponent], - imports: [SharedModule, HttpClientTestingModule], - providers: [i18nProviders] - }).compileComponents(); - })); + configureTestBed({ + declarations: [DeviceListComponent], + imports: [SharedModule, HttpClientTestingModule], + providers: [i18nProviders] + }); beforeEach(() => { fixture = TestBed.createComponent(DeviceListComponent); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/core/layouts/blank-layout/blank-layout.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/core/layouts/blank-layout/blank-layout.component.spec.ts index 75c3686d488f8..2b836c7138d65 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/core/layouts/blank-layout/blank-layout.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/core/layouts/blank-layout/blank-layout.component.spec.ts @@ -1,18 +1,17 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ComponentFixture, TestBed } from '@angular/core/testing'; import { RouterTestingModule } from '@angular/router/testing'; +import { configureTestBed } from '../../../../testing/unit-test-helper'; import { BlankLayoutComponent } from './blank-layout.component'; describe('DefaultLayoutComponent', () => { let component: BlankLayoutComponent; let fixture: ComponentFixture; - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [BlankLayoutComponent], - imports: [RouterTestingModule] - }).compileComponents(); - })); + configureTestBed({ + declarations: [BlankLayoutComponent], + imports: [RouterTestingModule] + }); beforeEach(() => { fixture = TestBed.createComponent(BlankLayoutComponent); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/core/layouts/login-layout/login-layout.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/core/layouts/login-layout/login-layout.component.spec.ts index 9299514e7c2cc..575984aa0b27b 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/core/layouts/login-layout/login-layout.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/core/layouts/login-layout/login-layout.component.spec.ts @@ -1,8 +1,9 @@ import { HttpClientTestingModule } from '@angular/common/http/testing'; -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ComponentFixture, TestBed } from '@angular/core/testing'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { RouterTestingModule } from '@angular/router/testing'; +import { configureTestBed } from '../../../../testing/unit-test-helper'; import { SharedModule } from '../../../shared/shared.module'; import { LoginLayoutComponent } from './login-layout.component'; @@ -10,12 +11,10 @@ describe('LoginLayoutComponent', () => { let component: LoginLayoutComponent; let fixture: ComponentFixture; - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [LoginLayoutComponent], - imports: [BrowserAnimationsModule, HttpClientTestingModule, RouterTestingModule, SharedModule] - }).compileComponents(); - })); + configureTestBed({ + declarations: [LoginLayoutComponent], + imports: [BrowserAnimationsModule, HttpClientTestingModule, RouterTestingModule, SharedModule] + }); beforeEach(() => { fixture = TestBed.createComponent(LoginLayoutComponent); diff --git a/src/pybind/mgr/dashboard/frontend/tslint.json b/src/pybind/mgr/dashboard/frontend/tslint.json index 5136dc651af55..ff81249e78eee 100644 --- a/src/pybind/mgr/dashboard/frontend/tslint.json +++ b/src/pybind/mgr/dashboard/frontend/tslint.json @@ -12,7 +12,7 @@ }, "eofline": true, "forin": true, - "import-blacklist": [true, "rxjs/Rx"], + "import-blacklist": [true, "rxjs/Rx", {"@angular/core/testing": ["async"]}], "import-spacing": true, "indent": [true, "spaces"], "interface-over-type-literal": true, -- 2.39.5