@@ -175,7 +175,8 @@ describe('ChatComponent', () => {
175175 mockFeatureFlagService . isTokenStreamingEnabledResponse . next ( true ) ;
176176 mockFeatureFlagService . isEventFilteringEnabledResponse . next ( true ) ;
177177 mockFeatureFlagService . isDeleteSessionEnabledResponse . next ( true ) ;
178- mockFeatureFlagService . isInfinityMessageScrollingEnabledResponse . next ( false ) ;
178+ mockFeatureFlagService . isInfinityMessageScrollingEnabledResponse . next (
179+ false ) ;
179180
180181 mockDialog = jasmine . createSpyObj ( 'MatDialog' , [ 'open' ] ) ;
181182 mockSnackBar = jasmine . createSpyObj ( 'MatSnackBar' , [ 'open' ] ) ;
@@ -934,24 +935,51 @@ describe('ChatComponent', () => {
934935 . toContain ( TEST_MESSAGE ) ;
935936 } ) ;
936937
937- it (
938- 'should clear "q" query param when message is sent' , fakeAsync ( ( ) => {
939- const urlTree = new UrlTree ( ) ;
940- urlTree . queryParams = { [ INITIAL_USER_INPUT_QUERY_PARAM ] : 'hello' } ;
941- mockRouter . parseUrl . and . returnValue ( urlTree as any ) ;
942- mockLocation . path . and . returnValue ( '/?q=hello' ) ;
943-
944- fixture = TestBed . createComponent ( ChatComponent ) ;
945- component = fixture . componentInstance ;
946- component . userInput = 'hello' ;
947- component . sendMessage ( new KeyboardEvent ( 'keydown' , { key : 'Enter' } ) ) ;
948- tick ( ) ;
949-
950- expect ( mockLocation . path ) . toHaveBeenCalled ( ) ;
951- expect ( mockRouter . parseUrl ) . toHaveBeenCalledWith ( '/?q=hello' ) ;
952- // The query param should be removed from the URL.
953- expect ( mockLocation . replaceState ) . toHaveBeenCalledWith ( '/' ) ;
954- } ) ) ;
938+ describe ( 'Query Param Handling' , ( ) => {
939+ let urlTree : UrlTree ;
940+
941+ beforeEach ( ( ) => {
942+ urlTree = new UrlTree ( ) ;
943+ fixture = TestBed . createComponent ( ChatComponent ) ;
944+ component = fixture . componentInstance ;
945+ component . userInput = 'hello' ;
946+ } ) ;
947+
948+ it (
949+ 'should clear "q" param on send' ,
950+ fakeAsync ( ( ) => {
951+ urlTree . queryParams = { [ INITIAL_USER_INPUT_QUERY_PARAM ] : 'hello' } ;
952+ mockRouter . parseUrl . and . returnValue ( urlTree as any ) ;
953+ mockLocation . path . and . returnValue ( '/?q=hello' ) ;
954+
955+ component . sendMessage (
956+ new KeyboardEvent ( 'keydown' , { key : 'Enter' } ) ) ;
957+ tick ( ) ;
958+
959+ expect ( mockLocation . path ) . toHaveBeenCalled ( ) ;
960+ expect ( mockRouter . parseUrl ) . toHaveBeenCalledWith ( '/?q=hello' ) ;
961+ // The query param should be removed from the URL.
962+ expect ( mockLocation . replaceState ) . toHaveBeenCalledWith ( '/' ) ;
963+ } ) ) ;
964+
965+ it (
966+ 'should not update URL if "q" param is missing' ,
967+ fakeAsync ( ( ) => {
968+ urlTree . queryParams = { } ;
969+ mockRouter . parseUrl . and . returnValue ( urlTree as any ) ;
970+ mockLocation . path . and . returnValue ( '/?' ) ;
971+
972+ component . sendMessage (
973+ new KeyboardEvent ( 'keydown' , { key : 'Enter' } ) ) ;
974+ tick ( ) ;
975+
976+ expect ( mockLocation . path ) . toHaveBeenCalled ( ) ;
977+ expect ( mockRouter . parseUrl ) . toHaveBeenCalledWith ( '/?' ) ;
978+ // The query param should be removed from the URL.
979+ expect ( mockLocation . replaceState ) . not . toHaveBeenCalled ( ) ;
980+ } ) ) ;
981+ } ) ;
982+
955983
956984 describe ( 'when event contains multiple text parts' , ( ) => {
957985 it (
0 commit comments