From be1b2e3e6ebdd00dcb93f04dc7f38914de5a3d77 Mon Sep 17 00:00:00 2001 From: Jinhyuk Kim Date: Mon, 12 Jan 2026 21:11:45 -0800 Subject: [PATCH] ADK changes PiperOrigin-RevId: 855510046 --- .../components/chat/chat.component.spec.ts | 26 ++++++------------- src/app/components/chat/chat.component.ts | 2 +- 2 files changed, 9 insertions(+), 19 deletions(-) diff --git a/src/app/components/chat/chat.component.spec.ts b/src/app/components/chat/chat.component.spec.ts index 7034933a..25776dea 100644 --- a/src/app/components/chat/chat.component.spec.ts +++ b/src/app/components/chat/chat.component.spec.ts @@ -23,7 +23,7 @@ import {MatDialog, MatDialogModule} from '@angular/material/dialog'; import {MatSnackBar} from '@angular/material/snack-bar'; import {By} from '@angular/platform-browser'; import {NoopAnimationsModule} from '@angular/platform-browser/animations'; -import {ActivatedRoute, NavigationEnd, Router} from '@angular/router'; +import {ActivatedRoute, NavigationEnd, Router, UrlTree} from '@angular/router'; // 1p-ONLY-IMPORTS: import {beforeEach, describe, expect, it} import {BehaviorSubject, NEVER, of, ReplaySubject, Subject, throwError} from 'rxjs'; @@ -935,32 +935,22 @@ describe('ChatComponent', () => { }); it( - 'should clear "q" query param when message is sent', - fakeAsync(() => { - mockAgentService.setApp(''); // Initially no app - mockActivatedRoute.snapshot! - .queryParams = {[INITIAL_USER_INPUT_QUERY_PARAM]: 'hello'}; - mockActivatedRoute.queryParams = - of({[INITIAL_USER_INPUT_QUERY_PARAM]: 'hello'}); - const urlTree = { - queryParams: {[INITIAL_USER_INPUT_QUERY_PARAM]: 'hello'}, - }; + 'should clear "q" query param when message is sent', fakeAsync(() => { + const urlTree = new UrlTree(); + urlTree.queryParams = {[INITIAL_USER_INPUT_QUERY_PARAM]: 'hello'}; mockRouter.parseUrl.and.returnValue(urlTree as any); mockLocation.path.and.returnValue('/?q=hello'); + fixture = TestBed.createComponent(ChatComponent); component = fixture.componentInstance; - fixture.detectChanges(); - mockAgentService.setApp(TEST_APP_1_NAME); - tick(); - + component.userInput = 'hello'; component.sendMessage(new KeyboardEvent('keydown', {key: 'Enter'})); tick(); expect(mockLocation.path).toHaveBeenCalled(); expect(mockRouter.parseUrl).toHaveBeenCalledWith('/?q=hello'); - expect(urlTree.queryParams).toEqual({} as any); // q param should be - // deleted. - expect(mockRouter.navigateByUrl).toHaveBeenCalledWith(urlTree as any); + // The query param should be removed from the URL. + expect(mockLocation.replaceState).toHaveBeenCalledWith('/'); })); describe('when event contains multiple text parts', () => { diff --git a/src/app/components/chat/chat.component.ts b/src/app/components/chat/chat.component.ts index 69fc662a..e54524d5 100644 --- a/src/app/components/chat/chat.component.ts +++ b/src/app/components/chat/chat.component.ts @@ -594,7 +594,7 @@ export class ChatComponent implements OnInit, AfterViewInit, OnDestroy { // Clear the query param for the initial user input once it is sent. const updatedUrl = this.router.parseUrl(this.location.path()); delete updatedUrl.queryParams[INITIAL_USER_INPUT_QUERY_PARAM]; - await this.router.navigateByUrl(updatedUrl); + this.location.replaceState(updatedUrl.toString()); this.changeDetectorRef.detectChanges(); }