Skip to content

Commit

Permalink
chore: tiktok ads update proxy test (#3111)
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsSudip authored Mar 5, 2024
2 parents d1102a2 + 2f49580 commit a7b30cc
Show file tree
Hide file tree
Showing 4 changed files with 431 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { ProxyV1TestData } from '../../../testTypes';
import { params, headers } from './business';
import { generateProxyV1Payload, generateMetadata } from '../../../testUtils';

export const v1OtherScenarios = [
export const v1OtherScenarios: ProxyV1TestData[] = [
{
id: 'criteo_audience_other_0',
name: 'criteo_audience',
Expand Down
249 changes: 249 additions & 0 deletions test/integrations/destinations/tiktok_ads/dataDelivery/business.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,249 @@
import { ProxyV1TestData } from '../../../testTypes';
import { generateMetadata, generateProxyV1Payload } from '../../../testUtils';

export const commonHeaderPart = {
'Access-Token': 'dummyAccessToken',
'Content-Type': 'application/json',
};

export const params = {
destination: 'tiktok_ads',
};

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

export const commonParts = {
context: {
ad: {
callback: '123ATXSfe',
},
page: {
url: 'http://demo.mywebsite.com/purchase',
referrer: 'http://demo.mywebsite.com',
},
user: {
external_id: 'f0e388f53921a51f0bb0fc8a2944109ec188b59172935d8f23020b1614cc44bc',
phone_number: '2f9d2b4df907e5c9a7b3434351b55700167b998a83dc479b825096486ffcf4ea',
email: 'dd6ff77f54e2106661089bae4d40cdb600979bf7edc9eb65c0942ba55c7c2d7f',
},
ip: '13.57.97.131',
user_agent: 'Mozilla/5.0 (platform; rv:geckoversion) Gecko/geckotrail Firefox/firefoxversion',
},
pixel_code: 'A1T8T4UYGVIQA8ORZMX9',
partner_name: 'RudderStack',
event: 'CompletePayment',
event_id: '1616318632825_357',
timestamp: '2020-09-17T19:49:27Z',
};

export const V1BusinessTestScenarion: ProxyV1TestData[] = [
{
id: 'tiktok_ads_business_0',
name: 'tiktok_ads',
description: '[Business]:: Test for tiktok_ads with multiple contents in properties',
feature: 'dataDelivery',
scenario: 'business',
successCriteria: 'Should return 200 after successfully sending the request',
module: 'destination',
version: 'v1',
input: {
request: {
body: generateProxyV1Payload(
{
headers: {
...commonHeaderPart,
'test-dest-response-key': 'successResponse',
},
params,
endpoint: 'https://business-api.tiktok.com/open_api/v1.2/pixel/batch/',
JSON: {
...commonParts,
properties: {
contents: [
{
price: 8,
quantity: 2,
content_type: 'socks',
content_id: '1077218',
},
{
price: 30,
quantity: 1,
content_type: 'dress',
content_id: '1197218',
},
],
currency: 'USD',
value: 46,
},
},
},
[generateMetadata(1234)],
),
method: 'POST',
},
},
output: {
response: {
status: 200,
body: {
output: {
status: 200,
message: '[TIKTOK_ADS Response Handler] - Request Processed Successfully',
response: [
{
error: '{"code":0,"message":"OK"}',
statusCode: 200,
metadata: generateMetadata(1234),
},
],
},
},
},
},
},
{
id: 'tiktok_ads_business_1',
name: 'tiktok_ads',
description:
'[Business]:: Test for tiktok_ads with multiple contents in properties but content_id is not a string',
feature: 'dataDelivery',
scenario: 'business',
successCriteria: 'Should return 400 after successfully processing the request with code 40002',
module: 'destination',
version: 'v1',
input: {
request: {
body: generateProxyV1Payload(
{
params,
headers: {
...commonHeaderPart,
'test-dest-response-key': 'invalidDataTypeResponse',
},
endpoint: 'https://business-api.tiktok.com/open_api/v1.2/pixel/batch/',
JSON: {
properties: {
contents: [
{
price: 8,
quantity: 2,
content_type: 'socks',
content_id: 1077218,
},
{
price: 30,
quantity: 1,
content_type: 'dress',
content_id: 1197218,
},
],
currency: 'USD',
value: 46,
},
...commonParts,
},
},
[generateMetadata(1234)],
),
method: 'POST',
},
},
output: {
response: {
status: 200,
body: {
output: {
status: 400,
message: 'Request failed with status: 40002',
response: [
{
statusCode: 400,
error:
'{"code":40002,"message":"Batch.0.properties.contents.0.content_id: Not a valid string"}',
metadata: generateMetadata(1234),
},
],
statTags,
},
},
},
},
},
{
id: 'tiktok_ads_business_2',
name: 'tiktok_ads',
description: '[Business]:: Test for tiktok_ads with wrong pixel code',
feature: 'dataDelivery',
scenario: 'business',
successCriteria: 'Should return 400 after successfully processing the request with code 40001',
module: 'destination',
version: 'v1',
input: {
request: {
body: generateProxyV1Payload(
{
params,
endpoint: 'https://business-api.tiktok.com/open_api/v1.2/pixel/batch/',
headers: {
...commonHeaderPart,
'test-dest-response-key': 'invalidPermissionsResponse',
},
JSON: {
...commonParts,
properties: {
contents: [
{
price: 8,
quantity: 2,
content_type: 'socks',
content_id: 1077218,
},
{
price: 30,
quantity: 1,
content_type: 'dress',
content_id: 1197218,
},
],
currency: 'USD',
value: 46,
},
},
},
[generateMetadata(1234)],
),
method: 'POST',
},
},
output: {
response: {
status: 200,
body: {
output: {
status: 400,
message: 'Request failed with status: 40001',
response: [
{
statusCode: 400,
error:
'{"code":40001,"message":"No permission to operate pixel code: BU35TSQHT2A1QT375OMG. You must be an admin or operator of this advertiser account."}',
metadata: generateMetadata(1234),
},
],
statTags,
},
},
},
},
},
];
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { AxiosError } from 'axios';
import MockAxiosAdapter from 'axios-mock-adapter';
import lodash from 'lodash';
import { V1BusinessTestScenarion } from './business';
import { v1OtherScenarios } from './other';

export const data = [
const oldV0TestCases = [
{
name: 'tiktok_ads',
description: 'Test 0',
Expand Down Expand Up @@ -670,3 +672,5 @@ export const data = [
},
},
];

export const data = [...oldV0TestCases, ...V1BusinessTestScenarion, ...v1OtherScenarios];
Loading

0 comments on commit a7b30cc

Please sign in to comment.