-
Notifications
You must be signed in to change notification settings - Fork 57
refactor: Migrate Forwarder Tests to TypeScript #976
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
refactor: Migrate Forwarder Tests to TypeScript #976
Conversation
b7b5e0c to
f06f6e2
Compare
rmi22186
left a comment
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.
Looking good so far...
src/mp-instance.ts
Outdated
| // this.EventType = EventType as unknown as valueof<typeof EventType>; | ||
| this.EventType = EventType; |
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.
Which one works here?
src/mparticle-instance-manager.ts
Outdated
| // this.EventType = EventType as unknown as valueof<typeof EventType>; | ||
| this.EventType = EventType; |
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.
ditto to comment above
| } = Utils; | ||
|
|
||
| const mParticle = window.mParticle; | ||
| // interface MockMParticleForIntegrationCapture extends IMParticleInstanceManager {} |
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.
necessary?
test/src/tests-kit-blocking.ts
Outdated
| import Types from '../../src/types'; | ||
| import { DataPlanVersion } from '@mparticle/data-planning-models'; | ||
| import fetchMock from 'fetch-mock/esm/client'; | ||
| // import { IMockForwarder } from './tests-forwarders'; |
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.
not needed?
test/src/tests-forwarders.ts
Outdated
| mParticle.logPageView(); | ||
|
|
||
| Should(window.MockForwarder1.instance.receivedEvent).not.be.ok(); | ||
| mParticle.logPageView('Page View'); |
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 argument to logPageView is technically optional, so we should update that in the definition. When it is invoked with no arguments, it will automatically log event attributes with title and hostname, but when you pass an argument, it will set an attribute called screen_name
test/src/tests-forwarders.ts
Outdated
|
|
||
| mParticle.init(apiKey, window.mParticle.config); | ||
| await waitForCondition(hasIdentityCallInflightReturned); | ||
| await waitForCondition(() => window.mParticle.getInstance()?._Store?.identityCallInFlight === 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.
Hm, why the change for this? Should we change the definition of hasIdentityCallInflightReturned to be this instead?
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 a mistake on my part.
test/src/tests-forwarders.ts
Outdated
| }); | ||
|
|
||
| it('should set only strings as integration attributes', async function() { | ||
| it('should set only strings as integration attributes', async () => { |
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 renaming this to sanitize is better actually, otherwise it sounds like we may be converting to strings
| it('should set only strings as integration attributes', async () => { | |
| it('should sanitize any non-strings from integration attributes', async () => { |
test/src/tests-forwarders.ts
Outdated
| // client calls reset | ||
| mParticle.reset(); | ||
| // QUESTION: Should this actually take a parameter? it should probably be optional | ||
| mParticle.reset(null); |
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.
doesn't look like it based on the function signatures and how its used - in this case you are calling reset on the instance manager, which will automatically call the default instance and pass in that instance.
however, we should make a ticket to revisit reset in general and see how we can make it better. right now it's mostly used for tests, but i do believe customers have asked how they could perform some sort of similar functionality
test/src/tests-forwarders.ts
Outdated
| // QUESTION: Where is this coming from? | ||
| // expect(mpInstance._Store.isUsingSideloadedKits).to.be.undefined; |
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 is likely a relic of a test when I was developing this. Putting my archaeology hat on...when i look at the store.ts, I see sideloadedKitsCount. So that probably suppllanted isUsingSideloadedKits and adds more info because if sideloadedKitsCount is greater than 0, that gives us the answer to "are they using side loaded kits", and also "how many are they using"
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.
IIRC I added sideloadedKitsCount when we were trying to add metrics around side loaded kits. Not sure if that helps add context.
I say we probably should just remove this line since it's not a real method.
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.
yea i agree with removing
rmi22186
left a comment
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.
one question otherwise looks great
8d9f826 to
351b0ff
Compare
|
|
🎉 This PR is included in version 2.34.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |


Instructions
developmentSummary
Testing Plan
mParticleobject in the dev console.Reference Issue (For mParticle employees only. Ignore if you are an outside contributor)