|
| 1 | +import { expect, test } from '@playwright/test'; |
| 2 | +import { waitForTransaction } from '@sentry-internal/event-proxy-server'; |
| 3 | + |
| 4 | +test('sends a pageload transaction with a parameterized URL', async ({ page }) => { |
| 5 | + const transactionPromise = waitForTransaction('tanstack-router', async transactionEvent => { |
| 6 | + return !!transactionEvent?.transaction && transactionEvent.contexts?.trace?.op === 'pageload'; |
| 7 | + }); |
| 8 | + |
| 9 | + await page.goto(`/posts/456`); |
| 10 | + |
| 11 | + const rootSpan = await transactionPromise; |
| 12 | + |
| 13 | + expect(rootSpan).toMatchObject({ |
| 14 | + contexts: { |
| 15 | + trace: { |
| 16 | + data: { |
| 17 | + 'sentry.source': 'route', |
| 18 | + 'sentry.origin': 'auto.pageload.react.tanstack_router', |
| 19 | + 'sentry.op': 'pageload', |
| 20 | + 'url.path.params.postId': '456', |
| 21 | + }, |
| 22 | + op: 'pageload', |
| 23 | + origin: 'auto.pageload.react.tanstack_router', |
| 24 | + }, |
| 25 | + }, |
| 26 | + transaction: '/posts/$postId', |
| 27 | + transaction_info: { |
| 28 | + source: 'route', |
| 29 | + }, |
| 30 | + spans: expect.arrayContaining([ |
| 31 | + expect.objectContaining({ |
| 32 | + description: 'loading-post-456', |
| 33 | + }), |
| 34 | + ]), |
| 35 | + }); |
| 36 | +}); |
| 37 | + |
| 38 | +test('sends a navigation transaction with a parameterized URL', async ({ page }) => { |
| 39 | + const pageloadTxnPromise = waitForTransaction('tanstack-router', async transactionEvent => { |
| 40 | + return !!transactionEvent?.transaction && transactionEvent.contexts?.trace?.op === 'pageload'; |
| 41 | + }); |
| 42 | + |
| 43 | + const navigationTxnPromise = waitForTransaction('tanstack-router', async transactionEvent => { |
| 44 | + return !!transactionEvent?.transaction && transactionEvent.contexts?.trace?.op === 'navigation'; |
| 45 | + }); |
| 46 | + |
| 47 | + await page.goto(`/`); |
| 48 | + await pageloadTxnPromise; |
| 49 | + |
| 50 | + await page.waitForTimeout(5000); |
| 51 | + await page.locator('#nav-link').click(); |
| 52 | + |
| 53 | + const navigationTxn = await navigationTxnPromise; |
| 54 | + |
| 55 | + expect(navigationTxn).toMatchObject({ |
| 56 | + contexts: { |
| 57 | + trace: { |
| 58 | + data: { |
| 59 | + 'sentry.source': 'route', |
| 60 | + 'sentry.origin': 'auto.navigation.react.tanstack_router', |
| 61 | + 'sentry.op': 'navigation', |
| 62 | + 'url.path.params.postId': '2', |
| 63 | + }, |
| 64 | + op: 'navigation', |
| 65 | + origin: 'auto.navigation.react.tanstack_router', |
| 66 | + }, |
| 67 | + }, |
| 68 | + transaction: '/posts/$postId', |
| 69 | + transaction_info: { |
| 70 | + source: 'route', |
| 71 | + }, |
| 72 | + spans: expect.arrayContaining([ |
| 73 | + expect.objectContaining({ |
| 74 | + description: 'loading-post-2', |
| 75 | + }), |
| 76 | + ]), |
| 77 | + }); |
| 78 | +}); |
0 commit comments