Skip to content

Commit 064f3f8

Browse files
committed
fix unit tests
1 parent 6ebf565 commit 064f3f8

File tree

3 files changed

+24
-16
lines changed

3 files changed

+24
-16
lines changed

backend/src/__tests__/main-prompt.test.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ import {
99
getToolCallString,
1010
renderToolResults,
1111
} from '@codebuff/common/tools/utils'
12-
import { getInitialSessionState } from '@codebuff/common/types/session-state'
12+
import {
13+
AgentTemplateTypes,
14+
getInitialSessionState,
15+
} from '@codebuff/common/types/session-state'
1316
import {
1417
afterAll,
1518
afterEach,
@@ -47,8 +50,8 @@ describe('mainPrompt', () => {
4750
beforeEach(() => {
4851
// Setup common mock agent templates
4952
mockLocalAgentTemplates = {
50-
base: {
51-
id: 'base',
53+
[AgentTemplateTypes.base]: {
54+
id: AgentTemplateTypes.base,
5255
displayName: 'Base Agent',
5356
outputMode: 'last_message',
5457
inputSchema: {},
@@ -61,8 +64,8 @@ describe('mainPrompt', () => {
6164
instructionsPrompt: '',
6265
stepPrompt: '',
6366
},
64-
base_max: {
65-
id: 'base_max',
67+
[AgentTemplateTypes.base_max]: {
68+
id: AgentTemplateTypes.base_max,
6669
displayName: 'Base Max Agent',
6770
outputMode: 'last_message',
6871
inputSchema: {},
@@ -256,7 +259,7 @@ describe('mainPrompt', () => {
256259
clientSessionId: 'test-session',
257260
onResponseChunk: () => {},
258261
localAgentTemplates: {
259-
base: {
262+
[AgentTemplateTypes.base]: {
260263
id: 'base',
261264
displayName: 'Base Agent',
262265
outputMode: 'last_message',
@@ -270,7 +273,7 @@ describe('mainPrompt', () => {
270273
instructionsPrompt: '',
271274
stepPrompt: '',
272275
},
273-
base_max: {
276+
[AgentTemplateTypes.base_max]: {
274277
id: 'base_max',
275278
displayName: 'Base Max Agent',
276279
outputMode: 'last_message',
@@ -397,7 +400,7 @@ describe('mainPrompt', () => {
397400
clientSessionId: 'test-session',
398401
onResponseChunk: () => {},
399402
localAgentTemplates: {
400-
base: {
403+
[AgentTemplateTypes.base]: {
401404
id: 'base',
402405
displayName: 'Base Agent',
403406
outputMode: 'last_message',
@@ -411,8 +414,8 @@ describe('mainPrompt', () => {
411414
instructionsPrompt: '',
412415
stepPrompt: '',
413416
},
414-
base_max: {
415-
id: 'base_max',
417+
[AgentTemplateTypes.base_max]: {
418+
id: 'base-max',
416419
displayName: 'Base Max Agent',
417420
outputMode: 'last_message',
418421
inputSchema: {},

backend/src/__tests__/parent-instructions.test.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1+
import {
2+
AgentTemplateTypes,
3+
type AgentState,
4+
} from '@codebuff/common/types/session-state'
15
import { describe, expect, it } from 'bun:test'
26

37
import { assembleLocalAgentTemplates } from '../templates/agent-registry'
48
import { collectParentInstructions } from '../templates/strings'
59

610
import type { DynamicAgentTemplate } from '@codebuff/common/types/dynamic-agent-template'
7-
import type { AgentState } from '@codebuff/common/types/session-state'
811
import type {
912
FileTreeNode,
1013
ProjectFileContext,
@@ -64,7 +67,8 @@ describe('Parent Instructions Injection', () => {
6467
parentInstructions: {
6568
researcher:
6669
'Spawn knowledge-keeper when you find documentation gaps.',
67-
file_picker: 'Spawn knowledge-keeper when you discover missing docs.',
70+
[AgentTemplateTypes.file_picker]:
71+
'Spawn knowledge-keeper when you discover missing docs.',
6872
},
6973
systemPrompt: 'You are a test agent.',
7074
instructionsPrompt: 'Process the user request.',

common/src/__tests__/dynamic-agent-template-schema.test.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { describe, expect, it } from 'bun:test'
2+
import { AgentTemplateTypes } from 'src/types/session-state'
23

34
import {
45
DynamicAgentConfigSchema,
@@ -362,11 +363,11 @@ describe('DynamicAgentConfigSchema', () => {
362363
describe('Parent Instructions Runtime Validation', () => {
363364
it('should validate parent instructions with valid agent IDs', () => {
364365
const parentInstructions = {
365-
researcher: 'Spawn when you need research',
366-
file_picker: 'Spawn when you need files',
367-
custom_agent: 'Spawn for custom tasks',
366+
[AgentTemplateTypes.researcher]: 'Spawn when you need research',
367+
[AgentTemplateTypes.file_picker]: 'Spawn when you need files',
368+
'custom-agent': 'Spawn for custom tasks',
368369
}
369-
const dynamicAgentIds = ['custom_agent']
370+
const dynamicAgentIds = ['custom-agent']
370371
const result = validateParentInstructions(
371372
parentInstructions,
372373
dynamicAgentIds,

0 commit comments

Comments
 (0)