File tree Expand file tree Collapse file tree 2 files changed +14
-5
lines changed
dev-packages/e2e-tests/test-applications/react-router-7-lazy-routes/tests Expand file tree Collapse file tree 2 files changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -4,8 +4,6 @@ import { waitForTransaction } from '@sentry-internal/test-utils';
44
55test ( 'Creates a pageload transaction with parameterized route' , async ( { page } ) => {
66 const transactionPromise = waitForTransaction ( 'react-router-7-lazy-routes' , async transactionEvent => {
7- console . debug ( 'transactionEvent' , transactionEvent ) ;
8-
97 return (
108 ! ! transactionEvent ?. transaction &&
119 transactionEvent . contexts ?. trace ?. op === 'pageload' &&
Original file line number Diff line number Diff line change @@ -66,11 +66,22 @@ const allRoutes = new Set<RouteObject>();
6666
6767/**
6868 * Adds resolved routes as children to the parent route.
69+ * Prevents duplicate routes by checking if they already exist.
6970 */
7071function addResolvedRoutesToParent ( resolvedRoutes : RouteObject [ ] , parentRoute : RouteObject ) : void {
71- parentRoute . children = Array . isArray ( parentRoute . children )
72- ? [ ...parentRoute . children , ...resolvedRoutes ]
73- : resolvedRoutes ;
72+ const existingChildren = parentRoute . children || [ ] ;
73+
74+ const newRoutes = resolvedRoutes . filter ( newRoute =>
75+ ! existingChildren . some ( existing =>
76+ existing === newRoute ||
77+ ( newRoute . path && existing . path === newRoute . path ) ||
78+ ( newRoute . id && existing . id === newRoute . id )
79+ )
80+ ) ;
81+
82+ if ( newRoutes . length > 0 ) {
83+ parentRoute . children = [ ...existingChildren , ...newRoutes ] ;
84+ }
7485}
7586
7687/**
You can’t perform that action at this time.
0 commit comments