From 41dada1dd00b82a404813cbb890a3bf1ca8995ca Mon Sep 17 00:00:00 2001 From: sandeepdigumarty Date: Fri, 1 Mar 2024 18:07:43 +0530 Subject: [PATCH] chore: updated tests --- .../dataDelivery/business.ts | 136 ++++++++---------- .../fb_custom_audience/dataDelivery/other.ts | 21 +-- 2 files changed, 64 insertions(+), 93 deletions(-) diff --git a/test/integrations/destinations/fb_custom_audience/dataDelivery/business.ts b/test/integrations/destinations/fb_custom_audience/dataDelivery/business.ts index 448ac0e23f..c48ad227ab 100644 --- a/test/integrations/destinations/fb_custom_audience/dataDelivery/business.ts +++ b/test/integrations/destinations/fb_custom_audience/dataDelivery/business.ts @@ -2,7 +2,7 @@ import { generateMetadata, generateProxyV1Payload } from '../../../testUtils'; import { ProxyV1TestData } from '../../../testTypes'; import { getEndPoint } from '../../../../../src/v0/destinations/fb_custom_audience/config'; -const statTags = { +export const statTags = { destType: 'FB_CUSTOM_AUDIENCE', destinationId: 'default-destinationId', errorCategory: 'network', @@ -13,7 +13,45 @@ const statTags = { workspaceId: 'default-workspaceId', }; -const params = { +const testParams1 = { + access_token: 'ABC', + payload: { + is_raw: true, + data_source: { + sub_type: 'ANYTHING', + }, + schema: [ + 'EMAIL', + 'DOBM', + 'DOBD', + 'DOBY', + 'PHONE', + 'GEN', + 'FI', + 'MADID', + 'ZIP', + 'ST', + 'COUNTRY', + ], + data: [ + [ + 'shrouti@abc.com', + '2', + '13', + '2013', + '@09432457768', + 'f', + 'Ms.', + 'ABC', + 'ZIP ', + '123abc ', + 'IN', + ], + ], + }, +}; + +export const testParams2 = { access_token: 'ABC', payload: { is_raw: true, @@ -25,6 +63,18 @@ const params = { }, }; +const testParams3 = { + access_token: 'BCD', + payload: { + is_raw: true, + data_source: { + sub_type: 'ANYTHING', + }, + schema: ['DOBM', 'DOBD', 'DOBY', 'PHONE', 'GEN', 'FI', 'MADID', 'ZIP', 'ST', 'COUNTRY'], + data: [['2', '13', '2013', '@09432457768', 'f', 'Ms.', 'ABC', 'ZIP ', '123abc ', 'IN']], + }, +}; + export const testScenariosForV1API: ProxyV1TestData[] = [ { id: 'fbca_v1_scenario_1', @@ -43,43 +93,7 @@ export const testScenariosForV1API: ProxyV1TestData[] = [ headers: { 'test-dest-response-key': 'successResponse', }, - params: { - access_token: 'ABC', - payload: { - is_raw: true, - data_source: { - sub_type: 'ANYTHING', - }, - schema: [ - 'EMAIL', - 'DOBM', - 'DOBD', - 'DOBY', - 'PHONE', - 'GEN', - 'FI', - 'MADID', - 'ZIP', - 'ST', - 'COUNTRY', - ], - data: [ - [ - 'shrouti@abc.com', - '2', - '13', - '2013', - '@09432457768', - 'f', - 'Ms.', - 'ABC', - 'ZIP ', - '123abc ', - 'IN', - ], - ], - }, - }, + params: testParams1, }), method: 'POST', }, @@ -121,30 +135,7 @@ export const testScenariosForV1API: ProxyV1TestData[] = [ headers: { 'test-dest-response-key': 'permissionMissingError', }, - params: { - access_token: 'BCD', - payload: { - is_raw: true, - data_source: { - sub_type: 'ANYTHING', - }, - schema: [ - 'DOBM', - 'DOBD', - 'DOBY', - 'PHONE', - 'GEN', - 'FI', - 'MADID', - 'ZIP', - 'ST', - 'COUNTRY', - ], - data: [ - ['2', '13', '2013', '@09432457768', 'f', 'Ms.', 'ABC', 'ZIP ', '123abc ', 'IN'], - ], - }, - }, + params: testParams3, }), method: 'POST', }, @@ -188,7 +179,7 @@ export const testScenariosForV1API: ProxyV1TestData[] = [ headers: { 'test-dest-response-key': 'audienceUnavailableError', }, - params, + params: testParams2, }), method: 'POST', }, @@ -232,7 +223,7 @@ export const testScenariosForV1API: ProxyV1TestData[] = [ headers: { 'test-dest-response-key': 'audienceDeletedError', }, - params, + params: testParams2, }), method: 'POST', }, @@ -274,7 +265,7 @@ export const testScenariosForV1API: ProxyV1TestData[] = [ headers: { 'test-dest-response-key': 'failedToUpdateAudienceError', }, - params, + params: testParams2, }), method: 'POST', }, @@ -317,7 +308,7 @@ export const testScenariosForV1API: ProxyV1TestData[] = [ headers: { 'test-dest-response-key': 'parameterExceededError', }, - params, + params: testParams2, }), method: 'POST', }, @@ -359,7 +350,7 @@ export const testScenariosForV1API: ProxyV1TestData[] = [ headers: { 'test-dest-response-key': 'code200PermissionError', }, - params, + params: testParams2, }), method: 'POST', }, @@ -401,7 +392,7 @@ export const testScenariosForV1API: ProxyV1TestData[] = [ headers: { 'test-dest-response-key': 'accessTokenInvalidError', }, - params, + params: testParams2, }), method: 'POST', }, @@ -415,15 +406,10 @@ export const testScenariosForV1API: ProxyV1TestData[] = [ message: 'Error validating access token: Session has expired on Tuesday, 01-Aug-23 10:12:14 PDT. The current time is Sunday, 28-Jan-24 16:01:17 PST.', statTags: { - destType: 'FB_CUSTOM_AUDIENCE', - destinationId: 'default-destinationId', + ...statTags, errorCategory: 'dataValidation', errorType: 'configuration', meta: 'accessTokenExpired', - feature: 'dataDelivery', - implementation: 'native', - module: 'destination', - workspaceId: 'default-workspaceId', }, response: [ { diff --git a/test/integrations/destinations/fb_custom_audience/dataDelivery/other.ts b/test/integrations/destinations/fb_custom_audience/dataDelivery/other.ts index a3f9b57a2d..52138604b0 100644 --- a/test/integrations/destinations/fb_custom_audience/dataDelivery/other.ts +++ b/test/integrations/destinations/fb_custom_audience/dataDelivery/other.ts @@ -1,6 +1,7 @@ import { generateMetadata, generateProxyV1Payload } from '../../../testUtils'; import { ProxyV1TestData } from '../../../testTypes'; import { getEndPoint } from '../../../../../src/v0/destinations/fb_custom_audience/config'; +import { statTags, testParams2 as testParams } from './business'; export const otherScenariosV1: ProxyV1TestData[] = [ { @@ -21,17 +22,7 @@ export const otherScenariosV1: ProxyV1TestData[] = [ headers: { 'test-dest-response-key': 'tooManyCallsError', }, - params: { - access_token: 'ABC', - payload: { - is_raw: true, - data_source: { - sub_type: 'ANYTHING', - }, - schema: ['DOBY', 'PHONE', 'GEN', 'FI', 'MADID', 'ZIP', 'ST', 'COUNTRY'], - data: [['2013', '@09432457768', 'f', 'Ms.', 'ABC', 'ZIP ', '123abc ', 'IN']], - }, - }, + params: testParams, }), method: 'POST', }, @@ -43,14 +34,8 @@ export const otherScenariosV1: ProxyV1TestData[] = [ output: { message: 'There have been too many calls to this ad-account.', statTags: { - destType: 'FB_CUSTOM_AUDIENCE', - destinationId: 'default-destinationId', - errorCategory: 'network', + ...statTags, errorType: 'throttled', - feature: 'dataDelivery', - implementation: 'native', - module: 'destination', - workspaceId: 'default-workspaceId', }, status: 429, response: [