From 4e1dcb4f5ebb3ce2e1b46acb25b010041f99d7a5 Mon Sep 17 00:00:00 2001 From: Charly Gomez Date: Wed, 28 Oct 2026 14:32:26 +0100 Subject: [PATCH] test(remix): Cover prefetched navigations in the Remix 3 E2E app Remix 3.1 adds data-rmx-prefetch. Bump the app to 3.1.0 and check that navigation spans to prefetched links are still named after the route. Co-Authored-By: Claude Opus 5.5 --- .../remix-v3/app/actions/controller.tsx | 6 ++++ .../test-applications/remix-v3/package.json | 2 +- .../remix-v3/tests/client.test.ts | 31 +++++++++++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/dev-packages/e2e-tests/test-applications/remix-v3/app/actions/controller.tsx b/dev-packages/e2e-tests/test-applications/remix-v3/app/actions/controller.tsx index 95b3ac655fec..471677646766 100644 --- a/dev-packages/e2e-tests/test-applications/remix-v3/app/actions/controller.tsx +++ b/dev-packages/e2e-tests/test-applications/remix-v3/app/actions/controller.tsx @@ -30,6 +30,12 @@ function HomePage(handle: Handle>) { User + + User (prefetch on intent) + + + User (prefetch in viewport) + diff --git a/dev-packages/e2e-tests/test-applications/remix-v3/package.json b/dev-packages/e2e-tests/test-applications/remix-v3/package.json index 557ccc9f0d72..7d52c7d0d8a1 100644 --- a/dev-packages/e2e-tests/test-applications/remix-v3/package.json +++ b/dev-packages/e2e-tests/test-applications/remix-v3/package.json @@ -14,7 +14,7 @@ }, "dependencies": { "@sentry/remix": "file:../../packed/sentry-remix-packed.tgz", - "remix": "3.0.0" + "remix": "3.1.0" }, "devDependencies": { "@playwright/test": "1.64.1", diff --git a/dev-packages/e2e-tests/test-applications/remix-v3/tests/client.test.ts b/dev-packages/e2e-tests/test-applications/remix-v3/tests/client.test.ts index 393a3e8e3195..5823184ba0c0 100644 --- a/dev-packages/e2e-tests/test-applications/remix-v3/tests/client.test.ts +++ b/dev-packages/e2e-tests/test-applications/remix-v3/tests/client.test.ts @@ -68,6 +68,37 @@ test('sends a navigation span for a link the runtime intercepts', async ({ page expect(span.attributes?.['sentry.segment.name.source']?.value).toBe('route'); }); +// The span is named by the navigation's own fetch, not the earlier prefetch. +for (const mode of ['intent', 'viewport'] as const) { + test(`names a navigation to a link prefetched on ${mode} by the route`, async ({ page }) => { + const prefetchPromise = page.waitForRequest( + request => request.url().endsWith(`/users/${mode}`) && request.headers()['x-remix-frame'] === 'true', + ); + + await page.goto('/'); + const link = page.locator(`#to-user-prefetch-${mode}`); + if (mode === 'intent') { + await link.hover(); + } + await (await prefetchPromise).response(); + + const spanPromise = waitForStreamedSpan( + APP_NAME, + span => + getSpanOp(span) === 'navigation' && + span.attributes?.['sentry.origin']?.value === 'auto.navigation.remix_v3' && + span.attributes?.['url.path']?.value === `/users/${mode}`, + ); + + await link.click(); + await expect(page.locator('#user')).toBeVisible(); + + const span = await spanPromise; + expect(span.name).toBe('/users/:id'); + expect(span.attributes?.['sentry.segment.name.source']?.value).toBe('route'); + }); +} + test('names a navigation to a route it loaded before right at the start', async ({ page }) => { await page.goto('/'); await page.locator('#to-user').click();