Skip to content

Commit

Permalink
chore: updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sandeepdsvs committed Mar 1, 2024
1 parent d46f56f commit 05ade78
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 170 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ import { generateMetadata, generateProxyV1Payload } from '../../../testUtils';
import { ProxyV1TestData } from '../../../testTypes';
import { VERSION } from '../../../../../src/v0/destinations/facebook_pixel/config';

const testData = [
'{"user_data":{"external_id":"c58f05b5e3cc4796f3181cf07349d306547c00b20841a175b179c6860e6a34ab","client_ip_address":"32.122.223.26","client_user_agent":"Mozilla/5.0 (iPhone; CPU iPhone OS 15_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.5 Mobile/15E148 Safari/604.1"},"event_name":"Checkout Step Viewed","event_time":1654772112,"event_source_url":"https://www.my.kaiser.com/checkout","event_id":"4f002656-a7b2-4c17-b9bd-8caa5a29190a","custom_data":{"checkout_id":"26SF29B","site":"www.my.kaiser.com","step":1}}',
];
const statTags = {
export const testFormData = {
data: [
'{"user_data":{"external_id":"c58f05b5e3cc4796f3181cf07349d306547c00b20841a175b179c6860e6a34ab","client_ip_address":"32.122.223.26","client_user_agent":"Mozilla/5.0 (iPhone; CPU iPhone OS 15_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.5 Mobile/15E148 Safari/604.1"},"event_name":"Checkout Step Viewed","event_time":1654772112,"event_source_url":"https://www.my.kaiser.com/checkout","event_id":"4f002656-a7b2-4c17-b9bd-8caa5a29190a","custom_data":{"checkout_id":"26SF29B","site":"www.my.kaiser.com","step":1}}',
],
};
export const statTags = {
destType: 'FACEBOOK_PIXEL',
errorCategory: 'network',
destinationId: 'default-destinationId',
Expand All @@ -29,9 +31,7 @@ export const testScenariosForV1API: ProxyV1TestData[] = [
request: {
body: generateProxyV1Payload({
endpoint: `https://graph.facebook.com/${VERSION}/1234567891234567/events?access_token=invalid_access_token`,
FORM: {
data: testData,
},
FORM: testFormData,
}),
method: 'POST',
},
Expand Down Expand Up @@ -77,9 +77,7 @@ export const testScenariosForV1API: ProxyV1TestData[] = [
params: {
destination: 'facebook_pixel',
},
FORM: {
data: testData,
},
FORM: testFormData,
}),
method: 'POST',
},
Expand Down Expand Up @@ -116,9 +114,7 @@ export const testScenariosForV1API: ProxyV1TestData[] = [
request: {
body: generateProxyV1Payload({
endpoint: `https://graph.facebook.com/${VERSION}/1234567891234567/events?access_token=invalid_timestamp_correct_access_token`,
FORM: {
data: testData,
},
FORM: testFormData,
}),
method: 'POST',
},
Expand Down Expand Up @@ -156,9 +152,7 @@ export const testScenariosForV1API: ProxyV1TestData[] = [
request: {
body: generateProxyV1Payload({
endpoint: `https://graph.facebook.com/${VERSION}/1234567891234567/events?access_token=invalid_account_id_valid_access_token`,
FORM: {
data: testData,
},
FORM: testFormData,
}),
method: 'POST',
},
Expand Down Expand Up @@ -198,11 +192,7 @@ export const testScenariosForV1API: ProxyV1TestData[] = [
request: {
body: generateProxyV1Payload({
endpoint: `https://graph.facebook.com/${VERSION}/1234567891234567/events?access_token=not_found_access_token`,
FORM: {
data: [
'{"user_data":{"external_id":"d58f05b5e3cc4796f3181cf07349d306547c00b20841a175b179c6860e6a34ab","client_ip_address":"32.122.223.26","client_user_agent":"Mozilla/5.0 (iPhone; CPU iPhone OS 15_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.5 Mobile/15E148 Safari/604.1"},"event_name":"Checkout Step Viewed","event_time":1654772112,"event_source_url":"https://www.my.kaiser.com/checkout","event_id":"4f002656-a7b2-4c17-b9bd-8caa5a29190a","custom_data":{"checkout_id":"26SF29B","site":"www.my.kaiser.com","step":1}}',
],
},
FORM: testFormData,
}),
method: 'POST',
},
Expand Down Expand Up @@ -240,9 +230,7 @@ export const testScenariosForV1API: ProxyV1TestData[] = [
request: {
body: generateProxyV1Payload({
endpoint: `https://graph.facebook.com/${VERSION}/1234567891234570/events?access_token=valid_access_token`,
FORM: {
data: testData,
},
FORM: testFormData,
}),
method: 'POST',
},
Expand Down Expand Up @@ -280,9 +268,7 @@ export const testScenariosForV1API: ProxyV1TestData[] = [
request: {
body: generateProxyV1Payload({
endpoint: `https://graph.facebook.com/${VERSION}/1234567891234571/events?access_token=valid_access_token`,
FORM: {
data: testData,
},
FORM: testFormData,
}),
method: 'POST',
},
Expand Down Expand Up @@ -320,9 +306,7 @@ export const testScenariosForV1API: ProxyV1TestData[] = [
request: {
body: generateProxyV1Payload({
endpoint: `https://graph.facebook.com/${VERSION}/1234567891234572/events?access_token=valid_access_token_unhandled_response`,
FORM: {
data: testData,
},
FORM: testFormData,
}),
method: 'POST',
},
Expand Down
144 changes: 26 additions & 118 deletions test/integrations/destinations/facebook_pixel/dataDelivery/data.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import { VERSION } from '../../../../../src/v0/destinations/facebook_pixel/config';
import { testScenariosForV1API } from './business';
import { testScenariosForV1API, testFormData, statTags as baseStatTags } from './business';
import { otherScenariosV1 } from './other';

export const existingTestData = [
const statTags = {
...baseStatTags,
destinationId: 'Non-determininable',
workspaceId: 'Non-determininable',
};

export const v0TestData = [
{
name: 'facebook_pixel',
description: 'Test 0',
Expand All @@ -14,11 +20,7 @@ export const existingTestData = [
body: {
body: {
XML: {},
FORM: {
data: [
'{"user_data":{"external_id":"c58f05b5e3cc4796f3181cf07349d306547c00b20841a175b179c6860e6a34ab","client_ip_address":"32.122.223.26","client_user_agent":"Mozilla/5.0 (iPhone; CPU iPhone OS 15_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.5 Mobile/15E148 Safari/604.1"},"event_name":"Checkout Step Viewed","event_time":1654772112,"event_source_url":"https://www.my.kaiser.com/checkout","event_id":"4f002656-a7b2-4c17-b9bd-8caa5a29190a","custom_data":{"checkout_id":"26SF29B","site":"www.my.kaiser.com","step":1}}',
],
},
FORM: testFormData,
JSON: {},
JSON_ARRAY: {},
},
Expand Down Expand Up @@ -53,15 +55,10 @@ export const existingTestData = [
status: 500,
},
statTags: {
destType: 'FACEBOOK_PIXEL',
...statTags,
errorCategory: 'dataValidation',
destinationId: 'Non-determininable',
workspaceId: 'Non-determininable',
errorType: 'configuration',
meta: 'accessTokenExpired',
feature: 'dataDelivery',
implementation: 'native',
module: 'destination',
},
},
},
Expand All @@ -79,11 +76,7 @@ export const existingTestData = [
body: {
body: {
XML: {},
FORM: {
data: [
'{"user_data":{"external_id":"c58f05b5e3cc4796f3181cf07349d306547c00b20841a175b179c6860e6a34ab","client_ip_address":"32.122.223.26","client_user_agent":"Mozilla/5.0 (iPhone; CPU iPhone OS 15_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.5 Mobile/15E148 Safari/604.1"},"event_name":"Checkout Step Viewed","event_time":1654772112,"event_source_url":"https://www.my.kaiser.com/checkout","event_id":"4f002656-a7b2-4c17-b9bd-8caa5a29190a","custom_data":{"checkout_id":"26SF29B","site":"www.my.kaiser.com","step":1}}',
],
},
FORM: testFormData,
JSON: {},
JSON_ARRAY: {},
},
Expand Down Expand Up @@ -128,11 +121,7 @@ export const existingTestData = [
body: {
body: {
XML: {},
FORM: {
data: [
'{"user_data":{"external_id":"c58f05b5e3cc4796f3181cf07349d306547c00b20841a175b179c6860e6a34ab","client_ip_address":"32.122.223.26","client_user_agent":"Mozilla/5.0 (iPhone; CPU iPhone OS 15_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.5 Mobile/15E148 Safari/604.1"},"event_name":"Checkout Step Viewed","event_time":1654772112,"event_source_url":"https://www.my.kaiser.com/checkout","event_id":"4f002656-a7b2-4c17-b9bd-8caa5a29190a","custom_data":{"checkout_id":"26SF29B","site":"www.my.kaiser.com","step":1}}',
],
},
FORM: testFormData,
JSON: {},
JSON_ARRAY: {},
},
Expand Down Expand Up @@ -171,16 +160,7 @@ export const existingTestData = [
},
status: 400,
},
statTags: {
destType: 'FACEBOOK_PIXEL',
errorCategory: 'network',
destinationId: 'Non-determininable',
workspaceId: 'Non-determininable',
errorType: 'aborted',
feature: 'dataDelivery',
implementation: 'native',
module: 'destination',
},
statTags,
},
},
},
Expand All @@ -197,11 +177,7 @@ export const existingTestData = [
body: {
body: {
XML: {},
FORM: {
data: [
'{"user_data":{"external_id":"c58f05b5e3cc4796f3181cf07349d306547c00b20841a175b179c6860e6a34ab","client_ip_address":"32.122.223.26","client_user_agent":"Mozilla/5.0 (iPhone; CPU iPhone OS 15_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.5 Mobile/15E148 Safari/604.1"},"event_name":"Checkout Step Viewed","event_time":1654772112,"event_source_url":"https://www.my.kaiser.com/checkout","event_id":"4f002656-a7b2-4c17-b9bd-8caa5a29190a","custom_data":{"checkout_id":"26SF29B","site":"www.my.kaiser.com","step":1}}',
],
},
FORM: testFormData,
JSON: {},
JSON_ARRAY: {},
},
Expand Down Expand Up @@ -236,14 +212,8 @@ export const existingTestData = [
status: 500,
},
statTags: {
destType: 'FACEBOOK_PIXEL',
errorCategory: 'network',
destinationId: 'Non-determininable',
workspaceId: 'Non-determininable',
...statTags,
errorType: 'throttled',
feature: 'dataDelivery',
implementation: 'native',
module: 'destination',
},
},
},
Expand All @@ -261,11 +231,7 @@ export const existingTestData = [
body: {
body: {
XML: {},
FORM: {
data: [
'{"user_data":{"external_id":"c58f05b5e3cc4796f3181cf07349d306547c00b20841a175b179c6860e6a34ab","client_ip_address":"32.122.223.26","client_user_agent":"Mozilla/5.0 (iPhone; CPU iPhone OS 15_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.5 Mobile/15E148 Safari/604.1"},"event_name":"Checkout Step Viewed","event_time":1654772112,"event_source_url":"https://www.my.kaiser.com/checkout","event_id":"4f002656-a7b2-4c17-b9bd-8caa5a29190a","custom_data":{"checkout_id":"26SF29B","site":"www.my.kaiser.com","step":1}}',
],
},
FORM: testFormData,
JSON: {},
JSON_ARRAY: {},
},
Expand Down Expand Up @@ -302,16 +268,7 @@ export const existingTestData = [
},
status: 400,
},
statTags: {
destType: 'FACEBOOK_PIXEL',
errorCategory: 'network',
destinationId: 'Non-determininable',
workspaceId: 'Non-determininable',
errorType: 'aborted',
feature: 'dataDelivery',
implementation: 'native',
module: 'destination',
},
statTags,
},
},
},
Expand All @@ -328,11 +285,7 @@ export const existingTestData = [
body: {
body: {
XML: {},
FORM: {
data: [
'{"user_data":{"external_id":"d58f05b5e3cc4796f3181cf07349d306547c00b20841a175b179c6860e6a34ab","client_ip_address":"32.122.223.26","client_user_agent":"Mozilla/5.0 (iPhone; CPU iPhone OS 15_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.5 Mobile/15E148 Safari/604.1"},"event_name":"Checkout Step Viewed","event_time":1654772112,"event_source_url":"https://www.my.kaiser.com/checkout","event_id":"4f002656-a7b2-4c17-b9bd-8caa5a29190a","custom_data":{"checkout_id":"26SF29B","site":"www.my.kaiser.com","step":1}}',
],
},
FORM: testFormData,
JSON: {},
JSON_ARRAY: {},
},
Expand Down Expand Up @@ -367,16 +320,7 @@ export const existingTestData = [
},
status: 404,
},
statTags: {
destType: 'FACEBOOK_PIXEL',
errorCategory: 'network',
destinationId: 'Non-determininable',
workspaceId: 'Non-determininable',
errorType: 'aborted',
feature: 'dataDelivery',
implementation: 'native',
module: 'destination',
},
statTags,
},
},
},
Expand All @@ -393,11 +337,7 @@ export const existingTestData = [
body: {
body: {
XML: {},
FORM: {
data: [
'{"user_data":{"external_id":"c58f05b5e3cc4796f3181cf07349d306547c00b20841a175b179c6860e6a34ab","client_ip_address":"32.122.223.26","client_user_agent":"Mozilla/5.0 (iPhone; CPU iPhone OS 15_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.5 Mobile/15E148 Safari/604.1"},"event_name":"Checkout Step Viewed","event_time":1654772112,"event_source_url":"https://www.my.kaiser.com/checkout","event_id":"4f002656-a7b2-4c17-b9bd-8caa5a29190a","custom_data":{"checkout_id":"26SF29B","site":"www.my.kaiser.com","step":1}}',
],
},
FORM: testFormData,
JSON: {},
JSON_ARRAY: {},
},
Expand Down Expand Up @@ -432,16 +372,7 @@ export const existingTestData = [
},
status: 400,
},
statTags: {
destType: 'FACEBOOK_PIXEL',
errorCategory: 'network',
destinationId: 'Non-determininable',
workspaceId: 'Non-determininable',
errorType: 'aborted',
feature: 'dataDelivery',
implementation: 'native',
module: 'destination',
},
statTags,
},
},
},
Expand All @@ -458,11 +389,7 @@ export const existingTestData = [
body: {
body: {
XML: {},
FORM: {
data: [
'{"user_data":{"external_id":"c58f05b5e3cc4796f3181cf07349d306547c00b20841a175b179c6860e6a34ab","client_ip_address":"32.122.223.26","client_user_agent":"Mozilla/5.0 (iPhone; CPU iPhone OS 15_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.5 Mobile/15E148 Safari/604.1"},"event_name":"Checkout Step Viewed","event_time":1654772112,"event_source_url":"https://www.my.kaiser.com/checkout","event_id":"4f002656-a7b2-4c17-b9bd-8caa5a29190a","custom_data":{"checkout_id":"26SF29B","site":"www.my.kaiser.com","step":1}}',
],
},
FORM: testFormData,
JSON: {},
JSON_ARRAY: {},
},
Expand Down Expand Up @@ -497,16 +424,7 @@ export const existingTestData = [
},
status: 500,
},
statTags: {
destType: 'FACEBOOK_PIXEL',
errorCategory: 'network',
destinationId: 'Non-determininable',
workspaceId: 'Non-determininable',
errorType: 'aborted',
feature: 'dataDelivery',
implementation: 'native',
module: 'destination',
},
statTags,
},
},
},
Expand All @@ -523,11 +441,7 @@ export const existingTestData = [
body: {
body: {
XML: {},
FORM: {
data: [
'{"user_data":{"external_id":"c58f05b5e3cc4796f3181cf07349d306547c00b20841a175b179c6860e6a34ab","client_ip_address":"32.122.223.26","client_user_agent":"Mozilla/5.0 (iPhone; CPU iPhone OS 15_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.5 Mobile/15E148 Safari/604.1"},"event_name":"Checkout Step Viewed","event_time":1654772112,"event_source_url":"https://www.my.kaiser.com/checkout","event_id":"4f002656-a7b2-4c17-b9bd-8caa5a29190a","custom_data":{"checkout_id":"26SF29B","site":"www.my.kaiser.com","step":1}}',
],
},
FORM: testFormData,
JSON: {},
JSON_ARRAY: {},
},
Expand Down Expand Up @@ -563,14 +477,8 @@ export const existingTestData = [
status: 412,
},
statTags: {
destType: 'FACEBOOK_PIXEL',
errorCategory: 'network',
destinationId: 'Non-determininable',
workspaceId: 'Non-determininable',
...statTags,
errorType: 'retryable',
feature: 'dataDelivery',
implementation: 'native',
module: 'destination',
meta: 'unhandledStatusCode',
},
},
Expand All @@ -580,4 +488,4 @@ export const existingTestData = [
},
];

export const data = [...existingTestData, ...testScenariosForV1API, ...otherScenariosV1];
export const data = [...v0TestData, ...testScenariosForV1API, ...otherScenariosV1];
Loading

0 comments on commit 05ade78

Please sign in to comment.