Skip to content

Commit 7205ee4

Browse files
reniowoodcopybara-github
authored andcommitted
ADK changes
PiperOrigin-RevId: 858932116
1 parent a1128ee commit 7205ee4

File tree

2 files changed

+12
-17
lines changed

2 files changed

+12
-17
lines changed

src/app/components/chat/chat.component.spec.ts

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import {MatDialog, MatDialogModule} from '@angular/material/dialog';
2323
import {MatSnackBar} from '@angular/material/snack-bar';
2424
import {By} from '@angular/platform-browser';
2525
import {NoopAnimationsModule} from '@angular/platform-browser/animations';
26-
import {ActivatedRoute, NavigationEnd, Params, Router, UrlTree} from '@angular/router';
26+
import {ActivatedRoute, NavigationEnd, Router, UrlTree} from '@angular/router';
2727
// 1p-ONLY-IMPORTS: import {beforeEach, describe, expect, it}
2828
import {BehaviorSubject, NEVER, of, ReplaySubject, Subject, throwError} from 'rxjs';
2929

@@ -190,12 +190,11 @@ describe('ChatComponent', () => {
190190
mockAgentBuilderService = jasmine.createSpyObj(
191191
'AgentBuilderService', ['clear', 'setLoadedAgentData']);
192192

193-
const queryParamsSubject = new BehaviorSubject<Params>({});
194193
mockActivatedRoute = {
195194
snapshot: {
196195
queryParams: {},
197196
} as any,
198-
queryParams: queryParamsSubject,
197+
queryParams: of({}),
199198
};
200199

201200
const appName = new BehaviorSubject<string>(TEST_APP_1_NAME);
@@ -321,9 +320,9 @@ describe('ChatComponent', () => {
321320
mockAgentService.listAppsResponse.next(
322321
[TEST_APP_1_NAME, TEST_APP_2_NAME]);
323322

324-
const params = {[APP_QUERY_PARAM]: INVALID_APP_NAME};
325-
mockActivatedRoute.snapshot!.queryParams = params;
326-
(mockActivatedRoute.queryParams as Subject<Params>).next(params);
323+
mockActivatedRoute.snapshot!.queryParams = {
324+
[APP_QUERY_PARAM]: INVALID_APP_NAME,
325+
};
327326
mockAgentService.listAppsResponse.next([TEST_APP_1_NAME]);
328327
fixture = TestBed.createComponent(ChatComponent);
329328
component = fixture.componentInstance;
@@ -402,11 +401,9 @@ describe('ChatComponent', () => {
402401
mockAgentService.listAppsResponse.next(
403402
[TEST_APP_1_NAME, TEST_APP_2_NAME]);
404403

405-
const params = {
404+
mockActivatedRoute.snapshot!.queryParams = {
406405
[APP_QUERY_PARAM]: TEST_APP_2_NAME,
407406
};
408-
mockActivatedRoute.snapshot!.queryParams = params;
409-
(mockActivatedRoute.queryParams as Subject<Params>).next(params);
410407
component.ngOnInit();
411408
});
412409
it('should create new session on init', () => {
@@ -423,12 +420,10 @@ describe('ChatComponent', () => {
423420
beforeEach(() => {
424421
mockAgentService.listAppsResponse.next([TEST_APP_1_NAME]);
425422
mockFeatureFlagService.isSessionUrlEnabledResponse.next(true);
426-
const params = {
423+
mockActivatedRoute.snapshot!.queryParams = {
427424
[APP_QUERY_PARAM]: TEST_APP_1_NAME,
428425
[SESSION_QUERY_PARAM]: SESSION_2_ID,
429426
};
430-
mockActivatedRoute.snapshot!.queryParams = params;
431-
(mockActivatedRoute.queryParams as Subject<Params>).next(params);
432427
mockSessionService.getSessionResponse.next(
433428
{id: SESSION_2_ID, state: {}, events: []});
434429
});
@@ -476,12 +471,10 @@ describe('ChatComponent', () => {
476471

477472
describe('when session in URL is not found', () => {
478473
beforeEach(async () => {
479-
const params = {
474+
mockActivatedRoute.snapshot!.queryParams = {
480475
[APP_QUERY_PARAM]: TEST_APP_1_NAME,
481476
[SESSION_QUERY_PARAM]: SESSION_2_ID,
482477
};
483-
mockActivatedRoute.snapshot!.queryParams = params;
484-
(mockActivatedRoute.queryParams as Subject<Params>).next(params);
485478
mockSessionService.getSession.and.callFake(
486479
(userId: string, app: string, sessionId: string) => {
487480
if (sessionId === SESSION_2_ID) {

src/app/components/chat/chat.component.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,6 @@ export class ChatComponent implements OnInit, AfterViewInit, OnDestroy {
265265
this.router.navigate([], {
266266
relativeTo: this.activatedRoute,
267267
queryParams: {app: app[0]},
268-
replaceUrl: true,
269268
});
270269
}
271270
}),
@@ -1658,7 +1657,10 @@ export class ChatComponent implements OnInit, AfterViewInit, OnDestroy {
16581657

16591658
private syncSelectedAppFromUrl() {
16601659
combineLatest([
1661-
this.activatedRoute.queryParams,
1660+
this.router.events.pipe(
1661+
filter((e) => e instanceof NavigationEnd),
1662+
map(() => this.activatedRoute.snapshot.queryParams),
1663+
),
16621664
this.apps$
16631665
]).subscribe(([params, apps]) => {
16641666
if (apps && apps.length) {

0 commit comments

Comments
 (0)