Skip to content

Commit

Permalink
chore: updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sandeepdsvs committed Mar 1, 2024
1 parent 457b601 commit 41dada1
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 93 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { generateMetadata, generateProxyV1Payload } from '../../../testUtils';
import { ProxyV1TestData } from '../../../testTypes';
import { getEndPoint } from '../../../../../src/v0/destinations/fb_custom_audience/config';

const statTags = {
export const statTags = {
destType: 'FB_CUSTOM_AUDIENCE',
destinationId: 'default-destinationId',
errorCategory: 'network',
Expand All @@ -13,7 +13,45 @@ const statTags = {
workspaceId: 'default-workspaceId',
};

const params = {
const testParams1 = {
access_token: 'ABC',
payload: {
is_raw: true,
data_source: {
sub_type: 'ANYTHING',
},
schema: [
'EMAIL',
'DOBM',
'DOBD',
'DOBY',
'PHONE',
'GEN',
'FI',
'MADID',
'ZIP',
'ST',
'COUNTRY',
],
data: [
[
'[email protected]',
'2',
'13',
'2013',
'@09432457768',
'f',
'Ms.',
'ABC',
'ZIP ',
'123abc ',
'IN',
],
],
},
};

export const testParams2 = {
access_token: 'ABC',
payload: {
is_raw: true,
Expand All @@ -25,6 +63,18 @@ const params = {
},
};

const testParams3 = {
access_token: 'BCD',
payload: {
is_raw: true,
data_source: {
sub_type: 'ANYTHING',
},
schema: ['DOBM', 'DOBD', 'DOBY', 'PHONE', 'GEN', 'FI', 'MADID', 'ZIP', 'ST', 'COUNTRY'],
data: [['2', '13', '2013', '@09432457768', 'f', 'Ms.', 'ABC', 'ZIP ', '123abc ', 'IN']],
},
};

export const testScenariosForV1API: ProxyV1TestData[] = [
{
id: 'fbca_v1_scenario_1',
Expand All @@ -43,43 +93,7 @@ export const testScenariosForV1API: ProxyV1TestData[] = [
headers: {
'test-dest-response-key': 'successResponse',
},
params: {
access_token: 'ABC',
payload: {
is_raw: true,
data_source: {
sub_type: 'ANYTHING',
},
schema: [
'EMAIL',
'DOBM',
'DOBD',
'DOBY',
'PHONE',
'GEN',
'FI',
'MADID',
'ZIP',
'ST',
'COUNTRY',
],
data: [
[
'[email protected]',
'2',
'13',
'2013',
'@09432457768',
'f',
'Ms.',
'ABC',
'ZIP ',
'123abc ',
'IN',
],
],
},
},
params: testParams1,
}),
method: 'POST',
},
Expand Down Expand Up @@ -121,30 +135,7 @@ export const testScenariosForV1API: ProxyV1TestData[] = [
headers: {
'test-dest-response-key': 'permissionMissingError',
},
params: {
access_token: 'BCD',
payload: {
is_raw: true,
data_source: {
sub_type: 'ANYTHING',
},
schema: [
'DOBM',
'DOBD',
'DOBY',
'PHONE',
'GEN',
'FI',
'MADID',
'ZIP',
'ST',
'COUNTRY',
],
data: [
['2', '13', '2013', '@09432457768', 'f', 'Ms.', 'ABC', 'ZIP ', '123abc ', 'IN'],
],
},
},
params: testParams3,
}),
method: 'POST',
},
Expand Down Expand Up @@ -188,7 +179,7 @@ export const testScenariosForV1API: ProxyV1TestData[] = [
headers: {
'test-dest-response-key': 'audienceUnavailableError',
},
params,
params: testParams2,
}),
method: 'POST',
},
Expand Down Expand Up @@ -232,7 +223,7 @@ export const testScenariosForV1API: ProxyV1TestData[] = [
headers: {
'test-dest-response-key': 'audienceDeletedError',
},
params,
params: testParams2,
}),
method: 'POST',
},
Expand Down Expand Up @@ -274,7 +265,7 @@ export const testScenariosForV1API: ProxyV1TestData[] = [
headers: {
'test-dest-response-key': 'failedToUpdateAudienceError',
},
params,
params: testParams2,
}),
method: 'POST',
},
Expand Down Expand Up @@ -317,7 +308,7 @@ export const testScenariosForV1API: ProxyV1TestData[] = [
headers: {
'test-dest-response-key': 'parameterExceededError',
},
params,
params: testParams2,
}),
method: 'POST',
},
Expand Down Expand Up @@ -359,7 +350,7 @@ export const testScenariosForV1API: ProxyV1TestData[] = [
headers: {
'test-dest-response-key': 'code200PermissionError',
},
params,
params: testParams2,
}),
method: 'POST',
},
Expand Down Expand Up @@ -401,7 +392,7 @@ export const testScenariosForV1API: ProxyV1TestData[] = [
headers: {
'test-dest-response-key': 'accessTokenInvalidError',
},
params,
params: testParams2,
}),
method: 'POST',
},
Expand All @@ -415,15 +406,10 @@ export const testScenariosForV1API: ProxyV1TestData[] = [
message:
'Error validating access token: Session has expired on Tuesday, 01-Aug-23 10:12:14 PDT. The current time is Sunday, 28-Jan-24 16:01:17 PST.',
statTags: {
destType: 'FB_CUSTOM_AUDIENCE',
destinationId: 'default-destinationId',
...statTags,
errorCategory: 'dataValidation',
errorType: 'configuration',
meta: 'accessTokenExpired',
feature: 'dataDelivery',
implementation: 'native',
module: 'destination',
workspaceId: 'default-workspaceId',
},
response: [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { generateMetadata, generateProxyV1Payload } from '../../../testUtils';
import { ProxyV1TestData } from '../../../testTypes';
import { getEndPoint } from '../../../../../src/v0/destinations/fb_custom_audience/config';
import { statTags, testParams2 as testParams } from './business';

export const otherScenariosV1: ProxyV1TestData[] = [
{
Expand All @@ -21,17 +22,7 @@ export const otherScenariosV1: ProxyV1TestData[] = [
headers: {
'test-dest-response-key': 'tooManyCallsError',
},
params: {
access_token: 'ABC',
payload: {
is_raw: true,
data_source: {
sub_type: 'ANYTHING',
},
schema: ['DOBY', 'PHONE', 'GEN', 'FI', 'MADID', 'ZIP', 'ST', 'COUNTRY'],
data: [['2013', '@09432457768', 'f', 'Ms.', 'ABC', 'ZIP ', '123abc ', 'IN']],
},
},
params: testParams,
}),
method: 'POST',
},
Expand All @@ -43,14 +34,8 @@ export const otherScenariosV1: ProxyV1TestData[] = [
output: {
message: 'There have been too many calls to this ad-account.',
statTags: {
destType: 'FB_CUSTOM_AUDIENCE',
destinationId: 'default-destinationId',
errorCategory: 'network',
...statTags,
errorType: 'throttled',
feature: 'dataDelivery',
implementation: 'native',
module: 'destination',
workspaceId: 'default-workspaceId',
},
status: 429,
response: [
Expand Down

0 comments on commit 41dada1

Please sign in to comment.