@@ -325,7 +325,7 @@ describe("makeMcpAppHost", () => {
325325
326326 it ( "forwards model context and download requests, and declares both" , async ( ) => {
327327 const contexts : Array < unknown > = [ ] ;
328- const downloads : Array < unknown > = [ ] ;
328+ const downloads : Array < ReadonlyArray < { readonly name : string } > > = [ ] ;
329329 const { host, sent } = setup ( {
330330 updateModelContext : async ( update ) => void contexts . push ( update ) ,
331331 downloadFile : async ( files ) => {
@@ -349,6 +349,7 @@ describe("makeMcpAppHost", () => {
349349 structuredContent : { overdue : 2 , since : undefined } ,
350350 } ,
351351 } ) ;
352+ const longName = `${ "a" . repeat ( 199 ) } 😀.csv` ;
352353 const embedded = {
353354 type : "resource" ,
354355 resource : { uri : "file:///report.csv" , mimeType : "text/csv" , text : "a,b" } ,
@@ -364,7 +365,7 @@ describe("makeMcpAppHost", () => {
364365 id : 3 ,
365366 method : "ui/download-file" ,
366367 params : {
367- contents : [ embedded , { type : "resource_link" , uri : "ui://todos/export" , name : "x" } ] ,
368+ contents : [ embedded , { type : "resource_link" , uri : "ui://todos/export" , name : longName } ] ,
368369 } ,
369370 } ) ;
370371 host . receive ( { jsonrpc : "2.0" , id : 4 , method : "ui/download-file" , params : { contents : [ { } ] } } ) ;
@@ -380,6 +381,9 @@ describe("makeMcpAppHost", () => {
380381 bytes : new TextEncoder ( ) . encode ( "a,b" ) ,
381382 } ,
382383 ] ) ;
384+ const capped = downloads [ 1 ] ?. [ 1 ] ?. name ?? "" ;
385+ expect ( capped . length ) . toBeLessThanOrEqual ( 200 ) ;
386+ expect ( capped . isWellFormed ( ) ) . toBe ( true ) ;
383387 expect ( sent . find ( ( m ) => m . id === 2 ) ?. result ) . toEqual ( { } ) ;
384388 expect ( sent . find ( ( m ) => m . id === 3 ) ?. result ) . toEqual ( { isError : true } ) ;
385389 expect ( sent . find ( ( m ) => m . id === 4 ) ?. error ) . toMatchObject ( { code : - 32602 } ) ;
0 commit comments