Skip to content

Commit

Permalink
chore: update component tests structure for snapchat custom audience
Browse files Browse the repository at this point in the history
  • Loading branch information
aashishmalik committed Feb 27, 2024
1 parent 84cb5f0 commit 795a31e
Show file tree
Hide file tree
Showing 4 changed files with 436 additions and 206 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
import { ProxyV1TestData } from '../../../testTypes';
import {
generateProxyV0Payload,
generateProxyV1Payload,
} from '../../../testUtils';

const commonHeaders = {
Authorization: 'Bearer abcd123',
'Content-Type': 'application/json',
'User-Agent': 'RudderLabs',
};

const commonRequestParameters = {
headers: commonHeaders,
JSON: {
users: [
{
schema: ['EMAIL_SHA256'],
data: [['938758751f5af66652a118e26503af824404bc13acd1cb7642ddff99916f0e1c']],
},
],
},
};

export const businessTestScenarios = [
{
id: 'snapchat_custom_audience_v0_oauth_scenario_1',
name: 'snapchat_custom_audience',
description: '[Proxy v0 API] :: successfull call',
successCriteria: 'Proper response from destination is received',
scenario: 'Oauth',
feature: 'dataDelivery',
module: 'destination',
version: 'v0',
input: {
request: {
body: generateProxyV0Payload({
...commonRequestParameters,
endpoint: 'https://adsapi.snapchat.com/v1/segments/123/users',
params: {
destination: 'snapchat_custom_audience',
},
}),
method: 'POST',
},
},
output: {
response: {
status: 200,
body: {
output: {
status: 200,
message: 'Request Processed Successfully',
destinationResponse: {
response: {
request_status: 'SUCCESS',
request_id: '12345',
users: [
{
sub_request_status: 'SUCCESS',
user: {
number_uploaded_users: 1,
},
},
],
},
status: 200,
},
},
},
},
},
},
{
id: 'snapchat_custom_audience_v0_oauth_scenario_1',
name: 'snapchat_custom_audience',
description: '[Proxy v1 API] :: successfull oauth',
successCriteria: 'Proper response from destination is received',
scenario: 'Oauth',
feature: 'dataDelivery',
module: 'destination',
version: 'v1',
input: {
request: {
body: generateProxyV1Payload({
...commonRequestParameters,
endpoint: 'https://adsapi.snapchat.com/v1/segments/123/users',
params: {
destination: 'snapchat_custom_audience',
},
}),
method: 'POST',
},
},
output: {
response: {
status: 200,
body: {
output: {
status: 200,
message: 'Request Processed Successfully',
response: [
{
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,
},
},
],
},
},
},
},
},
];
Original file line number Diff line number Diff line change
@@ -1,206 +1,4 @@
export const data = [
{
name: 'snapchat_custom_audience',
description: 'Test 0',
feature: 'dataDelivery',
module: 'destination',
version: 'v0',
input: {
request: {
body: {
version: '1',
type: 'REST',
method: 'POST',
endpoint: 'https://adsapi.snapchat.com/v1/segments/123/users',
headers: {
Authorization: 'Bearer abcd123',
'Content-Type': 'application/json',
},
body: {
JSON: {
users: [
{
schema: ['EMAIL_SHA256'],
data: [['938758751f5af66652a118e26503af824404bc13acd1cb7642ddff99916f0e1c']],
},
],
},
JSON_ARRAY: {},
XML: {},
FORM: {},
},
files: {},
params: {
destination: 'snapchat_custom_audience',
},
},
method: 'POST',
},
},
output: {
response: {
status: 200,
body: {
output: {
status: 200,
message: 'Request Processed Successfully',
destinationResponse: {
response: {
request_status: 'SUCCESS',
request_id: '12345',
users: [
{
sub_request_status: 'SUCCESS',
user: {
number_uploaded_users: 1,
},
},
],
},
status: 200,
},
},
},
},
},
},
{
name: 'snapchat_custom_audience',
description: 'Test 1',
feature: 'dataDelivery',
module: 'destination',
version: 'v0',
input: {
request: {
body: {
version: '1',
type: 'REST',
method: 'POST',
endpoint: 'https://adsapi.snapchat.com/v1/segments/456/users',
headers: {
Authorization: 'Bearer abcd123',
'Content-Type': 'application/json',
},
body: {
JSON: {
users: [
{
schema: ['EMAIL_SHA256'],
data: [['938758751f5af66652a118e26503af824404bc13acd1cb7642ddff99916f0e1c']],
},
],
},
JSON_ARRAY: {},
XML: {},
FORM: {},
},
files: {},
params: {
destination: 'snapchat_custom_audience',
},
},
method: 'POST',
},
},
output: {
response: {
status: 500,
body: {
output: {
status: 500,
destinationResponse: {
response: 'unauthorized',
status: 401,
},
message:
'Failed with unauthorized during snapchat_custom_audience response transformation',
statTags: {
destType: 'SNAPCHAT_CUSTOM_AUDIENCE',
errorCategory: 'network',
destinationId: 'Non-determininable',
workspaceId: 'Non-determininable',
errorType: 'retryable',
feature: 'dataDelivery',
implementation: 'native',
module: 'destination',
},
authErrorCategory: 'REFRESH_TOKEN',
},
},
},
},
},
{
name: 'snapchat_custom_audience',
description: 'Test 2',
feature: 'dataDelivery',
module: 'destination',
version: 'v0',
input: {
request: {
body: {
version: '1',
type: 'REST',
method: 'DELETE',
endpoint: 'https://adsapi.snapchat.com/v1/segments/789/users',
headers: {
Authorization: 'Bearer abcd123',
'Content-Type': 'application/json',
},
body: {
JSON: {
users: [
{
id: '123456',
schema: ['EMAIL_SHA256'],
data: [['938758751f5af66652a118e26503af824404bc13acd1cb7642ddff99916f0e1c']],
},
],
},
JSON_ARRAY: {},
XML: {},
FORM: {},
},
files: {},
params: {
destination: 'snapchat_custom_audience',
},
},
method: 'POST',
},
},
output: {
response: {
status: 400,
body: {
output: {
authErrorCategory: 'AUTH_STATUS_INACTIVE',
status: 400,
destinationResponse: {
response: {
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',
},
status: 403,
},
message: 'undefined during snapchat_custom_audience response transformation',
statTags: {
destType: 'SNAPCHAT_CUSTOM_AUDIENCE',
errorCategory: 'network',
destinationId: 'Non-determininable',
workspaceId: 'Non-determininable',
errorType: 'aborted',
feature: 'dataDelivery',
implementation: 'native',
module: 'destination',
},
},
},
},
},
},
];
import { businessTestScenarios } from './business';
import { v0OauthScenarios, v1OauthScenarios } from './oauth';

export const data = [ ...v0OauthScenarios, ...v1OauthScenarios, ...businessTestScenarios];
Loading

0 comments on commit 795a31e

Please sign in to comment.