-
Notifications
You must be signed in to change notification settings - Fork 252
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
resolved conflicts , merged with main
- Loading branch information
Showing
64 changed files
with
1,961 additions
and
635 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -118,6 +118,18 @@ describe('AmazonAds.syncAudiencesToDSP', () => { | |
) | ||
expect(response[0].options).toMatchSnapshot() | ||
}) | ||
it('should throw an error when an event has invalid externalUserId', async () => { | ||
await expect( | ||
testDestination.testAction('syncAudiencesToDSP', { | ||
event: { | ||
...event, | ||
userId: '[email protected]' | ||
}, | ||
settings, | ||
useDefaultMappings: true | ||
}) | ||
).rejects.toThrowError('externalUserId must satisfy regular expression pattern: [0-9a-zA-Z\\-\\_]{1,128}}') | ||
}) | ||
|
||
it('should work with batch events', async () => { | ||
nock(`https://advertising-api.amazon.com`) | ||
|
@@ -128,6 +140,7 @@ describe('AmazonAds.syncAudiencesToDSP', () => { | |
const events: SegmentEvent[] = [ | ||
{ | ||
...event, | ||
userId: '[email protected]', | ||
event: 'Audience Entered', | ||
properties: { | ||
audience_key: 'example_event_once_30_4_24_1', | ||
|
@@ -140,7 +153,7 @@ describe('AmazonAds.syncAudiencesToDSP', () => { | |
}, | ||
{ | ||
...event, | ||
userId: 'test-kochar-02', | ||
userId: 'test_kochar-02', | ||
event: 'Audience Exited', | ||
properties: { | ||
audience_key: 'example_event_once_30_4_24_1', | ||
|
@@ -165,11 +178,52 @@ describe('AmazonAds.syncAudiencesToDSP', () => { | |
expect(response[0].status).toBe(202) | ||
expect(response[0].data).toMatchObject({ jobRequestId: '1155d3e3-b18c-4b2b-a3b2-26173cdaf770' }) | ||
expect(response[0].options.body).toBe( | ||
'{"records":[{"externalUserId":"test-kochar-01","countryCode":"US","action":"CREATE","hashedPII":[{"firstname":"44104fcaef8476724152090d6d7bd9afa8ca5b385f6a99d3c6cf36b943b9872d","city":"b4c0372af033c406857a420644e46c806280a0bab8246bd0c62c7807f66f794f","state":"92db9c574d420b2437b29d898d55604f61df6c17f5163e53337f2169dd70d38d","email":"87924606b4131a8aceeeae8868531fbb9712aaa07a5d3a756b26ce0f5d6ca674"}]},{"externalUserId":"test-kochar-02","countryCode":"US","action":"DELETE","hashedPII":[{"firstname":"44104fcaef8476724152090d6d7bd9afa8ca5b385f6a99d3c6cf36b943b9872d","lastname":"4cd1cb0957bc59e698beab9e86f062f2e84138bff5a446e49762da8fe0c2f499","address":"45cfec5f1df1af649d49fc74314d7c9272e2f63ae9119bd3ef4b22a040d98cbc","postal":"9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08","state":"92db9c574d420b2437b29d898d55604f61df6c17f5163e53337f2169dd70d38d","email":"bd0bcf03735a1a00c6f1dd21c63c5d819e7e450298f301698192e8df90da3bb3"}]}],"audienceId":379909525712777677}' | ||
'{"records":[{"externalUserId":"test_kochar-02","countryCode":"US","action":"DELETE","hashedPII":[{"firstname":"44104fcaef8476724152090d6d7bd9afa8ca5b385f6a99d3c6cf36b943b9872d","lastname":"4cd1cb0957bc59e698beab9e86f062f2e84138bff5a446e49762da8fe0c2f499","address":"45cfec5f1df1af649d49fc74314d7c9272e2f63ae9119bd3ef4b22a040d98cbc","postal":"9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08","state":"92db9c574d420b2437b29d898d55604f61df6c17f5163e53337f2169dd70d38d","email":"bd0bcf03735a1a00c6f1dd21c63c5d819e7e450298f301698192e8df90da3bb3"}]}],"audienceId":379909525712777677}' | ||
) | ||
expect(response[0].options).toMatchSnapshot() | ||
}) | ||
|
||
it('should throw an error when all events are having invalid externalUserId', async () => { | ||
const events: SegmentEvent[] = [ | ||
{ | ||
...event, | ||
userId: '[email protected]', | ||
event: 'Audience Entered', | ||
properties: { | ||
audience_key: 'example_event_once_30_4_24_1', | ||
example_event_once_30_4_24_1: true, | ||
email: '[email protected]', | ||
first_name: 'gaurav', | ||
city: 'Gurgaon', | ||
state: 'Haryana' | ||
} | ||
}, | ||
{ | ||
...event, | ||
userId: '[email protected]', | ||
event: 'Audience Exited', | ||
properties: { | ||
audience_key: 'example_event_once_30_4_24_1', | ||
example_event_once_30_4_24_1: true, | ||
email: '[email protected]', | ||
postal: 'test', | ||
address: '#501/2, Test Address', | ||
first_name: 'gaurav', | ||
last_name: 'kochar', | ||
state: 'Haryana' | ||
} | ||
} | ||
] | ||
|
||
await expect( | ||
testDestination.testBatchAction('syncAudiencesToDSP', { | ||
events, | ||
settings, | ||
useDefaultMappings: true | ||
}) | ||
).rejects.toThrowError('externalUserId must satisfy regular expression pattern: [0-9a-zA-Z\\-\\_]{1,128}}') | ||
}) | ||
|
||
it('Handle Error when amazon ads API throw error', async () => { | ||
nock(`https://advertising-api.amazon.com`) | ||
.post('/amc/audiences/records') | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ Object { | |
}, | ||
"email": "[email protected]", | ||
"ip_address": "33.172.51.152", | ||
"sms_number": "XoS!vJs", | ||
"phone": "XoS!vJs", | ||
"status": "XoS!vJs", | ||
"status_updated_at": "2021-02-01T00:00:00.000Z", | ||
"tags": Array [ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ Object { | |
}, | ||
"email": "[email protected]", | ||
"ip_address": "100.102.165.77", | ||
"sms_number": "DVw6A7$UK[I", | ||
"phone": "DVw6A7$UK[I", | ||
"status": "DVw6A7$UK[I", | ||
"status_updated_at": "2021-02-01T00:00:00.000Z", | ||
"tags": Array [ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,7 +56,7 @@ describe('Drip.identify', () => { | |
}, | ||
email: '[email protected]', | ||
ip_address: '127.0.0.1', | ||
sms_number: '1234567890', | ||
phone: '1234567890', | ||
status: 'unsubscribed', | ||
status_updated_at: '2021-01-01T00:00:00Z', | ||
tags: ['tag1', 'tag2'], | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -130,7 +130,7 @@ Object { | |
"data": Object { | ||
"attributes": Object { | ||
"anonymous_id": "mTdOx(Nl)", | ||
"email": "[email protected]", | ||
"email": "[email protected]", | ||
"external_id": "mTdOx(Nl)", | ||
"phone_number": "+5694788449", | ||
}, | ||
|
Oops, something went wrong.