|
| 1 | +import test, { expect } from '@playwright/test'; |
| 2 | +import { waitForTransaction } from '@sentry-internal/test-utils'; |
| 3 | + |
| 4 | +test('Should create a transaction for node route handlers', async ({ request }) => { |
| 5 | + const routehandlerTransactionPromise = waitForTransaction('nextjs-15', async transactionEvent => { |
| 6 | + console.log(transactionEvent?.transaction); |
| 7 | + return transactionEvent?.transaction === 'GET /route-handler/[xoxo]/node'; |
| 8 | + }); |
| 9 | + |
| 10 | + const response = await request.get('/route-handler/123/node', { headers: { 'x-charly': 'gomez' } }); |
| 11 | + expect(await response.json()).toStrictEqual({ message: 'Hello Node Route Handler' }); |
| 12 | + |
| 13 | + const routehandlerTransaction = await routehandlerTransactionPromise; |
| 14 | + |
| 15 | + expect(routehandlerTransaction.contexts?.trace?.status).toBe('ok'); |
| 16 | + expect(routehandlerTransaction.contexts?.trace?.op).toBe('http.server'); |
| 17 | + |
| 18 | + // This is flaking on dev mode |
| 19 | + if (process.env.TEST_ENV !== 'development' && process.env.TEST_ENV !== 'dev-turbopack') { |
| 20 | + expect(routehandlerTransaction.contexts?.trace?.data?.['http.request.header.x_charly']).toBe('gomez'); |
| 21 | + } |
| 22 | +}); |
| 23 | + |
| 24 | +test('Should create a transaction for edge route handlers', async ({ request }) => { |
| 25 | + const routehandlerTransactionPromise = waitForTransaction('nextjs-15', async transactionEvent => { |
| 26 | + return transactionEvent?.transaction === 'GET /route-handler/[xoxo]/edge'; |
| 27 | + }); |
| 28 | + |
| 29 | + const response = await request.get('/route-handler/123/edge', { headers: { 'x-charly': 'gomez' } }); |
| 30 | + expect(await response.json()).toStrictEqual({ message: 'Hello Edge Route Handler' }); |
| 31 | + |
| 32 | + const routehandlerTransaction = await routehandlerTransactionPromise; |
| 33 | + |
| 34 | + expect(routehandlerTransaction.contexts?.trace?.status).toBe('ok'); |
| 35 | + expect(routehandlerTransaction.contexts?.trace?.op).toBe('http.server'); |
| 36 | + // todo: check if we can set request headers for edge on sdkProcessingMetadata |
| 37 | + // expect(routehandlerTransaction.contexts?.trace?.data?.['http.request.header.x-charly']).toBe('gomez'); |
| 38 | +}); |
0 commit comments