diff --git a/test/integrations/destinations/snapchat_custom_audience/dataDelivery/business.ts b/test/integrations/destinations/snapchat_custom_audience/dataDelivery/business.ts index a7ba2d4869..4ee646bedb 100644 --- a/test/integrations/destinations/snapchat_custom_audience/dataDelivery/business.ts +++ b/test/integrations/destinations/snapchat_custom_audience/dataDelivery/business.ts @@ -1,5 +1,6 @@ import { ProxyV1TestData } from '../../../testTypes'; import { + generateMetadata, generateProxyV0Payload, generateProxyV1Payload, } from '../../../testUtils'; @@ -22,7 +23,7 @@ const commonRequestParameters = { }, }; -export const businessTestScenarios = [ +export const businessV0TestScenarios = [ { id: 'snapchat_custom_audience_v0_oauth_scenario_1', name: 'snapchat_custom_audience', @@ -71,8 +72,11 @@ export const businessTestScenarios = [ }, }, }, +]; + +export const businessV1TestScenarios: ProxyV1TestData[] = [ { - id: 'snapchat_custom_audience_v0_oauth_scenario_1', + id: 'snapchat_custom_audience_v1_oauth_scenario_1', name: 'snapchat_custom_audience', description: '[Proxy v1 API] :: successfull oauth', successCriteria: 'Proper response from destination is received', @@ -103,18 +107,7 @@ export const businessTestScenarios = [ { error: `{\"request_status\":\"SUCCESS\",\"request_id\":\"12345\",\"users\":[{\"sub_request_status\":\"SUCCESS\",\"user\":{\"number_uploaded_users\":1}}]}`, statusCode: 200, - metadata: { - jobId: 1, - attemptNum: 1, - userId: 'default-userId', - destinationId: 'default-destinationId', - workspaceId: 'default-workspaceId', - sourceId: 'default-sourceId', - secret: { - accessToken: 'default-accessToken', - }, - dontBatch: false, - }, + metadata: generateMetadata(1), }, ], }, diff --git a/test/integrations/destinations/snapchat_custom_audience/dataDelivery/data.ts b/test/integrations/destinations/snapchat_custom_audience/dataDelivery/data.ts index c5a50eac1a..4991ed1d38 100644 --- a/test/integrations/destinations/snapchat_custom_audience/dataDelivery/data.ts +++ b/test/integrations/destinations/snapchat_custom_audience/dataDelivery/data.ts @@ -1,4 +1,11 @@ -import { businessTestScenarios } from './business'; +import { businessV0TestScenarios, businessV1TestScenarios } from './business'; import { v0OauthScenarios, v1OauthScenarios } from './oauth'; +import { otherScenariosV1 } from './other'; -export const data = [ ...v0OauthScenarios, ...v1OauthScenarios, ...businessTestScenarios]; \ No newline at end of file +export const data = [ + ...v0OauthScenarios, + ...v1OauthScenarios, + ...businessV0TestScenarios, + ...businessV1TestScenarios, + ...otherScenariosV1, +]; diff --git a/test/integrations/destinations/snapchat_custom_audience/dataDelivery/oauth.ts b/test/integrations/destinations/snapchat_custom_audience/dataDelivery/oauth.ts index 6ace1ca9b0..e4bf5d4588 100644 --- a/test/integrations/destinations/snapchat_custom_audience/dataDelivery/oauth.ts +++ b/test/integrations/destinations/snapchat_custom_audience/dataDelivery/oauth.ts @@ -1,5 +1,9 @@ import { ProxyV1TestData } from '../../../testTypes'; -import { generateProxyV1Payload, generateProxyV0Payload } from '../../../testUtils'; +import { + generateMetadata, + generateProxyV0Payload, + generateProxyV1Payload, +} from '../../../testUtils'; const commonHeaders = { Authorization: 'Bearer abcd123', @@ -32,6 +36,28 @@ const commonDeleteRequestParameters = { }, }; +const retryStatTags = { + destType: 'SNAPCHAT_CUSTOM_AUDIENCE', + errorCategory: 'network', + destinationId: 'default-destinationId', + workspaceId: 'default-workspaceId', + errorType: 'retryable', + feature: 'dataDelivery', + implementation: 'native', + module: 'destination', +}; + +const abortStatTags = { + destType: 'SNAPCHAT_CUSTOM_AUDIENCE', + errorCategory: 'network', + destinationId: 'default-destinationId', + workspaceId: 'default-workspaceId', + errorType: 'aborted', + feature: 'dataDelivery', + implementation: 'native', + module: 'destination', +}; + export const v0OauthScenarios = [ { id: 'snapchat_custom_audience_v0_oauth_scenario_2', @@ -68,16 +94,7 @@ export const v0OauthScenarios = [ }, message: 'Failed with unauthorized during snapchat_custom_audience response transformation', - statTags: { - destType: 'SNAPCHAT_CUSTOM_AUDIENCE', - errorCategory: 'network', - destinationId: 'default-destinationId', - workspaceId: 'default-workspaceId', - errorType: 'retryable', - feature: 'dataDelivery', - implementation: 'native', - module: 'destination', - }, + statTags: retryStatTags, authErrorCategory: 'REFRESH_TOKEN', }, }, @@ -126,16 +143,7 @@ export const v0OauthScenarios = [ status: 403, }, message: 'undefined during snapchat_custom_audience response transformation', - statTags: { - destType: 'SNAPCHAT_CUSTOM_AUDIENCE', - errorCategory: 'network', - destinationId: 'default-destinationId', - workspaceId: 'default-workspaceId', - errorType: 'aborted', - feature: 'dataDelivery', - implementation: 'native', - module: 'destination', - }, + statTags: abortStatTags, }, }, }, @@ -176,30 +184,10 @@ export const v1OauthScenarios: ProxyV1TestData[] = [ { error: '"unauthorized"', statusCode: 500, - metadata: { - jobId: 1, - attemptNum: 1, - userId: 'default-userId', - destinationId: 'default-destinationId', - workspaceId: 'default-workspaceId', - sourceId: 'default-sourceId', - secret: { - accessToken: 'default-accessToken', - }, - dontBatch: false, - }, + metadata: generateMetadata(1), }, ], - statTags: { - errorCategory: 'network', - errorType: 'retryable', - destType: 'SNAPCHAT_CUSTOM_AUDIENCE', - module: 'destination', - implementation: 'native', - feature: 'dataDelivery', - destinationId: 'default-destinationId', - workspaceId: 'default-workspaceId', - }, + statTags: retryStatTags, authErrorCategory: 'REFRESH_TOKEN', message: 'Failed with unauthorized during snapchat_custom_audience response transformation', @@ -241,30 +229,10 @@ export const v1OauthScenarios: ProxyV1TestData[] = [ { error: `{"request_status":"ERROR","request_id":"98e2a602-3cf4-4596-a8f9-7f034161f89a","debug_message":"Caller does not have permission","display_message":"We're sorry, but the requested resource is not available at this time","error_code":"E3002"}`, statusCode: 400, - metadata: { - jobId: 1, - attemptNum: 1, - userId: 'default-userId', - destinationId: 'default-destinationId', - workspaceId: 'default-workspaceId', - sourceId: 'default-sourceId', - secret: { - accessToken: 'default-accessToken', - }, - dontBatch: false, - }, + metadata: generateMetadata(1), }, ], - statTags: { - errorCategory: 'network', - errorType: 'aborted', - destType: 'SNAPCHAT_CUSTOM_AUDIENCE', - module: 'destination', - implementation: 'native', - feature: 'dataDelivery', - destinationId: 'default-destinationId', - workspaceId: 'default-workspaceId', - }, + statTags: abortStatTags, message: 'undefined during snapchat_custom_audience response transformation', status: 400, authErrorCategory: 'AUTH_STATUS_INACTIVE', diff --git a/test/integrations/destinations/snapchat_custom_audience/dataDelivery/other.ts b/test/integrations/destinations/snapchat_custom_audience/dataDelivery/other.ts new file mode 100644 index 0000000000..90508c2481 --- /dev/null +++ b/test/integrations/destinations/snapchat_custom_audience/dataDelivery/other.ts @@ -0,0 +1,204 @@ +import { ProxyV1TestData } from '../../../testTypes'; +import { generateMetadata, generateProxyV1Payload } from '../../../testUtils'; + +const expectedStatTags = { + destType: 'SNAPCHAT_CUSTOM_AUDIENCE', + errorCategory: 'network', + destinationId: 'default-destinationId', + workspaceId: 'default-workspaceId', + errorType: 'retryable', + feature: 'dataDelivery', + implementation: 'native', + module: 'destination', +}; + +export const otherScenariosV1: ProxyV1TestData[] = [ + { + id: 'snapchat_custom_audience_v1_other_scenario_1', + name: 'snapchat_custom_audience', + description: + '[Proxy v1 API] :: Scenario for testing Service Unavailable error from destination', + successCriteria: 'Should return 500 status code with error message', + scenario: 'Framework', + feature: 'dataDelivery', + module: 'destination', + version: 'v1', + input: { + request: { + body: generateProxyV1Payload({ + endpoint: 'https://random_test_url/test_for_service_not_available', + }), + method: 'POST', + }, + }, + output: { + response: { + status: 200, + body: { + output: { + response: [ + { + error: + '{"error":{"message":"Service Unavailable","description":"The server is currently unable to handle the request due to temporary overloading or maintenance of the server. Please try again later."}}', + statusCode: 503, + metadata: generateMetadata(1), + }, + ], + statTags: expectedStatTags, + status: 503, + message: 'Service Unavailable during snapchat_custom_audience response transformation', + }, + }, + }, + }, + }, + { + id: 'snapchat_custom_audience_v1_other_scenario_2', + name: 'snapchat_custom_audience', + description: '[Proxy v1 API] :: Scenario for testing Internal Server error from destination', + successCriteria: 'Should return 500 status code with error message', + scenario: 'Framework', + feature: 'dataDelivery', + module: 'destination', + version: 'v1', + input: { + request: { + body: generateProxyV1Payload({ + endpoint: 'https://random_test_url/test_for_internal_server_error', + }), + method: 'POST', + }, + }, + output: { + response: { + status: 200, + body: { + output: { + response: [ + { + error: '"Internal Server Error"', + statusCode: 500, + metadata: generateMetadata(1), + }, + ], + statTags: expectedStatTags, + status: 500, + message: 'undefined during snapchat_custom_audience response transformation', + }, + }, + }, + }, + }, + { + id: 'snapchat_custom_audience_v1_other_scenario_3', + name: 'snapchat_custom_audience', + description: '[Proxy v1 API] :: Scenario for testing Gateway Time Out error from destination', + successCriteria: 'Should return 504 status code with error message', + scenario: 'Framework', + feature: 'dataDelivery', + module: 'destination', + version: 'v1', + input: { + request: { + body: generateProxyV1Payload({ + endpoint: 'https://random_test_url/test_for_gateway_time_out', + }), + method: 'POST', + }, + }, + output: { + response: { + status: 200, + body: { + output: { + response: [ + { + error: '"Gateway Timeout"', + statusCode: 504, + metadata: generateMetadata(1), + }, + ], + statTags: expectedStatTags, + status: 504, + message: 'undefined during snapchat_custom_audience response transformation', + }, + }, + }, + }, + }, + { + id: 'snapchat_custom_audience_v1_other_scenario_4', + name: 'snapchat_custom_audience', + description: '[Proxy v1 API] :: Scenario for testing null response from destination', + successCriteria: 'Should return 500 status code with error message', + scenario: 'Framework', + feature: 'dataDelivery', + module: 'destination', + version: 'v1', + input: { + request: { + body: generateProxyV1Payload({ + endpoint: 'https://random_test_url/test_for_null_response', + }), + method: 'POST', + }, + }, + output: { + response: { + status: 200, + body: { + output: { + response: [ + { + error: '""', + statusCode: 500, + metadata: generateMetadata(1), + }, + ], + statTags: expectedStatTags, + status: 500, + message: 'undefined during snapchat_custom_audience response transformation', + }, + }, + }, + }, + }, + { + id: 'snapchat_custom_audience_v1_other_scenario_5', + name: 'snapchat_custom_audience', + description: + '[Proxy v1 API] :: Scenario for testing null and no status response from destination', + successCriteria: 'Should return 500 status code with error message', + scenario: 'Framework', + feature: 'dataDelivery', + module: 'destination', + version: 'v1', + input: { + request: { + body: generateProxyV1Payload({ + endpoint: 'https://random_test_url/test_for_null_and_no_status', + }), + method: 'POST', + }, + }, + output: { + response: { + status: 200, + body: { + output: { + response: [ + { + error: '""', + statusCode: 500, + metadata: generateMetadata(1), + }, + ], + statTags: expectedStatTags, + status: 500, + message: 'undefined during snapchat_custom_audience response transformation', + }, + }, + }, + }, + }, +];