@@ -24,8 +24,10 @@ import {By} from '@angular/platform-browser';
2424import { NoopAnimationsModule } from '@angular/platform-browser/animations' ;
2525import { of } from 'rxjs' ;
2626
27+ import { FEATURE_FLAG_SERVICE } from '../../core/services/feature-flag.service' ;
2728import { STRING_TO_COLOR_SERVICE } from '../../core/services/interfaces/string-to-color' ;
2829import { StringToColorServiceImpl } from '../../core/services/string-to-color.service' ;
30+ import { MockFeatureFlagService } from '../../core/services/testing/mock-feature-flag.service' ;
2931import { MockStringToColorService } from '../../core/services/testing/mock-string-to-color.service' ;
3032import { ChatPanelComponent } from './chat-panel.component' ;
3133import { MARKDOWN_COMPONENT } from '../markdown/markdown.component.interface' ;
@@ -37,8 +39,15 @@ const FUNC1_NAME = 'func1';
3739describe ( 'ChatPanelComponent' , ( ) => {
3840 let component : ChatPanelComponent ;
3941 let fixture : ComponentFixture < ChatPanelComponent > ;
42+ let mockFeatureFlagService : MockFeatureFlagService ;
4043
4144 beforeEach ( async ( ) => {
45+ mockFeatureFlagService = new MockFeatureFlagService ( ) ;
46+
47+ mockFeatureFlagService . isMessageFileUploadEnabledResponse . next ( true ) ;
48+ mockFeatureFlagService . isManualStateUpdateEnabledResponse . next ( true ) ;
49+ mockFeatureFlagService . isBidiStreamingEnabledResponse . next ( true ) ;
50+
4251 await TestBed
4352 . configureTestingModule ( {
4453 imports : [
@@ -54,6 +63,7 @@ describe('ChatPanelComponent', () => {
5463 useClass : StringToColorServiceImpl ,
5564 } ,
5665 { provide : MARKDOWN_COMPONENT , useValue : MarkdownComponent } ,
66+ { provide : FEATURE_FLAG_SERVICE , useValue : mockFeatureFlagService } ,
5767 ] ,
5868 } )
5969 . compileComponents ( ) ;
@@ -327,4 +337,58 @@ describe('ChatPanelComponent', () => {
327337 expect ( scrollContainerElement . scrollTo ) . toHaveBeenCalled ( ) ;
328338 } ) ) ;
329339 } ) ;
340+
341+ describe ( 'disabled features' , ( ) => {
342+ it ( 'should have the attach_file button disabled' , ( ) => {
343+ mockFeatureFlagService . isMessageFileUploadEnabledResponse . next ( false ) ;
344+ fixture . detectChanges ( ) ;
345+
346+ const allButtons =
347+ fixture . debugElement . queryAll ( By . css ( 'button[mat-icon-button]' ) ) ;
348+ const button = allButtons . find (
349+ b =>
350+ b . nativeElement . querySelector ( 'mat-icon' ) ?. textContent ?. trim ( ) ===
351+ 'attach_file' ) ;
352+ expect ( button ! . nativeElement . disabled ) . toBeTrue ( ) ;
353+ } ) ;
354+
355+ it ( 'should have the more_vert button disabled' , ( ) => {
356+ mockFeatureFlagService . isManualStateUpdateEnabledResponse . next ( false ) ;
357+ fixture . detectChanges ( ) ;
358+
359+ const allButtons =
360+ fixture . debugElement . queryAll ( By . css ( 'button[mat-icon-button]' ) ) ;
361+ const button = allButtons . find (
362+ b =>
363+ b . nativeElement . querySelector ( 'mat-icon' ) ?. textContent ?. trim ( ) ===
364+ 'more_vert' ) ;
365+ expect ( button ! . nativeElement . disabled ) . toBeTrue ( ) ;
366+ } ) ;
367+
368+ it ( 'should have the mic button disabled' , ( ) => {
369+ mockFeatureFlagService . isBidiStreamingEnabledResponse . next ( false ) ;
370+ fixture . detectChanges ( ) ;
371+
372+ const allButtons =
373+ fixture . debugElement . queryAll ( By . css ( 'button[mat-icon-button]' ) ) ;
374+ const button = allButtons . find (
375+ b =>
376+ b . nativeElement . querySelector ( 'mat-icon' ) ?. textContent ?. trim ( ) ===
377+ 'mic' ) ;
378+ expect ( button ! . nativeElement . disabled ) . toBeTrue ( ) ;
379+ } ) ;
380+
381+ it ( 'should have the videocam button disabled' , ( ) => {
382+ mockFeatureFlagService . isBidiStreamingEnabledResponse . next ( false ) ;
383+ fixture . detectChanges ( ) ;
384+
385+ const allButtons =
386+ fixture . debugElement . queryAll ( By . css ( 'button[mat-icon-button]' ) ) ;
387+ const button = allButtons . find (
388+ b =>
389+ b . nativeElement . querySelector ( 'mat-icon' ) ?. textContent ?. trim ( ) ===
390+ 'videocam' ) ;
391+ expect ( button ! . nativeElement . disabled ) . toBeTrue ( ) ;
392+ } ) ;
393+ } ) ;
330394} ) ;
0 commit comments