Skip to content

Commit 175edff

Browse files
committed
remove websockets from tests
1 parent 294a847 commit 175edff

File tree

2 files changed

+4
-24
lines changed

2 files changed

+4
-24
lines changed

backend/src/__tests__/cost-aggregation.test.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import { handleSpawnAgents } from '../tools/handlers/tool/spawn-agents'
2222

2323
import type { AgentState } from '@codebuff/common/types/session-state'
2424
import type { ProjectFileContext } from '@codebuff/common/util/file'
25-
import type { WebSocket } from 'ws'
2625

2726
const mockFileContext: ProjectFileContext = {
2827
projectRoot: '/test',
@@ -137,7 +136,6 @@ describe('Cost Aggregation System', () => {
137136
}
138137

139138
const mockValidatedState = {
140-
ws: new MockWebSocket() as unknown as WebSocket,
141139
fingerprintId: 'test-fingerprint',
142140
userId: 'test-user',
143141
agentTemplate: mockAgentTemplate,
@@ -212,7 +210,6 @@ describe('Cost Aggregation System', () => {
212210
}
213211

214212
const mockValidatedState = {
215-
ws: new MockWebSocket() as unknown as WebSocket,
216213
fingerprintId: 'test-fingerprint',
217214
userId: 'test-user',
218215
agentTemplate: mockAgentTemplate,
@@ -371,7 +368,6 @@ describe('Cost Aggregation System', () => {
371368

372369
// Mock subagent spawning that adds their costs
373370
const mockValidatedState = {
374-
ws: new MockWebSocket() as unknown as WebSocket,
375371
fingerprintId: 'test-fingerprint',
376372
userId: 'test-user',
377373
agentTemplate: mockAgentTemplate,

backend/src/__tests__/tool-call-schema.test.ts

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,8 @@
1-
import { describe, it, expect, beforeEach } from 'bun:test'
1+
import { describe, it, expect } from 'bun:test'
22

33
import type { WebSocket } from 'ws'
44

55
describe('Backend Tool Call Schema', () => {
6-
let mockWs: any
7-
8-
beforeEach(() => {
9-
// Create a simple mock WebSocket
10-
mockWs = {
11-
send: () => {},
12-
on: () => {},
13-
close: () => {},
14-
}
15-
})
16-
176
it('should validate tool call request structure', () => {
187
const toolCallRequest = {
198
type: 'tool-call-request' as const,
@@ -109,26 +98,23 @@ describe('Backend Tool Call Schema', () => {
10998
})
11099

111100
it('should generate mock project structure analysis', async () => {
112-
const analysis = await generateMockProjectStructureAnalysis(mockWs)
101+
const analysis = await generateMockProjectStructureAnalysis()
113102

114103
expect(analysis).toContain('## Project Analysis')
115104
expect(analysis).toContain('TypeScript/JavaScript/JSON files')
116105
expect(typeof analysis).toBe('string')
117106
})
118107

119108
it('should generate mock dependency analysis', async () => {
120-
const analysis = await generateMockDependencyAnalysis(mockWs)
109+
const analysis = await generateMockDependencyAnalysis()
121110

122111
expect(analysis).toContain('## Dependency Analysis')
123112
expect(analysis).toContain('Declared Dependencies')
124113
expect(typeof analysis).toBe('string')
125114
})
126115

127116
it('should handle error scenarios in mock generators', async () => {
128-
const errorAnalysis = await generateMockProjectStructureAnalysis(
129-
mockWs,
130-
true,
131-
)
117+
const errorAnalysis = await generateMockProjectStructureAnalysis(true)
132118

133119
expect(errorAnalysis).toContain('Project analysis failed')
134120
expect(typeof errorAnalysis).toBe('string')
@@ -141,7 +127,6 @@ describe('Backend Tool Call Schema', () => {
141127
* based on the current context or user request
142128
*/
143129
export async function generateMockProjectStructureAnalysis(
144-
ws: WebSocket,
145130
simulateError: boolean = false,
146131
): Promise<string> {
147132
try {
@@ -228,7 +213,6 @@ export async function generateMockProjectStructureAnalysis(
228213
* Dynamically searches for imports and analyzes dependencies
229214
*/
230215
export async function generateMockDependencyAnalysis(
231-
ws: WebSocket,
232216
searchPattern?: string,
233217
): Promise<string> {
234218
try {

0 commit comments

Comments
 (0)