@@ -2621,4 +2621,39 @@ describe("structuredContent", () => {
26212621 expect ( payload . issue . queryPattern ) . toBe ( "SELECT * FROM users WHERE id = ?" ) ;
26222622 expect ( payload . issue . location ) . toBe ( "/api/checkout" ) ;
26232623 } ) ;
2624+
2625+ it ( "caps related replays and reports the full count" , async ( ) => {
2626+ // a real issue came back with 51 of these
2627+ const many = Array . from ( { length : 51 } , ( _ , i ) =>
2628+ i . toString ( 16 ) . padStart ( 32 , "0" ) ,
2629+ ) ;
2630+ mswServer . use (
2631+ http . get (
2632+ "https://sentry.io/api/0/organizations/sentry-mcp-evals/issues/CLOUDFLARE-MCP-41/events/latest/" ,
2633+ ( ) =>
2634+ HttpResponse . json ( {
2635+ ...createDefaultEvent ( ) ,
2636+ formatted : { format : "json" , content : FORMATTER_JSON } ,
2637+ } ) ,
2638+ ) ,
2639+ // related ids come from replay-count, keyed by numeric issue id. Echo back whichever
2640+ // id was asked for: a preceding test can leave a different issue fixture registered.
2641+ http . get (
2642+ "https://sentry.io/api/0/organizations/sentry-mcp-evals/replay-count/" ,
2643+ ( { request } ) => {
2644+ const query = new URL ( request . url ) . searchParams . get ( "query" ) ?? "" ;
2645+ const issueId = query . match ( / i s s u e \. i d : \[ ( \d + ) \] / ) ?. [ 1 ] ;
2646+ return HttpResponse . json ( issueId ? { [ issueId ] : many } : { } ) ;
2647+ } ,
2648+ ) ,
2649+ ) ;
2650+
2651+ const result = await getIssueDetails . handler ( params , baseContext ) ;
2652+ const payload = ( result as { structuredContent : Record < string , any > } )
2653+ . structuredContent ;
2654+
2655+ expect ( payload . replays ) . not . toBeNull ( ) ;
2656+ expect ( payload . replays . relatedCount ) . toBe ( 51 ) ;
2657+ expect ( payload . replays . related ) . toHaveLength ( 5 ) ;
2658+ } ) ;
26242659} ) ;
0 commit comments