Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: refactor intercom proxy tests to new component structure #3088

Merged
merged 12 commits into from
Mar 13, 2024
147 changes: 147 additions & 0 deletions test/integrations/destinations/intercom/dataDelivery/business.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
import {
generateMetadata,
generateProxyV0Payload,
generateProxyV1Payload,
} from '../../../testUtils';

const commonHeaders = {
'Content-Type': 'application/json',
Authorization: 'Bearer intercomApiKey',
Accept: 'application/json',
'Intercom-Version': '1.4',
};

const createUserPayload = {
email: 'test_1@test.com',
phone: '9876543210',
name: 'Test Name',
signed_up_at: 1601493060,
last_seen_user_agent: 'unknown',
update_last_request_at: true,
user_id: 'test_user_id_1',
custom_attributes: {
anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33',
key1: 'value1',
'address.city': 'Kolkata',
'address.state': 'West Bengal',
'originalArray[0].nested_field': 'nested value',
'originalArray[0].tags[0]': 'tag_1',
'originalArray[0].tags[1]': 'tag_2',
'originalArray[0].tags[2]': 'tag_3',
'originalArray[1].nested_field': 'nested value',
'originalArray[1].tags[0]': 'tag_1',
'originalArray[2].nested_field': 'nested value',
},
};

const commonRequestParameters = {
JSON: createUserPayload,
headers: commonHeaders,
};

const expectedStatTags = {
destType: 'INTERCOM',
destinationId: 'default-destinationId',
errorCategory: 'network',
errorType: 'retryable',
feature: 'dataDelivery',
implementation: 'native',
module: 'destination',
workspaceId: 'default-workspaceId',
};

const metadataArray = [generateMetadata(1)];

export const testScenariosForV0API = [
{
id: 'intercom_v0_other_scenario_1',
name: 'intercom',
description: '[Proxy v0 API] :: Scenario for testing Request Timeout error from destination',
mihir-4116 marked this conversation as resolved.
Show resolved Hide resolved
successCriteria: 'Should return 500 status code with error message',
scenario: 'Business',
feature: 'dataDelivery',
module: 'destination',
version: 'v0',
input: {
request: {
body: generateProxyV0Payload({
...commonRequestParameters,
endpoint: 'https://api.intercom.io/users/test1',
}),
method: 'POST',
},
},
output: {
response: {
status: 500,
body: {
output: {
status: 500,
message:
'[Intercom Response Handler] Request failed for destination intercom with status: 408',
destinationResponse: {
response: {
type: 'error.list',
request_id: '000on04msi4jpk7d3u60',
errors: [
{
code: 'Request Timeout',
message: 'The server would not wait any longer for the client',
},
],
},
status: 408,
},
statTags: expectedStatTags,
},
},
},
},
},
];

export const testScenariosForV1API = [
{
id: 'intercom_v1_other_scenario_1',
name: 'intercom',
description: '[Proxy v1 API] :: Scenario for testing Request Timeout error from destination',
successCriteria: 'Should return 500 status code with error message',
scenario: 'Business',
feature: 'dataDelivery',
module: 'destination',
version: 'v1',
input: {
request: {
body: generateProxyV1Payload(
{
...commonRequestParameters,
endpoint: 'https://api.intercom.io/users/test1',
},
metadataArray,
),
method: 'POST',
},
},
output: {
response: {
status: 200,
body: {
output: {
message:
'[Intercom Response Handler] Request failed for destination intercom with status: 408',
response: [
{
error:
'{"type":"error.list","request_id":"000on04msi4jpk7d3u60","errors":[{"code":"Request Timeout","message":"The server would not wait any longer for the client"}]}',
metadata: generateMetadata(1),
statusCode: 500,
},
],
statTags: expectedStatTags,
status: 500,
},
},
},
},
},
];
94 changes: 3 additions & 91 deletions test/integrations/destinations/intercom/dataDelivery/data.ts
Original file line number Diff line number Diff line change
@@ -1,91 +1,3 @@
export const data = [
{
name: 'intercom',
description: 'Test 0',
feature: 'dataDelivery',
module: 'destination',
version: 'v0',
input: {
request: {
body: {
version: '1',
type: 'REST',
method: 'POST',
endpoint: 'https://api.intercom.io/users/test1',
headers: {
'Content-Type': 'application/json',
Authorization: 'Bearer intercomApiKey',
Accept: 'application/json',
'Intercom-Version': '1.4',
},
params: {},
body: {
JSON: {
email: 'test_1@test.com',
phone: '9876543210',
name: 'Test Name',
signed_up_at: 1601493060,
last_seen_user_agent: 'unknown',
update_last_request_at: true,
user_id: 'test_user_id_1',
custom_attributes: {
anonymousId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33',
key1: 'value1',
'address.city': 'Kolkata',
'address.state': 'West Bengal',
'originalArray[0].nested_field': 'nested value',
'originalArray[0].tags[0]': 'tag_1',
'originalArray[0].tags[1]': 'tag_2',
'originalArray[0].tags[2]': 'tag_3',
'originalArray[1].nested_field': 'nested value',
'originalArray[1].tags[0]': 'tag_1',
'originalArray[2].nested_field': 'nested value',
},
},
XML: {},
JSON_ARRAY: {},
FORM: {},
},
files: {},
userId: '58b21c2d-f8d5-4410-a2d0-b268a26b7e33',
},
method: 'POST',
},
},
output: {
response: {
status: 500,
body: {
output: {
status: 500,
message:
'[Intercom Response Handler] Request failed for destination intercom with status: 408',
destinationResponse: {
response: {
type: 'error.list',
request_id: '000on04msi4jpk7d3u60',
errors: [
{
code: 'Request Timeout',
message: 'The server would not wait any longer for the client',
},
],
},
status: 408,
},
statTags: {
destType: 'INTERCOM',
errorCategory: 'network',
destinationId: 'Non-determininable',
workspaceId: 'Non-determininable',
errorType: 'retryable',
feature: 'dataDelivery',
implementation: 'native',
module: 'destination',
},
},
},
},
},
},
];
import { testScenariosForV0API, testScenariosForV1API } from './business';

export const data = [...testScenariosForV0API, ...testScenariosForV1API];
Loading