Skip to content

Commit bf1c02e

Browse files
google-genai-botcopybara-github
authored andcommitted
ADK changes
PiperOrigin-RevId: 828484535
1 parent f2171ef commit bf1c02e

File tree

2 files changed

+46
-3
lines changed

2 files changed

+46
-3
lines changed

src/app/components/session-tab/session-tab.component.spec.ts

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import {ComponentFixture, TestBed,} from '@angular/core/testing';
1919
import {MatDialog, MatDialogModule} from '@angular/material/dialog';
2020
import {NoopAnimationsModule} from '@angular/platform-browser/animations';
21-
// 1p-ONLY-IMPORTS: import {beforeEach, describe, it,}
21+
// 1p-ONLY-IMPORTS: import {beforeEach, describe, it, }
2222
import {of} from 'rxjs';
2323

2424
import {SESSION_SERVICE, SessionService,} from '../../core/services/interfaces/session';
@@ -125,4 +125,44 @@ describe('SessionTabComponent', () => {
125125
});
126126
});
127127
});
128+
129+
describe('when reloading a session', () => {
130+
beforeEach(() => {
131+
spyOn(component.sessionReloaded, 'emit');
132+
});
133+
134+
describe('when reloading a session is successful', () => {
135+
beforeEach(() => {
136+
sessionService.getSessionResponse.next({} as any);
137+
component.reloadSession('session1');
138+
});
139+
140+
it('emits sessionReloaded', () => {
141+
expect(component.sessionReloaded.emit).toHaveBeenCalled();
142+
});
143+
});
144+
145+
describe('when reloading a session throws error', () => {
146+
beforeEach(() => {
147+
sessionService.getSessionResponse.error(new Error('error'));
148+
component.reloadSession('session1');
149+
});
150+
151+
it('does not emit sessionReloaded', () => {
152+
expect(component.sessionReloaded.emit).not.toHaveBeenCalled();
153+
});
154+
155+
describe('on retry', () => {
156+
beforeEach(() => {
157+
sessionService.getSession.calls.reset();
158+
sessionService.getSessionResponse.next({} as any);
159+
component.reloadSession('session1');
160+
});
161+
162+
it('fetches session again', () => {
163+
expect(sessionService.getSession).toHaveBeenCalled();
164+
});
165+
});
166+
});
167+
});
128168
});

src/app/components/session-tab/session-tab.component.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,12 @@ export class SessionTabComponent implements OnInit {
110110
this.reloadSessionSubject
111111
.pipe(
112112
switchMap(
113-
(sessionId) => this.sessionService.getSession(
114-
this.userId, this.appName, sessionId)),
113+
(sessionId) =>
114+
this.sessionService
115+
.getSession(this.userId, this.appName, sessionId)
116+
.pipe(catchError(() => of(null)))),
115117
tap((res) => {
118+
if (!res) return;
116119
const session = this.fromApiResultToSession(res);
117120
this.sessionReloaded.emit(session);
118121
this.changeDetectorRef.markForCheck();

0 commit comments

Comments
 (0)