diff options
Diffstat (limited to 'vid-webpack-master/src')
5 files changed, 34 insertions, 21 deletions
diff --git a/vid-webpack-master/src/app/instantiationStatus/instantiationStatus.component.html b/vid-webpack-master/src/app/instantiationStatus/instantiationStatus.component.html index 9ef98e55f..8e9e53602 100644 --- a/vid-webpack-master/src/app/instantiationStatus/instantiationStatus.component.html +++ b/vid-webpack-master/src/app/instantiationStatus/instantiationStatus.component.html @@ -74,7 +74,7 @@ </svg-icon> </custom-popover> - <div class="menu-div" (click)="onContextMenu($event, data)"> + <div class="menu-div" (click)="onContextMenu($event, data)" [attr.data-tests-id]="'menu-'+data.jobId"> <span class="icon-menu"></span> <context-menu> <ng-template *ngFor="let action of contextMenuActions" contextMenuItem let-item diff --git a/vid-webpack-master/src/app/instantiationStatus/instantiationStatus.component.service.spec.ts b/vid-webpack-master/src/app/instantiationStatus/instantiationStatus.component.service.spec.ts index 29adfa9e0..eedd46dd3 100644 --- a/vid-webpack-master/src/app/instantiationStatus/instantiationStatus.component.service.spec.ts +++ b/vid-webpack-master/src/app/instantiationStatus/instantiationStatus.component.service.spec.ts @@ -5,36 +5,25 @@ import {AaiService} from "../shared/services/aaiService/aai.service"; import {MsoService} from "../shared/services/msoService/mso.service"; import {NgRedux} from "@angular-redux/store"; import {HttpClientTestingModule} from "@angular/common/http/testing"; -import {FeatureFlagsService} from "../shared/services/featureFlag/feature-flags.service"; +import {FeatureFlagsService, Features} from "../shared/services/featureFlag/feature-flags.service"; import {DrawingBoardModes} from "../drawingBoard/service-planning/drawing-board.modes"; import {RouterTestingModule} from "@angular/router/testing"; import {of} from "rxjs"; import {UrlTree} from "@angular/router"; import each from "jest-each"; import {ServiceAction} from "../shared/models/serviceInstanceActions"; +import {instance, mock, when} from "ts-mockito"; class MockAppStore<T> { - - getState() { - return { - global: { - flags: { - 'FLAG_1902_NEW_VIEW_EDIT': true, - - } - } - } - } - - dispatch() { - - } + dispatch() {} } + describe('Instantiation Status Service', () => { let injector; let aaiService: AaiService; let msoService: MsoService; let service: InstantiationStatusComponentService; + let mockFeatureFlagsService: FeatureFlagsService = mock(FeatureFlagsService); beforeAll(done => (async () => { @@ -48,7 +37,9 @@ describe('Instantiation Status Service', () => { AaiService, MsoService, FeatureFlagsService, - {provide: NgRedux, useClass: MockAppStore}] + {provide: NgRedux, useClass: MockAppStore}, + {provide: FeatureFlagsService, useValue: instance(mockFeatureFlagsService)} + ] }); await TestBed.compileComponents(); @@ -172,6 +163,15 @@ describe('Instantiation Status Service', () => { expect(service.isRecreateEnabled(serviceInfoModel)).toBe(expected); }); + each([ + [true, true], + [false, false], + ]). + test('isRecreateVisible: should be %s if flag is %s', (expected:boolean, flag:boolean) => { + when(mockFeatureFlagsService.getFlagState(Features.FLAG_2004_CREATE_ANOTHER_INSTANCE_FROM_TEMPLATE)).thenReturn(flag); + expect(service.isRecreateVisible()).toEqual(expected); + }); + test('getStatusTooltip should return correct icon per job status', () => { let result : ServiceStatus = service.getStatus('pending'); expect(result.iconClassName).toEqual(PENDING); diff --git a/vid-webpack-master/src/app/instantiationStatus/instantiationStatus.component.service.ts b/vid-webpack-master/src/app/instantiationStatus/instantiationStatus.component.service.ts index 227fff10d..4bfedd913 100644 --- a/vid-webpack-master/src/app/instantiationStatus/instantiationStatus.component.service.ts +++ b/vid-webpack-master/src/app/instantiationStatus/instantiationStatus.component.service.ts @@ -29,7 +29,8 @@ export class InstantiationStatusComponentService { constructor( private _aaiService: AaiService, private _msoService: MsoService, private _router : Router, - private _store: NgRedux<AppState>) { + private _store: NgRedux<AppState>, + private _featureFlagsService:FeatureFlagsService) { } generateServiceInfoDataMapping(arr: ServiceInfoModel[]) : { [serviceInstanceId: string]: ServiceInfoModel[]}{ @@ -70,7 +71,7 @@ export class InstantiationStatusComponentService { } open(item: ServiceInfoModel): void { - if (FeatureFlagsService.getFlagState(Features.FLAG_1902_VNF_GROUPING, this._store)) { + if (this._featureFlagsService.getFlagState(Features.FLAG_1902_VNF_GROUPING)) { this._aaiService.getServiceModelById(item['serviceModelId']).subscribe((result)=>{ const serviceModel = new ServiceModel(result); @@ -92,7 +93,7 @@ export class InstantiationStatusComponentService { } navigateToNewViewOnlyOrOldEditView(item: ServiceInfoModel) { - if (FeatureFlagsService.getFlagState(Features.FLAG_1902_NEW_VIEW_EDIT, this._store)) { + if (this._featureFlagsService.getFlagState(Features.FLAG_1902_NEW_VIEW_EDIT)) { this.navigateToNewViewEdit(item, DrawingBoardModes.VIEW); } else { @@ -184,6 +185,9 @@ export class InstantiationStatusComponentService { return item.action === ServiceAction.INSTANTIATE; } + isRecreateVisible(): boolean { + return this._featureFlagsService.getFlagState(Features.FLAG_2004_CREATE_ANOTHER_INSTANCE_FROM_TEMPLATE); + } } diff --git a/vid-webpack-master/src/app/instantiationStatus/instantiationStatus.component.ts b/vid-webpack-master/src/app/instantiationStatus/instantiationStatus.component.ts index ba26716da..58227c9eb 100644 --- a/vid-webpack-master/src/app/instantiationStatus/instantiationStatus.component.ts +++ b/vid-webpack-master/src/app/instantiationStatus/instantiationStatus.component.ts @@ -59,6 +59,14 @@ export class InstantiationStatusComponent implements OnInit { visible: () => true, }, { + name: "Recreate", + dataTestId: "context-menu-recreate", + className: "fa-clone", + click: (item: ServiceInfoModel) => this.instantiationStatusComponentService.recreate(item), + enabled: (item: ServiceInfoModel) => this.instantiationStatusComponentService.isRecreateEnabled(item), + visible: () => this.instantiationStatusComponentService.isRecreateVisible(), + }, + { name: "Audit info", dataTestId: "context-menu-audit-info", className: "fa-info-circle", diff --git a/vid-webpack-master/src/app/shared/services/featureFlag/feature-flags.service.ts b/vid-webpack-master/src/app/shared/services/featureFlag/feature-flags.service.ts index 8570b0866..7e0575b68 100644 --- a/vid-webpack-master/src/app/shared/services/featureFlag/feature-flags.service.ts +++ b/vid-webpack-master/src/app/shared/services/featureFlag/feature-flags.service.ts @@ -14,6 +14,7 @@ export enum Features { FLAG_FLASH_MORE_ACTIONS_BUTTON_IN_OLD_VIEW_EDIT ='FLAG_FLASH_MORE_ACTIONS_BUTTON_IN_OLD_VIEW_EDIT', FLAG_2002_VFM_UPGRADE_ADDITIONAL_OPTIONS ='FLAG_2002_VFM_UPGRADE_ADDITIONAL_OPTIONS', FLAG_2004_INSTANTIATION_STATUS_FILTER ='FLAG_2004_INSTANTIATION_STATUS_FILTER', + FLAG_2004_CREATE_ANOTHER_INSTANCE_FROM_TEMPLATE = 'FLAG_2004_CREATE_ANOTHER_INSTANCE_FROM_TEMPLATE', FLAG_2004_TEMP_BUTTON_TO_INSTANTIATION_STATUS_FILTER ='FLAG_2004_TEMP_BUTTON_TO_INSTANTIATION_STATUS_FILTER', } |