Skip to content

test(astro): Add E2E test case for catch-all routes #17085

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
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
@@ -0,0 +1,12 @@
---
import Layout from '../../layouts/Layout.astro';

export const prerender = false;

const params = Astro.params;

---

<Layout title="CatchAll SSR page">
<p>params: {params}</p>
</Layout>
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ test.describe('nested SSR routes (client, server, server request)', () => {
expect(serverRequestHTTPClientSpan).toMatchObject({
op: 'http.client',
origin: 'auto.http.otel.node_fetch',
description: 'GET http://localhost:3030/api/user/myUsername123.json', // todo: parametrize (this is just a span though - no transaction)
description: 'GET http://localhost:3030/api/user/myUsername123.json', // http.client does not need to be parametrized
data: {
'sentry.op': 'http.client',
'sentry.origin': 'auto.http.otel.node_fetch',
Expand Down Expand Up @@ -262,4 +262,53 @@ test.describe('nested SSR routes (client, server, server request)', () => {
request: { url: expect.stringContaining('/api/user/myUsername123.json') },
});
});

test('sends parametrized pageload and server transaction names for catch-all routes', async ({ page }) => {
const clientPageloadTxnPromise = waitForTransaction('astro-5', txnEvent => {
return txnEvent?.transaction?.startsWith('/catchAll/') ?? false;
});

const serverPageRequestTxnPromise = waitForTransaction('astro-5', txnEvent => {
return txnEvent?.transaction?.startsWith('GET /catchAll/') ?? false;
});

await page.goto('/catchAll/hell0/whatever-do');

const clientPageloadTxn = await clientPageloadTxnPromise;
const serverPageRequestTxn = await serverPageRequestTxnPromise;

expect(clientPageloadTxn).toMatchObject({
transaction: '/catchAll/hell0/whatever-do', // todo: parametrize to '/catchAll/[...path]'
transaction_info: { source: 'url' },
contexts: {
trace: {
op: 'pageload',
origin: 'auto.pageload.browser',
data: {
'sentry.op': 'pageload',
'sentry.origin': 'auto.pageload.browser',
'sentry.source': 'url',
},
},
},
});

expect(serverPageRequestTxn).toMatchObject({
transaction: 'GET /catchAll/[path]',
transaction_info: { source: 'route' },
contexts: {
trace: {
op: 'http.server',
origin: 'auto.http.astro',
data: {
'sentry.op': 'http.server',
'sentry.origin': 'auto.http.astro',
'sentry.source': 'route',
url: expect.stringContaining('/catchAll/hell0/whatever-do'),
},
},
},
request: { url: expect.stringContaining('/catchAll/hell0/whatever-do') },
});
});
});
Loading