Skip to content

Commit

Permalink
Merge branch 'develop' into fb_pixel_v1_tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sandeepdsvs authored Mar 1, 2024
2 parents f8f7eec + 54178f8 commit 4ad6521
Show file tree
Hide file tree
Showing 4 changed files with 285 additions and 4 deletions.
226 changes: 226 additions & 0 deletions test/integrations/destinations/fb/dataDelivery/business.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,226 @@
import { generateMetadata, generateProxyV1Payload } from '../../../testUtils';
import { ProxyV1TestData } from '../../../testTypes';
import { VERSION } from '../../../../../src/v0/destinations/fb/config';

export const testData1 = {
event: 'CUSTOM_APP_EVENTS',
advertiser_id: 'df16bffa-5c3d-4fbb-9bce-3bab098129a7R',
'ud[em]': '48ddb93f0b30c475423fe177832912c5bcdce3cc72872f8051627967ef278e08',
'ud[fn]': '9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08',
'ud[ge]': '62c66a7a5dd70c3146618063c344e531e6d4b59e379808443ce962b3abd63c5a',
'ud[ln]': '3547cb112ac4489af2310c0626cdba6f3097a2ad5a3b42ddd3b59c76c7a079a3',
'ud[ph]': '588211a01b10feacbf7988d97a06e86c18af5259a7f457fd8759b7f7409a7d1f',
extinfo:
'["a2","","","","8.1.0","Redmi 6","","","Banglalink",640,480,"1.23",0,0,0,"Europe/Berlin"]',
app_user_id: 'c82cbdff-e5be-4009-ac78-cdeea09ab4b1',
custom_events:
'[{"_logTime":1567333011693,"_eventName":"spin_result","_valueToSum":400,"fb_currency":"GBP","additional_bet_index":0,"battle_id":"N/A","bet_amount":9,"bet_level":1,"bet_multiplier":1,"coin_balance":9466052,"current_module_name":"CasinoGameModule","days_in_game":0,"extra_param":"N/A","fb_profile":"0","featureGameType":"N/A","game_fps":30,"game_id":"fireEagleBase","game_name":"FireEagleSlots","gem_balance":0,"graphicsQuality":"HD","idfa":"2bf99787-33d2-4ae2-a76a-c49672f97252","internetReachability":"ReachableViaLocalAreaNetwork","isLowEndDevice":"False","is_auto_spin":"False","is_turbo":"False","isf":"False","ishighroller":"False","jackpot_win_amount":90,"jackpot_win_type":"Silver","level":6,"lifetime_gem_balance":0,"no_of_spin":1,"player_total_battles":0,"player_total_shields":0,"start_date":"2019-08-01","total_payments":0,"tournament_id":"T1561970819","userId":"c82cbdff-e5be-4009-ac78-cdeea09ab4b1","versionSessionCount":2,"win_amount":0,"fb_content_id":["123","345","567"]}]',
advertiser_tracking_enabled: '0',
application_tracking_enabled: '0',
};

export const testData2 = {
extinfo: '["a2","","","","8.1.0","Redmi 6","","","Banglalink",0,100,"50.00",0,0,0,""]',
custom_events:
'[{"_logTime":1567333011693,"_eventName":"Viewed Screen","fb_description":"Main.1233"}]',
'ud[em]': '48ddb93f0b30c475423fe177832912c5bcdce3cc72872f8051627967ef278e08',
advertiser_tracking_enabled: '0',
application_tracking_enabled: '0',
event: 'CUSTOM_APP_EVENTS',
};

export const statTags = {
destType: 'FB',
errorCategory: 'network',
destinationId: 'default-destinationId',
workspaceId: 'default-workspaceId',
errorType: 'aborted',
feature: 'dataDelivery',
implementation: 'native',
module: 'destination',
};

export const testScenariosForV1API: ProxyV1TestData[] = [
{
id: 'fb_v1_scenario_1',
name: 'fb',
description: 'app event fails due to access token error',
successCriteria: 'Should return 400 with invalid access token error',
scenario: 'Business',
feature: 'dataDelivery',
module: 'destination',
version: 'v1',
input: {
request: {
body: generateProxyV1Payload({
endpoint: `https://graph.facebook.com/${VERSION}/RudderFbApp/activities?access_token=invalid_access_token`,
headers: {
'x-forwarded-for': '1.2.3.4',
},
params: {
destination: 'fb',
},
FORM: testData1,
}),
method: 'POST',
},
},
output: {
response: {
status: 200,
body: {
output: {
status: 400,
message: 'Invalid OAuth 2.0 access token',
statTags: {
...statTags,
errorCategory: 'dataValidation',
errorType: 'configuration',
meta: 'accessTokenExpired',
},
response: [
{
error: 'Invalid OAuth 2.0 access token',
statusCode: 400,
metadata: generateMetadata(1),
},
],
},
},
},
},
},
{
id: 'fb_v1_scenario_2',
name: 'fb',
description: 'app event sent successfully',
successCriteria: 'Should return 200',
scenario: 'Business',
feature: 'dataDelivery',
module: 'destination',
version: 'v1',
input: {
request: {
body: generateProxyV1Payload({
endpoint: `https://graph.facebook.com/${VERSION}/RudderFbApp/activities?access_token=my_access_token`,
headers: {
'x-forwarded-for': '1.2.3.4',
},
params: {
destination: 'fb',
},
FORM: testData1,
}),
method: 'POST',
},
},
output: {
response: {
status: 200,
body: {
output: {
status: 200,
message: 'Request Processed Successfully',
response: [
{
error: '{"events_received":1,"fbtrace_id":"facebook_trace_id"}',
statusCode: 200,
metadata: generateMetadata(1),
},
],
},
},
},
},
},
{
id: 'fb_v1_scenario_3',
name: 'fb',
description: 'app event fails due to invalid timestamp',
successCriteria: 'Should return 400 with invalid timestamp error',
scenario: 'Business',
feature: 'dataDelivery',
module: 'destination',
version: 'v1',
input: {
request: {
body: generateProxyV1Payload({
endpoint: `https://graph.facebook.com/${VERSION}/1234567891234567/events?access_token=invalid_timestamp_correct_access_token`,
headers: {
'x-forwarded-for': '1.2.3.4',
},
params: {
destination: 'fb',
},
FORM: testData1,
}),
method: 'POST',
},
},
output: {
response: {
status: 200,
body: {
output: {
status: 400,
message: 'Event Timestamp Too Old',
statTags,
response: [
{
error: 'Event Timestamp Too Old',
statusCode: 400,
metadata: generateMetadata(1),
},
],
},
},
},
},
},
{
id: 'fb_v1_scenario_4',
name: 'fb',
description: 'app event fails due to missing permissions',
successCriteria: 'Should return 400 with missing permissions error',
scenario: 'Business',
feature: 'dataDelivery',
module: 'destination',
version: 'v1',
input: {
request: {
body: generateProxyV1Payload({
endpoint: `https://graph.facebook.com/${VERSION}/1234567891234567/events?access_token=invalid_account_id_valid_access_token`,
headers: {
'x-forwarded-for': '1.2.3.4',
},
params: {
destination: 'fb',
},
FORM: testData2,
}),
method: 'POST',
},
},
output: {
response: {
status: 200,
body: {
output: {
status: 400,
message:
"Object with ID 'PIXEL_ID' / 'DATASET_ID' / 'AUDIENCE_ID' does not exist, cannot be loaded due to missing permissions, or does not support this operation",
statTags,
response: [
{
error:
"Object with ID 'PIXEL_ID' / 'DATASET_ID' / 'AUDIENCE_ID' does not exist, cannot be loaded due to missing permissions, or does not support this operation",
statusCode: 400,
metadata: generateMetadata(1),
},
],
},
},
},
},
},
];
6 changes: 5 additions & 1 deletion test/integrations/destinations/fb/dataDelivery/data.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { VERSION } from '../../../../../src/v0/destinations/fb/config';
import { testScenariosForV1API } from './business';
import { otherScenariosV1 } from './other';

export const data = [
export const existingTestData = [
{
name: 'fb',
description: 'Test 0',
Expand Down Expand Up @@ -371,3 +373,5 @@ export const data = [
},
},
];

export const data = [...existingTestData, ...testScenariosForV1API, ...otherScenariosV1];
51 changes: 51 additions & 0 deletions test/integrations/destinations/fb/dataDelivery/other.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { generateMetadata, generateProxyV1Payload } from '../../../testUtils';
import { ProxyV1TestData } from '../../../testTypes';
import { VERSION } from '../../../../../src/v0/destinations/fb/config';
import { testData2 as testData, statTags } from './business';

export const otherScenariosV1: ProxyV1TestData[] = [
{
id: 'fb_v1_other_scenario_1',
name: 'fb',
description: 'user update request is throttled due to too many calls',
successCriteria: 'Should return 429 with message there have been too many calls',
scenario: 'Framework',
feature: 'dataDelivery',
module: 'destination',
version: 'v1',
input: {
request: {
body: generateProxyV1Payload({
endpoint: `https://graph.facebook.com/${VERSION}/1234567891234567/events?access_token=throttled_valid_access_token`,
params: {
destination: 'fb',
},
FORM: testData,
}),
method: 'POST',
},
},
output: {
response: {
status: 200,
body: {
output: {
status: 429,
message: 'API User Too Many Calls',
statTags: {
...statTags,
errorType: 'throttled',
},
response: [
{
error: 'API User Too Many Calls',
statusCode: 429,
metadata: generateMetadata(1),
},
],
},
},
},
},
},
];
6 changes: 3 additions & 3 deletions test/integrations/destinations/fb/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const fbPixelTcs = data
return nw.httpReq.url === fbendpoint;
})[0];
const clonedFbpTc = cloneDeep(fbpTc);
const clonedFormData = cloneDeep(d.input.request.body.body.FORM);
const clonedFormData = cloneDeep(d.input.request.body.body?.FORM);
clonedFbpTc.httpReq.data = getFormData(clonedFormData).toString();
return clonedFbpTc;
});
Expand All @@ -21,7 +21,7 @@ export const networkCallsData = [
{
httpReq: {
url: `https://graph.facebook.com/${VERSION}/RudderFbApp/activities?access_token=invalid_access_token`,
data: getFormData(data[0].input.request.body.body.FORM).toString(),
data: getFormData(data[0].input.request.body.body?.FORM).toString(),
params: { destination: 'fb' },
headers: { 'User-Agent': 'RudderLabs' },
method: 'POST',
Expand All @@ -41,7 +41,7 @@ export const networkCallsData = [
{
httpReq: {
url: `https://graph.facebook.com/${VERSION}/RudderFbApp/activities?access_token=my_access_token`,
data: getFormData(data[1].input.request.body.body.FORM).toString(),
data: getFormData(data[1].input.request.body.body?.FORM).toString(),
params: { destination: 'fb' },
headers: { 'x-forwarded-for': '1.2.3.4', 'User-Agent': 'RudderLabs' },
method: 'POST',
Expand Down

0 comments on commit 4ad6521

Please sign in to comment.