From be23c3956d7b5b42b235ed43e08e39299e149183 Mon Sep 17 00:00:00 2001 From: Vikas Venkatraman Date: Tue, 4 Jun 2024 20:38:49 +0530 Subject: [PATCH] chore: refactored tests --- .../fb_custom_audience/router/audienceList.ts | 123 ++ .../router/batchingRecord.ts | 130 ++ .../fb_custom_audience/router/data.ts | 1156 +++-------------- .../fb_custom_audience/router/eventStream.ts | 143 ++ .../fb_custom_audience/router/record.ts | 250 ++++ 5 files changed, 808 insertions(+), 994 deletions(-) create mode 100644 test/integrations/destinations/fb_custom_audience/router/audienceList.ts create mode 100644 test/integrations/destinations/fb_custom_audience/router/batchingRecord.ts create mode 100644 test/integrations/destinations/fb_custom_audience/router/eventStream.ts create mode 100644 test/integrations/destinations/fb_custom_audience/router/record.ts diff --git a/test/integrations/destinations/fb_custom_audience/router/audienceList.ts b/test/integrations/destinations/fb_custom_audience/router/audienceList.ts new file mode 100644 index 0000000000..c386fbf782 --- /dev/null +++ b/test/integrations/destinations/fb_custom_audience/router/audienceList.ts @@ -0,0 +1,123 @@ +import { Destination, RouterTransformationRequest } from '../../../../../src/types'; +import { generateMetadata } from '../../../testUtils'; + +const destination: Destination = { + Config: { + accessToken: 'ABC', + disableFormat: false, + isHashRequired: true, + isRaw: false, + maxUserCount: '50', + oneTrustCookieCategories: [], + skipVerify: false, + subType: 'NA', + type: 'NA', + userSchema: ['EMAIL'], + }, + ID: '1mMy5cqbtfuaKZv1IhVQKnBdVwe', + Name: 'FB_CUSTOM_AUDIENCE', + Enabled: true, + WorkspaceID: '1TSN08muJTZwH8iCDmnnRt1pmLd', + DestinationDefinition: { + ID: '1aIXqM806xAVm92nx07YwKbRrO9', + Name: 'FB_CUSTOM_AUDIENCE', + DisplayName: 'FB_CUSTOM_AUDIENCE', + Config: {}, + }, + Transformations: [], + IsConnectionEnabled: true, + IsProcessorEnabled: true, +}; + +export const rETLAudienceRouterRequest: RouterTransformationRequest = { + input: [ + { + message: { + sentAt: '2023-03-30 06:42:55.991938402 +0000 UTC', + userId: '2MUWghI7u85n91dd1qzGyswpZan-2MUWqbQqvctyfMGqU9QCNadpKNy', + channel: 'sources', + messageId: '4d906837-031d-4d34-b97a-62fdf51b4d3a', + event: 'Add_Audience', + context: { + destinationFields: 'EMAIL, FN', + externalId: [{ type: 'FB_CUSTOM_AUDIENCE-23848494844100489', identifierType: 'EMAIL' }], + mappedToDestination: 'true', + sources: { + job_run_id: 'cgiiurt8um7k7n5dq480', + task_run_id: 'cgiiurt8um7k7n5dq48g', + job_id: '2MUWghI7u85n91dd1qzGyswpZan', + version: '895/merge', + }, + }, + recordId: '725ad989-6750-4839-b46b-0ddb3b8e5aa2/1/10', + rudderId: '85c49666-c628-4835-937b-8f1d9ee7a724', + properties: { + listData: { + add: [ + { EMAIL: 'dede@gmail.com', FN: 'vishwa' }, + { EMAIL: 'fchsjjn@gmail.com', FN: 'hskks' }, + { EMAIL: 'fghjnbjk@gmail.com', FN: 'ghfry' }, + { EMAIL: 'gvhjkk@gmail.com', FN: 'hbcwqe' }, + { EMAIL: 'qsdwert@egf.com', FN: 'dsfds' }, + { EMAIL: 'ascscxsaca@com', FN: 'scadscdvcda' }, + { EMAIL: 'abc@gmail.com', FN: 'subscribed' }, + { EMAIL: 'ddwnkl@gmail.com', FN: 'subscribed' }, + { EMAIL: 'subscribed@eewrfrd.com', FN: 'pending' }, + { EMAIL: 'acsdvdf@ddfvf.com', FN: 'pending' }, + ], + }, + }, + type: 'audienceList', + anonymousId: '63228b51-394e-4ca2-97a0-427f6187480b', + }, + destination: destination, + metadata: generateMetadata(3), + }, + { + message: { + sentAt: '2023-03-30 06:42:55.991938402 +0000 UTC', + userId: '2MUWghI7u85n91dd1qzGyswpZan-2MUWqbQqvctyfMGqU9QCNadpKNy', + channel: 'sources', + messageId: '4d906837-031d-4d34-b97a-62fdf51b4d3a', + event: 'Add_Audience', + context: { + externalId: [{ type: 'FB_CUSTOM_AUDIENCE-23848494844100489', identifierType: 'EMAIL' }], + mappedToDestination: 'true', + sources: { + job_run_id: 'cgiiurt8um7k7n5dq480', + task_run_id: 'cgiiurt8um7k7n5dq48g', + job_id: '2MUWghI7u85n91dd1qzGyswpZan', + version: '895/merge', + }, + }, + recordId: '725ad989-6750-4839-b46b-0ddb3b8e5aa2/1/10', + rudderId: '85c49666-c628-4835-937b-8f1d9ee7a724', + properties: { + listData: { + add: [ + { EMAIL: 'dede@gmail.com', FN: 'vishwa' }, + { EMAIL: 'fchsjjn@gmail.com', FN: 'hskks' }, + { EMAIL: 'fghjnbjk@gmail.com', FN: 'ghfry' }, + { EMAIL: 'gvhjkk@gmail.com', FN: 'hbcwqe' }, + { EMAIL: 'qsdwert@egf.com', FN: 'dsfds' }, + { EMAIL: 'ascscxsaca@com', FN: 'scadscdvcda' }, + { EMAIL: 'abc@gmail.com', FN: 'subscribed' }, + { EMAIL: 'ddwnkl@gmail.com', FN: 'subscribed' }, + { EMAIL: 'subscribed@eewrfrd.com', FN: 'pending' }, + { EMAIL: 'acsdvdf@ddfvf.com', FN: 'pending' }, + ], + }, + }, + type: 'audienceList', + anonymousId: '63228b51-394e-4ca2-97a0-427f6187480b', + }, + destination: destination, + metadata: generateMetadata(4), + }, + ], + destType: 'fb_custom_audience', +}; + +module.exports = { + rETLAudienceRouterRequest, +}; diff --git a/test/integrations/destinations/fb_custom_audience/router/batchingRecord.ts b/test/integrations/destinations/fb_custom_audience/router/batchingRecord.ts new file mode 100644 index 0000000000..0ceff5260e --- /dev/null +++ b/test/integrations/destinations/fb_custom_audience/router/batchingRecord.ts @@ -0,0 +1,130 @@ +import { Destination, RouterTransformationRequest } from '../../../../../src/types'; +import { generateMetadata } from '../../../testUtils'; + +const destination: Destination = { + Config: { + accessToken: 'ABC', + disableFormat: false, + isHashRequired: true, + isRaw: false, + maxUserCount: '2', + oneTrustCookieCategories: [], + skipVerify: false, + subType: 'NA', + type: 'NA', + userSchema: ['EMAIL'], + }, + ID: '1mMy5cqbtfuaKZv1IhVQKnBdVwe', + Name: 'FB_CUSTOM_AUDIENCE', + Enabled: true, + WorkspaceID: '1TSN08muJTZwH8iCDmnnRt1pmLd', + DestinationDefinition: { + ID: '1aIXqM806xAVm92nx07YwKbRrO9', + Name: 'FB_CUSTOM_AUDIENCE', + DisplayName: 'FB_CUSTOM_AUDIENCE', + Config: {}, + }, + Transformations: [], + IsConnectionEnabled: true, + IsProcessorEnabled: true, +}; + +export const rETLBatchingRouterRequest: RouterTransformationRequest = { + input: [ + { + destination: destination, + message: { + action: 'insert', + context: { + destinationFields: 'EMAIL, FI', + externalId: [ + { + type: 'FB_CUSTOM_AUDIENCE-23848494844100489', + identifierType: 'EMAIL', + }, + ], + mappedToDestination: 'true', + sources: { + job_run_id: 'cgiiurt8um7k7n5dq480', + task_run_id: 'cgiiurt8um7k7n5dq48g', + job_id: '2MUWghI7u85n91dd1qzGyswpZan', + version: '895/merge', + }, + }, + recordId: '2', + rudderId: '2', + fields: { + EMAIL: 'subscribed@eewrfrd.com', + FI: 'ghui', + }, + type: 'record', + }, + metadata: generateMetadata(1), + }, + { + destination: destination, + message: { + action: 'insert', + context: { + destinationFields: 'EMAIL, FI', + externalId: [ + { + type: 'FB_CUSTOM_AUDIENCE-23848494844100489', + identifierType: 'EMAIL', + }, + ], + mappedToDestination: 'true', + sources: { + job_run_id: 'cgiiurt8um7k7n5dq480', + task_run_id: 'cgiiurt8um7k7n5dq48g', + job_id: '2MUWghI7u85n91dd1qzGyswpZan', + version: '895/merge', + }, + }, + recordId: '2', + rudderId: '2', + fields: { + EMAIL: 'subscribed@eewrfrd.com', + FI: 'ghui', + }, + type: 'record', + }, + metadata: generateMetadata(2), + }, + { + destination: destination, + message: { + action: 'insert', + context: { + destinationFields: 'EMAIL, FI', + externalId: [ + { + type: 'FB_CUSTOM_AUDIENCE-23848494844100489', + identifierType: 'EMAIL', + }, + ], + mappedToDestination: 'true', + sources: { + job_run_id: 'cgiiurt8um7k7n5dq480', + task_run_id: 'cgiiurt8um7k7n5dq48g', + job_id: '2MUWghI7u85n91dd1qzGyswpZan', + version: '895/merge', + }, + }, + recordId: '2', + rudderId: '2', + fields: { + EMAIL: 'subscribed@eewrfrd.com', + FI: 'ghui', + }, + type: 'record', + }, + metadata: generateMetadata(3), + }, + ], + destType: 'fb_custom_audience', +}; + +module.exports = { + rETLBatchingRouterRequest, +}; diff --git a/test/integrations/destinations/fb_custom_audience/router/data.ts b/test/integrations/destinations/fb_custom_audience/router/data.ts index 251430217d..72438e74b0 100644 --- a/test/integrations/destinations/fb_custom_audience/router/data.ts +++ b/test/integrations/destinations/fb_custom_audience/router/data.ts @@ -1,266 +1,14 @@ -import { getEndPoint } from '../../../../../src/v0/destinations/fb_custom_audience/config'; -import { Destination, RouterTransformationRequest } from '../../../../../src/types'; -import { generateMetadata } from '../../../testUtils'; -import { config } from 'dotenv'; - -const eventStreamDestination: Destination = { - Config: { - accessToken: 'ABC', - userSchema: [ - 'EMAIL', - 'DOBM', - 'DOBD', - 'DOBY', - 'PHONE', - 'GEN', - 'FI', - 'MADID', - 'ZIP', - 'ST', - 'COUNTRY', - ], - isHashRequired: false, - disableFormat: false, - audienceId: 'aud1', - isRaw: true, - type: 'NA', - subType: 'ANYTHING', - maxUserCount: '50', - }, - Enabled: true, - Transformations: [], - IsProcessorEnabled: true, - ID: '123', - Name: 'fb_custom_audience', - DestinationDefinition: { - ID: '123', - Name: 'fb_custom_audience', - DisplayName: 'fb_custom_audience', - Config: {}, - }, - WorkspaceID: '123', -}; - -const eventStreamRouterRequest: RouterTransformationRequest = { - input: [ - { - message: { - userId: 'user 1', - anonymousId: 'anon-id-new', - event: 'event1', - type: 'audiencelist', - properties: { - listData: { - add: [ - { - EMAIL: 'shrouti@abc.com', - DOBM: '2', - DOBD: '13', - DOBY: '2013', - PHONE: '@09432457768', - GEN: 'f', - FI: 'Ms.', - MADID: 'ABC', - ZIP: 'ZIP ', - ST: '123abc ', - COUNTRY: 'IN', - }, - ], - remove: [ - { - EMAIL: 'shrouti@abc.com', - DOBM: '2', - DOBD: '13', - DOBY: '2013', - PHONE: '@09432457768', - GEN: 'f', - FI: 'Ms.', - MADID: 'ABC', - ZIP: 'ZIP ', - ST: '123abc ', - COUNTRY: 'IN', - }, - ], - }, - }, - context: { ip: '14.5.67.21', library: { name: 'http' } }, - timestamp: '2020-02-02T00:23:09.544Z', - }, - metadata: generateMetadata(1), - destination: eventStreamDestination, - }, - { - message: { - userId: 'user 1', - anonymousId: 'anon-id-new', - event: 'event1', - type: 'audiencelist', - properties: { - listData: { - add: [ - { - EMAIL: 'shrouti@abc.com', - DOBM: '2', - DOBD: '13', - DOBY: '2013', - PHONE: '@09432457768', - GEN: 'f', - FI: 'Ms.', - MADID: 'ABC', - ZIP: 'ZIP ', - ST: '123abc ', - COUNTRY: 'IN', - }, - ], - remove: [ - { - EMAIL: 'shrouti@abc.com', - DOBM: '2', - DOBD: '13', - DOBY: '2013', - PHONE: '@09432457768', - GEN: 'f', - FI: 'Ms.', - MADID: 'ABC', - ZIP: 'ZIP ', - ST: '123abc ', - COUNTRY: 'IN', - }, - ], - }, - }, - context: { ip: '14.5.67.21', library: { name: 'http' } }, - timestamp: '2020-02-02T00:23:09.544Z', - }, - metadata: generateMetadata(2), - destination: eventStreamDestination, - request: { query: {} }, - }, - ], - destType: 'fb_custom_audience', -}; - -const rETLDestination: Destination = { - Config: { - accessToken: 'ABC', - disableFormat: false, - isHashRequired: true, - isRaw: false, - maxUserCount: '50', - oneTrustCookieCategories: [], - skipVerify: false, - subType: 'NA', - type: 'NA', - userSchema: ['EMAIL'], - }, - ID: '1mMy5cqbtfuaKZv1IhVQKnBdVwe', - Name: 'FB_CUSTOM_AUDIENCE', - Enabled: true, - WorkspaceID: '1TSN08muJTZwH8iCDmnnRt1pmLd', - DestinationDefinition: { - ID: '1aIXqM806xAVm92nx07YwKbRrO9', - Name: 'FB_CUSTOM_AUDIENCE', - DisplayName: 'FB_CUSTOM_AUDIENCE', - Config: {}, - }, - Transformations: [], - IsConnectionEnabled: true, - IsProcessorEnabled: true, -}; - -const rETLRouterRequest: RouterTransformationRequest = { - input: [ - { - message: { - sentAt: '2023-03-30 06:42:55.991938402 +0000 UTC', - userId: '2MUWghI7u85n91dd1qzGyswpZan-2MUWqbQqvctyfMGqU9QCNadpKNy', - channel: 'sources', - messageId: '4d906837-031d-4d34-b97a-62fdf51b4d3a', - event: 'Add_Audience', - context: { - destinationFields: 'EMAIL, FN', - externalId: [{ type: 'FB_CUSTOM_AUDIENCE-23848494844100489', identifierType: 'EMAIL' }], - mappedToDestination: 'true', - sources: { - job_run_id: 'cgiiurt8um7k7n5dq480', - task_run_id: 'cgiiurt8um7k7n5dq48g', - job_id: '2MUWghI7u85n91dd1qzGyswpZan', - version: '895/merge', - }, - }, - recordId: '725ad989-6750-4839-b46b-0ddb3b8e5aa2/1/10', - rudderId: '85c49666-c628-4835-937b-8f1d9ee7a724', - properties: { - listData: { - add: [ - { EMAIL: 'dede@gmail.com', FN: 'vishwa' }, - { EMAIL: 'fchsjjn@gmail.com', FN: 'hskks' }, - { EMAIL: 'fghjnbjk@gmail.com', FN: 'ghfry' }, - { EMAIL: 'gvhjkk@gmail.com', FN: 'hbcwqe' }, - { EMAIL: 'qsdwert@egf.com', FN: 'dsfds' }, - { EMAIL: 'ascscxsaca@com', FN: 'scadscdvcda' }, - { EMAIL: 'abc@gmail.com', FN: 'subscribed' }, - { EMAIL: 'ddwnkl@gmail.com', FN: 'subscribed' }, - { EMAIL: 'subscribed@eewrfrd.com', FN: 'pending' }, - { EMAIL: 'acsdvdf@ddfvf.com', FN: 'pending' }, - ], - }, - }, - type: 'audienceList', - anonymousId: '63228b51-394e-4ca2-97a0-427f6187480b', - }, - destination: rETLDestination, - metadata: generateMetadata(3), - }, - { - message: { - sentAt: '2023-03-30 06:42:55.991938402 +0000 UTC', - userId: '2MUWghI7u85n91dd1qzGyswpZan-2MUWqbQqvctyfMGqU9QCNadpKNy', - channel: 'sources', - messageId: '4d906837-031d-4d34-b97a-62fdf51b4d3a', - event: 'Add_Audience', - context: { - externalId: [{ type: 'FB_CUSTOM_AUDIENCE-23848494844100489', identifierType: 'EMAIL' }], - mappedToDestination: 'true', - sources: { - job_run_id: 'cgiiurt8um7k7n5dq480', - task_run_id: 'cgiiurt8um7k7n5dq48g', - job_id: '2MUWghI7u85n91dd1qzGyswpZan', - version: '895/merge', - }, - }, - recordId: '725ad989-6750-4839-b46b-0ddb3b8e5aa2/1/10', - rudderId: '85c49666-c628-4835-937b-8f1d9ee7a724', - properties: { - listData: { - add: [ - { EMAIL: 'dede@gmail.com', FN: 'vishwa' }, - { EMAIL: 'fchsjjn@gmail.com', FN: 'hskks' }, - { EMAIL: 'fghjnbjk@gmail.com', FN: 'ghfry' }, - { EMAIL: 'gvhjkk@gmail.com', FN: 'hbcwqe' }, - { EMAIL: 'qsdwert@egf.com', FN: 'dsfds' }, - { EMAIL: 'ascscxsaca@com', FN: 'scadscdvcda' }, - { EMAIL: 'abc@gmail.com', FN: 'subscribed' }, - { EMAIL: 'ddwnkl@gmail.com', FN: 'subscribed' }, - { EMAIL: 'subscribed@eewrfrd.com', FN: 'pending' }, - { EMAIL: 'acsdvdf@ddfvf.com', FN: 'pending' }, - ], - }, - }, - type: 'audienceList', - anonymousId: '63228b51-394e-4ca2-97a0-427f6187480b', - }, - destination: rETLDestination, - metadata: generateMetadata(4), - }, - ], - destType: 'fb_custom_audience', -}; +import { eventStreamRouterRequest } from './eventStream'; +import { rETLAudienceRouterRequest } from './audienceList'; +import { rETLBatchingRouterRequest } from './batchingRecord'; +import { rETLRecordRouterRequest } from './record'; export const data = [ { name: 'fb_custom_audience', description: 'eventStream tests', + scenario: 'business', + successCriteria: 'event stream events should be batched correctly', feature: 'router', module: 'destination', version: 'v0', @@ -600,12 +348,14 @@ export const data = [ { name: 'fb_custom_audience', description: 'rETL tests', + scenario: 'business', + successCriteria: 'it should transform audience event correctly', feature: 'router', module: 'destination', version: 'v0', input: { request: { - body: rETLRouterRequest, + body: rETLAudienceRouterRequest, }, }, output: { @@ -787,464 +537,14 @@ export const data = [ { name: 'fb_custom_audience', description: 'rETL record tests', + scenario: 'business', + successCriteria: 'all record events should be transformed correctly based on their operation', feature: 'router', module: 'destination', version: 'v0', input: { request: { - body: { - input: [ - { - destination: { - Config: { - accessToken: 'ABC', - disableFormat: false, - isHashRequired: true, - isRaw: false, - maxUserCount: '3', - oneTrustCookieCategories: [], - skipVerify: false, - subType: 'NA', - type: 'NA', - userSchema: ['EMAIL'], - }, - secretConfig: {}, - ID: '1mMy5cqbtfuaKZv1IhVQKnBdVwe', - name: 'FB_CUSTOM_AUDIENCE', - enabled: true, - workspaceId: '1TSN08muJTZwH8iCDmnnRt1pmLd', - deleted: false, - createdAt: '2020-12-30T08:39:32.005Z', - updatedAt: '2021-02-03T16:22:31.374Z', - destinationDefinition: { - id: '1aIXqM806xAVm92nx07YwKbRrO9', - name: 'FB_CUSTOM_AUDIENCE', - displayName: 'FB_CUSTOM_AUDIENCE', - createdAt: '2020-04-09T09:24:31.794Z', - updatedAt: '2021-01-11T11:03:28.103Z', - }, - transformations: [], - isConnectionEnabled: true, - isProcessorEnabled: true, - }, - message: { - action: 'insert', - context: { - destinationFields: 'EMAIL, FI', - externalId: [ - { - type: 'FB_CUSTOM_AUDIENCE-23848494844100489', - identifierType: 'EMAIL', - }, - ], - mappedToDestination: 'true', - sources: { - job_run_id: 'cgiiurt8um7k7n5dq480', - task_run_id: 'cgiiurt8um7k7n5dq48g', - job_id: '2MUWghI7u85n91dd1qzGyswpZan', - version: '895/merge', - }, - }, - recordId: '2', - rudderId: '2', - fields: { - EMAIL: 'subscribed@eewrfrd.com', - FI: 'ghui', - }, - type: 'record', - }, - metadata: { - jobId: 2, - userId: 'u1', - }, - }, - { - destination: { - Config: { - accessToken: 'ABC', - disableFormat: false, - isHashRequired: true, - isRaw: false, - maxUserCount: '3', - oneTrustCookieCategories: [], - skipVerify: false, - subType: 'NA', - type: 'NA', - userSchema: ['EMAIL'], - }, - secretConfig: {}, - ID: '1mMy5cqbtfuaKZv1IhVQKnBdVwe', - name: 'FB_CUSTOM_AUDIENCE', - enabled: true, - workspaceId: '1TSN08muJTZwH8iCDmnnRt1pmLd', - deleted: false, - createdAt: '2020-12-30T08:39:32.005Z', - updatedAt: '2021-02-03T16:22:31.374Z', - destinationDefinition: { - id: '1aIXqM806xAVm92nx07YwKbRrO9', - name: 'FB_CUSTOM_AUDIENCE', - displayName: 'FB_CUSTOM_AUDIENCE', - createdAt: '2020-04-09T09:24:31.794Z', - updatedAt: '2021-01-11T11:03:28.103Z', - }, - transformations: [], - isConnectionEnabled: true, - isProcessorEnabled: true, - }, - message: { - action: 'update', - context: { - destinationFields: 'EMAIL, FI', - externalId: [ - { - type: 'FB_CUSTOM_AUDIENCE-23848494844100489', - identifierType: 'EMAIL', - }, - ], - mappedToDestination: 'true', - sources: { - job_run_id: 'cgiiurt8um7k7n5dq480', - task_run_id: 'cgiiurt8um7k7n5dq48g', - job_id: '2MUWghI7u85n91dd1qzGyswpZan', - version: '895/merge', - }, - }, - recordId: '2', - rudderId: '2', - fields: { - EMAIL: 'subscribed@eewrfrd.com', - FI: 'ghui', - }, - type: 'record', - }, - metadata: { - jobId: 3, - userId: 'u2', - }, - }, - { - destination: { - Config: { - accessToken: 'ABC', - disableFormat: false, - isHashRequired: true, - isRaw: false, - maxUserCount: '3', - oneTrustCookieCategories: [], - skipVerify: false, - subType: 'NA', - type: 'NA', - userSchema: ['EMAIL'], - }, - secretConfig: {}, - ID: '1mMy5cqbtfuaKZv1IhVQKnBdVwe', - name: 'FB_CUSTOM_AUDIENCE', - enabled: true, - workspaceId: '1TSN08muJTZwH8iCDmnnRt1pmLd', - deleted: false, - createdAt: '2020-12-30T08:39:32.005Z', - updatedAt: '2021-02-03T16:22:31.374Z', - destinationDefinition: { - id: '1aIXqM806xAVm92nx07YwKbRrO9', - name: 'FB_CUSTOM_AUDIENCE', - displayName: 'FB_CUSTOM_AUDIENCE', - createdAt: '2020-04-09T09:24:31.794Z', - updatedAt: '2021-01-11T11:03:28.103Z', - }, - transformations: [], - isConnectionEnabled: true, - isProcessorEnabled: true, - }, - message: { - action: 'delete', - context: { - destinationFields: 'EMAIL, FI', - externalId: [ - { - type: 'FB_CUSTOM_AUDIENCE-23848494844100489', - identifierType: 'EMAIL', - }, - ], - mappedToDestination: 'true', - sources: { - job_run_id: 'cgiiurt8um7k7n5dq480', - task_run_id: 'cgiiurt8um7k7n5dq48g', - job_id: '2MUWghI7u85n91dd1qzGyswpZan', - version: '895/merge', - }, - }, - recordId: '2', - rudderId: '2', - fields: { - EMAIL: 'subscribed@eewrfrd.com', - FI: 'ghui', - }, - type: 'record', - }, - metadata: { - jobId: 4, - userId: 'u3', - }, - }, - { - destination: { - Config: { - accessToken: 'ABC', - disableFormat: false, - isHashRequired: true, - isRaw: false, - maxUserCount: '3', - oneTrustCookieCategories: [], - skipVerify: false, - subType: 'NA', - type: 'NA', - userSchema: ['EMAIL'], - }, - secretConfig: {}, - ID: '1mMy5cqbtfuaKZv1IhVQKnBdVwe', - name: 'FB_CUSTOM_AUDIENCE', - enabled: true, - workspaceId: '1TSN08muJTZwH8iCDmnnRt1pmLd', - deleted: false, - createdAt: '2020-12-30T08:39:32.005Z', - updatedAt: '2021-02-03T16:22:31.374Z', - destinationDefinition: { - id: '1aIXqM806xAVm92nx07YwKbRrO9', - name: 'FB_CUSTOM_AUDIENCE', - displayName: 'FB_CUSTOM_AUDIENCE', - createdAt: '2020-04-09T09:24:31.794Z', - updatedAt: '2021-01-11T11:03:28.103Z', - }, - transformations: [], - isConnectionEnabled: true, - isProcessorEnabled: true, - }, - message: { - action: 'delete', - context: { - destinationFields: 'EMAIL, FI', - externalId: [ - { - type: 'FB_CUSTOM_AUDIENCE-23848494844100489', - identifierType: 'EMAIL', - }, - ], - mappedToDestination: 'true', - sources: { - job_run_id: 'cgiiurt8um7k7n5dq480', - task_run_id: 'cgiiurt8um7k7n5dq48g', - job_id: '2MUWghI7u85n91dd1qzGyswpZan', - version: '895/merge', - }, - }, - recordId: '2', - rudderId: '2', - fields: { - EMAIL: 'subscribed@eewrfrd.com', - FI: 'ghui', - }, - type: 'record', - }, - metadata: { - jobId: 5, - userId: 'u4', - }, - }, - { - destination: { - Config: { - accessToken: 'ABC', - disableFormat: false, - isHashRequired: true, - isRaw: false, - maxUserCount: '3', - oneTrustCookieCategories: [], - skipVerify: false, - subType: 'NA', - type: 'NA', - userSchema: ['EMAIL'], - }, - secretConfig: {}, - ID: '1mMy5cqbtfuaKZv1IhVQKnBdVwe', - name: 'FB_CUSTOM_AUDIENCE', - enabled: true, - workspaceId: '1TSN08muJTZwH8iCDmnnRt1pmLd', - deleted: false, - createdAt: '2020-12-30T08:39:32.005Z', - updatedAt: '2021-02-03T16:22:31.374Z', - destinationDefinition: { - id: '1aIXqM806xAVm92nx07YwKbRrO9', - name: 'FB_CUSTOM_AUDIENCE', - displayName: 'FB_CUSTOM_AUDIENCE', - createdAt: '2020-04-09T09:24:31.794Z', - updatedAt: '2021-01-11T11:03:28.103Z', - }, - transformations: [], - isConnectionEnabled: true, - isProcessorEnabled: true, - }, - message: { - action: 'update', - context: { - destinationFields: 'EMAIL, FI', - externalId: [ - { - type: 'FB_CUSTOM_AUDIENCE-23848494844100489', - identifierType: 'EMAIL', - }, - ], - mappedToDestination: 'true', - sources: { - job_run_id: 'cgiiurt8um7k7n5dq480', - task_run_id: 'cgiiurt8um7k7n5dq48g', - job_id: '2MUWghI7u85n91dd1qzGyswpZan', - version: '895/merge', - }, - }, - recordId: '2', - rudderId: '2', - fields: { - EMAIL: 'subscribed@eewrfrd.com', - FI: 'ghui', - }, - type: 'record', - }, - metadata: { - jobId: 6, - userId: 'u5', - }, - }, - { - destination: { - Config: { - accessToken: 'ABC', - disableFormat: false, - isHashRequired: true, - isRaw: false, - maxUserCount: '3', - oneTrustCookieCategories: [], - skipVerify: false, - subType: 'NA', - type: 'NA', - userSchema: ['EMAIL'], - }, - secretConfig: {}, - ID: '1mMy5cqbtfuaKZv1IhVQKnBdVwe', - name: 'FB_CUSTOM_AUDIENCE', - enabled: true, - workspaceId: '1TSN08muJTZwH8iCDmnnRt1pmLd', - deleted: false, - createdAt: '2020-12-30T08:39:32.005Z', - updatedAt: '2021-02-03T16:22:31.374Z', - destinationDefinition: { - id: '1aIXqM806xAVm92nx07YwKbRrO9', - name: 'FB_CUSTOM_AUDIENCE', - displayName: 'FB_CUSTOM_AUDIENCE', - createdAt: '2020-04-09T09:24:31.794Z', - updatedAt: '2021-01-11T11:03:28.103Z', - }, - transformations: [], - isConnectionEnabled: true, - isProcessorEnabled: true, - }, - message: { - action: 'update', - context: { - destinationFields: 'EMAIL, FI', - externalId: [ - { - type: 'FB_CUSTOM_AUDIENCE-23848494844100489', - identifierType: 'EMAIL', - }, - ], - mappedToDestination: 'true', - sources: { - job_run_id: 'cgiiurt8um7k7n5dq480', - task_run_id: 'cgiiurt8um7k7n5dq48g', - job_id: '2MUWghI7u85n91dd1qzGyswpZan', - version: '895/merge', - }, - }, - recordId: '2', - rudderId: '2', - fields: { - EMAIL: 'subscribed@eewrfrd.com', - FI: 'ghui', - }, - type: 'record', - }, - metadata: { - jobId: 7, - userId: 'u6', - }, - }, - { - destination: { - Config: { - accessToken: 'ABC', - disableFormat: false, - isHashRequired: true, - isRaw: false, - maxUserCount: '3', - oneTrustCookieCategories: [], - skipVerify: false, - subType: 'NA', - type: 'NA', - userSchema: ['EMAIL'], - }, - secretConfig: {}, - ID: '1mMy5cqbtfuaKZv1IhVQKnBdVwe', - name: 'FB_CUSTOM_AUDIENCE', - enabled: true, - workspaceId: '1TSN08muJTZwH8iCDmnnRt1pmLd', - deleted: false, - createdAt: '2020-12-30T08:39:32.005Z', - updatedAt: '2021-02-03T16:22:31.374Z', - destinationDefinition: { - id: '1aIXqM806xAVm92nx07YwKbRrO9', - name: 'FB_CUSTOM_AUDIENCE', - displayName: 'FB_CUSTOM_AUDIENCE', - createdAt: '2020-04-09T09:24:31.794Z', - updatedAt: '2021-01-11T11:03:28.103Z', - }, - transformations: [], - isConnectionEnabled: true, - isProcessorEnabled: true, - }, - message: { - action: 'lol', - context: { - destinationFields: 'EMAIL, FI', - externalId: [ - { - type: 'FB_CUSTOM_AUDIENCE-23848494844100489', - identifierType: 'EMAIL', - }, - ], - mappedToDestination: 'true', - sources: { - job_run_id: 'cgiiurt8um7k7n5dq480', - task_run_id: 'cgiiurt8um7k7n5dq48g', - job_id: '2MUWghI7u85n91dd1qzGyswpZan', - version: '895/merge', - }, - }, - recordId: '2', - rudderId: '2', - fields: { - EMAIL: 'subscribed@eewrfrd.com', - FI: 'ghui', - }, - type: 'record', - }, - metadata: { - jobId: 8, - userId: 'u7', - }, - }, - ], - destType: 'fb_custom_audience', - }, + body: rETLRecordRouterRequest, }, }, output: { @@ -1287,12 +587,28 @@ export const data = [ ], metadata: [ { - jobId: 4, - userId: 'u3', + attemptNum: 1, + destinationId: 'default-destinationId', + dontBatch: false, + jobId: 1, + secret: { + accessToken: 'default-accessToken', + }, + sourceId: 'default-sourceId', + userId: 'default-userId', + workspaceId: 'default-workspaceId', }, { - jobId: 5, - userId: 'u4', + attemptNum: 1, + destinationId: 'default-destinationId', + dontBatch: false, + jobId: 2, + secret: { + accessToken: 'default-accessToken', + }, + sourceId: 'default-sourceId', + userId: 'default-userId', + workspaceId: 'default-workspaceId', }, ], batched: true, @@ -1310,24 +626,19 @@ export const data = [ type: 'NA', userSchema: ['EMAIL'], }, - secretConfig: {}, ID: '1mMy5cqbtfuaKZv1IhVQKnBdVwe', - name: 'FB_CUSTOM_AUDIENCE', - enabled: true, - workspaceId: '1TSN08muJTZwH8iCDmnnRt1pmLd', - deleted: false, - createdAt: '2020-12-30T08:39:32.005Z', - updatedAt: '2021-02-03T16:22:31.374Z', - destinationDefinition: { - id: '1aIXqM806xAVm92nx07YwKbRrO9', - name: 'FB_CUSTOM_AUDIENCE', - displayName: 'FB_CUSTOM_AUDIENCE', - createdAt: '2020-04-09T09:24:31.794Z', - updatedAt: '2021-01-11T11:03:28.103Z', + Name: 'FB_CUSTOM_AUDIENCE', + Enabled: true, + WorkspaceID: '1TSN08muJTZwH8iCDmnnRt1pmLd', + DestinationDefinition: { + ID: '1aIXqM806xAVm92nx07YwKbRrO9', + Name: 'FB_CUSTOM_AUDIENCE', + DisplayName: 'FB_CUSTOM_AUDIENCE', + Config: {}, }, - transformations: [], - isConnectionEnabled: true, - isProcessorEnabled: true, + Transformations: [], + IsConnectionEnabled: true, + IsProcessorEnabled: true, }, }, { @@ -1361,8 +672,16 @@ export const data = [ ], metadata: [ { - jobId: 2, - userId: 'u1', + attemptNum: 1, + destinationId: 'default-destinationId', + dontBatch: false, + jobId: 3, + secret: { + accessToken: 'default-accessToken', + }, + sourceId: 'default-sourceId', + userId: 'default-userId', + workspaceId: 'default-workspaceId', }, ], batched: true, @@ -1380,24 +699,19 @@ export const data = [ type: 'NA', userSchema: ['EMAIL'], }, - secretConfig: {}, ID: '1mMy5cqbtfuaKZv1IhVQKnBdVwe', - name: 'FB_CUSTOM_AUDIENCE', - enabled: true, - workspaceId: '1TSN08muJTZwH8iCDmnnRt1pmLd', - deleted: false, - createdAt: '2020-12-30T08:39:32.005Z', - updatedAt: '2021-02-03T16:22:31.374Z', - destinationDefinition: { - id: '1aIXqM806xAVm92nx07YwKbRrO9', - name: 'FB_CUSTOM_AUDIENCE', - displayName: 'FB_CUSTOM_AUDIENCE', - createdAt: '2020-04-09T09:24:31.794Z', - updatedAt: '2021-01-11T11:03:28.103Z', + Name: 'FB_CUSTOM_AUDIENCE', + Enabled: true, + WorkspaceID: '1TSN08muJTZwH8iCDmnnRt1pmLd', + DestinationDefinition: { + ID: '1aIXqM806xAVm92nx07YwKbRrO9', + Name: 'FB_CUSTOM_AUDIENCE', + DisplayName: 'FB_CUSTOM_AUDIENCE', + Config: {}, }, - transformations: [], - isConnectionEnabled: true, - isProcessorEnabled: true, + Transformations: [], + IsConnectionEnabled: true, + IsProcessorEnabled: true, }, }, { @@ -1439,16 +753,40 @@ export const data = [ ], metadata: [ { - jobId: 3, - userId: 'u2', + attemptNum: 1, + destinationId: 'default-destinationId', + dontBatch: false, + jobId: 4, + secret: { + accessToken: 'default-accessToken', + }, + sourceId: 'default-sourceId', + userId: 'default-userId', + workspaceId: 'default-workspaceId', }, { - jobId: 6, - userId: 'u5', + attemptNum: 1, + destinationId: 'default-destinationId', + dontBatch: false, + jobId: 5, + secret: { + accessToken: 'default-accessToken', + }, + sourceId: 'default-sourceId', + userId: 'default-userId', + workspaceId: 'default-workspaceId', }, { - jobId: 7, - userId: 'u6', + attemptNum: 1, + destinationId: 'default-destinationId', + dontBatch: false, + jobId: 6, + secret: { + accessToken: 'default-accessToken', + }, + sourceId: 'default-sourceId', + userId: 'default-userId', + workspaceId: 'default-workspaceId', }, ], batched: true, @@ -1466,31 +804,34 @@ export const data = [ type: 'NA', userSchema: ['EMAIL'], }, - secretConfig: {}, ID: '1mMy5cqbtfuaKZv1IhVQKnBdVwe', - name: 'FB_CUSTOM_AUDIENCE', - enabled: true, - workspaceId: '1TSN08muJTZwH8iCDmnnRt1pmLd', - deleted: false, - createdAt: '2020-12-30T08:39:32.005Z', - updatedAt: '2021-02-03T16:22:31.374Z', - destinationDefinition: { - id: '1aIXqM806xAVm92nx07YwKbRrO9', - name: 'FB_CUSTOM_AUDIENCE', - displayName: 'FB_CUSTOM_AUDIENCE', - createdAt: '2020-04-09T09:24:31.794Z', - updatedAt: '2021-01-11T11:03:28.103Z', + Name: 'FB_CUSTOM_AUDIENCE', + Enabled: true, + WorkspaceID: '1TSN08muJTZwH8iCDmnnRt1pmLd', + DestinationDefinition: { + ID: '1aIXqM806xAVm92nx07YwKbRrO9', + Name: 'FB_CUSTOM_AUDIENCE', + DisplayName: 'FB_CUSTOM_AUDIENCE', + Config: {}, }, - transformations: [], - isConnectionEnabled: true, - isProcessorEnabled: true, + Transformations: [], + IsConnectionEnabled: true, + IsProcessorEnabled: true, }, }, { metadata: [ { - jobId: 8, - userId: 'u7', + attemptNum: 1, + destinationId: 'default-destinationId', + dontBatch: false, + jobId: 7, + secret: { + accessToken: 'default-accessToken', + }, + sourceId: 'default-sourceId', + userId: 'default-userId', + workspaceId: 'default-workspaceId', }, ], batched: false, @@ -1498,8 +839,10 @@ export const data = [ error: 'Invalid action type in record event', statTags: { errorCategory: 'dataValidation', + destinationId: 'default-destinationId', errorType: 'instrumentation', destType: 'FB_CUSTOM_AUDIENCE', + workspaceId: 'default-workspaceId', module: 'destination', implementation: 'native', feature: 'router', @@ -1513,208 +856,14 @@ export const data = [ { name: 'fb_custom_audience', description: 'rETL record batching tests', + scenario: 'Framework', + successCriteria: 'All the record events should be batched', feature: 'router', module: 'destination', version: 'v0', input: { request: { - body: { - input: [ - { - destination: { - Config: { - accessToken: 'ABC', - disableFormat: false, - isHashRequired: true, - isRaw: false, - maxUserCount: '2', - oneTrustCookieCategories: [], - skipVerify: false, - subType: 'NA', - type: 'NA', - userSchema: ['EMAIL'], - }, - secretConfig: {}, - ID: '1mMy5cqbtfuaKZv1IhVQKnBdVwe', - name: 'FB_CUSTOM_AUDIENCE', - enabled: true, - workspaceId: '1TSN08muJTZwH8iCDmnnRt1pmLd', - deleted: false, - createdAt: '2020-12-30T08:39:32.005Z', - updatedAt: '2021-02-03T16:22:31.374Z', - destinationDefinition: { - id: '1aIXqM806xAVm92nx07YwKbRrO9', - name: 'FB_CUSTOM_AUDIENCE', - displayName: 'FB_CUSTOM_AUDIENCE', - createdAt: '2020-04-09T09:24:31.794Z', - updatedAt: '2021-01-11T11:03:28.103Z', - }, - transformations: [], - isConnectionEnabled: true, - isProcessorEnabled: true, - }, - message: { - action: 'insert', - context: { - destinationFields: 'EMAIL, FI', - externalId: [ - { - type: 'FB_CUSTOM_AUDIENCE-23848494844100489', - identifierType: 'EMAIL', - }, - ], - mappedToDestination: 'true', - sources: { - job_run_id: 'cgiiurt8um7k7n5dq480', - task_run_id: 'cgiiurt8um7k7n5dq48g', - job_id: '2MUWghI7u85n91dd1qzGyswpZan', - version: '895/merge', - }, - }, - recordId: '2', - rudderId: '2', - fields: { - EMAIL: 'subscribed@eewrfrd.com', - FI: 'ghui', - }, - type: 'record', - }, - metadata: { - jobId: 2, - userId: 'u1', - }, - }, - { - destination: { - Config: { - accessToken: 'ABC', - disableFormat: false, - isHashRequired: true, - isRaw: false, - maxUserCount: '2', - oneTrustCookieCategories: [], - skipVerify: false, - subType: 'NA', - type: 'NA', - userSchema: ['EMAIL'], - }, - secretConfig: {}, - ID: '1mMy5cqbtfuaKZv1IhVQKnBdVwe', - name: 'FB_CUSTOM_AUDIENCE', - enabled: true, - workspaceId: '1TSN08muJTZwH8iCDmnnRt1pmLd', - deleted: false, - createdAt: '2020-12-30T08:39:32.005Z', - updatedAt: '2021-02-03T16:22:31.374Z', - destinationDefinition: { - id: '1aIXqM806xAVm92nx07YwKbRrO9', - name: 'FB_CUSTOM_AUDIENCE', - displayName: 'FB_CUSTOM_AUDIENCE', - createdAt: '2020-04-09T09:24:31.794Z', - updatedAt: '2021-01-11T11:03:28.103Z', - }, - transformations: [], - isConnectionEnabled: true, - isProcessorEnabled: true, - }, - message: { - action: 'insert', - context: { - destinationFields: 'EMAIL, FI', - externalId: [ - { - type: 'FB_CUSTOM_AUDIENCE-23848494844100489', - identifierType: 'EMAIL', - }, - ], - mappedToDestination: 'true', - sources: { - job_run_id: 'cgiiurt8um7k7n5dq480', - task_run_id: 'cgiiurt8um7k7n5dq48g', - job_id: '2MUWghI7u85n91dd1qzGyswpZan', - version: '895/merge', - }, - }, - recordId: '2', - rudderId: '2', - fields: { - EMAIL: 'subscribed@eewrfrd.com', - FI: 'ghui', - }, - type: 'record', - }, - metadata: { - jobId: 3, - userId: 'u2', - }, - }, - { - destination: { - Config: { - accessToken: 'ABC', - disableFormat: false, - isHashRequired: true, - isRaw: false, - maxUserCount: '2', - oneTrustCookieCategories: [], - skipVerify: false, - subType: 'NA', - type: 'NA', - userSchema: ['EMAIL'], - }, - secretConfig: {}, - ID: '1mMy5cqbtfuaKZv1IhVQKnBdVwe', - name: 'FB_CUSTOM_AUDIENCE', - enabled: true, - workspaceId: '1TSN08muJTZwH8iCDmnnRt1pmLd', - deleted: false, - createdAt: '2020-12-30T08:39:32.005Z', - updatedAt: '2021-02-03T16:22:31.374Z', - destinationDefinition: { - id: '1aIXqM806xAVm92nx07YwKbRrO9', - name: 'FB_CUSTOM_AUDIENCE', - displayName: 'FB_CUSTOM_AUDIENCE', - createdAt: '2020-04-09T09:24:31.794Z', - updatedAt: '2021-01-11T11:03:28.103Z', - }, - transformations: [], - isConnectionEnabled: true, - isProcessorEnabled: true, - }, - message: { - action: 'insert', - context: { - destinationFields: 'EMAIL, FI', - externalId: [ - { - type: 'FB_CUSTOM_AUDIENCE-23848494844100489', - identifierType: 'EMAIL', - }, - ], - mappedToDestination: 'true', - sources: { - job_run_id: 'cgiiurt8um7k7n5dq480', - task_run_id: 'cgiiurt8um7k7n5dq48g', - job_id: '2MUWghI7u85n91dd1qzGyswpZan', - version: '895/merge', - }, - }, - recordId: '2', - rudderId: '2', - fields: { - EMAIL: 'subscribed@eewrfrd.com', - FI: 'ghui', - }, - type: 'record', - }, - metadata: { - jobId: 4, - userId: 'u3', - }, - }, - ], - destType: 'fb_custom_audience', - }, + body: rETLBatchingRouterRequest, }, }, output: { @@ -1783,16 +932,40 @@ export const data = [ ], metadata: [ { - jobId: 2, - userId: 'u1', + attemptNum: 1, + destinationId: 'default-destinationId', + dontBatch: false, + jobId: 1, + secret: { + accessToken: 'default-accessToken', + }, + sourceId: 'default-sourceId', + userId: 'default-userId', + workspaceId: 'default-workspaceId', }, { - jobId: 3, - userId: 'u2', + attemptNum: 1, + destinationId: 'default-destinationId', + dontBatch: false, + jobId: 2, + secret: { + accessToken: 'default-accessToken', + }, + sourceId: 'default-sourceId', + userId: 'default-userId', + workspaceId: 'default-workspaceId', }, { - jobId: 4, - userId: 'u3', + attemptNum: 1, + destinationId: 'default-destinationId', + dontBatch: false, + jobId: 3, + secret: { + accessToken: 'default-accessToken', + }, + sourceId: 'default-sourceId', + userId: 'default-userId', + workspaceId: 'default-workspaceId', }, ], batched: true, @@ -1810,24 +983,19 @@ export const data = [ type: 'NA', userSchema: ['EMAIL'], }, - secretConfig: {}, - ID: '1mMy5cqbtfuaKZv1IhVQKnBdVwe', - name: 'FB_CUSTOM_AUDIENCE', - enabled: true, - workspaceId: '1TSN08muJTZwH8iCDmnnRt1pmLd', - deleted: false, - createdAt: '2020-12-30T08:39:32.005Z', - updatedAt: '2021-02-03T16:22:31.374Z', - destinationDefinition: { - id: '1aIXqM806xAVm92nx07YwKbRrO9', - name: 'FB_CUSTOM_AUDIENCE', - displayName: 'FB_CUSTOM_AUDIENCE', - createdAt: '2020-04-09T09:24:31.794Z', - updatedAt: '2021-01-11T11:03:28.103Z', + Name: 'FB_CUSTOM_AUDIENCE', + Enabled: true, + WorkspaceID: '1TSN08muJTZwH8iCDmnnRt1pmLd', + DestinationDefinition: { + Config: {}, + DisplayName: 'FB_CUSTOM_AUDIENCE', + ID: '1aIXqM806xAVm92nx07YwKbRrO9', + Name: 'FB_CUSTOM_AUDIENCE', }, - transformations: [], - isConnectionEnabled: true, - isProcessorEnabled: true, + ID: '1mMy5cqbtfuaKZv1IhVQKnBdVwe', + Transformations: [], + IsConnectionEnabled: true, + IsProcessorEnabled: true, }, }, ], diff --git a/test/integrations/destinations/fb_custom_audience/router/eventStream.ts b/test/integrations/destinations/fb_custom_audience/router/eventStream.ts new file mode 100644 index 0000000000..b4dcebf48b --- /dev/null +++ b/test/integrations/destinations/fb_custom_audience/router/eventStream.ts @@ -0,0 +1,143 @@ +import { Destination, RouterTransformationRequest } from '../../../../../src/types'; +import { generateMetadata } from '../../../testUtils'; + +const destination: Destination = { + Config: { + accessToken: 'ABC', + userSchema: [ + 'EMAIL', + 'DOBM', + 'DOBD', + 'DOBY', + 'PHONE', + 'GEN', + 'FI', + 'MADID', + 'ZIP', + 'ST', + 'COUNTRY', + ], + isHashRequired: false, + disableFormat: false, + audienceId: 'aud1', + isRaw: true, + type: 'NA', + subType: 'ANYTHING', + maxUserCount: '50', + }, + Enabled: true, + Transformations: [], + IsProcessorEnabled: true, + ID: '123', + Name: 'fb_custom_audience', + DestinationDefinition: { + ID: '123', + Name: 'fb_custom_audience', + DisplayName: 'fb_custom_audience', + Config: {}, + }, + WorkspaceID: '123', +}; + +export const eventStreamRouterRequest: RouterTransformationRequest = { + input: [ + { + message: { + userId: 'user 1', + anonymousId: 'anon-id-new', + event: 'event1', + type: 'audiencelist', + properties: { + listData: { + add: [ + { + EMAIL: 'shrouti@abc.com', + DOBM: '2', + DOBD: '13', + DOBY: '2013', + PHONE: '@09432457768', + GEN: 'f', + FI: 'Ms.', + MADID: 'ABC', + ZIP: 'ZIP ', + ST: '123abc ', + COUNTRY: 'IN', + }, + ], + remove: [ + { + EMAIL: 'shrouti@abc.com', + DOBM: '2', + DOBD: '13', + DOBY: '2013', + PHONE: '@09432457768', + GEN: 'f', + FI: 'Ms.', + MADID: 'ABC', + ZIP: 'ZIP ', + ST: '123abc ', + COUNTRY: 'IN', + }, + ], + }, + }, + context: { ip: '14.5.67.21', library: { name: 'http' } }, + timestamp: '2020-02-02T00:23:09.544Z', + }, + metadata: generateMetadata(1), + destination: destination, + }, + { + message: { + userId: 'user 1', + anonymousId: 'anon-id-new', + event: 'event1', + type: 'audiencelist', + properties: { + listData: { + add: [ + { + EMAIL: 'shrouti@abc.com', + DOBM: '2', + DOBD: '13', + DOBY: '2013', + PHONE: '@09432457768', + GEN: 'f', + FI: 'Ms.', + MADID: 'ABC', + ZIP: 'ZIP ', + ST: '123abc ', + COUNTRY: 'IN', + }, + ], + remove: [ + { + EMAIL: 'shrouti@abc.com', + DOBM: '2', + DOBD: '13', + DOBY: '2013', + PHONE: '@09432457768', + GEN: 'f', + FI: 'Ms.', + MADID: 'ABC', + ZIP: 'ZIP ', + ST: '123abc ', + COUNTRY: 'IN', + }, + ], + }, + }, + context: { ip: '14.5.67.21', library: { name: 'http' } }, + timestamp: '2020-02-02T00:23:09.544Z', + }, + metadata: generateMetadata(2), + destination: destination, + request: { query: {} }, + }, + ], + destType: 'fb_custom_audience', +}; + +module.exports = { + eventStreamRouterRequest, +}; diff --git a/test/integrations/destinations/fb_custom_audience/router/record.ts b/test/integrations/destinations/fb_custom_audience/router/record.ts new file mode 100644 index 0000000000..534c1c40c2 --- /dev/null +++ b/test/integrations/destinations/fb_custom_audience/router/record.ts @@ -0,0 +1,250 @@ +import { Destination, RouterTransformationRequest } from '../../../../../src/types'; +import { generateMetadata } from '../../../testUtils'; + +const destination: Destination = { + Config: { + accessToken: 'ABC', + disableFormat: false, + isHashRequired: true, + isRaw: false, + maxUserCount: '3', + oneTrustCookieCategories: [], + skipVerify: false, + subType: 'NA', + type: 'NA', + userSchema: ['EMAIL'], + }, + ID: '1mMy5cqbtfuaKZv1IhVQKnBdVwe', + Name: 'FB_CUSTOM_AUDIENCE', + Enabled: true, + WorkspaceID: '1TSN08muJTZwH8iCDmnnRt1pmLd', + DestinationDefinition: { + ID: '1aIXqM806xAVm92nx07YwKbRrO9', + Name: 'FB_CUSTOM_AUDIENCE', + DisplayName: 'FB_CUSTOM_AUDIENCE', + Config: {}, + }, + Transformations: [], + IsConnectionEnabled: true, + IsProcessorEnabled: true, +}; + +export const rETLRecordRouterRequest: RouterTransformationRequest = { + input: [ + { + destination: destination, + message: { + action: 'insert', + context: { + destinationFields: 'EMAIL, FI', + externalId: [ + { + type: 'FB_CUSTOM_AUDIENCE-23848494844100489', + identifierType: 'EMAIL', + }, + ], + mappedToDestination: 'true', + sources: { + job_run_id: 'cgiiurt8um7k7n5dq480', + task_run_id: 'cgiiurt8um7k7n5dq48g', + job_id: '2MUWghI7u85n91dd1qzGyswpZan', + version: '895/merge', + }, + }, + recordId: '2', + rudderId: '2', + fields: { + EMAIL: 'subscribed@eewrfrd.com', + FI: 'ghui', + }, + type: 'record', + }, + metadata: generateMetadata(3), + }, + { + destination: destination, + message: { + action: 'update', + context: { + destinationFields: 'EMAIL, FI', + externalId: [ + { + type: 'FB_CUSTOM_AUDIENCE-23848494844100489', + identifierType: 'EMAIL', + }, + ], + mappedToDestination: 'true', + sources: { + job_run_id: 'cgiiurt8um7k7n5dq480', + task_run_id: 'cgiiurt8um7k7n5dq48g', + job_id: '2MUWghI7u85n91dd1qzGyswpZan', + version: '895/merge', + }, + }, + recordId: '2', + rudderId: '2', + fields: { + EMAIL: 'subscribed@eewrfrd.com', + FI: 'ghui', + }, + type: 'record', + }, + metadata: generateMetadata(4), + }, + { + destination: destination, + message: { + action: 'delete', + context: { + destinationFields: 'EMAIL, FI', + externalId: [ + { + type: 'FB_CUSTOM_AUDIENCE-23848494844100489', + identifierType: 'EMAIL', + }, + ], + mappedToDestination: 'true', + sources: { + job_run_id: 'cgiiurt8um7k7n5dq480', + task_run_id: 'cgiiurt8um7k7n5dq48g', + job_id: '2MUWghI7u85n91dd1qzGyswpZan', + version: '895/merge', + }, + }, + recordId: '2', + rudderId: '2', + fields: { + EMAIL: 'subscribed@eewrfrd.com', + FI: 'ghui', + }, + type: 'record', + }, + metadata: generateMetadata(1), + }, + { + destination: destination, + message: { + action: 'delete', + context: { + destinationFields: 'EMAIL, FI', + externalId: [ + { + type: 'FB_CUSTOM_AUDIENCE-23848494844100489', + identifierType: 'EMAIL', + }, + ], + mappedToDestination: 'true', + sources: { + job_run_id: 'cgiiurt8um7k7n5dq480', + task_run_id: 'cgiiurt8um7k7n5dq48g', + job_id: '2MUWghI7u85n91dd1qzGyswpZan', + version: '895/merge', + }, + }, + recordId: '2', + rudderId: '2', + fields: { + EMAIL: 'subscribed@eewrfrd.com', + FI: 'ghui', + }, + type: 'record', + }, + metadata: generateMetadata(2), + }, + { + destination: destination, + message: { + action: 'update', + context: { + destinationFields: 'EMAIL, FI', + externalId: [ + { + type: 'FB_CUSTOM_AUDIENCE-23848494844100489', + identifierType: 'EMAIL', + }, + ], + mappedToDestination: 'true', + sources: { + job_run_id: 'cgiiurt8um7k7n5dq480', + task_run_id: 'cgiiurt8um7k7n5dq48g', + job_id: '2MUWghI7u85n91dd1qzGyswpZan', + version: '895/merge', + }, + }, + recordId: '2', + rudderId: '2', + fields: { + EMAIL: 'subscribed@eewrfrd.com', + FI: 'ghui', + }, + type: 'record', + }, + metadata: generateMetadata(5), + }, + { + destination: destination, + message: { + action: 'update', + context: { + destinationFields: 'EMAIL, FI', + externalId: [ + { + type: 'FB_CUSTOM_AUDIENCE-23848494844100489', + identifierType: 'EMAIL', + }, + ], + mappedToDestination: 'true', + sources: { + job_run_id: 'cgiiurt8um7k7n5dq480', + task_run_id: 'cgiiurt8um7k7n5dq48g', + job_id: '2MUWghI7u85n91dd1qzGyswpZan', + version: '895/merge', + }, + }, + recordId: '2', + rudderId: '2', + fields: { + EMAIL: 'subscribed@eewrfrd.com', + FI: 'ghui', + }, + type: 'record', + }, + metadata: generateMetadata(6), + }, + { + destination: destination, + message: { + action: 'lol', + context: { + destinationFields: 'EMAIL, FI', + externalId: [ + { + type: 'FB_CUSTOM_AUDIENCE-23848494844100489', + identifierType: 'EMAIL', + }, + ], + mappedToDestination: 'true', + sources: { + job_run_id: 'cgiiurt8um7k7n5dq480', + task_run_id: 'cgiiurt8um7k7n5dq48g', + job_id: '2MUWghI7u85n91dd1qzGyswpZan', + version: '895/merge', + }, + }, + recordId: '2', + rudderId: '2', + fields: { + EMAIL: 'subscribed@eewrfrd.com', + FI: 'ghui', + }, + type: 'record', + }, + metadata: generateMetadata(7), + }, + ], + destType: 'fb_custom_audience', +}; + +module.exports = { + rETLRecordRouterRequest, +};