@@ -594,6 +594,84 @@ describe('reactRouterV6BrowserTracingIntegration', () => {
594594 } ) ;
595595 } ) ;
596596
597+ it ( 'works under a slash route with a trailing slash' , ( ) => {
598+ const client = createMockBrowserClient ( ) ;
599+ setCurrentClient ( client ) ;
600+
601+ client . addIntegration (
602+ reactRouterV6BrowserTracingIntegration ( {
603+ useEffect : React . useEffect ,
604+ useLocation,
605+ useNavigationType,
606+ createRoutesFromChildren,
607+ matchRoutes,
608+ } ) ,
609+ ) ;
610+ const SentryRoutes = withSentryReactRouterV6Routing ( Routes ) ;
611+
612+ render (
613+ < MemoryRouter initialEntries = { [ '/' ] } >
614+ < SentryRoutes >
615+ < Route index element = { < Navigate to = "/issues/123/" /> } />
616+ < Route path = "/" element = { < div > root</ div > } >
617+ < Route path = "/issues/:groupId/" element = { < div > issues group</ div > } >
618+ < Route index element = { < div > index</ div > } />
619+ </ Route >
620+ </ Route >
621+ </ SentryRoutes >
622+ </ MemoryRouter > ,
623+ ) ;
624+
625+ expect ( mockStartBrowserTracingNavigationSpan ) . toHaveBeenCalledTimes ( 1 ) ;
626+ expect ( mockStartBrowserTracingNavigationSpan ) . toHaveBeenLastCalledWith ( expect . any ( BrowserClient ) , {
627+ name : '/issues/:groupId/' ,
628+ attributes : {
629+ [ SEMANTIC_ATTRIBUTE_SENTRY_SOURCE ] : 'route' ,
630+ [ SEMANTIC_ATTRIBUTE_SENTRY_OP ] : 'navigation' ,
631+ [ SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN ] : 'auto.navigation.react.reactrouter_v6' ,
632+ } ,
633+ } ) ;
634+ } ) ;
635+
636+ it ( 'works nested under a slash root without a trailing slash' , ( ) => {
637+ const client = createMockBrowserClient ( ) ;
638+ setCurrentClient ( client ) ;
639+
640+ client . addIntegration (
641+ reactRouterV6BrowserTracingIntegration ( {
642+ useEffect : React . useEffect ,
643+ useLocation,
644+ useNavigationType,
645+ createRoutesFromChildren,
646+ matchRoutes,
647+ } ) ,
648+ ) ;
649+ const SentryRoutes = withSentryReactRouterV6Routing ( Routes ) ;
650+
651+ render (
652+ < MemoryRouter initialEntries = { [ '/' ] } >
653+ < SentryRoutes >
654+ < Route index element = { < Navigate to = "/issues/123" /> } />
655+ < Route path = "/" element = { < div > root</ div > } >
656+ < Route path = "/issues/:groupId/" element = { < div > issues group</ div > } >
657+ < Route index element = { < div > index</ div > } />
658+ </ Route >
659+ </ Route >
660+ </ SentryRoutes >
661+ </ MemoryRouter > ,
662+ ) ;
663+
664+ expect ( mockStartBrowserTracingNavigationSpan ) . toHaveBeenCalledTimes ( 1 ) ;
665+ expect ( mockStartBrowserTracingNavigationSpan ) . toHaveBeenLastCalledWith ( expect . any ( BrowserClient ) , {
666+ name : '/issues/:groupId/' ,
667+ attributes : {
668+ [ SEMANTIC_ATTRIBUTE_SENTRY_SOURCE ] : 'route' ,
669+ [ SEMANTIC_ATTRIBUTE_SENTRY_OP ] : 'navigation' ,
670+ [ SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN ] : 'auto.navigation.react.reactrouter_v6' ,
671+ } ,
672+ } ) ;
673+ } ) ;
674+
597675 it ( "updates the scope's `transactionName` on a navigation" , ( ) => {
598676 const client = createMockBrowserClient ( ) ;
599677 setCurrentClient ( client ) ;
@@ -1397,6 +1475,84 @@ describe('reactRouterV6BrowserTracingIntegration', () => {
13971475 expect ( mockRootSpan . setAttribute ) . toHaveBeenCalledWith ( SEMANTIC_ATTRIBUTE_SENTRY_SOURCE , 'route' ) ;
13981476 } ) ;
13991477
1478+ it ( 'works under a slash route with a trailing slash' , ( ) => {
1479+ const client = createMockBrowserClient ( ) ;
1480+ setCurrentClient ( client ) ;
1481+
1482+ client . addIntegration (
1483+ reactRouterV6BrowserTracingIntegration ( {
1484+ useEffect : React . useEffect ,
1485+ useLocation,
1486+ useNavigationType,
1487+ createRoutesFromChildren,
1488+ matchRoutes,
1489+ } ) ,
1490+ ) ;
1491+ const SentryRoutes = withSentryReactRouterV6Routing ( Routes ) ;
1492+
1493+ render (
1494+ < MemoryRouter initialEntries = { [ '/' ] } >
1495+ < SentryRoutes >
1496+ < Route index element = { < Navigate to = "/issues/123/" /> } />
1497+ < Route path = "/" element = { < div > root</ div > } >
1498+ < Route path = "/issues/:groupId/" element = { < div > issues group</ div > } >
1499+ < Route index element = { < div > index</ div > } />
1500+ </ Route >
1501+ </ Route >
1502+ </ SentryRoutes >
1503+ </ MemoryRouter > ,
1504+ ) ;
1505+
1506+ expect ( mockStartBrowserTracingNavigationSpan ) . toHaveBeenCalledTimes ( 1 ) ;
1507+ expect ( mockStartBrowserTracingNavigationSpan ) . toHaveBeenLastCalledWith ( expect . any ( BrowserClient ) , {
1508+ name : '/issues/:groupId/' ,
1509+ attributes : {
1510+ [ SEMANTIC_ATTRIBUTE_SENTRY_SOURCE ] : 'route' ,
1511+ [ SEMANTIC_ATTRIBUTE_SENTRY_OP ] : 'navigation' ,
1512+ [ SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN ] : 'auto.navigation.react.reactrouter_v6' ,
1513+ } ,
1514+ } ) ;
1515+ } ) ;
1516+
1517+ it ( 'works nested under a slash root without a trailing slash' , ( ) => {
1518+ const client = createMockBrowserClient ( ) ;
1519+ setCurrentClient ( client ) ;
1520+
1521+ client . addIntegration (
1522+ reactRouterV6BrowserTracingIntegration ( {
1523+ useEffect : React . useEffect ,
1524+ useLocation,
1525+ useNavigationType,
1526+ createRoutesFromChildren,
1527+ matchRoutes,
1528+ } ) ,
1529+ ) ;
1530+ const SentryRoutes = withSentryReactRouterV6Routing ( Routes ) ;
1531+
1532+ render (
1533+ < MemoryRouter initialEntries = { [ '/' ] } >
1534+ < SentryRoutes >
1535+ < Route index element = { < Navigate to = "/issues/123" /> } />
1536+ < Route path = "/" element = { < div > root</ div > } >
1537+ < Route path = "/issues/:groupId/" element = { < div > issues group</ div > } >
1538+ < Route index element = { < div > index</ div > } />
1539+ </ Route >
1540+ </ Route >
1541+ </ SentryRoutes >
1542+ </ MemoryRouter > ,
1543+ ) ;
1544+
1545+ expect ( mockStartBrowserTracingNavigationSpan ) . toHaveBeenCalledTimes ( 1 ) ;
1546+ expect ( mockStartBrowserTracingNavigationSpan ) . toHaveBeenLastCalledWith ( expect . any ( BrowserClient ) , {
1547+ name : '/issues/:groupId/' ,
1548+ attributes : {
1549+ [ SEMANTIC_ATTRIBUTE_SENTRY_SOURCE ] : 'route' ,
1550+ [ SEMANTIC_ATTRIBUTE_SENTRY_OP ] : 'navigation' ,
1551+ [ SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN ] : 'auto.navigation.react.reactrouter_v6' ,
1552+ } ,
1553+ } ) ;
1554+ } ) ;
1555+
14001556 it ( "updates the scope's `transactionName` on a navigation" , ( ) => {
14011557 const client = createMockBrowserClient ( ) ;
14021558 setCurrentClient ( client ) ;
0 commit comments