Skip to content

Commit 476e011

Browse files
committed
test(core): add tests for stack trace and warning log
1 parent d139bce commit 476e011

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

packages/core/src/agent/content-utils.test.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7-
import { describe, expect, it } from 'vitest';
7+
import { describe, expect, it, vi } from 'vitest';
88
import {
99
geminiPartsToContentParts,
1010
contentPartsToGeminiParts,
1111
buildToolResponseData,
1212
} from './content-utils.js';
1313
import type { Part } from '@google/genai';
1414
import type { ContentPart } from './types.js';
15+
import { debugLogger } from '../utils/debugLogger.js';
1516

1617
describe('geminiPartsToContentParts', () => {
1718
it('converts text parts', () => {
@@ -191,11 +192,17 @@ describe('contentPartsToGeminiParts', () => {
191192
const content = [
192193
{ type: 'custom_widget', payload: 123 },
193194
] as unknown as ContentPart[];
195+
196+
const warnSpy = vi.spyOn(debugLogger, 'warn');
194197
const result = contentPartsToGeminiParts(content);
198+
199+
expect(warnSpy).toHaveBeenCalled();
195200
expect(result).toHaveLength(1);
196201
expect(result[0]).toEqual({
197202
text: JSON.stringify({ type: 'custom_widget', payload: 123 }),
198203
});
204+
205+
warnSpy.mockRestore();
199206
});
200207
});
201208

packages/core/src/agent/legacy-agent-session.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1330,6 +1330,7 @@ describe('LegacyAgentSession', () => {
13301330
);
13311331
expect(err?.message).toBe('Connection refused');
13321332
expect(err?.fatal).toBe(true);
1333+
expect(err?._meta?.['stack']).toBeDefined();
13331334

13341335
const streamEnd = events.find(
13351336
(e): e is AgentEvent<'agent_end'> => e.type === 'agent_end',

0 commit comments

Comments
 (0)