@@ -162,7 +162,7 @@ describe("MCP App UI resources", () => {
162162 releases . slice ( 1 ) . forEach ( ( entry ) => entry ( ) ) ;
163163 } ) ;
164164
165- it ( "normalizes CSP metadata before retaining the view" , async ( ) => {
165+ it ( "normalizes CSP and snapshots the session deadline before retaining the view" , async ( ) => {
166166 const sessionRuntime = runtime ( async ( ) => ( {
167167 contents : [
168168 {
@@ -180,6 +180,10 @@ describe("MCP App UI resources", () => {
180180 } ,
181181 ] ,
182182 } ) ) ;
183+ const peekCatalog = vi . fn ( ( ) => null ) ;
184+ sessionRuntime . peekCatalog = peekCatalog ;
185+ sessionRuntime . getServerRequestTimeoutMs = ( serverName ) =>
186+ serverName === "demo" ? 120_000 : undefined ;
183187 const result = await fetchMcpAppView ( {
184188 runtime : sessionRuntime ,
185189 serverName : "demo" ,
@@ -194,6 +198,8 @@ describe("MCP App UI resources", () => {
194198 resourceDomains : [ "https://cdn.example.com" ] ,
195199 } ) ;
196200 expect ( view ?. html . startsWith ( "<!doctype html>" ) ) . toBe ( true ) ;
201+ expect ( view ?. requestTimeoutMs ) . toBe ( 120_000 ) ;
202+ expect ( peekCatalog ) . not . toHaveBeenCalled ( ) ;
197203 expect ( buildMcpAppSandboxPath ( view ?. csp ) ) . toContain ( "?csp=" ) ;
198204 } ) ;
199205
@@ -295,38 +301,6 @@ describe("MCP App UI resources", () => {
295301 expect ( getMcpAppViewLease ( viewIds [ 31 ] ?? "" , sessionRuntime ) ) . toBeDefined ( ) ;
296302 } ) ;
297303
298- it ( "reads the request timeout from the runtime session when the cached catalog is null" , async ( ) => {
299- const sessionRuntime = runtime ( async ( ) => ( {
300- contents : [
301- {
302- uri : "ui://demo/app" ,
303- mimeType : MCP_APP_RESOURCE_MIME_TYPE ,
304- text : "<html>demo</html>" ,
305- _meta : { ui : { csp : { connectDomains : [ "https://api.example.com" ] } } } ,
306- } ,
307- ] ,
308- } ) ) ;
309- // Simulate catalog invalidation (peekCatalog returns null) while the session
310- // still has the configured timeout.
311- sessionRuntime . peekCatalog = ( ) => null ;
312- sessionRuntime . getServerRequestTimeoutMs = ( serverName ) =>
313- serverName === "demo" ? 120_000 : undefined ;
314-
315- const result = await fetchMcpAppView ( {
316- runtime : sessionRuntime ,
317- serverName : "demo" ,
318- toolName : "show" ,
319- uiResourceUri : "ui://demo/app" ,
320- toolInput : { } ,
321- toolResult : { content : [ ] } ,
322- } ) ;
323- expect ( result ) . toBeDefined ( ) ;
324-
325- const lease = getMcpAppViewLease ( result ! . viewId , sessionRuntime ) ;
326- expect ( lease ) . toBeDefined ( ) ;
327- expect ( lease ! . requestTimeoutMs ) . toBe ( 120_000 ) ;
328- } ) ;
329-
330304 it ( "replaces a reconstructed view id without leaking the previous runtime lease" , async ( ) => {
331305 const releases = [ vi . fn ( ) , vi . fn ( ) ] ;
332306 const sessionRuntime = runtime ( async ( ) => ( {
0 commit comments