@@ -54,3 +54,111 @@ test('Creates a navigation transaction inside a lazy route', async ({ page }) =>
54
54
expect ( event . type ) . toBe ( 'transaction' ) ;
55
55
expect ( event . contexts ?. trace ?. op ) . toBe ( 'navigation' ) ;
56
56
} ) ;
57
+
58
+ test ( 'Creates navigation transactions between two different lazy routes' , async ( { page } ) => {
59
+ // First, navigate to the "another-lazy" route
60
+ const firstTransactionPromise = waitForTransaction ( 'react-router-7-lazy-routes' , async transactionEvent => {
61
+ return (
62
+ ! ! transactionEvent ?. transaction &&
63
+ transactionEvent . contexts ?. trace ?. op === 'navigation' &&
64
+ transactionEvent . transaction === '/another-lazy/sub/:id/:subId'
65
+ ) ;
66
+ } ) ;
67
+
68
+ await page . goto ( '/' ) ;
69
+
70
+ // Navigate to another lazy route first
71
+ const navigationToAnotherDeep = page . locator ( 'id=navigation-to-another-deep' ) ;
72
+ await expect ( navigationToAnotherDeep ) . toBeVisible ( ) ;
73
+ await navigationToAnotherDeep . click ( ) ;
74
+
75
+ const firstEvent = await firstTransactionPromise ;
76
+
77
+ // Check if the first lazy route content is rendered
78
+ const anotherLazyContent = page . locator ( 'id=another-lazy-route-deep' ) ;
79
+ await expect ( anotherLazyContent ) . toBeVisible ( ) ;
80
+
81
+ // Validate the first transaction event
82
+ expect ( firstEvent . transaction ) . toBe ( '/another-lazy/sub/:id/:subId' ) ;
83
+ expect ( firstEvent . type ) . toBe ( 'transaction' ) ;
84
+ expect ( firstEvent . contexts ?. trace ?. op ) . toBe ( 'navigation' ) ;
85
+
86
+ // Now navigate from the first lazy route to the second lazy route
87
+ const secondTransactionPromise = waitForTransaction ( 'react-router-7-lazy-routes' , async transactionEvent => {
88
+ return (
89
+ ! ! transactionEvent ?. transaction &&
90
+ transactionEvent . contexts ?. trace ?. op === 'navigation' &&
91
+ transactionEvent . transaction === '/lazy/inner/:id/:anotherId/:someAnotherId'
92
+ ) ;
93
+ } ) ;
94
+
95
+ // Click the navigation link from within the first lazy route to the second lazy route
96
+ const navigationToInnerFromDeep = page . locator ( 'id=navigate-to-inner-from-deep' ) ;
97
+ await expect ( navigationToInnerFromDeep ) . toBeVisible ( ) ;
98
+ await navigationToInnerFromDeep . click ( ) ;
99
+
100
+ const secondEvent = await secondTransactionPromise ;
101
+
102
+ // Check if the second lazy route content is rendered
103
+ const innerLazyContent = page . locator ( 'id=innermost-lazy-route' ) ;
104
+ await expect ( innerLazyContent ) . toBeVisible ( ) ;
105
+
106
+ // Validate the second transaction event
107
+ expect ( secondEvent . transaction ) . toBe ( '/lazy/inner/:id/:anotherId/:someAnotherId' ) ;
108
+ expect ( secondEvent . type ) . toBe ( 'transaction' ) ;
109
+ expect ( secondEvent . contexts ?. trace ?. op ) . toBe ( 'navigation' ) ;
110
+ } ) ;
111
+
112
+ test ( 'Creates navigation transactions from inner lazy route to another lazy route' , async ( { page } ) => {
113
+ // First, navigate to the inner lazy route
114
+ const firstTransactionPromise = waitForTransaction ( 'react-router-7-lazy-routes' , async transactionEvent => {
115
+ return (
116
+ ! ! transactionEvent ?. transaction &&
117
+ transactionEvent . contexts ?. trace ?. op === 'navigation' &&
118
+ transactionEvent . transaction === '/lazy/inner/:id/:anotherId/:someAnotherId'
119
+ ) ;
120
+ } ) ;
121
+
122
+ await page . goto ( '/' ) ;
123
+
124
+ // Navigate to inner lazy route first
125
+ const navigationToInner = page . locator ( 'id=navigation' ) ;
126
+ await expect ( navigationToInner ) . toBeVisible ( ) ;
127
+ await navigationToInner . click ( ) ;
128
+
129
+ const firstEvent = await firstTransactionPromise ;
130
+
131
+ // Check if the inner lazy route content is rendered
132
+ const innerLazyContent = page . locator ( 'id=innermost-lazy-route' ) ;
133
+ await expect ( innerLazyContent ) . toBeVisible ( ) ;
134
+
135
+ // Validate the first transaction event
136
+ expect ( firstEvent . transaction ) . toBe ( '/lazy/inner/:id/:anotherId/:someAnotherId' ) ;
137
+ expect ( firstEvent . type ) . toBe ( 'transaction' ) ;
138
+ expect ( firstEvent . contexts ?. trace ?. op ) . toBe ( 'navigation' ) ;
139
+
140
+ // Now navigate from the inner lazy route to another lazy route
141
+ const secondTransactionPromise = waitForTransaction ( 'react-router-7-lazy-routes' , async transactionEvent => {
142
+ return (
143
+ ! ! transactionEvent ?. transaction &&
144
+ transactionEvent . contexts ?. trace ?. op === 'navigation' &&
145
+ transactionEvent . transaction === '/another-lazy/sub/:id/:subId'
146
+ ) ;
147
+ } ) ;
148
+
149
+ // Click the navigation link from within the inner lazy route to another lazy route
150
+ const navigationToAnotherFromInner = page . locator ( 'id=navigate-to-another-from-inner' ) ;
151
+ await expect ( navigationToAnotherFromInner ) . toBeVisible ( ) ;
152
+ await navigationToAnotherFromInner . click ( ) ;
153
+
154
+ const secondEvent = await secondTransactionPromise ;
155
+
156
+ // Check if the another lazy route content is rendered
157
+ const anotherLazyContent = page . locator ( 'id=another-lazy-route-deep' ) ;
158
+ await expect ( anotherLazyContent ) . toBeVisible ( ) ;
159
+
160
+ // Validate the second transaction event
161
+ expect ( secondEvent . transaction ) . toBe ( '/another-lazy/sub/:id/:subId' ) ;
162
+ expect ( secondEvent . type ) . toBe ( 'transaction' ) ;
163
+ expect ( secondEvent . contexts ?. trace ?. op ) . toBe ( 'navigation' ) ;
164
+ } ) ;
0 commit comments