-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: facebook_pixel to v1 proxy tests (#3149)
* chore: facebook_pixel to v1 proxy tests * chore: updated tests * chore: updated tests * chore: updated tests * chore: updated tests
- Loading branch information
1 parent
e93e47f
commit 3e416be
Showing
5 changed files
with
440 additions
and
126 deletions.
There are no files selected for viewing
258 changes: 258 additions & 0 deletions
258
test/integrations/destinations/facebook_pixel/dataDelivery/business.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,258 @@ | ||
import { generateMetadata, generateProxyV1Payload } from '../../../testUtils'; | ||
import { ProxyV1TestData } from '../../../testTypes'; | ||
import { VERSION } from '../../../../../src/v0/destinations/facebook_pixel/config'; | ||
|
||
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', | ||
workspaceId: 'default-workspaceId', | ||
errorType: 'aborted', | ||
feature: 'dataDelivery', | ||
implementation: 'native', | ||
module: 'destination', | ||
}; | ||
export const testScenariosForV1API: ProxyV1TestData[] = [ | ||
{ | ||
id: 'facebook_pixel_v1_scenario_1', | ||
name: 'facebook_pixel', | ||
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}/1234567891234567/events?access_token=invalid_access_token`, | ||
FORM: testFormData, | ||
}), | ||
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: 'facebook_pixel_v1_scenario_2', | ||
name: 'facebook_pixel', | ||
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}/1234567891234567/events?access_token=my_access_token`, | ||
params: { | ||
destination: 'facebook_pixel', | ||
}, | ||
FORM: testFormData, | ||
}), | ||
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: 'facebook_pixel_v1_scenario_3', | ||
name: 'facebook_pixel', | ||
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`, | ||
FORM: testFormData, | ||
}), | ||
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: 'facebook_pixel_v1_scenario_4', | ||
name: 'facebook_pixel', | ||
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`, | ||
FORM: testFormData, | ||
}), | ||
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), | ||
}, | ||
], | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
{ | ||
id: 'facebook_pixel_v1_scenario_5', | ||
name: 'facebook_pixel', | ||
description: 'app event fails due to invalid parameter', | ||
successCriteria: 'Should return 400 with Invalid parameter error', | ||
scenario: 'Business', | ||
feature: 'dataDelivery', | ||
module: 'destination', | ||
version: 'v1', | ||
input: { | ||
request: { | ||
body: generateProxyV1Payload({ | ||
endpoint: `https://graph.facebook.com/${VERSION}/1234567891234567/events?access_token=not_found_access_token`, | ||
FORM: testFormData, | ||
}), | ||
method: 'POST', | ||
}, | ||
}, | ||
output: { | ||
response: { | ||
status: 200, | ||
body: { | ||
output: { | ||
status: 400, | ||
message: 'Invalid Parameter', | ||
statTags, | ||
response: [ | ||
{ | ||
error: 'Invalid Parameter', | ||
statusCode: 400, | ||
metadata: generateMetadata(1), | ||
}, | ||
], | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
{ | ||
id: 'facebook_pixel_v1_scenario_6', | ||
name: 'facebook_pixel', | ||
description: 'app event fails due to invalid parameter', | ||
successCriteria: 'Should return 400 with Invalid parameter error', | ||
scenario: 'Business', | ||
feature: 'dataDelivery', | ||
module: 'destination', | ||
version: 'v1', | ||
input: { | ||
request: { | ||
body: generateProxyV1Payload({ | ||
endpoint: `https://graph.facebook.com/${VERSION}/1234567891234570/events?access_token=valid_access_token`, | ||
FORM: testFormData, | ||
}), | ||
method: 'POST', | ||
}, | ||
}, | ||
output: { | ||
response: { | ||
status: 200, | ||
body: { | ||
output: { | ||
status: 400, | ||
message: 'Invalid Parameter', | ||
statTags, | ||
response: [ | ||
{ | ||
error: 'Invalid Parameter', | ||
statusCode: 400, | ||
metadata: generateMetadata(1), | ||
}, | ||
], | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
]; |
Oops, something went wrong.