Skip to content

Commit 68b20a8

Browse files
committed
tests: added tests
1 parent 1355a1e commit 68b20a8

File tree

2 files changed

+74
-0
lines changed

2 files changed

+74
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export default async function I18nTestPage({ params }: { params: Promise<{ locale: string }> }) {
2+
const { locale } = await params;
3+
return (
4+
<div>
5+
<h1>I18n Test Page</h1>
6+
<p>Current locale: {locale || 'default'}</p>
7+
<p>This page tests i18n route parameterization</p>
8+
</div>
9+
);
10+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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

Comments
 (0)