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