-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
test(browser): Add integration tests for sessions. #4500
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
Conversation
@@ -0,0 +1,11 @@ | |||
document.getElementById('start-session').addEventListener('click', () => { | |||
Sentry.getCurrentHub().startSession(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer if we only tested the autoSessionTracking
for now, so the sessions that start in pageload/navigation. Let’s not do manual sessions for the time being.
|
||
const session = await page.evaluateHandle<Session>('window.Sentry.getCurrentHub().getScope().getSession()'); | ||
|
||
return session.jsonValue(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer if we assert on the session envelopes instead of grabbing it this way.
size-limit report
|
* @return {*} {Promise<SessionContext>} | ||
*/ | ||
async function getCurrentSession(page: Page, url?: string): Promise<SessionContext> { | ||
return (await getMultipleSentryTransactionRequests(page, 1, url))[0]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically this is not guaranteed to be a session right?
I think we should rename getMultipleSentryTransactionRequests
-> getMultipleSentryEnvelopeRequests
and directly call that in the tests. The tests can just handle picking the right request and asserting on it (they can even assert on the total amount of requests sent if needed).
Maybe we use getMultipleSentryEnvelopeRequests
just for this PR, and then migrate the other test files in another PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, and #4527 seems to solve the confusion. I'll update the PR with proper types after that gets merged, unless this one is urgent?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing using those types internally yet, I would just make the changes here and we can come back and update this after.
@AbhiPrasad, I updated as discussed. Will also open another PR to update the other tests to use the new helper(s). Renaming |
I agree with those changes, let’s move forward with that. |
Resolves: #4358
I could not reproduce the case when the session status is not
'ok'
.