Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,16 @@ describe('Audience Destination', () => {
describe('createAudience', () => {
it('creates an audience successfully', async () => {
nock('https://displayvideo.googleapis.com')
.post('/v3/firstAndThirdPartyAudiences?advertiserId=12345', {
.post('/v4/firstPartyAndPartnerAudiences?advertiserId=12345', {
displayName: audienceName,
audienceType: 'CUSTOMER_MATCH_CONTACT_INFO',
membershipDurationDays: '30',
description: 'Test description',
audienceSource: 'AUDIENCE_SOURCE_UNSPECIFIED',
firstAndThirdPartyAudienceType: 'FIRST_AND_THIRD_PARTY_AUDIENCE_TYPE_FIRST_PARTY'
firstPartyAndPartnerAudienceType: 'TYPE_FIRST_PARTY'
})
.matchHeader('Authorization', 'Bearer temp-token')
.reply(200, { firstAndThirdPartyAudienceId: 'audience-id-123' })
.reply(200, { firstPartyAndPartnerAudienceId: 'audience-id-123' })

const result = await testDestination.createAudience(createAudienceInput)
expect(result).toEqual({ externalId: 'audience-id-123' })
Expand All @@ -81,10 +81,10 @@ describe('Audience Destination', () => {
describe('getAudience', () => {
it('should succeed when provided with a valid audience ID', async () => {
nock('https://displayvideo.googleapis.com')
.get(`/v3/firstAndThirdPartyAudiences/audience-id-123?advertiserId=12345`)
.get(`/v4/firstPartyAndPartnerAudiences/audience-id-123?advertiserId=12345`)
.matchHeader('Authorization', 'Bearer temp-token')
.reply(200, {
firstAndThirdPartyAudienceId: 'audience-id-123'
firstPartyAndPartnerAudienceId: 'audience-id-123'
})

const result = await testDestination.getAudience(getAudienceInput)
Expand Down Expand Up @@ -132,7 +132,7 @@ describe('Audience Destination', () => {

it('should add customer match members successfully', async () => {
nock('https://displayvideo.googleapis.com')
.post('/v3/firstAndThirdPartyAudiences/audience-id-123:editCustomerMatchMembers', {
.post('/v4/firstPartyAndPartnerAudiences/audience-id-123:editCustomerMatchMembers', {
advertiserId: '12345',
addedContactInfoList: {
contactInfos: [
Expand All @@ -151,7 +151,7 @@ describe('Audience Destination', () => {
}
}
})
.reply(200, { firstAndThirdPartyAudienceId: 'audience-id-123' })
.reply(200, { firstPartyAndPartnerAudienceId: 'audience-id-123' })

const result = await testDestination.testAction('addToAudContactInfo', {
event,
Expand All @@ -160,15 +160,15 @@ describe('Audience Destination', () => {
expect(result).toContainEqual(
expect.objectContaining({
data: expect.objectContaining({
firstAndThirdPartyAudienceId: 'audience-id-123'
firstPartyAndPartnerAudienceId: 'audience-id-123'
})
})
)
})

it('should remove customer match members successfully', async () => {
nock('https://displayvideo.googleapis.com')
.post('/v3/firstAndThirdPartyAudiences/audience-id-123:editCustomerMatchMembers', {
.post('/v4/firstPartyAndPartnerAudiences/audience-id-123:editCustomerMatchMembers', {
advertiserId: '12345',
removedContactInfoList: {
contactInfos: [
Expand All @@ -187,7 +187,7 @@ describe('Audience Destination', () => {
}
}
})
.reply(200, { firstAndThirdPartyAudienceId: 'audience-id-123' })
.reply(200, { firstPartyAndPartnerAudienceId: 'audience-id-123' })

const result = await testDestination.testAction('removeFromAudContactInfo', {
event,
Expand All @@ -196,7 +196,7 @@ describe('Audience Destination', () => {
expect(result).toContainEqual(
expect.objectContaining({
data: expect.objectContaining({
firstAndThirdPartyAudienceId: 'audience-id-123'
firstPartyAndPartnerAudienceId: 'audience-id-123'
})
})
)
Expand Down Expand Up @@ -227,7 +227,7 @@ describe('Audience Destination', () => {

it('should add customer match members successfully', async () => {
nock('https://displayvideo.googleapis.com')
.post('/v3/firstAndThirdPartyAudiences/audience-id-123:editCustomerMatchMembers', {
.post('/v4/firstPartyAndPartnerAudiences/audience-id-123:editCustomerMatchMembers', {
advertiserId: '12345',
addedMobileDeviceIdList: {
mobileDeviceIds: ['123'],
Expand All @@ -237,7 +237,7 @@ describe('Audience Destination', () => {
}
}
})
.reply(200, { firstAndThirdPartyAudienceId: 'audience-id-123' })
.reply(200, { firstPartyAndPartnerAudienceId: 'audience-id-123' })

const result = await testDestination.testAction('addToAudMobileDeviceId', {
event,
Expand All @@ -246,15 +246,15 @@ describe('Audience Destination', () => {
expect(result).toContainEqual(
expect.objectContaining({
data: expect.objectContaining({
firstAndThirdPartyAudienceId: 'audience-id-123'
firstPartyAndPartnerAudienceId: 'audience-id-123'
})
})
)
})

it('should remove customer match members successfully', async () => {
nock('https://displayvideo.googleapis.com')
.post('/v3/firstAndThirdPartyAudiences/audience-id-123:editCustomerMatchMembers', {
.post('/v4/firstPartyAndPartnerAudiences/audience-id-123:editCustomerMatchMembers', {
advertiserId: '12345',
removedMobileDeviceIdList: {
mobileDeviceIds: ['123'],
Expand All @@ -264,7 +264,7 @@ describe('Audience Destination', () => {
}
}
})
.reply(200, { firstAndThirdPartyAudienceId: 'audience-id-123' })
.reply(200, { firstPartyAndPartnerAudienceId: 'audience-id-123' })

const result = await testDestination.testAction('removeFromAudMobileDeviceId', {
event,
Expand All @@ -273,7 +273,7 @@ describe('Audience Destination', () => {
expect(result).toContainEqual(
expect.objectContaining({
data: expect.objectContaining({
firstAndThirdPartyAudienceId: 'audience-id-123'
firstPartyAndPartnerAudienceId: 'audience-id-123'
})
})
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const event = createTestEvent({

describe('First-Party-dv360.addToAudContactInfo', () => {
it('should hash pii data if not already hashed', async () => {
nock('https://displayvideo.googleapis.com/v3/firstAndThirdPartyAudiences')
nock('https://displayvideo.googleapis.com/v4/firstPartyAndPartnerAudiences')
.post('/1234567890:editCustomerMatchMembers')
.reply(200, { success: true })

Expand All @@ -53,7 +53,7 @@ describe('First-Party-dv360.addToAudContactInfo', () => {
})

it('should not hash pii data if already hashed', async () => {
nock('https://displayvideo.googleapis.com/v3/firstAndThirdPartyAudiences')
nock('https://displayvideo.googleapis.com/v4/firstPartyAndPartnerAudiences')
.post('/1234567890:editCustomerMatchMembers')
.reply(200, { success: true })

Expand All @@ -77,4 +77,76 @@ describe('First-Party-dv360.addToAudContactInfo', () => {
'"{\\"advertiserId\\":\\"1234567890\\",\\"addedContactInfoList\\":{\\"contactInfos\\":[{\\"hashedEmails\\":\\"584c4423c421df49955759498a71495aba49b8780eb9387dff333b6f0982c777\\",\\"hashedPhoneNumbers\\":\\"422ce82c6fc1724ac878042f7d055653ab5e983d186e616826a72d4384b68af8\\",\\"zipCodes\\":\\"12345\\",\\"hashedFirstName\\":\\"96d9632f363564cc3032521409cf22a852f2032eec099ed5967c0d000cec607a\\",\\"hashedLastName\\":\\"799ef92a11af918e3fb741df42934f3b568ed2d93ac1df74f1b8d41a27932a6f\\",\\"countryCode\\":\\"US\\"}],\\"consent\\":{\\"adUserData\\":\\"CONSENT_STATUS_GRANTED\\",\\"adPersonalization\\":\\"CONSENT_STATUS_GRANTED\\"}}}"'
)
})

it('should batch multiple payloads into a single request when enable_batching is true', async () => {
nock('https://displayvideo.googleapis.com/v4/firstPartyAndPartnerAudiences')
.post('/1234567890:editCustomerMatchMembers')
.reply(200, { success: true })

const events = createBatchTestEvents(createContactList)
const responses = await testDestination.testBatchAction('addToAudContactInfo', {
events: events,
mapping: {
emails: ['584c4423c421df49955759498a71495aba49b8780eb9387dff333b6f0982c777'],
phoneNumbers: ['422ce82c6fc1724ac878042f7d055653ab5e983d186e616826a72d4384b68af8'],
zipCodes: ['12345'],
firstName: '96d9632f363564cc3032521409cf22a852f2032eec099ed5967c0d000cec607a',
lastName: '799ef92a11af918e3fb741df42934f3b568ed2d93ac1df74f1b8d41a27932a6f',
countryCode: 'US',
external_id: '1234567890',
advertiser_id: '1234567890',
enable_batching: true,
batch_size: 2
}
})

const requestBody = JSON.parse(String(responses[0].options.body))
expect(requestBody.addedContactInfoList.contactInfos.length).toBe(2)
expect(requestBody.addedContactInfoList.contactInfos[0].hashedEmails).toBeDefined()
expect(requestBody.addedContactInfoList.contactInfos[1].hashedEmails).toBeDefined()
// Optionally, check that the emails are correctly hashed and correspond to the input
})
})

export type BatchContactListItem = {
id?: string
email: string
firstname: string
lastname: string
}

export const createBatchTestEvents = (batchContactList: BatchContactListItem[]) =>
batchContactList.map((contact) =>
createTestEvent({
type: 'identify',
traits: {
email: contact.email,
firstname: contact.firstname,
lastname: contact.lastname,
address: {
city: 'San Francisco',
country: 'USA',
postal_code: '600001',
state: 'California',
street: 'Vancover st'
},
graduation_date: 1664533942262,
company: 'Some Company',
phone: '+13134561129',
website: 'somecompany.com'
}
})
)

const createContactList: BatchContactListItem[] = [
{
email: '[email protected]',
firstname: 'User',
lastname: 'One'
},
{
email: '[email protected]',
firstname: 'User',
lastname: 'Two'
}
]
Loading
Loading