@@ -27,6 +27,7 @@ import { provideHttpClientTesting } from '@angular/common/http/testing'
2727import { provideTranslateHttpLoader , TRANSLATE_HTTP_LOADER_CONFIG } from '@ngx-translate/http-loader'
2828
2929describe ( 'ProfileDetailComponent' , ( ) => {
30+ const defaultCloudMode = environment . cloud
3031 let component : ProfileDetailComponent
3132 let fixture : ComponentFixture < ProfileDetailComponent >
3233 let profileSpy : jasmine . Spy
@@ -148,6 +149,7 @@ describe('ProfileDetailComponent', () => {
148149 } )
149150
150151 afterEach ( ( ) => {
152+ environment . cloud = defaultCloudMode
151153 TestBed . resetTestingModule ( )
152154 } )
153155
@@ -166,6 +168,14 @@ describe('ProfileDetailComponent', () => {
166168 component . getAmtProfile ( 'profile' )
167169 }
168170
171+ const recreateComponent = ( ) : void => {
172+ fixture = TestBed . createComponent ( ProfileDetailComponent )
173+ component = fixture . componentInstance
174+ translate = TestBed . inject ( TranslateService )
175+ translate . setFallbackLang ( 'en' )
176+ fixture . detectChanges ( )
177+ }
178+
169179 it ( 'should create' , ( ) => {
170180 expect ( component ) . toBeTruthy ( )
171181 expect ( ciraGetDataSpy ) . toHaveBeenCalled ( )
@@ -174,6 +184,49 @@ describe('ProfileDetailComponent', () => {
174184 expect ( wirelessGetDataSpy ) . toHaveBeenCalled ( )
175185 expect ( proxyGetDataSpy ) . toHaveBeenCalled ( )
176186 } )
187+
188+ it ( 'should hide CIRA option and skip CIRA config fetch when enterprise has CIRA disabled' , ( ) => {
189+ environment . cloud = false
190+ serverFeaturesGetFeaturesSpy . and . returnValue ( of ( { ciraEnabled : false } ) )
191+ serverFeaturesGetFeaturesSpy . calls . reset ( )
192+ ciraGetDataSpy . calls . reset ( )
193+
194+ recreateComponent ( )
195+
196+ expect ( serverFeaturesGetFeaturesSpy ) . toHaveBeenCalled ( )
197+ expect ( ciraGetDataSpy ) . not . toHaveBeenCalled ( )
198+ expect ( component . ciraEnabled ( ) ) . toBeFalse ( )
199+ expect ( fixture . nativeElement . querySelector ( '[data-cy="radio-cira"]' ) ) . toBeNull ( )
200+ } )
201+
202+ it ( 'should show CIRA option and fetch CIRA configs when enterprise has CIRA enabled' , ( ) => {
203+ environment . cloud = false
204+ serverFeaturesGetFeaturesSpy . and . returnValue ( of ( { ciraEnabled : true } ) )
205+ serverFeaturesGetFeaturesSpy . calls . reset ( )
206+ ciraGetDataSpy . calls . reset ( )
207+
208+ recreateComponent ( )
209+
210+ expect ( serverFeaturesGetFeaturesSpy ) . toHaveBeenCalled ( )
211+ expect ( ciraGetDataSpy ) . toHaveBeenCalled ( )
212+ expect ( component . ciraEnabled ( ) ) . toBeTrue ( )
213+ expect ( fixture . nativeElement . querySelector ( '[data-cy="radio-cira"]' ) ) . not . toBeNull ( )
214+ } )
215+
216+ it ( 'should fail open for enterprise CIRA features API errors' , ( ) => {
217+ environment . cloud = false
218+ serverFeaturesGetFeaturesSpy . and . returnValue ( throwError ( ( ) => new Error ( 'features call failed' ) ) )
219+ serverFeaturesGetFeaturesSpy . calls . reset ( )
220+ ciraGetDataSpy . calls . reset ( )
221+
222+ recreateComponent ( )
223+
224+ expect ( serverFeaturesGetFeaturesSpy ) . toHaveBeenCalled ( )
225+ expect ( ciraGetDataSpy ) . toHaveBeenCalled ( )
226+ expect ( component . ciraEnabled ( ) ) . toBeTrue ( )
227+ expect ( fixture . nativeElement . querySelector ( '[data-cy="radio-cira"]' ) ) . not . toBeNull ( )
228+ } )
229+
177230 it ( 'should set connectionMode to TLS when tlsMode is a TLS mode (1-4)' , ( ) => {
178231 const profile : Profile = { tlsMode : 4 , ciraConfigName : 'config1' } as any
179232 component . setConnectionMode ( profile )
0 commit comments