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 1de83e9 + feb256b commit f6af85e
Show file tree
Hide file tree
Showing 4 changed files with 287 additions and 174 deletions.
131 changes: 131 additions & 0 deletions test/integrations/destinations/reddit/dataDelivery/business.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
import {
generateMetadata,
generateProxyV0Payload,
generateProxyV1Payload,
} from '../../../testUtils';

const validRequestPayload = {
events: [
{
event_at: '2019-10-14T09:03:17.562Z',
event_type: {
tracking_type: 'Purchase',
},
user: {
aaid: 'c12d34889302d3c656b5699fa9190b51c50d6f62fce57e13bd56b503d66c487a',
email: 'ac144532d9e4efeab19475d9253a879173ea12a3d2238d1cb8a332a7b3a105f2',
external_id: '7b023241a3132b792a5a33915a5afb3133cbb1e13d72879689bf6504de3b036d',
ip_address: 'e80bd55a3834b7c2a34ade23c7ecb54d2a49838227080f50716151e765a619db',
user_agent:
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36',
screen_dimensions: {},
},
event_metadata: {
item_count: 3,
products: [
{
id: '123',
name: 'Monopoly',
category: 'Games',
},
{
id: '345',
name: 'UNO',
category: 'Games',
},
],
},
},
],
};

const commonHeaders = {
Authorization: 'Bearer dummyAccessToken',
'Content-Type': 'application/json',
};

const commonRequestParameters = {
headers: commonHeaders,
JSON: validRequestPayload,
};

export const testScenariosForV0API = [
{
id: 'reddit_v0_scenario_1',
name: 'reddit',
description:
'[Proxy v0 API] :: Test for a valid request with a successful 200 response from the destination',
scenario: 'Business',
feature: 'dataDelivery',
module: 'destination',
version: 'v0',
input: {
request: {
body: generateProxyV0Payload({
...commonRequestParameters,
endpoint: 'https://ads-api.reddit.com/api/v2.0/conversions/events/a2_fsddXXXfsfd',
}),
method: 'POST',
},
},
output: {
response: {
status: 200,
body: {
output: {
destResp: {
response: {
message: 'Successfully processed 1 conversion events.',
},
status: 200,
},
message: 'Request Processed Successfully',
status: 200,
},
},
},
},
},
];

export const testScenariosForV1API = [
{
id: 'reddit_v1_scenario_1',
name: 'reddit',
description:
'[Proxy v1 API] :: Test for a valid request with a successful 200 response from the destination',
scenario: 'Business',
feature: 'dataDelivery',
module: 'destination',
version: 'v1',
input: {
request: {
body: generateProxyV1Payload(
{
...commonRequestParameters,
endpoint: 'https://dfareporting.googleapis.com/test_url_for_valid_request',
},
[generateMetadata(1)],
),
method: 'POST',
},
},
output: {
response: {
status: 200,
body: {
output: {
message: 'Request Processed Successfully',
response: [
{
metadata: generateMetadata(1),
statusCode: 500,
},
],
status: 500,
},
},
},
},
},
];
9 changes: 9 additions & 0 deletions test/integrations/destinations/reddit/dataDelivery/data.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { testScenariosForV0API, testScenariosForV1API } from './business';
import { v0oauthScenarios, v1oauthScenarios } from './oauth';

export const data = [
...v0oauthScenarios,
...v1oauthScenarios,
...testScenariosForV0API,
...testScenariosForV1API,
];
147 changes: 147 additions & 0 deletions test/integrations/destinations/reddit/dataDelivery/oauth.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
import {
generateMetadata,
generateProxyV1Payload,
generateProxyV0Payload,
} from '../../../testUtils';

const authorizationRequiredRequestPayload = {
events: [
{
event_at: '2019-10-14T09:03:17.562Z',
event_type: {
tracking_type: 'ViewContent',
},
user: {
aaid: 'c12d34889302d3c656b5699fa9190b51c50d6f62fce57e13bd56b503d66c487a',
email: 'ac144532d9e4efeab19475d9253a879173ea12a3d2238d1cb8a332a7b3a105f2',
external_id: '7b023241a3132b792a5a33915a5afb3133cbb1e13d72879689bf6504de3b036d',
ip_address: 'e80bd55a3834b7c2a34ade23c7ecb54d2a49838227080f50716151e765a619db',
user_agent:
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36',
screen_dimensions: {},
},
event_metadata: {
item_count: 3,
products: [
{
id: '123',
name: 'Monopoly',
category: 'Games',
},
{
id: '345',
name: 'UNO',
category: 'Games',
},
],
},
},
],
};

const commonHeaders = {
Authorization: 'Bearer dummyAccessToken',
'Content-Type': 'application/json',
};

const commonRequestParameters = {
headers: commonHeaders,
JSON: authorizationRequiredRequestPayload,
};

const expectedStatTags = {
destType: 'REDDIT',
destinationId: 'default-destinationId',
errorCategory: 'network',
errorType: 'retryable',
feature: 'dataDelivery',
implementation: 'native',
module: 'destination',
workspaceId: 'default-workspaceId',
};

export const v0oauthScenarios = [
{
id: 'reddit_v0_oauth_scenario_1',
name: 'reddit',
description: '[Proxy v0 API] :: Oauth where Authorization Required response from destination',
successCriteria: 'Should return 500 with authErrorCategory as REFRESH_TOKEN',
scenario: 'Oauth',
feature: 'dataDelivery',
module: 'destination',
version: 'v0',
input: {
request: {
body: generateProxyV0Payload({
...commonRequestParameters,
endpoint: 'https://ads-api.reddit.com/api/v2.0/conversions/events/a2_gsddXXXfsfd',
}),
method: 'POST',
},
},
output: {
response: {
status: 500,
body: {
output: {
authErrorCategory: 'REFRESH_TOKEN',
destinationResponse: {
response: 'Authorization Required',
status: 401,
},
message:
"Request failed due to Authorization Required 'during reddit response transformation'",
statTags: expectedStatTags,
status: 500,
},
},
},
},
},
];

export const v1oauthScenarios = [
{
id: 'reddit_v1_oauth_scenario_1',
name: 'reddit',
description: '[Proxy v1 API] :: Oauth where Authorization Required response from destination',
successCriteria: 'Should return 500 with authErrorCategory as REFRESH_TOKEN',
scenario: 'Oauth',
feature: 'dataDelivery',
module: 'destination',
version: 'v1',
input: {
request: {
body: generateProxyV1Payload(
{
...commonRequestParameters,
endpoint: 'https://ads-api.reddit.com/api/v2.0/conversions/events/a2_gsddXXXfsfd',
},
[generateMetadata(1)],
),
method: 'POST',
},
},
output: {
response: {
status: 500,
body: {
output: {
authErrorCategory: 'REFRESH_TOKEN',
message:
"Request failed due to Authorization Required 'during reddit response transformation'",
response: [
{
error: '"Authorization Required"',
metadata: generateMetadata(1),
statusCode: 500,
},
],
statTags: expectedStatTags,
status: 500,
},
},
},
},
},
];
Loading

0 comments on commit f6af85e

Please sign in to comment.