Skip to content

Commit d0af0d4

Browse files
committed
debug rr routing (children index route)
1 parent f2a1581 commit d0af0d4

File tree

9 files changed

+860
-5
lines changed

9 files changed

+860
-5
lines changed

dev-packages/e2e-tests/test-applications/react-router-7-cross-usage/src/index.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,14 @@ const ProjectsRoutes = () => (
8989
);
9090

9191
const router = sentryCreateBrowserRouter([
92+
{
93+
path: '/post/:post',
94+
element: <div>Post</div>,
95+
children: [
96+
{ index: true, element: <div>Post Index</div> },
97+
{ path: '/post/:post/related', element: <div>Related Posts</div> },
98+
],
99+
},
92100
{
93101
children: [
94102
{
@@ -103,5 +111,7 @@ const router = sentryCreateBrowserRouter([
103111
},
104112
]);
105113

114+
console.log('router::', router);
115+
106116
const root = ReactDOM.createRoot(document.getElementById('root') as HTMLElement);
107117
root.render(<RouterProvider router={router} />);

dev-packages/e2e-tests/test-applications/react-router-7-cross-usage/tests/transactions.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { expect, test } from '@playwright/test';
22
import { waitForTransaction } from '@sentry-internal/test-utils';
33

44
test('sends a pageload transaction with a parameterized URL', async ({ page }) => {
5+
page.on('console', msg => console.log(msg.text()));
6+
57
const transactionPromise = waitForTransaction('react-router-7-cross-usage', async transactionEvent => {
68
return !!transactionEvent?.transaction && transactionEvent.contexts?.trace?.op === 'pageload';
79
});
Lines changed: 258 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,258 @@
1+
## Expected Outcome
2+
3+
It should work with index routes inside the children routes
4+
5+
## Scenario
6+
7+
- no recursion
8+
```ts
9+
export function addRoutesToAllRoutes(routes: RouteObject[]): void {
10+
console.log('routes to add to allRoutes::', JSON.stringify(routes));
11+
routes.forEach(route => {
12+
if (!allRoutes.has(route)) {
13+
allRoutes.add(route);
14+
}
15+
});
16+
}
17+
```
18+
- no index route
19+
```ts
20+
{
21+
path: '/post/:post',
22+
element: <div>Post</div>,
23+
children: [
24+
// { index: true, element: <div>Post Index</div> },
25+
{ path: '/post/:post/related', element: <div>Related Posts</div> },
26+
],
27+
},
28+
```
29+
30+
## Logs during E2E test
31+
32+
Running 4 tests using 1 worker
33+
34+
createV6CompatibleWrapCreateBrowserRouter - routes:: [{"path":"/post/:post","element":{"type":"div","key":null,"ref":null,"props":{"children":"Post"},"\_owner":null},"children":[{"path":"/post/:post/related","element":{"type":"div","key":null,"ref":null,"props":{"children":"Related Posts"},"_owner":null}}]},{"children":[{"path":"/","element":{"key":null,"ref":null,"props":{},"_owner":null}},{"path":"/*","element":{"key":null,"ref":null,"props":{},"_owner":null}}]}]
35+
36+
routes to add to allRoutes:: [{"path":"/post/:post","element":{"type":"div","key":null,"ref":null,"props":{"children":"Post"},"\_owner":null},"children":[{"path":"/post/:post/related","element":{"type":"div","key":null,"ref":null,"props":{"children":"Related Posts"},"_owner":null}}]},{"children":[{"path":"/","element":{"key":null,"ref":null,"props":{},"_owner":null}},{"path":"/*","element":{"key":null,"ref":null,"props":{},"_owner":null}}]}]
37+
38+
updatePageloadTransaction::
39+
40+
isInDescendantRoute:: true
41+
42+
rebuildRoutePathFromAllRoutes matched: {pathname: /projects/123/views/234/567, search: , hash: , state: null, key: default} [{"params":{"_":"projects/123/views/234/567"},"pathname":"/","pathnameBase":"/","route":{"children":[{"path":"/","element":{"key":null,"ref":null,"props":{},"\_owner":null}},{"path":"/_","element":{"key":null,"ref":null,"props":{},"\_owner":null}}]}},{"params":{"_":"projects/123/views/234/567"},"pathname":"/projects/123/views/234/567","pathnameBase":"/","route":{"path":"/_","element":{"key":null,"ref":null,"props":{},"\_owner":null}}}]
43+
44+
desc: name:: /projects/123/views/234/567 source:: route
45+
46+
router:: {basename: undefined, future: undefined, state: undefined, routes: undefined, window: undefined}
47+
48+
routes to add to allRoutes:: [{"path":":detailId","element":{"type":"div","key":null,"ref":null,"props":{"id":"details","children":"Details"},"_owner":null}}]
49+
50+
updatePageloadTransaction::
51+
52+
isInDescendantRoute:: true
53+
54+
rebuildRoutePathFromAllRoutes matched: {pathname: /projects/123/views/234/567, search: , hash: , state: null, key: default} [{"params":{"_":"projects/123/views/234/567"},"pathname":"/","pathnameBase":"/","route":{"children":[{"path":"/","element":{"key":null,"ref":null,"props":{},"\_owner":null}},{"path":"/_","element":{"key":null,"ref":null,"props":{},"\_owner":null}}]}},{"params":{"_":"projects/123/views/234/567"},"pathname":"/projects/123/views/234/567","pathnameBase":"/","route":{"path":"/_","element":{"key":null,"ref":null,"props":{},"\_owner":null}}}]
55+
desc: name:: /projects/123/views/234/567 source:: route
56+
57+
routes to add to allRoutes:: [{"index":true,"element":{"type":"div","key":null,"ref":null,"props":{"id":"views","children":"Views"},"_owner":null}},{"path":"views/:viewId/*","element":{"key":null,"ref":null,"props":{},"_owner":null}},{"path":"old-views/:viewId/*","element":{"key":null,"ref":null,"props":{},"_owner":null}}]
58+
59+
updatePageloadTransaction::
60+
isInDescendantRoute:: true
61+
rebuildRoutePathFromAllRoutes matched: {pathname: /projects/123/views/234/567, search: , hash: , state: null, key: default} [{"params":{"_":"projects/123/views/234/567"},"pathname":"/","pathnameBase":"/","route":{"children":[{"path":"/","element":{"key":null,"ref":null,"props":{},"\_owner":null}},{"path":"/_","element":{"key":null,"ref":null,"props":{},"\_owner":null}}]}},{"params":{"_":"projects/123/views/234/567"},"pathname":"/projects/123/views/234/567","pathnameBase":"/","route":{"path":"/_","element":{"key":null,"ref":null,"props":{},"\_owner":null}}}]
62+
63+
desc: name:: /projects/123/views/234/567 source:: route
64+
65+
routesFromChildren:: [{"id":"0","element":{"key":null,"ref":null,"props":{},"\_owner":null},"path":"projects","hasErrorBoundary":false,"children":[{"id":"0-0","element":{"type":"div","key":null,"ref":null,"props":{"children":"Project Page Root"},"\_owner":null},"index":true,"hasErrorBoundary":false},{"id":"0-1","element":{"key":null,"ref":null,"props":{},"\_owner":null},"path":"_","hasErrorBoundary":false,"children":[{"id":"0-1-0","element":{"key":null,"ref":null,"props":{},"\_owner":null},"path":":projectId/_","hasErrorBoundary":false}]}]}]
66+
67+
routes to add to allRoutes:: [{"id":"0","element":{"key":null,"ref":null,"props":{},"\_owner":null},"path":"projects","hasErrorBoundary":false,"children":[{"id":"0-0","element":{"type":"div","key":null,"ref":null,"props":{"children":"Project Page Root"},"\_owner":null},"index":true,"hasErrorBoundary":false},{"id":"0-1","element":{"key":null,"ref":null,"props":{},"\_owner":null},"path":"_","hasErrorBoundary":false,"children":[{"id":"0-1-0","element":{"key":null,"ref":null,"props":{},"\_owner":null},"path":":projectId/_","hasErrorBoundary":false}]}]}]
68+
updatePageloadTransaction::
69+
70+
isInDescendantRoute:: true
71+
72+
rebuildRoutePathFromAllRoutes matched: {pathname: /projects/123/views/234/567, search: , hash: , state: null, key: default} [{"params":{"_":"views/234/567","projectId":"123"},"pathname":"/projects","pathnameBase":"/projects","route":{"id":"0","element":{"key":null,"ref":null,"props":{},"\_owner":null},"path":"projects","hasErrorBoundary":false,"children":[{"id":"0-0","element":{"type":"div","key":null,"ref":null,"props":{"children":"Project Page Root"},"\_owner":null},"index":true,"hasErrorBoundary":false},{"id":"0-1","element":{"key":null,"ref":null,"props":{},"\_owner":null},"path":"_","hasErrorBoundary":false,"children":[{"id":"0-1-0","element":{"key":null,"ref":null,"props":{},"_owner":null},"path":":projectId/*","hasErrorBoundary":false}]}]}},{"params":{"_":"views/234/567","projectId":"123"},"pathname":"/projects/123/views/234/567","pathnameBase":"/projects","route":{"id":"0-1","element":{"key":null,"ref":null,"props":{},"\_owner":null},"path":"_","hasErrorBoundary":false,"children":[{"id":"0-1-0","element":{"key":null,"ref":null,"props":{},"_owner":null},"path":":projectId/*","hasErrorBoundary":false}]}},{"params":{"_":"views/234/567","projectId":"123"},"pathname":"/projects/123/views/234/567","pathnameBase":"/projects/123","route":{"id":"0-1-0","element":{"key":null,"ref":null,"props":{},"\_owner":null},"path":":projectId/_","hasErrorBoundary":false}}]
73+
74+
rebuildRoutePathFromAllRoutes matched: {pathname: /123/views/234/567} [{"params":{"_":"123/views/234/567"},"pathname":"/","pathnameBase":"/","route":{"children":[{"path":"/","element":{"key":null,"ref":null,"props":{},"\_owner":null}},{"path":"/_","element":{"key":null,"ref":null,"props":{},"\_owner":null}}]}},{"params":{"_":"123/views/234/567"},"pathname":"/123/views/234/567","pathnameBase":"/","route":{"path":"/_","element":{"key":null,"ref":null,"props":{},"\_owner":null}}}]
75+
76+
desc: name:: /projects/123/views/234/567 source:: route
77+
78+
✘ 1 [chromium] › tests/transactions.test.ts:4:5 › sends a pageload transaction with a parameterized URL (1.3s)
79+
80+
✘ 2 [chromium] › tests/transactions.test.ts:30:5 › sends a pageload transaction with a parameterized URL - alternative route (1.2s)
81+
82+
✘ 3 [chromium] › tests/transactions.test.ts:54:5 › sends a navigation transaction with a parameterized URL (2.3s)
83+
84+
✘ 4 [chromium] › tests/transactions.test.ts:98:5 › sends a navigation transaction with a parameterized URL - alternative route (2.3s)
85+
86+
1. [chromium] › tests/transactions.test.ts:4:5 › sends a pageload transaction with a parameterized URL
87+
88+
Error: expect(received).toMatchObject(expected)
89+
- Expected - 1
90+
* Received + 1
91+
92+
@@ -3,10 +3,10 @@
93+
"trace": Object {
94+
"op": "pageload",
95+
"origin": "auto.pageload.react.reactrouter_v7",
96+
},
97+
},
98+
- "transaction": "/projects/:projectId/views/:viewId/:detailId",
99+
* "transaction": "/projects/123/views/234/567",
100+
"transaction_info": Object {
101+
"source": "route",
102+
},
103+
}
104+
105+
14 |
106+
15 | expect((await page.innerHTML('#root')).includes('Details')).toBe(true);
107+
108+
> 16 | expect(rootSpan).toMatchObject({
109+
110+
| ^
111+
112+
17 | contexts: {
113+
18 | trace: {
114+
19 | op: 'pageload',
115+
at /private/var/folders/zg/3jx06d797kv5pggvpxj2bc540000gn/T/sentry-e2e-tests-react-router-7-cross-usage-mSvGiI/tests/transactions.test.ts:16:20
116+
117+
Error Context: test-results/transactions-sends-a-pagel-84aa8-on-with-a-parameterized-URL-chromium/error-context.md
118+
119+
attachment #2: trace (application/zip) ─────────────────────────────────────────────────────────
120+
test-results/transactions-sends-a-pagel-84aa8-on-with-a-parameterized-URL-chromium/trace.zip
121+
Usage:
122+
123+
pnpm exec playwright show-trace test-results/transactions-sends-a-pagel-84aa8-on-with-a-parameterized-URL-chromium/trace.zip
124+
125+
────────────────────────────────────────────────────────────────────────────────────────────────
126+
127+
2. [chromium] › tests/transactions.test.ts:30:5 › sends a pageload transaction with a parameterized URL - alternative route
128+
129+
Error: expect(received).toMatchObject(expected)
130+
- Expected - 1
131+
* Received + 1
132+
133+
@@ -3,10 +3,10 @@
134+
"trace": Object {
135+
"op": "pageload",
136+
"origin": "auto.pageload.react.reactrouter_v7",
137+
},
138+
},
139+
- "transaction": "/projects/:projectId/old-views/:viewId/:detailId",
140+
* "transaction": "/projects/234/old-views/234/567",
141+
"transaction_info": Object {
142+
"source": "route",
143+
},
144+
}
145+
146+
38 |
147+
39 | expect((await page.innerHTML('#root')).includes('Details')).toBe(true);
148+
149+
> 40 | expect(rootSpan).toMatchObject({
150+
151+
| ^
152+
153+
41 | contexts: {
154+
42 | trace: {
155+
43 | op: 'pageload',
156+
at /private/var/folders/zg/3jx06d797kv5pggvpxj2bc540000gn/T/sentry-e2e-tests-react-router-7-cross-usage-mSvGiI/tests/transactions.test.ts:40:20
157+
158+
Error Context: test-results/transactions-sends-a-pagel-f5147-zed-URL---alternative-route-chromium/error-context.md
159+
160+
attachment #2: trace (application/zip) ─────────────────────────────────────────────────────────
161+
test-results/transactions-sends-a-pagel-f5147-zed-URL---alternative-route-chromium/trace.zip
162+
Usage:
163+
164+
pnpm exec playwright show-trace test-results/transactions-sends-a-pagel-f5147-zed-URL---alternative-route-chromium/trace.zip
165+
166+
────────────────────────────────────────────────────────────────────────────────────────────────
167+
168+
3. [chromium] › tests/transactions.test.ts:54:5 › sends a navigation transaction with a parameterized URL
169+
170+
Error: expect(received).toMatchObject(expected)
171+
- Expected - 1
172+
* Received + 1
173+
174+
@@ -3,10 +3,10 @@
175+
"trace": Object {
176+
"op": "navigation",
177+
"origin": "auto.navigation.react.reactrouter_v7",
178+
},
179+
},
180+
- "transaction": "/projects/:projectId/views/:viewId/:detailId",
181+
* "transaction": "/projects/123/views/456/789",
182+
"transaction_info": Object {
183+
"source": "route",
184+
},
185+
}
186+
187+
82 |
188+
83 | expect((await page.innerHTML('#root')).includes('Details')).toBe(true);
189+
190+
> 84 | expect(navigationTxn).toMatchObject({
191+
192+
| ^
193+
194+
85 | contexts: {
195+
86 | trace: {
196+
87 | op: 'navigation',
197+
at /private/var/folders/zg/3jx06d797kv5pggvpxj2bc540000gn/T/sentry-e2e-tests-react-router-7-cross-usage-mSvGiI/tests/transactions.test.ts:84:25
198+
199+
Error Context: test-results/transactions-sends-a-navig-fc4a1-on-with-a-parameterized-URL-chromium/error-context.md
200+
201+
attachment #2: trace (application/zip) ─────────────────────────────────────────────────────────
202+
test-results/transactions-sends-a-navig-fc4a1-on-with-a-parameterized-URL-chromium/trace.zip
203+
Usage:
204+
205+
pnpm exec playwright show-trace test-results/transactions-sends-a-navig-fc4a1-on-with-a-parameterized-URL-chromium/trace.zip
206+
207+
────────────────────────────────────────────────────────────────────────────────────────────────
208+
209+
4. [chromium] › tests/transactions.test.ts:98:5 › sends a navigation transaction with a parameterized URL - alternative route
210+
211+
Error: expect(received).toMatchObject(expected)
212+
- Expected - 1
213+
* Received + 1
214+
215+
@@ -3,10 +3,10 @@
216+
"trace": Object {
217+
"op": "navigation",
218+
"origin": "auto.navigation.react.reactrouter_v7",
219+
},
220+
},
221+
- "transaction": "/projects/:projectId/old-views/:viewId/:detailId",
222+
* "transaction": "/projects/123/old-views/345/654",
223+
"transaction_info": Object {
224+
"source": "route",
225+
},
226+
}
227+
228+
126 |
229+
127 | expect((await page.innerHTML('#root')).includes('Details')).toBe(true);
230+
231+
> 128 | expect(navigationTxn).toMatchObject({
232+
233+
| ^
234+
235+
129 | contexts: {
236+
130 | trace: {
237+
131 | op: 'navigation',
238+
at /private/var/folders/zg/3jx06d797kv5pggvpxj2bc540000gn/T/sentry-e2e-tests-react-router-7-cross-usage-mSvGiI/tests/transactions.test.ts:128:25
239+
240+
Error Context: test-results/transactions-sends-a-navig-c389f-zed-URL---alternative-route-chromium/error-context.md
241+
242+
attachment #2: trace (application/zip) ─────────────────────────────────────────────────────────
243+
test-results/transactions-sends-a-navig-c389f-zed-URL---alternative-route-chromium/trace.zip
244+
Usage:
245+
246+
pnpm exec playwright show-trace test-results/transactions-sends-a-navig-c389f-zed-URL---alternative-route-chromium/trace.zip
247+
248+
────────────────────────────────────────────────────────────────────────────────────────────────
249+
250+
4 failed
251+
[chromium] › tests/transactions.test.ts:4:5 › sends a pageload transaction with a parameterized URL
252+
[chromium] › tests/transactions.test.ts:30:5 › sends a pageload transaction with a parameterized URL - alternative route
253+
[chromium] › tests/transactions.test.ts:54:5 › sends a navigation transaction with a parameterized URL
254+
[chromium] › tests/transactions.test.ts:98:5 › sends a navigation transaction with a parameterized URL - alternative route
255+
256+
ELIFECYCLE  Test failed. See above for more details.
257+
258+
ELIFECYCLE  Command failed with exit code 1.

0 commit comments

Comments
 (0)