@@ -23,6 +23,37 @@ test('Creates a pageload transaction with parameterized route', async ({ page })
2323 expect ( event . contexts ?. trace ?. op ) . toBe ( 'pageload' ) ;
2424} ) ;
2525
26+ test ( 'Does not create a navigation transaction on initial load to deep lazy route' , async ( { page } ) => {
27+ const navigationPromise = waitForTransaction ( 'react-router-7-lazy-routes' , async transactionEvent => {
28+ return ! ! transactionEvent ?. transaction && transactionEvent . contexts ?. trace ?. op === 'navigation' ;
29+ } ) ;
30+
31+ const pageloadPromise = waitForTransaction ( 'react-router-7-lazy-routes' , async transactionEvent => {
32+ return (
33+ ! ! transactionEvent ?. transaction &&
34+ transactionEvent . contexts ?. trace ?. op === 'pageload' &&
35+ transactionEvent . transaction === '/lazy/inner/:id/:anotherId/:someAnotherId'
36+ ) ;
37+ } ) ;
38+
39+ await page . goto ( '/lazy/inner/1/2/3' ) ;
40+
41+ const pageloadEvent = await pageloadPromise ;
42+
43+ expect ( pageloadEvent . transaction ) . toBe ( '/lazy/inner/:id/:anotherId/:someAnotherId' ) ;
44+
45+ const lazyRouteContent = page . locator ( 'id=innermost-lazy-route' ) ;
46+ await expect ( lazyRouteContent ) . toBeVisible ( ) ;
47+
48+ // "Race" between navigation transaction and a timeout to ensure no navigation transaction is created within the timeout period
49+ const result = await Promise . race ( [
50+ navigationPromise . then ( ( ) => 'navigation' ) ,
51+ new Promise < 'timeout' > ( resolve => setTimeout ( ( ) => resolve ( 'timeout' ) , 1500 ) ) ,
52+ ] ) ;
53+
54+ expect ( result ) . toBe ( 'timeout' ) ;
55+ } ) ;
56+
2657test ( 'Creates a navigation transaction inside a lazy route' , async ( { page } ) => {
2758 const transactionPromise = waitForTransaction ( 'react-router-7-lazy-routes' , async transactionEvent => {
2859 return (
0 commit comments