Skip to content

Commit aaf244f

Browse files
committed
tests: test the actual transaction sending for page loads
1 parent 4303908 commit aaf244f

File tree

7 files changed

+70
-63
lines changed

7 files changed

+70
-63
lines changed

dev-packages/e2e-tests/test-applications/nextjs-15/app/isr-test/[product]/page.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
export const revalidate = 60; // ISR: revalidate every 60 seconds
2+
export const dynamicParams = true; // Allow dynamic params beyond generateStaticParams
3+
14
export async function generateStaticParams(): Promise<Array<{ product: string }>> {
25
return [{ product: 'laptop' }, { product: 'phone' }, { product: 'tablet' }];
36
}

dev-packages/e2e-tests/test-applications/nextjs-15/app/isr-test/static/page.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
export const revalidate = 60; // ISR: revalidate every 60 seconds
2+
export const dynamicParams = true;
3+
14
export async function generateStaticParams(): Promise<never[]> {
25
return [];
36
}

dev-packages/e2e-tests/test-applications/nextjs-15/instrumentation-client.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ import * as Sentry from '@sentry/nextjs';
22

33
Sentry.init({
44
environment: 'qa', // dynamic sampling bias to keep transactions
5-
dsn: process.env.NEXT_PUBLIC_E2E_TEST_DSN,
5+
dsn: 'https://username@domain/123',
66
tunnel: `http://localhost:3031/`, // proxy server
77
tracesSampleRate: 1.0,
88
sendDefaultPii: true,
9+
debug: true,
910
});
1011

1112
export const onRouterTransitionStart = Sentry.captureRouterTransitionStart;

dev-packages/e2e-tests/test-applications/nextjs-15/tests/isr-routes.test.ts

