@@ -445,6 +445,43 @@ describe('File Parse API Route', () => {
445445 expect ( inputValidationMockFns . mockSecureFetchWithPinnedIP ) . toHaveBeenCalledTimes ( 1 )
446446 } )
447447
448+ it ( 'should include successful multi-file parse results when a later file exceeds the cap' , async ( ) => {
449+ inputValidationMockFns . mockValidateUrlWithDNS . mockResolvedValue ( {
450+ isValid : true ,
451+ resolvedIP : '203.0.113.10' ,
452+ } )
453+ inputValidationMockFns . mockSecureFetchWithPinnedIP . mockResolvedValue (
454+ new Response ( 'file content' , {
455+ status : 200 ,
456+ headers : { 'content-type' : 'text/plain' } ,
457+ } )
458+ )
459+
460+ mockParseBuffer
461+ . mockResolvedValueOnce ( {
462+ content : 'first file' ,
463+ metadata : { pageCount : 1 } ,
464+ } )
465+ . mockResolvedValueOnce ( {
466+ content : 'a' . repeat ( 5 * 1024 * 1024 ) ,
467+ metadata : { pageCount : 1 } ,
468+ } )
469+
470+ const req = createMockRequest ( 'POST' , {
471+ filePath : [ 'https://example.com/file1.txt' , 'https://example.com/file2.txt' ] ,
472+ } )
473+
474+ const response = await POST ( req )
475+ const data = await response . json ( )
476+
477+ expect ( response . status ) . toBe ( 413 )
478+ expect ( data . success ) . toBe ( false )
479+ expect ( data . error ) . toContain ( 'too large' )
480+ expect ( data . results ) . toHaveLength ( 1 )
481+ expect ( data . results [ 0 ] . output . content ) . toBe ( 'first file' )
482+ expect ( inputValidationMockFns . mockSecureFetchWithPinnedIP ) . toHaveBeenCalledTimes ( 2 )
483+ } )
484+
448485 it ( 'should pass custom headers when fetching external URLs' , async ( ) => {
449486 inputValidationMockFns . mockValidateUrlWithDNS . mockResolvedValue ( {
450487 isValid : true ,
0 commit comments