@@ -427,8 +427,7 @@ test('Updates pageload transaction name correctly when span is cancelled early (
427427 // Check if the span was indeed cancelled (should have idle_span_finish_reason attribute)
428428 const idleSpanFinishReason = event . contexts ?. trace ?. data ?. [ 'sentry.idle_span_finish_reason' ] ;
429429 if ( idleSpanFinishReason ) {
430- // If the span was cancelled due to visibility change, verify it still got the right name
431- expect ( [ 'externalFinish' , 'cancelled' ] ) . toContain ( idleSpanFinishReason ) ;
430+ expect ( [ 'externalFinish' , 'cancelled' , 'idleTimeout' ] ) . toContain ( idleSpanFinishReason ) ;
432431 }
433432} ) ;
434433
@@ -498,7 +497,7 @@ test('Updates navigation transaction name correctly when span is cancelled early
498497 }
499498
500499 if ( idleSpanFinishReason ) {
501- expect ( [ 'externalFinish' , 'cancelled' ] ) . toContain ( idleSpanFinishReason ) ;
500+ expect ( [ 'externalFinish' , 'cancelled' , 'idleTimeout' ] ) . toContain ( idleSpanFinishReason ) ;
502501 }
503502} ) ;
504503
@@ -1034,9 +1033,11 @@ test('Three-route rapid navigation preserves distinct transaction names', async
10341033 await slowFetchLink . click ( ) ;
10351034 await page . waitForTimeout ( 150 ) ;
10361035
1037- // Navigate to another-lazy before slow-fetch resolves
1038- const anotherLazyLink = page . locator ( 'id=delayed-lazy-to-another-lazy' ) ;
1039- await anotherLazyLink . click ( ) ;
1036+ // Navigate to another-lazy before slow-fetch resolves.
1037+ // Use programmatic navigation because the delayed-lazy page may have
1038+ // already unmounted (the /slow-fetch route has no element).
1039+ // eslint-disable-next-line no-restricted-globals
1040+ await page . evaluate ( ( ) => ( window as any ) . __REACT_ROUTER__ . navigate ( '/another-lazy/sub' ) ) ;
10401041
10411042 await expect ( page . locator ( 'id=another-lazy-route' ) ) . toBeVisible ( { timeout : 10000 } ) ;
10421043 await page . waitForTimeout ( 2000 ) ;
@@ -1241,8 +1242,8 @@ test('Slow lazy route pageload with early span end still gets parameterized rout
12411242 ) ;
12421243 } ) ;
12431244
1244- // idleTimeout=300 ends span before 500ms lazy route loads, timeout=1000 waits for lazy routes
1245- await page . goto ( '/slow-fetch/123?idleTimeout=300&timeout=1000 ' ) ;
1245+ // idleTimeout=300 ends span before 500ms lazy route loads
1246+ await page . goto ( '/slow-fetch/123?idleTimeout=300' ) ;
12461247
12471248 const event = await transactionPromise ;
12481249
@@ -1255,60 +1256,6 @@ test('Slow lazy route pageload with early span end still gets parameterized rout
12551256 expect ( [ 'idleTimeout' , 'externalFinish' ] ) . toContain ( idleSpanFinishReason ) ;
12561257} ) ;
12571258
1258- // Regression: Wildcard route names should be upgraded to parameterized routes when lazy routes load
1259- test ( 'Wildcard route pageload gets upgraded to parameterized route name (regression)' , async ( { page } ) => {
1260- const transactionPromise = waitForTransaction ( 'react-router-7-lazy-routes' , async transactionEvent => {
1261- return (
1262- ! ! transactionEvent ?. transaction &&
1263- transactionEvent . contexts ?. trace ?. op === 'pageload' &&
1264- ( transactionEvent . transaction ?. startsWith ( '/wildcard-lazy' ) ?? false )
1265- ) ;
1266- } ) ;
1267-
1268- await page . goto ( '/wildcard-lazy/456?idleTimeout=300&timeout=1000' ) ;
1269-
1270- const event = await transactionPromise ;
1271-
1272- expect ( event . transaction ) . toBe ( '/wildcard-lazy/:id' ) ;
1273- expect ( event . type ) . toBe ( 'transaction' ) ;
1274- expect ( event . contexts ?. trace ?. op ) . toBe ( 'pageload' ) ;
1275- expect ( event . contexts ?. trace ?. data ?. [ 'sentry.source' ] ) . toBe ( 'route' ) ;
1276- } ) ;
1277-
1278- // Regression: Navigation to slow lazy route should get parameterized name even if span ends early.
1279- // Network activity from dynamic imports extends the idle timeout until lazy routes load.
1280- test ( 'Slow lazy route navigation with early span end still gets parameterized route name (regression)' , async ( {
1281- page,
1282- } ) => {
1283- // Configure short idle timeout (300ms) but longer lazy route timeout (1000ms)
1284- await page . goto ( '/?idleTimeout=300&timeout=1000' ) ;
1285-
1286- // Wait for pageload to complete
1287- await page . waitForTimeout ( 500 ) ;
1288-
1289- const navigationPromise = waitForTransaction ( 'react-router-7-lazy-routes' , async transactionEvent => {
1290- return (
1291- ! ! transactionEvent ?. transaction &&
1292- transactionEvent . contexts ?. trace ?. op === 'navigation' &&
1293- ( transactionEvent . transaction ?. startsWith ( '/wildcard-lazy' ) ?? false )
1294- ) ;
1295- } ) ;
1296-
1297- // Navigate to wildcard-lazy route (500ms delay in module via top-level await)
1298- // The dynamic import creates network activity that extends the span lifetime
1299- const wildcardLazyLink = page . locator ( 'id=navigation-to-wildcard-lazy' ) ;
1300- await expect ( wildcardLazyLink ) . toBeVisible ( ) ;
1301- await wildcardLazyLink . click ( ) ;
1302-
1303- const event = await navigationPromise ;
1304-
1305- // The navigation transaction should have the parameterized route name
1306- expect ( event . transaction ) . toBe ( '/wildcard-lazy/:id' ) ;
1307- expect ( event . type ) . toBe ( 'transaction' ) ;
1308- expect ( event . contexts ?. trace ?. op ) . toBe ( 'navigation' ) ;
1309- expect ( event . contexts ?. trace ?. data ?. [ 'sentry.source' ] ) . toBe ( 'route' ) ;
1310- } ) ;
1311-
13121259test ( 'Captured navigation context is used instead of stale window.location during rapid navigation' , async ( {
13131260 page,
13141261} ) => {
@@ -1437,7 +1384,7 @@ test('Second navigation span is not corrupted by first slow lazy handler complet
14371384// lazyRouteManifest: provides parameterized name when lazy routes don't resolve in time
14381385test ( 'Route manifest provides correct name when navigation span ends before lazy route resolves' , async ( { page } ) => {
14391386 // Short idle timeout (50ms) ensures span ends before lazy route (500ms) resolves
1440- await page . goto ( '/?idleTimeout=50&timeout=0 ' ) ;
1387+ await page . goto ( '/?idleTimeout=50' ) ;
14411388
14421389 // Wait for pageload to complete
14431390 await page . waitForTimeout ( 200 ) ;
@@ -1474,7 +1421,7 @@ test('Route manifest provides correct name when pageload span ends before lazy r
14741421 ) ;
14751422 } ) ;
14761423
1477- await page . goto ( '/wildcard-lazy/123?idleTimeout=50&timeout=0 ' ) ;
1424+ await page . goto ( '/wildcard-lazy/123?idleTimeout=50' ) ;
14781425
14791426 const event = await pageloadPromise ;
14801427
0 commit comments