|
| 1 | +import { expect, test } from '@playwright/test'; |
| 2 | +import { waitForTransaction } from '@sentry-internal/test-utils'; |
| 3 | + |
| 4 | +test('should create consistent parameterized transaction for default locale (no prefix)', async ({ page }) => { |
| 5 | + const transactionPromise = waitForTransaction('nextjs-15', async transactionEvent => { |
| 6 | + return transactionEvent.transaction === '/:locale/i18n-test' && transactionEvent.contexts?.trace?.op === 'pageload'; |
| 7 | + }); |
| 8 | + |
| 9 | + // Visit route without locale prefix (simulating default locale behavior) |
| 10 | + const response = await page.goto(`/i18n-test`); |
| 11 | + |
| 12 | + // Ensure page loaded successfully |
| 13 | + expect(response?.status()).toBe(200); |
| 14 | + |
| 15 | + const transaction = await transactionPromise; |
| 16 | + |
| 17 | + expect(transaction).toMatchObject({ |
| 18 | + contexts: { |
| 19 | + trace: { |
| 20 | + data: { |
| 21 | + 'sentry.op': 'pageload', |
| 22 | + 'sentry.origin': 'auto.pageload.nextjs.app_router_instrumentation', |
| 23 | + 'sentry.source': 'route', |
| 24 | + }, |
| 25 | + op: 'pageload', |
| 26 | + origin: 'auto.pageload.nextjs.app_router_instrumentation', |
| 27 | + }, |
| 28 | + }, |
| 29 | + transaction: '/:locale/i18n-test', |
| 30 | + transaction_info: { source: 'route' }, |
| 31 | + type: 'transaction', |
| 32 | + }); |
| 33 | +}); |
| 34 | + |
| 35 | +test('should create consistent parameterized transaction for non-default locale (with prefix)', async ({ page }) => { |
| 36 | + const transactionPromise = waitForTransaction('nextjs-15', async transactionEvent => { |
| 37 | + return transactionEvent.transaction === '/:locale/i18n-test' && transactionEvent.contexts?.trace?.op === 'pageload'; |
| 38 | + }); |
| 39 | + |
| 40 | + // Visit route with locale prefix (simulating non-default locale) |
| 41 | + const response = await page.goto(`/ar/i18n-test`); |
| 42 | + |
| 43 | + // Ensure page loaded successfully |
| 44 | + expect(response?.status()).toBe(200); |
| 45 | + |
| 46 | + const transaction = await transactionPromise; |
| 47 | + |
| 48 | + expect(transaction).toMatchObject({ |
| 49 | + contexts: { |
| 50 | + trace: { |
| 51 | + data: { |
| 52 | + 'sentry.op': 'pageload', |
| 53 | + 'sentry.origin': 'auto.pageload.nextjs.app_router_instrumentation', |
| 54 | + 'sentry.source': 'route', |
| 55 | + }, |
| 56 | + op: 'pageload', |
| 57 | + origin: 'auto.pageload.nextjs.app_router_instrumentation', |
| 58 | + }, |
| 59 | + }, |
| 60 | + transaction: '/:locale/i18n-test', |
| 61 | + transaction_info: { source: 'route' }, |
| 62 | + type: 'transaction', |
| 63 | + }); |
| 64 | +}); |
0 commit comments