Skip to content

Commit

Permalink
fix: migrating processor and router test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
shrouti1507 committed Jan 6, 2025
1 parent 933473a commit ebfeffc
Show file tree
Hide file tree
Showing 7 changed files with 2,830 additions and 1,001 deletions.
27 changes: 1 addition & 26 deletions test/integrations/destinations/iterable/dataDelivery/business.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,32 +21,7 @@ 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,
},
{
jobId: 2,
attemptNum: 1,
userId: 'default-userId',
destinationId: 'default-destinationId',
workspaceId: 'default-workspaceId',
sourceId: 'default-sourceId',
secret: {
accessToken: 'default-accessToken',
},
dontBatch: false,
},
];
export const metadata = [generateMetadata(1), generateMetadata(2)];

export const singleMetadata = [
{
Expand Down
151 changes: 102 additions & 49 deletions test/integrations/destinations/iterable/processor/aliasTestData.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,40 @@
import {
generateMetadata,
overrideDestination,
transformResultBuilder,
} from './../../../testUtils';
import { Destination } from '../../../../../src/types';
import { ProcessorTestData } from '../../../testTypes';
import { Destination, Metadata } from '../../../../../src/types';
import { overrideDestination } from '../../../testUtils';

const baseMetadata: Metadata = {
sourceId: 'default-sourceId',
workspaceId: 'default-workspaceId',
namespace: 'default-namespace',
instanceId: 'default-instance',
sourceType: 'default-source-type',
sourceCategory: 'default-category',
trackingPlanId: 'default-tracking-plan',
trackingPlanVersion: 1,
sourceTpConfig: {},
mergedTpConfig: {},
destinationId: 'default-destinationId',
jobRunId: 'default-job-run',
jobId: 1,
sourceBatchId: 'default-batch',
sourceJobId: 'default-source-job',
sourceJobRunId: 'default-source-job-run',
sourceTaskId: 'default-task',
sourceTaskRunId: 'default-task-run',
recordId: {},
destinationType: 'default-destination-type',
messageId: 'default-message-id',
oauthAccessToken: 'default-token',
messageIds: ['default-message-id'],
rudderId: 'default-rudder-id',
receivedAt: '2025-01-06T04:12:38.713Z',
eventName: 'default-event',
eventType: 'default-type',
sourceDefinitionId: 'default-source-def',
destinationDefinitionId: 'default-dest-def',
transformationId: 'default-transform',
dontBatch: false,
};

const destination: Destination = {
ID: '123',
Expand All @@ -29,23 +59,6 @@ const destination: Destination = {
Enabled: true,
};

const headers = {
api_key: 'testApiKey',
'Content-Type': 'application/json',
};

const properties = {
path: '/abc',
referrer: '',
search: '',
title: '',
url: '',
category: 'test-category',
};

const sentAt = '2020-08-28T16:26:16.473Z';
const originalTimestamp = '2020-08-28T16:26:06.468Z';

export const aliasTestData: ProcessorTestData[] = [
{
id: 'iterable-alias-test-1',
Expand All @@ -59,42 +72,62 @@ export const aliasTestData: ProcessorTestData[] = [
version: 'v0',
input: {
request: {
method: 'POST',
body: [
{
destination,
message: {
anonymousId: 'anonId',
userId: 'new@email.com',
previousId: 'old@email.com',
name: 'ApplicationLoaded',
context: {},
properties,
properties: {
path: '/abc',
referrer: '',
search: '',
title: '',
url: '',
category: 'test-category',
},
type: 'alias',
sentAt,
originalTimestamp,
sentAt: '2020-08-28T16:26:16.473Z',
originalTimestamp: '2020-08-28T16:26:06.468Z',
},
metadata: generateMetadata(1),
metadata: baseMetadata,
destination,
},
],
method: 'POST',
},
},
output: {
response: {
status: 200,
body: [
{
output: transformResultBuilder({
output: {
version: '1',
type: 'REST',
userId: '',
headers,
method: 'POST',
endpoint: 'https://api.iterable.com/api/users/updateEmail',
JSON: {
currentEmail: 'old@email.com',
newEmail: 'new@email.com',
headers: {
api_key: 'testApiKey',
'Content-Type': 'application/json',
},
params: {},
body: {
JSON: {
currentEmail: 'old@email.com',
newEmail: 'new@email.com',
},
JSON_ARRAY: {},
XML: {},
FORM: {},
},
}),
files: {},
},
metadata: baseMetadata,
statusCode: 200,
metadata: generateMetadata(1),
},
],
},
Expand All @@ -112,42 +145,62 @@ export const aliasTestData: ProcessorTestData[] = [
version: 'v0',
input: {
request: {
method: 'POST',
body: [
{
destination: overrideDestination(destination, { dataCenter: 'EUDC' }),
message: {
anonymousId: 'anonId',
userId: 'new@email.com',
previousId: 'old@email.com',
name: 'ApplicationLoaded',
context: {},
properties,
properties: {
path: '/abc',
referrer: '',
search: '',
title: '',
url: '',
category: 'test-category',
},
type: 'alias',
sentAt,
originalTimestamp,
sentAt: '2020-08-28T16:26:16.473Z',
originalTimestamp: '2020-08-28T16:26:06.468Z',
},
metadata: generateMetadata(1),
metadata: baseMetadata,
destination: overrideDestination(destination, { dataCenter: 'EUDC' }),
},
],
method: 'POST',
},
},
output: {
response: {
status: 200,
body: [
{
output: transformResultBuilder({
output: {
version: '1',
type: 'REST',
userId: '',
headers,
method: 'POST',
endpoint: 'https://api.eu.iterable.com/api/users/updateEmail',
JSON: {
currentEmail: 'old@email.com',
newEmail: 'new@email.com',
headers: {
api_key: 'testApiKey',
'Content-Type': 'application/json',
},
}),
params: {},
body: {
JSON: {
currentEmail: 'old@email.com',
newEmail: 'new@email.com',
},
JSON_ARRAY: {},
XML: {},
FORM: {},
},
files: {},
},
metadata: baseMetadata,
statusCode: 200,
metadata: generateMetadata(1),
},
],
},
Expand Down
Loading

0 comments on commit ebfeffc

Please sign in to comment.