summaryrefslogtreecommitdiffstats
path: root/vid-webpack-master/src/app/healthStatus
diff options
context:
space:
mode:
authorIttay Stern <ittay.stern@att.com>2018-08-29 17:01:32 +0300
committerIttay Stern <ittay.stern@att.com>2019-02-18 18:35:30 +0200
commit6f900cc45d7dd7f97430812b86b5c1d1693c8ae3 (patch)
tree936005c364dc5a7264d6304d4777c3d83494db22 /vid-webpack-master/src/app/healthStatus
parent67d99f816cc583643c35193197594cf78d8ce60a (diff)
merge from ecomp a88f0072 - Modern UI
Issue-ID: VID-378 Change-Id: Ibcb23dd27f550cf32ce2fe0239f0f496ae014ff6 Signed-off-by: Ittay Stern <ittay.stern@att.com>
Diffstat (limited to 'vid-webpack-master/src/app/healthStatus')
-rw-r--r--vid-webpack-master/src/app/healthStatus/health-status.component.spec.ts64
-rw-r--r--vid-webpack-master/src/app/healthStatus/health-status.component.ts6
-rw-r--r--vid-webpack-master/src/app/healthStatus/health-status.module.ts25
-rw-r--r--vid-webpack-master/src/app/healthStatus/health-status.routing.ts19
4 files changed, 111 insertions, 3 deletions
diff --git a/vid-webpack-master/src/app/healthStatus/health-status.component.spec.ts b/vid-webpack-master/src/app/healthStatus/health-status.component.spec.ts
new file mode 100644
index 000000000..8a37c77ee
--- /dev/null
+++ b/vid-webpack-master/src/app/healthStatus/health-status.component.spec.ts
@@ -0,0 +1,64 @@
+import {TestBed, ComponentFixture, async} from '@angular/core/testing';
+import {HealthStatusComponent} from "./health-status.component";
+import {HealthStatusService} from "../shared/server/healthStatusService/health-status.service";
+import {HttpClientTestingModule} from "@angular/common/http/testing";
+import {ExternalComponentStatus} from "../shared/models/externalComponentStatus";
+import {Observable} from "rxjs";
+import {of} from "rxjs";
+
+export class MockHealthStatusService {
+
+
+ getProbe(): Observable<Array<ExternalComponentStatus>> {
+ return of(new Array<ExternalComponentStatus>(
+ new ExternalComponentStatus("x", true, {y:"r"})));
+ }
+}
+
+describe('HealthStatusComponent', () => {
+ let component: HealthStatusComponent;
+ let fixture: ComponentFixture<HealthStatusComponent>;
+ let mockHealthStatusService : MockHealthStatusService;
+
+ mockHealthStatusService = new MockHealthStatusService();
+
+ beforeAll(done => (async () => {
+
+ TestBed.configureTestingModule({
+ imports: [HttpClientTestingModule],
+ providers: [{provide: HealthStatusService, useValue: mockHealthStatusService}],
+ declarations: [HealthStatusComponent]
+ });
+ await TestBed.compileComponents();
+
+ fixture = TestBed.createComponent(HealthStatusComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ })().then(done).catch(done.fail));
+
+ test('isAvailable taken from component status available field', () => {
+ expect(component.isAvailable(new ExternalComponentStatus("a", true, null))).toBeTruthy();
+ expect(component.isAvailable(new ExternalComponentStatus("a", false, null))).toBeFalsy();
+ });
+
+ test('getMetadata filter rawData ', () => {
+ let metadata:string = JSON.stringify(component.getMetadata(new ExternalComponentStatus("a", true, {a:1, rawData:2})));
+ expect(metadata).toContain("1");
+ expect(metadata.indexOf("2")).toEqual(-1);
+ });
+
+ test('componentStatus is initialized on startup ', () => {
+ expect(JSON.stringify(component.componentStatuses[0].metadata)).toContain("y");
+ });
+
+ test('when refresh componentStatus is updated', () => {
+ spyOn(mockHealthStatusService, "getProbe" ).and.returnValue(
+ of(new Array<ExternalComponentStatus>(
+ new ExternalComponentStatus("mySpecialValue", true, {y:"z"}))));
+ component.refreshData();
+ expect(component.componentStatuses[0].component).toEqual("mySpecialValue");
+ expect(mockHealthStatusService.getProbe).toHaveBeenCalledTimes(1);
+
+ });
+
+});
diff --git a/vid-webpack-master/src/app/healthStatus/health-status.component.ts b/vid-webpack-master/src/app/healthStatus/health-status.component.ts
index 6a9ddfdd7..a2b175788 100644
--- a/vid-webpack-master/src/app/healthStatus/health-status.component.ts
+++ b/vid-webpack-master/src/app/healthStatus/health-status.component.ts
@@ -8,9 +8,9 @@ import {HealthStatusService} from "../shared/server/healthStatusService/health-s
styleUrls: ['./health-status.component.scss']
})
export class HealthStatusComponent implements OnInit {
- private componentStatuses: Array<ExternalComponentStatus> = [];
- private dataIsReady: boolean;
- private lastUpdatedDate: Date;
+ componentStatuses: Array<ExternalComponentStatus> = [];
+ dataIsReady: boolean;
+ lastUpdatedDate: Date;
constructor(private _healthStatusService: HealthStatusService) {
}
diff --git a/vid-webpack-master/src/app/healthStatus/health-status.module.ts b/vid-webpack-master/src/app/healthStatus/health-status.module.ts
new file mode 100644
index 000000000..7479394f1
--- /dev/null
+++ b/vid-webpack-master/src/app/healthStatus/health-status.module.ts
@@ -0,0 +1,25 @@
+import {NgModule} from "@angular/core";
+import {BrowserModule} from "@angular/platform-browser";
+import {FormsModule} from "@angular/forms";
+import {TooltipModule} from "ngx-tooltip";
+import {CommonModule} from "@angular/common";
+import {SharedModule} from "../shared/shared.module";
+import {FeatureFlagModule} from "../featureFlag/featureFlag.module";
+import {HealthStatusService} from "../shared/server/healthStatusService/health-status.service";
+import {HealthStatusComponent} from "./health-status.component";
+
+@NgModule({
+ imports: [
+ BrowserModule,
+ FormsModule,
+ TooltipModule,
+ CommonModule,
+ SharedModule.forRoot(),
+ FeatureFlagModule.forRoot()],
+ providers: [HealthStatusService],
+ declarations: [HealthStatusComponent],
+ entryComponents: [HealthStatusComponent],
+ exports: [HealthStatusComponent]
+})
+
+export class HealthStatusModule {}
diff --git a/vid-webpack-master/src/app/healthStatus/health-status.routing.ts b/vid-webpack-master/src/app/healthStatus/health-status.routing.ts
new file mode 100644
index 000000000..5344d2e5b
--- /dev/null
+++ b/vid-webpack-master/src/app/healthStatus/health-status.routing.ts
@@ -0,0 +1,19 @@
+import {Route} from '@angular/router';
+import {FlagsResolve} from "../shared/resolvers/flag/flag.resolver";
+import {HealthStatusComponent} from "./health-status.component";
+
+export const HealthStatusRoutes: Route[] = [
+ {
+ path: 'healthStatus',
+ children: [
+ {
+ path: '',
+ component: HealthStatusComponent,
+ resolve: {
+ flags: FlagsResolve
+ },
+ }
+ ]
+ }
+];
+