File tree Expand file tree Collapse file tree
apps/sim/app/api/tools/quickbooks Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -346,6 +346,28 @@ describe('QuickBooks document API routes', () => {
346346 )
347347 } )
348348
349+ it ( 'uses the binary fallback MIME type when an attachment response omits Content-Type' , async ( ) => {
350+ mockFetch . mockResolvedValueOnce (
351+ new Response ( 'https://intuit-download.example/attachment.bin' , {
352+ headers : { 'content-type' : 'text/plain' } ,
353+ } )
354+ )
355+ mockSecureFetchWithPinnedIP . mockResolvedValueOnce ( new Response ( new Uint8Array ( [ 1 , 2 , 3 ] ) ) )
356+
357+ const response = await downloadAttachment (
358+ createMockRequest ( 'POST' , { ...auth , attachmentId : '16' } )
359+ )
360+ const body = await response . json ( )
361+
362+ expect ( response . status ) . toBe ( 200 )
363+ expect ( body . output ) . toMatchObject ( {
364+ attachmentId : '16' ,
365+ fileName : 'attachment.bin' ,
366+ mimeType : 'application/octet-stream' ,
367+ size : 3 ,
368+ } )
369+ } )
370+
349371 it ( 'rejects note-only and oversized attachment downloads' , async ( ) => {
350372 mockFetch . mockResolvedValueOnce ( new Response ( '' ) )
351373 const note = await downloadAttachment (
Original file line number Diff line number Diff line change @@ -104,7 +104,7 @@ export const POST = withRouteHandler(async (request: NextRequest) => {
104104 } )
105105 if ( buffer . length === 0 ) throw new Error ( 'QuickBooks attachment file is empty' )
106106 const mimeType =
107- downloadResponse . headers . get ( 'content-type' ) ?. split ( ';' , 1 ) [ 0 ] . trim ( ) . toLowerCase ( ) ||
107+ downloadResponse . headers . get ( 'content-type' ) ?. split ( ';' , 1 ) [ 0 ] ? .trim ( ) . toLowerCase ( ) ||
108108 'application/octet-stream'
109109 let fallbackName = `quickbooks-attachment-${ attachmentId } `
110110 try {
You can’t perform that action at this time.
0 commit comments