-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: reddit proxy test refactor (#3096)
* feat: update proxy data type for response handler input * feat: update proxy v1 test cases * feat: update proxy tests for cm360 Added new structure for proxy test scnearios for cm360 also added zod validations as part of tests * fix: typo * Update test/integrations/destinations/campaign_manager/dataDelivery/business.ts Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update test/integrations/destinations/campaign_manager/dataDelivery/business.ts Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * fix: api contract for v1 proxy * chore: clean up zod type * chore: update testutils * chore: update V0 proxy request type and zod schema * feat: adding zod validations (#3066) * feat: add type definitions for test cases * fix: update networkHandler for rakuten --------- Co-authored-by: Utsab Chowdhury <[email protected]> * chore: update delivery test cases for criteo audience * Revert "chore: update delivery test cases for criteo audience" This reverts commit 689b0cd. * chore: add type def for proxy v1 test * chore: fix generateMetdata func * chore: criteo audience update proxy test (#3068) * chore: update delivery test cases for criteo audience * chore: enable batch response schema check (#3083) * chore: reddit proxy test refactor * chore: code review changes --------- Co-authored-by: Utsab Chowdhury <[email protected]> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Utsab Chowdhury <[email protected]> Co-authored-by: ItsSudip <[email protected]> Co-authored-by: Sudip Paul <[email protected]> Co-authored-by: chandumlg <[email protected]>
- Loading branch information
1 parent
7532c90
commit feb256b
Showing
4 changed files
with
287 additions
and
174 deletions.
There are no files selected for viewing
131 changes: 131 additions & 0 deletions
131
test/integrations/destinations/reddit/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,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, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
]; |
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,9 @@ | ||
import { testScenariosForV0API, testScenariosForV1API } from './business'; | ||
import { v0oauthScenarios, v1oauthScenarios } from './oauth'; | ||
|
||
export const data = [ | ||
...v0oauthScenarios, | ||
...v1oauthScenarios, | ||
...testScenariosForV0API, | ||
...testScenariosForV1API, | ||
]; |
147 changes: 147 additions & 0 deletions
147
test/integrations/destinations/reddit/dataDelivery/oauth.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,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, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
]; |
Oops, something went wrong.