Skip to content

Commit

Permalink
feat: review comments addressed
Browse files Browse the repository at this point in the history
  • Loading branch information
shrouti1507 committed Mar 31, 2024
1 parent 83ee321 commit 5c36283
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 105 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,18 @@ export const statTags = {
module: 'destination',
};

export const metadata = {
jobId: 1,
attemptNum: 1,
userId: 'default-userId',
destinationId: 'default-destinationId',
workspaceId: 'default-workspaceId',
sourceId: 'default-sourceId',
secret: {
accessToken: 'default-accessToken',
},
dontBatch: false,
};
export const headerBlockWithCorrectAccessToken = {
Authorization: 'Bearer default-accessToken',
'Content-Type': 'application/json',
Expand Down Expand Up @@ -116,38 +128,18 @@ export const testScenariosForV1API: ProxyV1TestData[] = [
error:
'{"message":"Incorrect conversions information provided. Conversion\'s method should be CONVERSIONS_API, indices [0] (0-indexed)","status":400}',
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,
},
],
statTags: {
errorCategory: 'network',
errorType: 'aborted',
destType: 'LINKEDIN_ADS',
module: 'destination',
implementation: 'native',
feature: 'dataDelivery',
destinationId: 'default-destinationId',
workspaceId: 'default-workspaceId',
},
statTags,
status: 400,
},
},
},
},
},
{
id: 'linkedin_ads_v1_scenario_1',
id: 'linkedin_ads_v1_scenario_2',
name: 'linkedin_ads',
description: 'Event fails due to wrong format payload sent to linkedin',
successCriteria: 'Should return 400 with appropriate reason of failure',
Expand Down Expand Up @@ -184,18 +176,7 @@ export const testScenariosForV1API: ProxyV1TestData[] = [
error:
'/conversionValue/amount :: field is required but not found and has no default value',
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,
},
],
status: 422,
Expand Down
67 changes: 20 additions & 47 deletions test/integrations/destinations/linkedin_ads/dataDelivery/oauth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,19 @@ export const statTags = {
module: 'destination',
};

export const metadata = {
jobId: 1,
attemptNum: 1,
userId: 'default-userId',
destinationId: 'default-destinationId',
workspaceId: 'default-workspaceId',
sourceId: 'default-sourceId',
secret: {
accessToken: 'default-accessToken',
},
dontBatch: false,
};

