Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { waitForTransaction } from '@sentry-internal/test-utils';

test('Should create a transaction for node route handlers', async ({ request }) => {
const routehandlerTransactionPromise = waitForTransaction('nextjs-15', async transactionEvent => {
console.log(transactionEvent?.transaction);
return transactionEvent?.transaction === 'GET /route-handler/[xoxo]/node';
});

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { PropsWithChildren } from 'react';

export const dynamic = 'force-dynamic';

export default function Layout({ children }: PropsWithChildren<{}>) {
return (
<div>
<p>Layout</p>
{children}
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { PropsWithChildren } from 'react';

export const dynamic = 'force-dynamic';

export default function Layout({ children }: PropsWithChildren<{}>) {
return (
<div>
<p>DynamicLayout</p>
{children}
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export const dynamic = 'force-dynamic';

export default async function Page() {
return (
<div>
<p>Dynamic Page</p>
</div>
);
}

export async function generateMetadata() {
return {
title: 'I am dynamic page generated metadata',
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { PropsWithChildren } from 'react';

export const dynamic = 'force-dynamic';

export default function Layout({ children }: PropsWithChildren<{}>) {
return (
<div>
<p>Layout</p>
{children}
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export const dynamic = 'force-dynamic';

export default function Page() {
return <p>Hello World!</p>;
}

export async function generateMetadata() {
return {
title: 'I am generated metadata',
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { waitForTransaction } from '@sentry-internal/test-utils';

test('Should create a transaction for node route handlers', async ({ request }) => {
const routehandlerTransactionPromise = waitForTransaction('nextjs-16', async transactionEvent => {
console.log(transactionEvent?.transaction);
return transactionEvent?.transaction === 'GET /route-handler/[xoxo]/node';
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,53 @@ test('Sends a transaction for a request to app router with URL', async ({ page }
}),
).toHaveLength(0);
});

test('Will create a transaction with spans for every server component and metadata generation functions when visiting a page', async ({
page,
}) => {
const serverTransactionEventPromise = waitForTransaction('nextjs-16', async transactionEvent => {
return transactionEvent?.transaction === 'GET /nested-layout';
});

await page.goto('/nested-layout');

const spanDescriptions = (await serverTransactionEventPromise).spans?.map(span => {
return span.description;
});

expect(spanDescriptions).toContainEqual('render route (app) /nested-layout');
expect(spanDescriptions).toContainEqual('build component tree');
expect(spanDescriptions).toContainEqual('resolve root layout server component');
expect(spanDescriptions).toContainEqual('resolve layout server component "(nested-layout)"');
expect(spanDescriptions).toContainEqual('resolve layout server component "nested-layout"');
expect(spanDescriptions).toContainEqual('resolve page server component "/nested-layout"');
expect(spanDescriptions).toContainEqual('generateMetadata /(nested-layout)/nested-layout/page');
expect(spanDescriptions).toContainEqual('start response');
expect(spanDescriptions).toContainEqual('NextNodeServer.clientComponentLoading');
});

test('Will create a transaction with spans for every server component and metadata generation functions when visiting a dynamic page', async ({
page,
}) => {
const serverTransactionEventPromise = waitForTransaction('nextjs-16', async transactionEvent => {
return transactionEvent?.transaction === 'GET /nested-layout/[dynamic]';
});

await page.goto('/nested-layout/123');

const spanDescriptions = (await serverTransactionEventPromise).spans?.map(span => {
return span.description;
});

expect(spanDescriptions).toContainEqual('resolve page components');
expect(spanDescriptions).toContainEqual('render route (app) /nested-layout/[dynamic]');
expect(spanDescriptions).toContainEqual('build component tree');
expect(spanDescriptions).toContainEqual('resolve root layout server component');
expect(spanDescriptions).toContainEqual('resolve layout server component "(nested-layout)"');
expect(spanDescriptions).toContainEqual('resolve layout server component "nested-layout"');
expect(spanDescriptions).toContainEqual('resolve layout server component "[dynamic]"');
expect(spanDescriptions).toContainEqual('resolve page server component "/nested-layout/[dynamic]"');
expect(spanDescriptions).toContainEqual('generateMetadata /(nested-layout)/nested-layout/[dynamic]/page');
expect(spanDescriptions).toContainEqual('start response');
expect(spanDescriptions).toContainEqual('NextNodeServer.clientComponentLoading');
});
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ test('Will create a transaction with spans for every server component and metada
page,
}) => {
const serverTransactionEventPromise = waitForTransaction('nextjs-app-dir', async transactionEvent => {
console.log(transactionEvent?.transaction);
return transactionEvent?.transaction === 'GET /nested-layout/[dynamic]';
});

Expand Down
Loading