mirror of
https://github.com/ceph/ceph
synced 2025-01-04 02:02:36 +00:00
mgr/dashboard: dashboard-v3: details card
mgr/dashboard: added interface, changed html table to list, using mgrModuleService now tracker: https://tracker.ceph.com/issues/58731 Signed-off-by: Pedro Gonzalez Gomez <pegonzal@redhat.com>
This commit is contained in:
parent
6fbc9ae01a
commit
cc93d53080
@ -1,22 +1,62 @@
|
||||
import { HttpClientTestingModule } from '@angular/common/http/testing';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
|
||||
import { BehaviorSubject, of } from 'rxjs';
|
||||
|
||||
import { ConfigurationService } from '~/app/shared/api/configuration.service';
|
||||
import { MgrModuleService } from '~/app/shared/api/mgr-module.service';
|
||||
import { SummaryService } from '~/app/shared/services/summary.service';
|
||||
import { configureTestBed } from '~/testing/unit-test-helper';
|
||||
import { CardComponent } from '../card/card.component';
|
||||
import { DashboardComponent } from './dashboard.component';
|
||||
|
||||
export class SummaryServiceMock {
|
||||
summaryDataSource = new BehaviorSubject({
|
||||
version:
|
||||
'ceph version 17.0.0-12222-gcd0cd7cb ' +
|
||||
'(b8193bb4cda16ccc5b028c3e1df62bc72350a15d) quincy (dev)'
|
||||
});
|
||||
summaryData$ = this.summaryDataSource.asObservable();
|
||||
|
||||
subscribe(call: any) {
|
||||
return this.summaryData$.subscribe(call);
|
||||
}
|
||||
}
|
||||
|
||||
describe('CardComponent', () => {
|
||||
let component: DashboardComponent;
|
||||
let fixture: ComponentFixture<DashboardComponent>;
|
||||
let configurationService: ConfigurationService;
|
||||
let orchestratorService: MgrModuleService;
|
||||
|
||||
const configValueData: any = {
|
||||
value: [
|
||||
{
|
||||
section: 'mgr',
|
||||
value: 'e90a0d58-658e-4148-8f61-e896c86f0696'
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
const orchData: any = {
|
||||
log_level: '',
|
||||
log_to_cluster: false,
|
||||
log_to_cluster_level: 'info',
|
||||
log_to_file: false,
|
||||
orchestrator: 'cephadm'
|
||||
};
|
||||
|
||||
configureTestBed({
|
||||
imports: [RouterTestingModule],
|
||||
declarations: [DashboardComponent, CardComponent]
|
||||
imports: [HttpClientTestingModule],
|
||||
declarations: [DashboardComponent, CardComponent],
|
||||
providers: [{ provide: SummaryService, useClass: SummaryServiceMock }]
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(DashboardComponent);
|
||||
component = fixture.componentInstance;
|
||||
configurationService = TestBed.inject(ConfigurationService);
|
||||
orchestratorService = TestBed.inject(MgrModuleService);
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
@ -27,4 +67,13 @@ describe('CardComponent', () => {
|
||||
const dashboardCards = fixture.debugElement.nativeElement.querySelectorAll('cd-card');
|
||||
expect(dashboardCards.length).toBe(5);
|
||||
});
|
||||
|
||||
it('should get corresponding data into detailsCardData', () => {
|
||||
spyOn(configurationService, 'get').and.returnValue(of(configValueData));
|
||||
spyOn(orchestratorService, 'getConfig').and.returnValue(of(orchData));
|
||||
component.ngOnInit();
|
||||
expect(component.detailsCardData.fsid).toBe('e90a0d58-658e-4148-8f61-e896c86f0696');
|
||||
expect(component.detailsCardData.orchestrator).toBe('Cephadm');
|
||||
expect(component.detailsCardData.cephVersion).toBe('17.0.0-12222-gcd0cd7cb quincy (dev)');
|
||||
});
|
||||
});
|
||||
|
@ -1,4 +1,9 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
|
||||
import { ConfigurationService } from '~/app/shared/api/configuration.service';
|
||||
import { MgrModuleService } from '~/app/shared/api/mgr-module.service';
|
||||
import { DashboardDetails } from '~/app/shared/models/cd-details';
|
||||
import { SummaryService } from '~/app/shared/services/summary.service';
|
||||
|
||||
@Component({
|
||||
selector: 'cd-dashboard',
|
||||
|
@ -0,0 +1,5 @@
|
||||
export interface DashboardDetails {
|
||||
fsid?: string;
|
||||
orchestrator?: string;
|
||||
cephVersion?: string;
|
||||
}
|
Loading…
Reference in New Issue
Block a user