From 963eab78cf990e62bcf7479069c4fcb0136071a7 Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Thu, 11 Jul 2024 17:34:12 +0200 Subject: [PATCH] test(nextjs): Fix canary tests (#12875) --- .../tests/client-app-routing-instrumentation.test.ts | 5 ++++- .../nextjs-app-dir/tests/server-components.test.ts | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/dev-packages/e2e-tests/test-applications/nextjs-app-dir/tests/client-app-routing-instrumentation.test.ts b/dev-packages/e2e-tests/test-applications/nextjs-app-dir/tests/client-app-routing-instrumentation.test.ts index 8645d36c4c8a..9143bd0b2f90 100644 --- a/dev-packages/e2e-tests/test-applications/nextjs-app-dir/tests/client-app-routing-instrumentation.test.ts +++ b/dev-packages/e2e-tests/test-applications/nextjs-app-dir/tests/client-app-routing-instrumentation.test.ts @@ -39,7 +39,10 @@ test('Creates a navigation transaction for app router routes', async ({ page }) const serverComponentTransactionPromise = waitForTransaction('nextjs-app-dir', async transactionEvent => { return ( - transactionEvent?.transaction === 'GET /server-component/parameter/foo/bar/baz' && + // It seems to differ between Next.js versions whether the route is parameterized or not + (transactionEvent?.transaction === 'GET /server-component/parameter/foo/bar/baz' || + transactionEvent?.transaction === 'GET /server-component/parameter/[...parameters]') && + transactionEvent.contexts?.trace?.data?.['http.target'].startsWith('/server-component/parameter/foo/bar/baz') && (await clientNavigationTransactionPromise).contexts?.trace?.trace_id === transactionEvent.contexts?.trace?.trace_id ); diff --git a/dev-packages/e2e-tests/test-applications/nextjs-app-dir/tests/server-components.test.ts b/dev-packages/e2e-tests/test-applications/nextjs-app-dir/tests/server-components.test.ts index ba232ad558b0..49afe791328f 100644 --- a/dev-packages/e2e-tests/test-applications/nextjs-app-dir/tests/server-components.test.ts +++ b/dev-packages/e2e-tests/test-applications/nextjs-app-dir/tests/server-components.test.ts @@ -3,7 +3,10 @@ import { waitForError, waitForTransaction } from '@sentry-internal/test-utils'; test('Sends a transaction for a request to app router', async ({ page }) => { const serverComponentTransactionPromise = waitForTransaction('nextjs-app-dir', transactionEvent => { - return transactionEvent?.transaction === 'GET /server-component/parameter/[...parameters]'; + return ( + transactionEvent?.transaction === 'GET /server-component/parameter/[...parameters]' && + transactionEvent.contexts?.trace?.data?.['http.target'].startsWith('/server-component/parameter/1337/42') + ); }); await page.goto('/server-component/parameter/1337/42');