-
Couldn't load subscription status.
- Fork 55
test: updated setup for identity tests #1105
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
base: test/SDKE-303-evaluate-each-integration-test-setup
Are you sure you want to change the base?
test: updated setup for identity tests #1105
Conversation
| captureConsole, | ||
| mocha: { | ||
| timeout: 5000 // 5 seconds. Increase from default 2 seconds. | ||
| timeout: 10000 // 10 seconds. Increase from default 2 seconds. |
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.
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.
nevermind, may be the comment i left above actually in the utils.js file for waitForCondition instead
test/src/config/utils.js
Outdated
| waitForCondition = function async( | ||
| conditionFn, | ||
| timeout = 200, | ||
| timeout = 2000, |
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.
| await waitForCondition(hasIdentityCallInflightReturned); | ||
| await waitForCondition(() => { |
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.
this should be either the await you added OR the await that's already here. there isn't really a reason to have both. I'd test again using just the bottom one, because the fetchMock on line 1051 i the reason the current waitForConfition should be working. if the one you added is more reliable though, that's fine
| await waitForCondition(() => { | ||
| const currentUser = mParticle.Identity.getCurrentUser(); | ||
| const userIdentities = currentUser?.getUserIdentities()?.userIdentities; | ||
| return userIdentities && | ||
| userIdentities.customerid === 'customerid1' && | ||
| userIdentities.email === '[email protected]'; | ||
| }); |
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 think I see why the waitForCondition for identityCallInFlight === false may not be reliable. because it is set to false BEFORE parsing the identityResponse, which is where a lot of the additional logic about making a new current user, happens. So we can probably remove the waitForCondition and leave yours.
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.
This can be a future cleanup ticket once we merge everything in, but at the bottom of the parseIdentityResponse, we do log Successfully parsed Identity Response. I wonder if we should be mocking the logger and waiting for this to be called and then this will basically allow us to know that an identity has been fully returned AND completely parsed.
| mParticle.getInstance()._Store.identityCallInFlight === false | ||
| ); | ||
| }); | ||
| // switching back to logged in user should not result in any UIC events |
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.
let's keep this comment
test/src/tests-identity.ts
Outdated
| mParticle.init(apiKey, window.mParticle.config); | ||
|
|
||
| await waitForCondition(hasIdentityCallInflightReturned) | ||
| await waitForCondition(hasIdentityCallInflightReturned); |
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.
| await waitForCondition(hasIdentityCallInflightReturned); | |
| await waitForCondition(hasIdentityCallInflightReturned); |
…o test/SDKE-399-evaluate-identity-related-tests
test/src/config/utils.js
Outdated
| hasIdentityResponseParsed = (loggerSpy) => { | ||
| return () => loggerSpy?.verbose?.getCalls()?.some(call => | ||
| call.args[0] === 'Successfully parsed Identity Response' | ||
| ) || false; |
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.
the || false here is unnecessary since the .some() already returns a boolean
| ) || false; | |
| ); |
|
|
||
| fetchMock.resetHistory(); | ||
| // Clear out before each init call | ||
| await waitForCondition(hasBeforeEachCallbackReturned); |
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.
If you add await waitForCondition anywhere in this file, I'd suggest adding it above resetForTests in the same codeblock
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.
Yeah, totally makes sense since we're checking if the beforeEach init has completed before resetting. Updated for all occurrences in the code.
test/src/tests-identity.ts
Outdated
| await waitForCondition(hasIdentityCallInflightReturned); | ||
| await waitForCondition(hasLoginReturned); |
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 think this can be just
| await waitForCondition(hasIdentityCallInflightReturned); | |
| await waitForCondition(hasLoginReturned); | |
| await waitForCondition(hasIdentityResponseParsed(loggerSpy)); |
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, missed that. Updated the test now.
|




Background
What Has Changed
Screenshots/Video
Checklist
Additional Notes
Reference Issue (For employees only. Ignore if you are an outside contributor)