Skip to content

Commit c3ddbdb

Browse files
committed
Update e2e tests.
1 parent e80a0a7 commit c3ddbdb

File tree

4 files changed

+44
-51
lines changed

4 files changed

+44
-51
lines changed

dev-packages/e2e-tests/test-applications/react-router-6-descendant-routes/package.json

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,5 @@
5151
},
5252
"volta": {
5353
"extends": "../../package.json"
54-
},
55-
"sentryTest": {
56-
"variants": [
57-
{
58-
"build-command": "test:build-ts3.8",
59-
"label": "react-router-6 (TS 3.8)"
60-
}
61-
]
6254
}
6355
}

dev-packages/e2e-tests/test-applications/react-router-6-descendant-routes/src/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
useLocation,
1212
useNavigationType,
1313
} from 'react-router-dom';
14+
import Index from './pages/Index';
1415

1516
const replay = Sentry.replayIntegration();
1617

@@ -60,7 +61,7 @@ const root = ReactDOM.createRoot(document.getElementById('root') as HTMLElement)
6061
root.render(
6162
<BrowserRouter>
6263
<SentryRoutes>
63-
{/* <Route index element={<Navigate to="/projects/123/views/234" />} /> */}
64+
<Route path='/' element={<Index/>} />
6465
<Route path="projects/*" element={<ProjectsRoutes />}></Route>
6566
</SentryRoutes>
6667
</BrowserRouter>,

dev-packages/e2e-tests/test-applications/react-router-6-descendant-routes/src/pages/Index.tsx

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,7 @@ import { Link } from 'react-router-dom';
55
const Index = () => {
66
return (
77
<>
8-
<input
9-
type="button"
10-
value="Capture Exception"
11-
id="exception-button"
12-
onClick={() => {
13-
throw new Error('I am an error!');
14-
}}
15-
/>
16-
<Link to="/user/5" id="navigation">
8+
<Link to="/projects/123/views/456" id="navigation">
179
navigate
1810
</Link>
1911
</>

dev-packages/e2e-tests/test-applications/react-router-6-descendant-routes/tests/transactions.test.ts

Lines changed: 41 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ test('sends a pageload transaction with a parameterized URL', async ({ page }) =
1010

1111
const rootSpan = await transactionPromise;
1212

13-
console.debug('rootSpan', rootSpan);
14-
1513
expect(rootSpan).toMatchObject({
1614
contexts: {
1715
trace: {
@@ -26,34 +24,44 @@ test('sends a pageload transaction with a parameterized URL', async ({ page }) =
2624
});
2725
});
2826

29-
// test('sends a navigation transaction with a parameterized URL', async ({ page }) => {
30-
// page.on('console', msg => console.log(msg.text()));
31-
32-
// const pageloadTxnPromise = waitForTransaction('react-router-6-descendant-routes', async transactionEvent => {
33-
// return !!transactionEvent?.transaction && transactionEvent.contexts?.trace?.op === 'pageload';
34-
// });
35-
36-
// const navigationTxnPromise = waitForTransaction('react-router-6-descendant-routes', async transactionEvent => {
37-
// return !!transactionEvent?.transaction && transactionEvent.contexts?.trace?.op === 'navigation';
38-
// });
39-
40-
// await page.goto(`/`);
41-
// await pageloadTxnPromise;
42-
43-
// const linkElement = page.locator('id=navigation');
44-
45-
// const [_, navigationTxn] = await Promise.all([linkElement.click(), navigationTxnPromise]);
46-
47-
// expect(navigationTxn).toMatchObject({
48-
// contexts: {
49-
// trace: {
50-
// op: 'navigation',
51-
// origin: 'auto.navigation.react.reactrouter_v6',
52-
// },
53-
// },
54-
// transaction: '/user/:id',
55-
// transaction_info: {
56-
// source: 'route',
57-
// },
58-
// });
59-
// });
27+
test('sends a navigation transaction with a parameterized URL', async ({ page }) => {
28+
const pageloadTxnPromise = waitForTransaction('react-router-6-descendant-routes', async transactionEvent => {
29+
return !!transactionEvent?.transaction && transactionEvent.contexts?.trace?.op === 'pageload';
30+
});
31+
32+
const navigationTxnPromise = waitForTransaction('react-router-6-descendant-routes', async transactionEvent => {
33+
return !!transactionEvent?.transaction && transactionEvent.contexts?.trace?.op === 'navigation';
34+
});
35+
36+
await page.goto(`/`);
37+
const pageloadTxn = await pageloadTxnPromise;
38+
39+
expect(pageloadTxn).toMatchObject({
40+
contexts: {
41+
trace: {
42+
op: 'pageload',
43+
origin: 'auto.pageload.react.reactrouter_v6',
44+
},
45+
},
46+
transaction: '/',
47+
transaction_info: {
48+
source: 'route',
49+
},
50+
});
51+
52+
const linkElement = page.locator('id=navigation');
53+
54+
const [_, navigationTxn] = await Promise.all([linkElement.click(), navigationTxnPromise]);
55+
expect(navigationTxn).toMatchObject({
56+
contexts: {
57+
trace: {
58+
op: 'navigation',
59+
origin: 'auto.navigation.react.reactrouter_v6',
60+
},
61+
},
62+
transaction: '/projects/:projectId/views/:viewId',
63+
transaction_info: {
64+
source: 'route',
65+
},
66+
});
67+
});

0 commit comments

Comments
 (0)