-
Notifications
You must be signed in to change notification settings - Fork 42
[MOB-12267] add pauseEmbeddedImpression method to manage embedded message impressions #785
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
Changes from all commits
b1e5760
ed9b4ad
ebe8c47
c942457
da20dcf
a626f06
9e07bac
49f5e2f
718a158
05f737d
c3710c5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -49,6 +49,26 @@ export const Embedded = () => { | |||||||
| }); | ||||||||
| }, [getPlacementIds]); | ||||||||
|
|
||||||||
| const startEmbeddedImpression = useCallback( | ||||||||
| (message: IterableEmbeddedMessage) => { | ||||||||
| console.log(`startEmbeddedImpression`, message); | ||||||||
| Iterable.embeddedManager.startImpression( | ||||||||
| message.metadata.messageId, | ||||||||
| // TODO: check if this should be changed to a number, as per the type | ||||||||
| Number(message.metadata.placementId) | ||||||||
|
Comment on lines
+57
to
+58
|
||||||||
| // TODO: check if this should be changed to a number, as per the type | |
| Number(message.metadata.placementId) | |
| message.metadata.placementId |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -167,5 +167,92 @@ describe('IterableEmbeddedManager', () => { | |
| }); | ||
| }); | ||
|
|
||
| describe('startImpression', () => { | ||
| it('should call IterableApi.startEmbeddedImpression with messageId and placementId', () => { | ||
| // GIVEN a message ID and placement ID | ||
| const messageId = 'message-123'; | ||
| const placementId = 456; | ||
|
|
||
| // WHEN startImpression is called | ||
| embeddedManager.startImpression(messageId, placementId); | ||
|
|
||
| // THEN IterableApi.startEmbeddedImpression is called with the correct parameters | ||
| expect(MockRNIterableAPI.startEmbeddedImpression).toHaveBeenCalledTimes( | ||
| 1 | ||
| ); | ||
| expect(MockRNIterableAPI.startEmbeddedImpression).toHaveBeenCalledWith( | ||
| messageId, | ||
| placementId | ||
| ); | ||
| }); | ||
|
|
||
| it('should handle multiple impression starts', () => { | ||
| // GIVEN multiple messages | ||
| const messageId1 = 'message-1'; | ||
| const placementId1 = 100; | ||
| const messageId2 = 'message-2'; | ||
| const placementId2 = 200; | ||
|
|
||
| // WHEN startImpression is called multiple times | ||
| embeddedManager.startImpression(messageId1, placementId1); | ||
| embeddedManager.startImpression(messageId2, placementId2); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not exactly remembering how the session works. If mutiple embedded messages can gather in one session and how impressions are tracked. What should starting a session mean if it is called twice. Does it append over active session? |
||
|
|
||
| // THEN IterableApi.startEmbeddedImpression is called twice | ||
| expect(MockRNIterableAPI.startEmbeddedImpression).toHaveBeenCalledTimes( | ||
| 2 | ||
| ); | ||
| expect(MockRNIterableAPI.startEmbeddedImpression).toHaveBeenNthCalledWith( | ||
| 1, | ||
| messageId1, | ||
| placementId1 | ||
| ); | ||
| expect(MockRNIterableAPI.startEmbeddedImpression).toHaveBeenNthCalledWith( | ||
| 2, | ||
| messageId2, | ||
| placementId2 | ||
| ); | ||
| }); | ||
| }); | ||
|
|
||
| describe('pauseImpression', () => { | ||
| it('should call IterableApi.pauseEmbeddedImpression with messageId', () => { | ||
| // GIVEN a message ID | ||
| const messageId = 'message-123'; | ||
|
|
||
| // WHEN pauseImpression is called | ||
| embeddedManager.pauseImpression(messageId); | ||
|
|
||
| // THEN IterableApi.pauseEmbeddedImpression is called with the correct parameter | ||
| expect(MockRNIterableAPI.pauseEmbeddedImpression).toHaveBeenCalledTimes( | ||
| 1 | ||
| ); | ||
| expect(MockRNIterableAPI.pauseEmbeddedImpression).toHaveBeenCalledWith( | ||
| messageId | ||
| ); | ||
| }); | ||
|
|
||
| it('should handle multiple impression pauses', () => { | ||
| // GIVEN multiple message IDs | ||
| const messageId1 = 'message-1'; | ||
| const messageId2 = 'message-2'; | ||
|
|
||
| // WHEN pauseImpression is called multiple times | ||
| embeddedManager.pauseImpression(messageId1); | ||
| embeddedManager.pauseImpression(messageId2); | ||
|
|
||
| // THEN IterableApi.pauseEmbeddedImpression is called twice | ||
| expect(MockRNIterableAPI.pauseEmbeddedImpression).toHaveBeenCalledTimes( | ||
| 2 | ||
| ); | ||
| expect(MockRNIterableAPI.pauseEmbeddedImpression).toHaveBeenNthCalledWith( | ||
| 1, | ||
| messageId1 | ||
| ); | ||
| expect(MockRNIterableAPI.pauseEmbeddedImpression).toHaveBeenNthCalledWith( | ||
| 2, | ||
| messageId2 | ||
| ); | ||
| }); | ||
| }); | ||
| }); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.