Skip to content

test(e2e/react): Add e2e tests for Scope transactionName changes #11053

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

Closed
wants to merge 3 commits into from

Conversation

Lms24
Copy link
Member

@Lms24 Lms24 commented Mar 12, 2024

This PR adds two React standard-frontend-react e2e tests to cover the changes made in #11048. To avoid adding tests that poll the Sentry API and potentially cause timeouts, I added our event proxy e2e testing stragegy to the standard-frontend-react test app.

ref #10846

@Lms24 Lms24 changed the base branch from develop to lms/feat-react-auto-update-transactionName March 12, 2024 14:48
Comment on lines +68 to +99
const sentryRequest = https.request(
sentryIngestUrl,
{ headers: proxyRequest.headers, method: proxyRequest.method },
sentryResponse => {
sentryResponse.addListener('data', (chunk: Buffer) => {
proxyResponse.write(chunk, 'binary');
sentryResponseChunks.push(chunk);
});

sentryResponse.addListener('end', () => {
eventCallbackListeners.forEach(listener => {
const rawSentryResponseBody = Buffer.concat(sentryResponseChunks).toString();

const data: SentryRequestCallbackData = {
envelope: parseEnvelope(proxyRequestBody),
rawProxyRequestBody: proxyRequestBody,
rawSentryResponseBody,
sentryResponseStatusCode: sentryResponse.statusCode,
};

listener(Buffer.from(JSON.stringify(data)).toString('base64'));
});
proxyResponse.end();
});

sentryResponse.addListener('error', err => {
throw err;
});

proxyResponse.writeHead(sentryResponse.statusCode || 500, sentryResponse.headers);
},
);

Check failure

Code scanning / CodeQL

Server-side request forgery

The [URL](1) of this request depends on a [user-provided value](2).
Comment on lines +13 to +42
expect(error).toMatchObject({
exception: {
values: [
{
type: 'Error',
value: 'I am an error!',
mechanism: {
type: 'generic',
handled: true, // called via captureException, this makes sense
},
},
],
},
transaction: '/',
contexts: {
trace: {
data: {
'sentry.source': 'route',
'sentry.origin': 'auto.pageload.react.reactrouter_v6',
'sentry.op': 'pageload',
'sentry.sample_rate': 1,
},
op: 'pageload',
span_id: expect.any(String),
trace_id: expect.any(String),
origin: 'auto.pageload.react.reactrouter_v6',
},
},
});
});
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This checks two things:

  1. That the trace context is applied correctly to the error event (this is inherently tied to the active root span)
  2. That the transaction field is set correctly (this is no longer tied to the active root span at all)

@Lms24 Lms24 requested review from lforst and mydea March 12, 2024 14:51
@Lms24 Lms24 force-pushed the lms/feat-react-auto-update-transactionName branch from 9d16569 to 7680875 Compare March 12, 2024 15:16
Base automatically changed from lms/feat-react-auto-update-transactionName to develop March 12, 2024 16:43
@Lms24 Lms24 force-pushed the lms/test-react-e2e-add-error-transaction-test branch from 01ea3e7 to defe516 Compare March 13, 2024 09:26
@Lms24 Lms24 force-pushed the lms/test-react-e2e-add-error-transaction-test branch from 92d3a07 to 1e5dd9c Compare March 13, 2024 12:10
@mydea
Copy link
Member

mydea commented Apr 17, 2024

@Lms24 would we still like to merge this?

@Lms24
Copy link
Member Author

Lms24 commented Apr 17, 2024

@mydea yes, I'd like to merge these but something was still off with the tests. I need to come back to #10846 anyway so let's keep this open for now

@Lms24 Lms24 closed this Aug 26, 2024
@Lms24 Lms24 deleted the lms/test-react-e2e-add-error-transaction-test branch December 3, 2024 09:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants