Skip to content

Commit

Permalink
feat: updated fb tests to pick version dynamically from config.js
Browse files Browse the repository at this point in the history
  • Loading branch information
sandeepdsvs committed Nov 29, 2023
1 parent 7de0c09 commit 30a193f
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 24 deletions.
3 changes: 3 additions & 0 deletions src/v0/destinations/fb/config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const fs = require('fs');
const path = require('path');

const VERSION = 'v18.0';

const getPath = (file) => path.resolve(__dirname, file);

const baseMapping = JSON.parse(fs.readFileSync(getPath('./data/FbAppBasicMapping.json')));
Expand All @@ -20,6 +22,7 @@ const eventPropToTypeMapping = JSON.parse(
);

module.exports = {
VERSION,
baseMapping,
eventNameMapping,
eventPropsMapping,
Expand Down
3 changes: 2 additions & 1 deletion src/v0/destinations/fb/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const {
} = require('../../util');

const {
VERSION,
baseMapping,
eventNameMapping,
eventPropsMapping,
Expand Down Expand Up @@ -250,7 +251,7 @@ function responseBuilderSimple(message, payload, destination) {

// "https://graph.facebook.com/v13.0/644748472345539/activities"

const endpoint = `https://graph.facebook.com/v18.0/${appID}/activities`;
const endpoint = `https://graph.facebook.com/${VERSION}/${appID}/activities`;

const response = defaultRequestConfig();
response.endpoint = endpoint;
Expand Down
17 changes: 7 additions & 10 deletions test/integrations/destinations/fb/dataDelivery/data.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { VERSION } from '../../../../../src/v0/destinations/fb/config';

export const data = [
{
name: 'fb',
Expand Down Expand Up @@ -29,8 +31,7 @@ export const data = [
},
JSON: {},
},
endpoint:
'https://graph.facebook.com/v18.0/RudderFbApp/activities?access_token=invalid_access_token',
endpoint: `https://graph.facebook.com/${VERSION}/RudderFbApp/activities?access_token=invalid_access_token`,
files: {},
headers: {
'x-forwarded-for': '1.2.3.4',
Expand Down Expand Up @@ -108,8 +109,7 @@ export const data = [
},
JSON: {},
},
endpoint:
'https://graph.facebook.com/v18.0/RudderFbApp/activities?access_token=my_access_token',
endpoint: `https://graph.facebook.com/${VERSION}/RudderFbApp/activities?access_token=my_access_token`,
files: {},
headers: {
'x-forwarded-for': '1.2.3.4',
Expand Down Expand Up @@ -173,8 +173,7 @@ export const data = [
},
JSON: {},
},
endpoint:
'https://graph.facebook.com/v18.0/1234567891234567/events?access_token=invalid_timestamp_correct_access_token',
endpoint: `https://graph.facebook.com/${VERSION}/1234567891234567/events?access_token=invalid_timestamp_correct_access_token`,
files: {},
headers: {
'x-forwarded-for': '1.2.3.4',
Expand Down Expand Up @@ -239,8 +238,7 @@ export const data = [
version: '1',
type: 'REST',
method: 'POST',
endpoint:
'https://graph.facebook.com/v18.0/1234567891234567/events?access_token=throttled_valid_access_token',
endpoint: `https://graph.facebook.com/${VERSION}/1234567891234567/events?access_token=throttled_valid_access_token`,
headers: {},
body: {
JSON: {},
Expand Down Expand Up @@ -310,8 +308,7 @@ export const data = [
version: '1',
type: 'REST',
method: 'POST',
endpoint:
'https://graph.facebook.com/v18.0/1234567891234567/events?access_token=invalid_account_id_valid_access_token',
endpoint: `https://graph.facebook.com/${VERSION}/1234567891234567/events?access_token=invalid_account_id_valid_access_token`,
headers: {},
body: {
JSON: {},
Expand Down
5 changes: 3 additions & 2 deletions test/integrations/destinations/fb/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { cloneDeep } from 'lodash';
import { getFormData } from '../../../../src/adapters/network';
import * as fbPixelNw from '../facebook_pixel/network';
import { data } from './dataDelivery/data';
import { VERSION } from '../../../../src/v0/destinations/fb/config';

const fbPixelTcs = data
.filter((_, i) => [2, 3, 4].includes(i))
Expand All @@ -19,7 +20,7 @@ const fbPixelTcs = data
export const networkCallsData = [
{
httpReq: {
url: 'https://graph.facebook.com/v18.0/RudderFbApp/activities?access_token=invalid_access_token',
url: `https://graph.facebook.com/${VERSION}/RudderFbApp/activities?access_token=invalid_access_token`,
data: getFormData(data[0].input.request.body.body.FORM).toString(),
params: { destination: 'fb' },
headers: { 'User-Agent': 'RudderLabs' },
Expand All @@ -39,7 +40,7 @@ export const networkCallsData = [
},
{
httpReq: {
url: 'https://graph.facebook.com/v18.0/RudderFbApp/activities?access_token=my_access_token',
url: `https://graph.facebook.com/${VERSION}/RudderFbApp/activities?access_token=my_access_token`,
data: getFormData(data[1].input.request.body.body.FORM).toString(),
params: { destination: 'fb' },
headers: { 'x-forwarded-for': '1.2.3.4', 'User-Agent': 'RudderLabs' },
Expand Down
24 changes: 13 additions & 11 deletions test/integrations/destinations/fb/processor/data.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { VERSION } from '../../../../../src/v0/destinations/fb/config';

export const data = [
{
name: 'fb',
Expand Down Expand Up @@ -618,7 +620,7 @@ export const data = [
},
JSON: {},
},
endpoint: 'https://graph.facebook.com/v18.0/RudderFbApp/activities',
endpoint: `https://graph.facebook.com/${VERSION}/RudderFbApp/activities`,
files: {},
headers: {
'x-forwarded-for': '1.2.3.4',
Expand Down Expand Up @@ -803,7 +805,7 @@ export const data = [
},
JSON: {},
},
endpoint: 'https://graph.facebook.com/v18.0/RudderFbApp/activities',
endpoint: `https://graph.facebook.com/${VERSION}/RudderFbApp/activities`,
files: {},
headers: {
'x-forwarded-for': '1.2.3.4',
Expand Down Expand Up @@ -893,7 +895,7 @@ export const data = [
version: '1',
type: 'REST',
method: 'POST',
endpoint: 'https://graph.facebook.com/v18.0/RudderFbApp/activities',
endpoint: `https://graph.facebook.com/${VERSION}/RudderFbApp/activities`,
headers: {},
params: {},
body: {
Expand Down Expand Up @@ -993,7 +995,7 @@ export const data = [
version: '1',
type: 'REST',
method: 'POST',
endpoint: 'https://graph.facebook.com/v18.0/RudderFbApp/activities',
endpoint: `https://graph.facebook.com/${VERSION}/RudderFbApp/activities`,
headers: {},
params: {},
body: {
Expand Down Expand Up @@ -1177,7 +1179,7 @@ export const data = [
version: '1',
type: 'REST',
method: 'POST',
endpoint: 'https://graph.facebook.com/v18.0/RudderFbApp/activities',
endpoint: `https://graph.facebook.com/${VERSION}/RudderFbApp/activities`,
headers: {},
params: {},
body: {
Expand Down Expand Up @@ -1277,7 +1279,7 @@ export const data = [
version: '1',
type: 'REST',
method: 'POST',
endpoint: 'https://graph.facebook.com/v18.0/RudderFbApp/activities',
endpoint: `https://graph.facebook.com/${VERSION}/RudderFbApp/activities`,
headers: {},
params: {},
body: {
Expand Down Expand Up @@ -1377,7 +1379,7 @@ export const data = [
version: '1',
type: 'REST',
method: 'POST',
endpoint: 'https://graph.facebook.com/v18.0/RudderFbApp/activities',
endpoint: `https://graph.facebook.com/${VERSION}/RudderFbApp/activities`,
headers: {},
params: {},
body: {
Expand Down Expand Up @@ -1551,7 +1553,7 @@ export const data = [
version: '1',
type: 'REST',
method: 'POST',
endpoint: 'https://graph.facebook.com/v18.0/RudderFbApp/activities',
endpoint: `https://graph.facebook.com/${VERSION}/RudderFbApp/activities`,
headers: {},
params: {},
body: {
Expand Down Expand Up @@ -1731,7 +1733,7 @@ export const data = [
version: '1',
type: 'REST',
method: 'POST',
endpoint: 'https://graph.facebook.com/v18.0/RudderFbApp/activities',
endpoint: `https://graph.facebook.com/${VERSION}/RudderFbApp/activities`,
headers: {},
params: {},
body: {
Expand Down Expand Up @@ -1831,7 +1833,7 @@ export const data = [
version: '1',
type: 'REST',
method: 'POST',
endpoint: 'https://graph.facebook.com/v18.0/RudderFbApp/activities',
endpoint: `https://graph.facebook.com/${VERSION}/RudderFbApp/activities`,
headers: {
'x-forwarded-for': '2.3.4.5',
},
Expand Down Expand Up @@ -2153,7 +2155,7 @@ export const data = [
version: '1',
type: 'REST',
method: 'POST',
endpoint: 'https://graph.facebook.com/v18.0/RudderFbApp/activities',
endpoint: `https://graph.facebook.com/${VERSION}/RudderFbApp/activities`,
headers: {},
params: {},
body: {
Expand Down

0 comments on commit 30a193f

Please sign in to comment.