Skip to content

Commit

Permalink
Assert on transaction names
Browse files Browse the repository at this point in the history
  • Loading branch information
andreiborza committed Jul 12, 2024
1 parent 6e3bed4 commit 76a3594
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ export default function Home() {
User 5
</A>
</li>
<li>
<A id="navLinkUserBack" href="/users/6">
User 6
</A>
</li>
</ul>
</>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { waitForTransaction } from '@sentry-internal/test-utils';

test('sends a pageload transaction', async ({ page }) => {
const transactionPromise = waitForTransaction('solidstart', async transactionEvent => {
return !!transactionEvent?.transaction && transactionEvent.contexts?.trace?.op === 'pageload';
return transactionEvent?.transaction === '/' && transactionEvent.contexts?.trace?.op === 'pageload';
});

await page.goto('/');
Expand All @@ -25,7 +25,7 @@ test('sends a pageload transaction', async ({ page }) => {

test('sends a navigation transaction', async ({ page }) => {
const transactionPromise = waitForTransaction('solidstart', async transactionEvent => {
return !!transactionEvent?.transaction && transactionEvent.contexts?.trace?.op === 'navigation';
return transactionEvent?.transaction === '/users/5' && transactionEvent.contexts?.trace?.op === 'navigation';
});

await page.goto(`/`);
Expand All @@ -51,11 +51,11 @@ test('updates the transaction when using the back button', async ({ page }) => {
// The sentry solidRouterBrowserTracingIntegration tries to update such
// transactions with the proper name once the `useLocation` hook triggers.
const navigationTxnPromise = waitForTransaction('solidstart', async transactionEvent => {
return !!transactionEvent?.transaction && transactionEvent.contexts?.trace?.op === 'navigation';
return transactionEvent?.transaction === '/users/6' && transactionEvent.contexts?.trace?.op === 'navigation';
});

await page.goto(`/`);
await page.locator('#navLink').click();
await page.locator('#navLinkUserBack').click();
const navigationTxn = await navigationTxnPromise;

expect(navigationTxn).toMatchObject({
Expand All @@ -65,14 +65,14 @@ test('updates the transaction when using the back button', async ({ page }) => {
origin: 'auto.navigation.solid.solidrouter',
},
},
transaction: '/users/5',
transaction: '/users/6',
transaction_info: {
source: 'url',
},
});

const backNavigationTxnPromise = waitForTransaction('solidstart', async transactionEvent => {
return !!transactionEvent?.transaction && transactionEvent.contexts?.trace?.op === 'navigation';
return transactionEvent?.transaction === '/' && transactionEvent.contexts?.trace?.op === 'navigation';
});

await page.goBack();
Expand Down

0 comments on commit 76a3594

Please sign in to comment.