@@ -1475,6 +1475,84 @@ describe('reactRouterV6BrowserTracingIntegration', () => {
14751475 expect ( mockRootSpan . setAttribute ) . toHaveBeenCalledWith ( SEMANTIC_ATTRIBUTE_SENTRY_SOURCE , 'route' ) ;
14761476 } ) ;
14771477
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+
14781556 it ( "updates the scope's `transactionName` on a navigation" , ( ) => {
14791557 const client = createMockBrowserClient ( ) ;
14801558 setCurrentClient ( client ) ;
0 commit comments