Skip to content
Open
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 @@ -53,7 +53,7 @@ beforeEach(() => {
// Create Audience Tests
describe('Audience Destination', () => {
describe('createAudience', () => {
it('creates an audience successfully with feature flag ON (v4)', async () => {
it('creates an audience successfully with CANARY VERSION', async () => {
nock('https://displayvideo.googleapis.com')
.post('/v4/firstPartyAndPartnerAudiences?advertiserId=12345', {
displayName: audienceName,
Expand All @@ -68,27 +68,7 @@ describe('Audience Destination', () => {

const result = await testDestination.createAudience({
...createAudienceInput,
features: { 'actions-first-party-dv360-version-update': true }
})
expect(result).toEqual({ externalId: 'audience-id-123' })
})

it('creates an audience successfully with feature flag OFF (v3)', async () => {
nock('https://displayvideo.googleapis.com')
.post('/v3/firstAndThirdPartyAudiences?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'
})
.matchHeader('Authorization', 'Bearer temp-token')
.reply(200, { firstAndThirdPartyAudienceId: 'audience-id-123' })

const result = await testDestination.createAudience({
...createAudienceInput,
features: { 'actions-first-party-dv360-version-update': false }
features: { 'first-party-dv360-canary-version': true }
})
expect(result).toEqual({ externalId: 'audience-id-123' })
})
Expand All @@ -100,28 +80,15 @@ describe('Audience Destination', () => {
})

describe('getAudience', () => {
it('should succeed with feature flag ON (v4)', async () => {
it('should succeed with CANARY VERSION', async () => {
nock('https://displayvideo.googleapis.com')
.get(`/v4/firstPartyAndPartnerAudiences/audience-id-123?advertiserId=12345`)
.matchHeader('Authorization', 'Bearer temp-token')
.reply(200, { firstPartyAndPartnerAudienceId: 'audience-id-123' })

const result = await testDestination.getAudience({
...getAudienceInput,
features: { 'actions-first-party-dv360-version-update': true }
})
expect(result).toEqual({ externalId: 'audience-id-123' })
})

it('should succeed with feature flag OFF (v3)', async () => {
nock('https://displayvideo.googleapis.com')
.get(`/v3/firstAndThirdPartyAudiences/audience-id-123?advertiserId=12345`)
.matchHeader('Authorization', 'Bearer temp-token')
.reply(200, { firstAndThirdPartyAudienceId: 'audience-id-123' })

const result = await testDestination.getAudience({
...getAudienceInput,
features: { 'actions-first-party-dv360-version-update': false }
features: { 'first-party-dv360-canary-version': true }
})
expect(result).toEqual({ externalId: 'audience-id-123' })
})
Expand Down Expand Up @@ -164,14 +131,14 @@ describe('Audience Destination', () => {
}
})

it('should add customer match members successfully with feature flag ON (v4)', async () => {
it('should add customer match members successfully with CANARY VERSION', async () => {
nock('https://displayvideo.googleapis.com')
.post('/v4/firstPartyAndPartnerAudiences/audience-id-123:editCustomerMatchMembers')
.reply(200, { firstPartyAndPartnerAudienceId: 'audience-id-123' })
const result = await testDestination.testAction('addToAudContactInfo', {
event,
useDefaultMappings: true,
features: { 'actions-first-party-dv360-version-update': true }
features: { 'first-party-dv360-canary-version': true }
})
expect(result).toContainEqual(
expect.objectContaining({
Expand All @@ -181,24 +148,7 @@ describe('Audience Destination', () => {
})
)
})
it('should add customer match members successfully with feature flag OFF (v3)', async () => {
nock('https://displayvideo.googleapis.com')
.post('/v3/firstAndThirdPartyAudiences/audience-id-123:editCustomerMatchMembers')
.reply(200, { firstAndThirdPartyAudienceId: 'audience-id-123' })
const result = await testDestination.testAction('addToAudContactInfo', {
event,
useDefaultMappings: true,
features: { 'actions-first-party-dv360-version-update': false }
})
expect(result).toContainEqual(
expect.objectContaining({
data: expect.objectContaining({
firstAndThirdPartyAudienceId: 'audience-id-123'
})
})
)
})
it('should remove customer match members successfully with feature flag ON (v4)', async () => {
it('should remove customer match members successfully with CANARY VERSION', async () => {
nock('https://displayvideo.googleapis.com')
.post('/v4/firstPartyAndPartnerAudiences/audience-id-123:editCustomerMatchMembers', {
advertiserId: '12345',
Expand All @@ -224,7 +174,7 @@ describe('Audience Destination', () => {
const result = await testDestination.testAction('removeFromAudContactInfo', {
event,
useDefaultMappings: true,
features: { 'actions-first-party-dv360-version-update': true }
features: { 'first-party-dv360-canary-version': true }
})
expect(result).toContainEqual(
expect.objectContaining({
Expand All @@ -234,42 +184,6 @@ describe('Audience Destination', () => {
})
)
})
it('should remove customer match members successfully with feature flag OFF (v3)', async () => {
nock('https://displayvideo.googleapis.com')
.post('/v3/firstAndThirdPartyAudiences/audience-id-123:editCustomerMatchMembers', {
advertiserId: '12345',
removedContactInfoList: {
contactInfos: [
{
hashedEmails: '87924606b4131a8aceeeae8868531fbb9712aaa07a5d3a756b26ce0f5d6ca674',
hashedPhoneNumbers: 'c775e7b757ede630cd0aa1113bd102661ab38829ca52a6422ab782862f268646',
zipCodes: '12345',
hashedFirstName: '96d9632f363564cc3032521409cf22a852f2032eec099ed5967c0d000cec607a',
hashedLastName: '799ef92a11af918e3fb741df42934f3b568ed2d93ac1df74f1b8d41a27932a6f',
countryCode: '+1'
}
],
consent: {
adUserData: 'CONSENT_STATUS_GRANTED',
adPersonalization: 'CONSENT_STATUS_GRANTED'
}
}
})
.reply(200, { firstAndThirdPartyAudienceId: 'audience-id-123' })

const result = await testDestination.testAction('removeFromAudContactInfo', {
event,
useDefaultMappings: true,
features: { 'actions-first-party-dv360-version-update': false }
})
expect(result).toContainEqual(
expect.objectContaining({
data: expect.objectContaining({
firstAndThirdPartyAudienceId: 'audience-id-123'
})
})
)
})
})

// Edit Customer Match Members - Mobile Device ID List
Expand All @@ -294,7 +208,7 @@ describe('Audience Destination', () => {
}
})

it('should add customer match members successfully with feature flag ON (v4)', async () => {
it('should add customer match members successfully with CANARY VERSION', async () => {
nock('https://displayvideo.googleapis.com')
.post('/v4/firstPartyAndPartnerAudiences/audience-id-123:editCustomerMatchMembers', {
advertiserId: '12345',
Expand All @@ -311,7 +225,7 @@ describe('Audience Destination', () => {
const result = await testDestination.testAction('addToAudMobileDeviceId', {
event,
useDefaultMappings: true,
features: { 'actions-first-party-dv360-version-update': true }
features: { 'first-party-dv360-canary-version': true }
})
expect(result).toContainEqual(
expect.objectContaining({
Expand All @@ -322,35 +236,7 @@ describe('Audience Destination', () => {
)
})

it('should add customer match members successfully with feature flag OFF (v3)', async () => {
nock('https://displayvideo.googleapis.com')
.post('/v3/firstAndThirdPartyAudiences/audience-id-123:editCustomerMatchMembers', {
advertiserId: '12345',
addedMobileDeviceIdList: {
mobileDeviceIds: ['123'],
consent: {
adUserData: 'CONSENT_STATUS_GRANTED',
adPersonalization: 'CONSENT_STATUS_GRANTED'
}
}
})
.reply(200, { firstAndThirdPartyAudienceId: 'audience-id-123' })

const result = await testDestination.testAction('addToAudMobileDeviceId', {
event,
useDefaultMappings: true,
features: { 'actions-first-party-dv360-version-update': false }
})
expect(result).toContainEqual(
expect.objectContaining({
data: expect.objectContaining({
firstAndThirdPartyAudienceId: 'audience-id-123'
})
})
)
})

it('should remove customer match members successfully with feature flag ON (v4)', async () => {
it('should remove customer match members successfully with CANARY VERSION', async () => {
nock('https://displayvideo.googleapis.com')
.post('/v4/firstPartyAndPartnerAudiences/audience-id-123:editCustomerMatchMembers', {
advertiserId: '12345',
Expand All @@ -367,7 +253,7 @@ describe('Audience Destination', () => {
const result = await testDestination.testAction('removeFromAudMobileDeviceId', {
event,
useDefaultMappings: true,
features: { 'actions-first-party-dv360-version-update': true }
features: { 'first-party-dv360-canary-version': true }
})
expect(result).toContainEqual(
expect.objectContaining({
Expand All @@ -377,33 +263,5 @@ describe('Audience Destination', () => {
})
)
})

it('should remove customer match members successfully with feature flag OFF (v3)', async () => {
nock('https://displayvideo.googleapis.com')
.post('/v3/firstAndThirdPartyAudiences/audience-id-123:editCustomerMatchMembers', {
advertiserId: '12345',
removedMobileDeviceIdList: {
mobileDeviceIds: ['123'],
consent: {
adUserData: 'CONSENT_STATUS_GRANTED',
adPersonalization: 'CONSENT_STATUS_GRANTED'
}
}
})
.reply(200, { firstAndThirdPartyAudienceId: 'audience-id-123' })

const result = await testDestination.testAction('removeFromAudMobileDeviceId', {
event,
useDefaultMappings: true,
features: { 'actions-first-party-dv360-version-update': false }
})
expect(result).toContainEqual(
expect.objectContaining({
data: expect.objectContaining({
firstAndThirdPartyAudienceId: 'audience-id-123'
})
})
)
})
})
})
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 @@ -79,7 +79,7 @@ describe('First-Party-dv360.addToAudContactInfo', () => {
})

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

Expand Down Expand Up @@ -107,7 +107,7 @@ describe('First-Party-dv360.addToAudContactInfo', () => {
// Optionally, check that the emails are correctly hashed and correspond to the input
})

it('should batch multiple payloads into a single request when enable_batching is true (feature flag ON, v4)', async () => {
it('should batch multiple payloads into a single request when enable_batching is true ( CANARY VERSION )', async () => {
nock('https://displayvideo.googleapis.com/v4/firstPartyAndPartnerAudiences')
.post('/1234567890:editCustomerMatchMembers')
.reply(200, { success: true })
Expand All @@ -127,36 +127,7 @@ describe('First-Party-dv360.addToAudContactInfo', () => {
enable_batching: true,
batch_size: 2
},
features: { 'actions-first-party-dv360-version-update': true }
})

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()
})

it('should batch multiple payloads into a single request when enable_batching is true (feature flag OFF, v3)', async () => {
nock('https://displayvideo.googleapis.com/v3/firstAndThirdPartyAudiences')
.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
},
features: { 'actions-first-party-dv360-version-update': false }
features: { 'first-party-dv360-canary-version': true }
})

const requestBody = JSON.parse(String(responses[0].options.body))
Expand Down
Loading
Loading