Skip to content

Commit cec648e

Browse files
committed
add test case for deely nested route
1 parent 2a684f5 commit cec648e

File tree

3 files changed

+60
-9
lines changed

3 files changed

+60
-9
lines changed

dev-packages/e2e-tests/test-applications/react-create-hash-router/src/index.tsx

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,20 +62,26 @@ const router = sentryCreateHashRouter([
6262
element: <Group />,
6363
},
6464
{
65-
path: '/v2/post/:post',
66-
element: <Post />,
65+
path: '/v1/post/:post',
66+
element: <div />,
6767
children: [
68-
{ index: true, element: <PostIndex /> },
69-
{
70-
path: 'featured',
71-
element: <PostFeatured />,
72-
},
68+
{ path: 'featured', element: <div /> },
69+
{ path: '/v1/post/:post/related', element: <div /> },
7370
{
74-
path: '/v2/post/:post/related',
75-
element: <PostRelated />,
71+
element: <div>More Nested Children</div>,
72+
children: [{ path: 'edit', element: <div>Edit Post</div> }],
7673
},
7774
],
7875
},
76+
{
77+
path: '/v2/post/:post',
78+
element: <div />,
79+
children: [
80+
{ index: true, element: <div /> },
81+
{ path: 'featured', element: <div /> },
82+
{ path: '/v2/post/:post/related', element: <div /> },
83+
],
84+
},
7985
]);
8086

8187
console.log(router.routes);

dev-packages/e2e-tests/test-applications/react-create-hash-router/src/pages/Index.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ const Index = () => {
1818
<Link to="/v2/post/1" id="navigation-post-1">
1919
Post 1
2020
</Link>
21+
<Link to="/v1/post/1/edit" id="navigation-post-1-edit">
22+
Edit Post 1
23+
</Link>
2124
<Link to="/v2/post/1/featured" id="navigation-post-1-featured">
2225
Post 1 featured
2326
</Link>

dev-packages/e2e-tests/test-applications/react-create-hash-router/tests/transactions.test.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,26 @@ test('Captures a parameterized path pageload transaction for nested route', asyn
191191
);
192192
});
193193

194+
test('Captures a parameterized path pageload transaction for deeply nested route', async ({ page }) => {
195+
const transactionEventPromise = waitForTransaction('react-create-hash-router', event => {
196+
return event.contexts?.trace?.op === 'pageload';
197+
});
198+
199+
await page.goto('/#/v1/post/1/edit');
200+
201+
const transactionEvent = await transactionEventPromise;
202+
203+
expect(transactionEvent).toEqual(
204+
expect.objectContaining({
205+
transaction: '/v1/post/:post/edit',
206+
type: 'transaction',
207+
transaction_info: {
208+
source: 'route',
209+
},
210+
}),
211+
);
212+
});
213+
194214
test('Captures a parameterized path pageload transaction for nested route with absolute path', async ({ page }) => {
195215
const transactionEventPromise = waitForTransaction('react-create-hash-router', event => {
196216
return event.contexts?.trace?.op === 'pageload';
@@ -255,6 +275,28 @@ test('Captures a parameterized path navigation transaction for nested route', as
255275
);
256276
});
257277

278+
test('Captures a parameterized path navigation transaction for deeply nested route', async ({ page }) => {
279+
const transactionEventPromise = waitForTransaction('react-create-hash-router', event => {
280+
return event.contexts?.trace?.op === 'navigation';
281+
});
282+
283+
await page.goto('/');
284+
const linkElement = page.locator('id=navigation-post-1-edit');
285+
await linkElement.click();
286+
287+
const transactionEvent = await transactionEventPromise;
288+
289+
expect(transactionEvent).toEqual(
290+
expect.objectContaining({
291+
transaction: '/v1/post/:post/edit',
292+
type: 'transaction',
293+
transaction_info: {
294+
source: 'route',
295+
},
296+
}),
297+
);
298+
});
299+
258300
test('Captures a parameterized path navigation transaction for nested route with absolute path', async ({ page }) => {
259301
const transactionEventPromise = waitForTransaction('react-create-hash-router', event => {
260302
return event.contexts?.trace?.op === 'navigation';

0 commit comments

Comments
 (0)