Skip to content

Commit

Permalink
chore: code review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mihir-4116 committed Mar 15, 2024
1 parent 55542c0 commit d966bd3
Show file tree
Hide file tree
Showing 4 changed files with 388 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ const responseHandler = (responseParams) => {
// Ref - https://github.com/googleapis/googleapis/blob/master/google/rpc/code.proto
if (partialFailureError && partialFailureError.code !== 0) {
throw new NetworkError(
`[Google Ads Offline Conversions]:: partialFailureError - ${JSON.stringify(
`[Google Adwords Enhanced Conversions]:: partialFailureError - ${JSON.stringify(
partialFailureError,
)}`,
400,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,17 @@ const commonRequestParameters = {
JSON: validRequestPaylod,
};

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

export const testScenariosForV0API = [
{
id: 'gaec_v0_scenario_1',
Expand Down Expand Up @@ -108,6 +119,72 @@ export const testScenariosForV0API = [
},
},
},
{
id: 'gaec_v0_scenario_2',
name: 'google_adwords_enhanced_conversions',
description:
'[Proxy v0 API] :: Test for a partial failure request with a 200 response from the destination',
successCriteria: 'Should return 400 with partial failure error',
scenario: 'Business',
feature: 'dataDelivery',
module: 'destination',
version: 'v0',
input: {
request: {
body: generateProxyV0Payload({
...commonRequestParameters,
params: {
event: 'Product Added',
customerId: '1234567888',
destination: 'google_adwords_enhanced_conversions',
},
endpoint:
'https://googleads.googleapis.com/v15/customers/1234567888:uploadConversionAdjustments',
}),
method: 'POST',
},
},
output: {
response: {
status: 400,
body: {
output: {
destinationResponse: {
code: 3,
details: [
{
'@type': 'type.googleapis.com/google.ads.googleads.v15.errors.GoogleAdsFailure',
errors: [
{
errorCode: {
conversionAdjustmentUploadError: 'CONVERSION_ALREADY_ENHANCED',
},
location: {
fieldPathElements: [
{
fieldName: 'conversion_adjustments',
index: 0,
},
],
},
message:
'Conversion already has enhancements with the same Order ID and conversion action. Make sure your data is correctly configured and try again.',
},
],
},
],
message:
'Conversion already has enhancements with the same Order ID and conversion action. Make sure your data is correctly configured and try again., at conversion_adjustments[0]',
},
message:
'[Google Adwords Enhanced Conversions]:: partialFailureError - {"code":3,"message":"Conversion already has enhancements with the same Order ID and conversion action. Make sure your data is correctly configured and try again., at conversion_adjustments[0]","details":[{"@type":"type.googleapis.com/google.ads.googleads.v15.errors.GoogleAdsFailure","errors":[{"errorCode":{"conversionAdjustmentUploadError":"CONVERSION_ALREADY_ENHANCED"},"message":"Conversion already has enhancements with the same Order ID and conversion action. Make sure your data is correctly configured and try again.","location":{"fieldPathElements":[{"fieldName":"conversion_adjustments","index":0}]}}]}]}',
statTags: expectedStatTags,
status: 400,
},
},
},
},
},
];

export const testScenariosForV1API: ProxyV1TestData[] = [
Expand Down Expand Up @@ -154,4 +231,54 @@ export const testScenariosForV1API: ProxyV1TestData[] = [
},
},
},
{
id: 'gaec_v1_scenario_2',
name: 'google_adwords_enhanced_conversions',
description:
'[Proxy v1 API] :: Test for a partial failure request with a 200 response from the destination',
successCriteria: 'Should return 400 with partial failure error',
scenario: 'Business',
feature: 'dataDelivery',
module: 'destination',
version: 'v1',
input: {
request: {
body: generateProxyV1Payload(
{
...commonRequestParameters,
params: {
event: 'Product Added',
customerId: '1234567888',
destination: 'google_adwords_enhanced_conversions',
},
endpoint:
'https://googleads.googleapis.com/v15/customers/1234567888:uploadConversionAdjustments',
},
[generateMetadata(1)],
),
method: 'POST',
},
},
output: {
response: {
status: 200,
body: {
output: {
message:
'[Google Adwords Enhanced Conversions]:: partialFailureError - {"code":3,"message":"Conversion already has enhancements with the same Order ID and conversion action. Make sure your data is correctly configured and try again., at conversion_adjustments[0]","details":[{"@type":"type.googleapis.com/google.ads.googleads.v15.errors.GoogleAdsFailure","errors":[{"errorCode":{"conversionAdjustmentUploadError":"CONVERSION_ALREADY_ENHANCED"},"message":"Conversion already has enhancements with the same Order ID and conversion action. Make sure your data is correctly configured and try again.","location":{"fieldPathElements":[{"fieldName":"conversion_adjustments","index":0}]}}]}]}',
response: [
{
error:
'[Google Adwords Enhanced Conversions]:: partialFailureError - {"code":3,"message":"Conversion already has enhancements with the same Order ID and conversion action. Make sure your data is correctly configured and try again., at conversion_adjustments[0]","details":[{"@type":"type.googleapis.com/google.ads.googleads.v15.errors.GoogleAdsFailure","errors":[{"errorCode":{"conversionAdjustmentUploadError":"CONVERSION_ALREADY_ENHANCED"},"message":"Conversion already has enhancements with the same Order ID and conversion action. Make sure your data is correctly configured and try again.","location":{"fieldPathElements":[{"fieldName":"conversion_adjustments","index":0}]}}]}]}',
metadata: generateMetadata(1),
statusCode: 400,
},
],
statTags: expectedStatTags,
status: 400,
},
},
},
},
}
];
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { ProxyV1TestData } from '../../../testTypes';
import { generateProxyV1Payload, generateProxyV0Payload, generateMetadata } from '../../../testUtils';
import {
generateProxyV1Payload,
generateProxyV0Payload,
generateMetadata,
} from '../../../testUtils';

const requestPayload = {
partialFailure: true,
Expand Down Expand Up @@ -39,6 +43,7 @@ const headers = {
'developer-token': 'ijkl91011',
'login-customer-id': '0987654321',
};

const params = {
event: 'Product Added',
customerId: '1234567890',
Expand Down Expand Up @@ -109,6 +114,66 @@ export const v0oauthScenarios = [
},
},
},
{
id: 'gaec_v0_oauth_scenario_2',
name: 'google_adwords_enhanced_conversions',
description:
'[Proxy v0 API] :: Oauth where caller does not have permission mock response from destination',
successCriteria:
'Since the error from the destination is 403 - the proxy should return 403 with error',
scenario: 'Oauth',
feature: 'dataDelivery',
module: 'destination',
version: 'v0',
input: {
request: {
body: generateProxyV0Payload({
JSON: {
query: `SELECT conversion_action.id FROM conversion_action WHERE conversion_action.name = 'Product Added'`,
},
headers,
params: {
event: 'Product Added',
customerId: '1234567910',
destination: 'google_adwords_enhanced_conversions',
},
endpoint:
'https://googleads.googleapis.com/v15/customers/1234567910/googleAds:searchStream',
}),
method: 'POST',
},
},
output: {
response: {
status: 403,
body: {
output: {
authErrorCategory: 'AUTH_STATUS_INACTIVE',
destinationResponse: [
{
error: {
code: 403,
errors: [
{
domain: 'global',
message: 'The caller does not have permission',
reason: 'forbidden',
},
],
message: 'The caller does not have permission',
status: 'PERMISSION_DENIED',
},
},
],
message:
'""The caller does not have permission" during Google_adwords_enhanced_conversions response transformation"',
statTags: expectedStatTags,
status: 403,
},
},
},
},
},
];

export const v1oauthScenarios = [
Expand Down Expand Up @@ -156,4 +221,56 @@ export const v1oauthScenarios = [
},
},
},
{
id: 'gaec_v1_oauth_scenario_2',
name: 'google_adwords_enhanced_conversions',
description:
'[Proxy v1 API] :: Oauth where caller does not have permission mock response from destination',
successCriteria:
'Since the error from the destination is 403 - the proxy should return 403 with error',
scenario: 'Oauth',
feature: 'dataDelivery',
module: 'destination',
version: 'v1',
input: {
request: {
body: generateProxyV1Payload({
JSON: {
query: `SELECT conversion_action.id FROM conversion_action WHERE conversion_action.name = 'Product Added'`,
},
headers,
params: {
event: 'Product Added',
customerId: '1234567910',
destination: 'google_adwords_enhanced_conversions',
},
endpoint:
'https://googleads.googleapis.com/v15/customers/1234567910/googleAds:searchStream',
}),
method: 'POST',
},
},
output: {
response: {
status: 403,
body: {
output: {
authErrorCategory: 'AUTH_STATUS_INACTIVE',
message:
'""The caller does not have permission" during Google_adwords_enhanced_conversions response transformation"',
response: [
{
error:
'""The caller does not have permission" during Google_adwords_enhanced_conversions response transformation"',
metadata: generateMetadata(1),
statusCode: 403,
},
],
statTags: expectedStatTags,
status: 403,
},
},
},
},
},
];
Loading

0 comments on commit d966bd3

Please sign in to comment.