Lines changed: 28 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -41,37 +41,34 @@ test('should remove meta tags for different ISR dynamic route values', async ({
4141
await expect(page.locator('meta[name="baggage"]')).toHaveCount(0);
4242
});
4343

44-
test('should create unique transactions for ISR pages (not using stale trace IDs)', async ({ page }) => {
45-
// First navigation - capture the trace ID
46-
const firstTransactionPromise = waitForTransaction('nextjs-15', async transactionEvent => {
47-
return transactionEvent.transaction === '/isr-test/:product' && transactionEvent.contexts?.trace?.op === 'pageload';
48-
});
49-
50-
await page.goto('/isr-test/laptop');
51-
const firstTransaction = await firstTransactionPromise;
52-
const firstTraceId = firstTransaction.contexts?.trace?.trace_id;
53-
54-
expect(firstTraceId).toBeDefined();
55-
expect(firstTraceId).toMatch(/[a-f0-9]{32}/);
56-
57-
// Second navigation to the same ISR route with different param
58-
const secondTransactionPromise = waitForTransaction('nextjs-15', async transactionEvent => {
59-
return !!(
60-
transactionEvent.transaction === '/isr-test/:product' &&
61-
transactionEvent.contexts?.trace?.op === 'pageload' &&
62-
transactionEvent.request?.url?.includes('/isr-test/phone')
63-
);
64-
});
65-
66-
await page.goto('/isr-test/phone');
67-
const secondTransaction = await secondTransactionPromise;
68-
const secondTraceId = secondTransaction.contexts?.trace?.trace_id;
69-
70-
expect(secondTraceId).toBeDefined();
71-
expect(secondTraceId).toMatch(/[a-f0-9]{32}/);
72-
73-
// Verify that each page load gets a NEW trace ID (not reusing cached/stale ones)
74-
expect(firstTraceId).not.toBe(secondTraceId);
44+
test('should create unique transactions for ISR pages on each visit', async ({ page }) => {
45+
const traceIds: string[] = [];
46+
47+
// Load the same ISR page 5 times to ensure cached HTML meta tags are consistently removed
48+
for (let i = 0; i < 5; i++) {
49+
const transactionPromise = waitForTransaction('nextjs-15', async transactionEvent => {
50+
return !!(
51+
transactionEvent.transaction === '/isr-test/:product' && transactionEvent.contexts?.trace?.op === 'pageload'
52+
);
53+
});
54+
55+
if (i === 0) {
56+
await page.goto('/isr-test/laptop');
57+
} else {
58+
await page.reload();
59+
}
60+
61+
const transaction = await transactionPromise;
62+
const traceId = transaction.contexts?.trace?.trace_id;
63+
64+
expect(traceId).toBeDefined();
65+
expect(traceId).toMatch(/[a-f0-9]{32}/);
66+
traceIds.push(traceId!);
67+
}
68+
69+
// Verify all 5 page loads have unique trace IDs (no reuse of cached/stale meta tags)
70+
const uniqueTraceIds = new Set(traceIds);
71+
expect(uniqueTraceIds.size).toBe(5);
7572
});
7673

7774
test('ISR route should be identified correctly in the route manifest', async ({ page }) => {

dev-packages/e2e-tests/test-applications/nextjs-16/app/isr-test/[product]/page.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
export const revalidate = 60; // ISR: revalidate every 60 seconds
2+
export const dynamicParams = true; // Allow dynamic params beyond generateStaticParams
3+
14
export async function generateStaticParams(): Promise<Array<{ product: string }>> {
25
return [{ product: 'laptop' }, { product: 'phone' }, { product: 'tablet' }];
36
}

dev-packages/e2e-tests/test-applications/nextjs-16/app/isr-test/static/page.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
export const revalidate = 60; // ISR: revalidate every 60 seconds
2+
export const dynamicParams = true;
3+
14
export async function generateStaticParams(): Promise<never[]> {
25
return [];
36
}

dev-packages/e2e-tests/test-applications/nextjs-16/tests/isr-routes.test.ts

Lines changed: 28 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -41,37 +41,34 @@ test('should remove meta tags for different ISR dynamic route values', async ({
4141
await expect(page.locator('meta[name="baggage"]')).toHaveCount(0);
4242
});
4343

44-
test('should create unique transactions for ISR pages (not using stale trace IDs)', async ({ page }) => {
45-
// First navigation - capture the trace ID
46-
const firstTransactionPromise = waitForTransaction('nextjs-16', async transactionEvent => {
47-
return transactionEvent.transaction === '/isr-test/:product' && transactionEvent.contexts?.trace?.op === 'pageload';
48-
});
49-
50-
await page.goto('/isr-test/laptop');
51-
const firstTransaction = await firstTransactionPromise;
52-
const firstTraceId = firstTransaction.contexts?.trace?.trace_id;
53-
54-
expect(firstTraceId).toBeDefined();
55-
expect(firstTraceId).toMatch(/[a-f0-9]{32}/);
56-
57-
// Second navigation to the same ISR route with different param
58-
const secondTransactionPromise = waitForTransaction('nextjs-16', async transactionEvent => {
59-
return !!(
60-
transactionEvent.transaction === '/isr-test/:product' &&
61-
transactionEvent.contexts?.trace?.op === 'pageload' &&
62-
transactionEvent.request?.url?.includes('/isr-test/phone')
63-
);
64-
});
65-
66-
await page.goto('/isr-test/phone');
67-
const secondTransaction = await secondTransactionPromise;
68-
const secondTraceId = secondTransaction.contexts?.trace?.trace_id;
69-
70-
expect(secondTraceId).toBeDefined();
71-
expect(secondTraceId).toMatch(/[a-f0-9]{32}/);
72-
73-
// Verify that each page load gets a NEW trace ID (not reusing cached/stale ones)
74-
expect(firstTraceId).not.toBe(secondTraceId);
44+
test('should create unique transactions for ISR pages on each visit', async ({ page }) => {
45+
const traceIds: string[] = [];
46+
47+
// Load the same ISR page 5 times to ensure cached HTML meta tags are consistently removed
48+
for (let i = 0; i < 5; i++) {
49+
const transactionPromise = waitForTransaction('nextjs-16', async transactionEvent => {
50+
return !!(
51+
transactionEvent.transaction === '/isr-test/:product' && transactionEvent.contexts?.trace?.op === 'pageload'
52+
);
53+
});
54+
55+
if (i === 0) {
56+
await page.goto('/isr-test/laptop');
57+
} else {
58+
await page.reload();
59+
}
60+
61+
const transaction = await transactionPromise;
62+
const traceId = transaction.contexts?.trace?.trace_id;
63+
64+
expect(traceId).toBeDefined();
65+
expect(traceId).toMatch(/[a-f0-9]{32}/);
66+
traceIds.push(traceId!);
67+
}
68+
69+
// Verify all 5 page loads have unique trace IDs (no reuse of cached/stale meta tags)
70+
const uniqueTraceIds = new Set(traceIds);
71+
expect(uniqueTraceIds.size).toBe(5);
7572
});
7673

7774
test('ISR route should be identified correctly in the route manifest', async ({ page }) => {

0 commit comments

Comments
 (0)