export const headerBlockWithCorrectAccessToken = {
Authorization: 'Bearer default-accessToken',
'Content-Type': 'application/json',
Expand All @@ -59,7 +72,7 @@ const commonRequestParametersWithRevokedAccess = {

export const oauthScenariosV1: ProxyV1TestData[] = [
{
id: 'linkedin_ads_v1_scenario_1',
id: 'linkedin_ads_v1_oauth_scenario_1',
name: 'linkedin_ads',
description: 'app event fails due to revoked access token error',
successCriteria: 'Should return 500 with revoked access token error',
Expand All @@ -86,30 +99,10 @@ export const oauthScenariosV1: ProxyV1TestData[] = [
error:
'{"status":401,"serviceErrorCode":65601,"code":"REVOKED_ACCESS_TOKEN","message":"The token used in the request has been revoked by the user"}',
statusCode: 500,
metadata: {
jobId: 1,
attemptNum: 1,
userId: 'default-userId',
destinationId: 'default-destinationId',
workspaceId: 'default-workspaceId',
sourceId: 'default-sourceId',
secret: {
accessToken: 'revokedToken',
},
dontBatch: false,
},
metadata: { ...metadata, secret: { accessToken: 'revokedToken' } },
},
],
statTags: {
errorCategory: 'network',
errorType: 'retryable',
destType: 'LINKEDIN_ADS',
module: 'destination',
implementation: 'native',
feature: 'dataDelivery',
destinationId: 'default-destinationId',
workspaceId: 'default-workspaceId',
},
statTags: { ...statTags, errorType: 'retryable' },
authErrorCategory: 'REFRESH_TOKEN',
message:
'LinkedIn Conversion API: Error transformer proxy v1 during LinkedIn Conversion API response transformation. Invalid or expired access token. Retrying',
Expand All @@ -120,7 +113,7 @@ export const oauthScenariosV1: ProxyV1TestData[] = [
},
},
{
id: 'linkedin_ads_v1_scenario_1',
id: 'linkedin_ads_v1_oauth_scenario_2',
name: 'linkedin_ads',
description: 'app event fails due to invalid access token error',
successCriteria: 'Should return 500 with invalid access token error',
Expand All @@ -147,30 +140,10 @@ export const oauthScenariosV1: ProxyV1TestData[] = [
error:
'{"status":401,"serviceErrorCode":65600,"code":"INVALID_ACCESS_TOKEN","message":"Invalid access token"}',
statusCode: 500,
metadata: {
jobId: 1,
attemptNum: 1,
userId: 'default-userId',
destinationId: 'default-destinationId',
workspaceId: 'default-workspaceId',
sourceId: 'default-sourceId',
secret: {
accessToken: 'invalidToken',
},
dontBatch: false,
},
metadata: { ...metadata, secret: { accessToken: 'invalidToken' } },
},
],
statTags: {
errorCategory: 'network',
errorType: 'retryable',
destType: 'LINKEDIN_ADS',
module: 'destination',
implementation: 'native',
feature: 'dataDelivery',
destinationId: 'default-destinationId',
workspaceId: 'default-workspaceId',
},
statTags: { ...statTags, errorType: 'retryable' },
authErrorCategory: 'REFRESH_TOKEN',
message:
'LinkedIn Conversion API: Error transformer proxy v1 during LinkedIn Conversion API response transformation. Invalid or expired access token. Retrying',
Expand All @@ -181,7 +154,7 @@ export const oauthScenariosV1: ProxyV1TestData[] = [
},
},
{
id: 'linkedin_ads_v1_scenario_1',
id: 'linkedin_ads_v1_oauth_scenario_3',
name: 'linkedin_ads',
description: 'success case',
successCriteria: 'Should return 200 response',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const commonTimestamp = new Date('2023-10-14');

export const configLevelFeaturesTestData: ProcessorTestData[] = [
{
id: 'linkedin_ads-track-test-1',
id: 'linkedin_ads-config-test-1',
name: 'linkedin_ads',
description: 'Track call : hashData is set to false and no deduplication key is provided',
scenario: 'Business',
Expand Down Expand Up @@ -139,7 +139,7 @@ export const configLevelFeaturesTestData: ProcessorTestData[] = [
},
},
{
id: 'linkedin_ads-track-test-1',
id: 'linkedin_ads-config-test-2',
name: 'linkedin_ads',
description: 'Track call : hashData is set to true and deduplication key is provided',
scenario: 'Business',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ export const trackTestData: ProcessorTestData[] = [
},
},
{
id: 'linkedin_ads-track-test-5',
id: 'linkedin_ads-track-test-7',
name: 'linkedin_ads',
description:
'Track call : track event containing product array where not all products contains price field',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
import {
generateMetadata,
generateTrackPayload,
overrideDestination,
transformResultBuilder,
} from '../../../testUtils';
import { generateMetadata, generateTrackPayload, overrideDestination } from '../../../testUtils';
import { Destination } from '../../../../../src/types';
import { ProcessorTestData } from '../../../testTypes';

Expand Down Expand Up @@ -85,7 +80,7 @@ const olderTimestamp = new Date('2023-07-13');

export const validationTestData: ProcessorTestData[] = [
{
id: 'linkedin_ads-track-test-1',
id: 'linkedin_ads-validation-test-1',
name: 'linkedin_ads',
description: 'Track call : event is older than 90 days',
scenario: 'Business',
Expand Down Expand Up @@ -137,7 +132,7 @@ export const validationTestData: ProcessorTestData[] = [
},
},
{
id: 'linkedin_ads-track-test-2',
id: 'linkedin_ads-validation-test-2',
name: 'linkedin_ads',
description: 'Track call : event not mapped to conversion rule in UI',
scenario: 'Business',
Expand Down Expand Up @@ -234,7 +229,7 @@ export const validationTestData: ProcessorTestData[] = [
},
},
{
id: 'linkedin_ads-track-test-4',
id: 'linkedin_ads-validation-test-4',
name: 'linkedin_ads',
description: 'Track call : properties without product array and no price',
scenario: 'Business',
Expand Down Expand Up @@ -272,24 +267,15 @@ export const validationTestData: ProcessorTestData[] = [
error:
'[LinkedIn Conversion API]: Cannot map price for event random event. Aborting: Workflow: procWorkflow, Step: commonFields, ChildStep: undefined, OriginalError: [LinkedIn Conversion API]: Cannot map price for event random event. Aborting',
metadata: generateMetadata(1),
statTags: {
destinationId: 'default-destinationId',
errorCategory: 'dataValidation',
errorType: 'instrumentation',
implementation: 'cdkV2',
destType: 'LINKEDIN_ADS',
module: 'destination',
feature: 'processor',
workspaceId: 'default-workspaceId',
},
statTags: commonStats,
statusCode: 400,
},
],
},
},
},
{
id: 'linkedin_ads-track-test-5',
id: 'linkedin_ads-validation-test-5',
name: 'linkedin_ads',
description: 'Track call : properties without product array and no price',
scenario: 'Business',
Expand Down

0 comments on commit 5c36283

Please sign in to comment.