Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@ test.describe('client - navigation performance', () => {
);
});

const pageloadTxPromise = waitForTransaction(APP_NAME, async transactionEvent => {
return transactionEvent.transaction === '/performance' && transactionEvent.contexts?.trace?.op === 'pageload';
});

await page.goto(`/performance`); // pageload
await page.waitForTimeout(1000); // give it a sec before navigation
await pageloadTxPromise;
await page.getByRole('link', { name: 'SSR Page' }).click(); // navigation

const transaction = await navigationPromise;
Expand Down Expand Up @@ -67,8 +71,12 @@ test.describe('client - navigation performance', () => {
);
});

const pageloadTxPromise = waitForTransaction(APP_NAME, async transactionEvent => {
return transactionEvent.transaction === '/performance' && transactionEvent.contexts?.trace?.op === 'pageload';
});

await page.goto(`/performance`); // pageload
await page.waitForTimeout(1000); // give it a sec before navigation
await pageloadTxPromise;
await page.getByRole('link', { name: 'With Param Page' }).click(); // navigation

const transaction = await txPromise;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import { Link } from 'react-router';
import { Link, useNavigate } from 'react-router';

export default function SsrPage() {
const navigate = useNavigate();

return (
<div>
<h1>SSR Page</h1>
<nav>
<Link to="/performance">Back to Performance</Link>
</nav>
<button type="button" onClick={() => navigate(-1)}>
History Back Navigate
</button>
</div>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@ test.describe('client - hybrid navigation (instrumentation API span + legacy par
test('should create navigation span via instrumentation API and parameterize via legacy subscribe', async ({
page,
}) => {
// First load the performance page
const pageloadTxPromise = waitForTransaction(APP_NAME, async transactionEvent => {
return transactionEvent.transaction === '/performance' && transactionEvent.contexts?.trace?.op === 'pageload';
});

await page.goto(`/performance`);
await page.waitForTimeout(1000);
await pageloadTxPromise;

const navigationTxPromise = waitForTransaction(APP_NAME, async transactionEvent => {
return (
Expand Down Expand Up @@ -92,8 +95,12 @@ test.describe('client - hybrid navigation (instrumentation API span + legacy par
});

test('should parameterize navigation transaction for dynamic routes', async ({ page }) => {
const pageloadTxPromise = waitForTransaction(APP_NAME, async transactionEvent => {
return transactionEvent.transaction === '/performance' && transactionEvent.contexts?.trace?.op === 'pageload';
});

await page.goto(`/performance`);
await page.waitForTimeout(1000);
await pageloadTxPromise;

const navigationTxPromise = waitForTransaction(APP_NAME, async transactionEvent => {
return (
Expand Down Expand Up @@ -126,8 +133,12 @@ test.describe('client - hybrid navigation (instrumentation API span + legacy par
});

test('should send multiple navigation transactions in sequence', async ({ page }) => {
const pageloadTxPromise = waitForTransaction(APP_NAME, async transactionEvent => {
return transactionEvent.transaction === '/performance' && transactionEvent.contexts?.trace?.op === 'pageload';
});

await page.goto(`/performance`);
await page.waitForTimeout(1000);
await pageloadTxPromise;

// First navigation: /performance -> /performance/ssr
const firstNavPromise = waitForTransaction(APP_NAME, async transactionEvent => {
Expand Down Expand Up @@ -171,6 +182,54 @@ test.describe('client - hybrid navigation (instrumentation API span + legacy par
type: 'transaction',
});
});

test('should create navigation transaction for navigate(-1) with correct url attributes', async ({ page }) => {
const pageloadTxPromise = waitForTransaction(APP_NAME, async transactionEvent => {
return transactionEvent.transaction === '/performance' && transactionEvent.contexts?.trace?.op === 'pageload';
});

await page.goto(`/performance`);
await pageloadTxPromise;

const forwardNavPromise = waitForTransaction(APP_NAME, async transactionEvent => {
return (
transactionEvent.transaction === '/performance/ssr' && transactionEvent.contexts?.trace?.op === 'navigation'
);
});

await page.getByRole('link', { name: 'SSR Page' }).click();
await forwardNavPromise;

const backNavPromise = waitForTransaction(APP_NAME, async transactionEvent => {
return transactionEvent.transaction === '/performance' && transactionEvent.contexts?.trace?.op === 'navigation';
});

await page.getByRole('button', { name: 'History Back Navigate' }).click();

const transaction = await backNavPromise;

expect(transaction).toMatchObject({
contexts: {
trace: {
op: 'navigation',
origin: 'auto.navigation.react_router.instrumentation_api',
data: {
'sentry.source': 'route',
'sentry.op': 'navigation',
'sentry.origin': 'auto.navigation.react_router.instrumentation_api',
'navigation.type': 'router.back',
'url.template': '/performance',
// react-router-serve 301-redirects the bare index route to a trailing slash
'url.path': '/performance/',
'url.full': expect.stringMatching(/^https?:\/\/localhost:\d+\/performance\/$/),
},
},
},
transaction: '/performance',
type: 'transaction',
transaction_info: { source: 'route' },
});
});
});

// Tests for instrumentation API navigation - expected to fail until React Router fixes upstream
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@ test.describe('client - navigation performance', () => {
);
});

const pageloadTxPromise = waitForTransaction(APP_NAME, async transactionEvent => {
return transactionEvent.transaction === '/performance' && transactionEvent.contexts?.trace?.op === 'pageload';
});

await page.goto(`/performance`); // pageload
await page.waitForTimeout(1000); // give it a sec before navigation
await pageloadTxPromise;
await page.getByRole('link', { name: 'SSR Page' }).click(); // navigation

const transaction = await navigationPromise;
Expand Down Expand Up @@ -67,8 +71,12 @@ test.describe('client - navigation performance', () => {
);
});

const pageloadTxPromise = waitForTransaction(APP_NAME, async transactionEvent => {
return transactionEvent.transaction === '/performance' && transactionEvent.contexts?.trace?.op === 'pageload';
});

await page.goto(`/performance`); // pageload
await page.waitForTimeout(1000); // give it a sec before navigation
await pageloadTxPromise;
await page.getByRole('link', { name: 'With Param Page' }).click(); // navigation

const transaction = await txPromise;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@ test.describe('client - navigation performance', () => {
);
});

const pageloadTxPromise = waitForTransaction(APP_NAME, async transactionEvent => {
return transactionEvent.transaction === '/performance' && transactionEvent.contexts?.trace?.op === 'pageload';
});

await page.goto(`/performance`); // pageload
await page.waitForTimeout(1000); // give it a sec before navigation
await pageloadTxPromise;
await page.getByRole('link', { name: 'With Param Page' }).click(); // navigation

const transaction = await txPromise;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@ test.describe('client - navigation performance', () => {
);
});

const pageloadTxPromise = waitForTransaction(APP_NAME, async transactionEvent => {
return transactionEvent.transaction === '/performance' && transactionEvent.contexts?.trace?.op === 'pageload';
});

await page.goto(`/performance`); // pageload
await page.waitForTimeout(1000); // give it a sec before navigation
await pageloadTxPromise;
await page.getByRole('link', { name: 'With Param Page' }).click(); // navigation

const transaction = await txPromise;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import { useNavigate } from 'react-router';

export default function SsrPage() {
const navigate = useNavigate();

return (
<div>
<h1>SSR Page</h1>
<button type="button" onClick={() => navigate(-1)}>
History Back Navigate
</button>
</div>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@ test.describe('client - navigation performance', () => {
);
});

const pageloadTxPromise = waitForTransaction(APP_NAME, async transactionEvent => {
return transactionEvent.transaction === '/performance' && transactionEvent.contexts?.trace?.op === 'pageload';
});

await page.goto(`/performance`); // pageload
await page.waitForTimeout(1000); // give it a sec before navigation
await pageloadTxPromise;
await page.getByRole('link', { name: 'SSR Page' }).click(); // navigation

const transaction = await navigationPromise;
Expand Down Expand Up @@ -67,8 +71,12 @@ test.describe('client - navigation performance', () => {
);
});

const pageloadTxPromise = waitForTransaction(APP_NAME, async transactionEvent => {
return transactionEvent.transaction === '/performance' && transactionEvent.contexts?.trace?.op === 'pageload';
});

await page.goto(`/performance`); // pageload
await page.waitForTimeout(1000); // give it a sec before navigation
await pageloadTxPromise;
await page.getByRole('link', { name: 'Object Navigate' }).click(); // navigation with object to

const transaction = await txPromise;
Expand Down Expand Up @@ -97,8 +105,12 @@ test.describe('client - navigation performance', () => {
return transactionEvent.transaction === '/performance' && transactionEvent.contexts?.trace?.op === 'navigation';
});

const pageloadTxPromise = waitForTransaction(APP_NAME, async transactionEvent => {
return transactionEvent.transaction === '/performance' && transactionEvent.contexts?.trace?.op === 'pageload';
});

await page.goto(`/performance`); // pageload
await page.waitForTimeout(1000); // give it a sec before navigation
await pageloadTxPromise;
await page.getByRole('link', { name: 'Search Only Navigate' }).click(); // navigation with search-only object to

const transaction = await txPromise;
Expand Down Expand Up @@ -129,8 +141,12 @@ test.describe('client - navigation performance', () => {
);
});

const pageloadTxPromise = waitForTransaction(APP_NAME, async transactionEvent => {
return transactionEvent.transaction === '/performance' && transactionEvent.contexts?.trace?.op === 'pageload';
});

await page.goto(`/performance`); // pageload
await page.waitForTimeout(1000); // give it a sec before navigation
await pageloadTxPromise;
await page.getByRole('link', { name: 'With Param Page' }).click(); // navigation

const transaction = await txPromise;
Expand Down Expand Up @@ -177,4 +193,51 @@ test.describe('client - navigation performance', () => {
tags: { runtime: 'browser' },
});
});

test('should create navigation transaction for navigate(-1) with correct url attributes', async ({ page }) => {
const pageloadTxPromise = waitForTransaction(APP_NAME, async transactionEvent => {
return transactionEvent.transaction === '/performance' && transactionEvent.contexts?.trace?.op === 'pageload';
});

await page.goto(`/performance`);
await pageloadTxPromise;

const forwardNavPromise = waitForTransaction(APP_NAME, async transactionEvent => {
return (
transactionEvent.transaction === '/performance/ssr' && transactionEvent.contexts?.trace?.op === 'navigation'
);
});

await page.getByRole('link', { name: 'SSR Page' }).click();
await forwardNavPromise;

const backNavPromise = waitForTransaction(APP_NAME, async transactionEvent => {
return transactionEvent.transaction === '/performance' && transactionEvent.contexts?.trace?.op === 'navigation';
});

await page.getByRole('button', { name: 'History Back Navigate' }).click();

const transaction = await backNavPromise;

expect(transaction).toMatchObject({
contexts: {
trace: {
op: 'navigation',
origin: 'auto.navigation.react_router',
data: {
'sentry.source': 'route',
'sentry.op': 'navigation',
'sentry.origin': 'auto.navigation.react_router',
'url.template': '/performance',
// react-router-serve 301-redirects the bare index route to a trailing slash
'url.path': '/performance/',
'url.full': expect.stringMatching(/^https?:\/\/localhost:\d+\/performance\/$/),
},
},
},
transaction: '/performance',
type: 'transaction',
transaction_info: { source: 'route' },
});
});
});
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import { useNavigate } from 'react-router';

export default function SsrPage() {
const navigate = useNavigate();

return (
<div>
<h1>SSR Page</h1>
<button type="button" onClick={() => navigate(-1)}>
History Back Navigate
</button>
</div>
);
}
Loading
Loading