44
55import { loggerMock } from '@sim/testing'
66import { beforeEach , describe , expect , it , vi } from 'vitest'
7+ import { TOOL_RESULT_MAX_INLINE_CHARS } from '@/lib/copilot/constants'
78
89const { getOrMaterializeVFS } = vi . hoisted ( ( ) => ( {
910 getOrMaterializeVFS : vi . fn ( ) ,
@@ -24,6 +25,8 @@ vi.mock('./upload-file-reader', () => ({
2425
2526import { executeVfsGrep , executeVfsRead } from './vfs'
2627
28+ const OVERSIZED_INLINE_CONTENT = 'x' . repeat ( TOOL_RESULT_MAX_INLINE_CHARS + 1 )
29+
2730function makeVfs ( ) {
2831 return {
2932 grep : vi . fn ( ) ,
@@ -40,10 +43,7 @@ describe('vfs handlers oversize policy', () => {
4043
4144 it ( 'fails oversized grep results with narrowing guidance' , async ( ) => {
4245 const vfs = makeVfs ( )
43- vfs . grep . mockReturnValue ( [
44- { path : 'files/a.txt' , line : 1 , content : 'a' . repeat ( 60_000 ) } ,
45- { path : 'files/b.txt' , line : 2 , content : 'b' . repeat ( 60_000 ) } ,
46- ] )
46+ vfs . grep . mockReturnValue ( [ { path : 'files/a.txt' , line : 1 , content : OVERSIZED_INLINE_CONTENT } ] )
4747 getOrMaterializeVFS . mockResolvedValue ( vfs )
4848
4949 const result = await executeVfsGrep (
@@ -57,7 +57,7 @@ describe('vfs handlers oversize policy', () => {
5757
5858 it ( 'fails oversized read results with grep guidance' , async ( ) => {
5959 const vfs = makeVfs ( )
60- vfs . read . mockReturnValue ( { content : 'a' . repeat ( 100_001 ) , totalLines : 1 } )
60+ vfs . read . mockReturnValue ( { content : OVERSIZED_INLINE_CONTENT , totalLines : 1 } )
6161 getOrMaterializeVFS . mockResolvedValue ( vfs )
6262
6363 const result = await executeVfsRead (
0 commit comments