Skip to content

Commit

Permalink
test: update testcases
Browse files Browse the repository at this point in the history
  • Loading branch information
Gauravudia committed Feb 27, 2024
1 parent d9f7788 commit b28d5d3
Showing 1 changed file with 94 additions and 15 deletions.
109 changes: 94 additions & 15 deletions test/integrations/destinations/klaviyo/processor/identifyTestData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ const commonTraits = {
userId: 'user@1',
title: 'Developer',
organization: 'Rudder',
street: '63, Shibuya',
city: 'Tokyo',
region: 'Kanto',
country: 'JP',
Expand All @@ -34,6 +33,8 @@ const commonTraits = {
},
};

const commonTraits2 = { ...commonTraits, street: '63, Shibuya' };

const commonOutputUserProps = {
external_id: 'user@1',
email: 'test@rudderstack.com',
Expand All @@ -47,15 +48,19 @@ const commonOutputUserProps = {
region: 'Kanto',
country: 'JP',
zip: '100-0001',
address1: '63, Shibuya',
},
properties: {
Flagged: false,
Residence: 'Shibuya',
street: '63, Shibuya',
},
};

const commonOutputUserProps2 = {
...commonOutputUserProps,
location: { ...commonOutputUserProps.location, address1: '63, Shibuya' },
properties: { ...commonOutputUserProps.properties, street: '63, Shibuya' },
};

const commonOutputSubscriptionProps = {
list_id: 'XUepkK',
subscriptions: [
Expand Down Expand Up @@ -105,7 +110,7 @@ export const identifyData = [
destination,
message: generateSimplifiedIdentifyPayload({
context: {
traits: commonTraits,
traits: commonTraits2,
},
anonymousId,
userId,
Expand All @@ -128,7 +133,7 @@ export const identifyData = [
JSON: {
data: {
type: 'profile',
attributes: commonOutputUserProps,
attributes: commonOutputUserProps2,
id: '01GW3PHVY0MTCDGS0A1612HARX',
},
},
Expand Down Expand Up @@ -174,7 +179,7 @@ export const identifyData = [
userId,
context: {
traits: {
...commonTraits,
...commonTraits2,
friend: {
names: {
first: 'Alice',
Expand Down Expand Up @@ -206,9 +211,9 @@ export const identifyData = [
type: 'profile',
id: '01GW3PHVY0MTCDGS0A1612HARX',
attributes: {
...commonOutputUserProps,
...commonOutputUserProps2,
properties: {
...commonOutputUserProps.properties,
...commonOutputUserProps2.properties,
'friend.age': 25,
'friend.names.first': 'Alice',
'friend.names.last': 'Smith',
Expand Down Expand Up @@ -263,7 +268,7 @@ export const identifyData = [
userId,
context: {
traits: {
...commonTraits,
...commonTraits2,
email: 'test3@rudderstack.com',
},
},
Expand Down Expand Up @@ -315,7 +320,7 @@ export const identifyData = [
userId,
context: {
traits: {
...commonTraits,
...commonTraits2,
properties: { ...commonTraits.properties, subscribe: false },
},
},
Expand All @@ -338,7 +343,7 @@ export const identifyData = [
JSON: {
data: {
type: 'profile',
attributes: commonOutputUserProps,
attributes: commonOutputUserProps2,
id: '01GW3PHVY0MTCDGS0A1612HARX',
},
},
Expand Down Expand Up @@ -369,7 +374,7 @@ export const identifyData = [
sentAt,
userId,
context: {
traits: commonTraits,
traits: commonTraits2,
},
anonymousId,
originalTimestamp,
Expand All @@ -392,9 +397,9 @@ export const identifyData = [
data: {
type: 'profile',
attributes: removeUndefinedAndNullValues({
...commonOutputUserProps,
...commonOutputUserProps2,
properties: {
...commonOutputUserProps.properties,
...commonOutputUserProps2.properties,
_id: userId,
},
// remove external_id from the payload
Expand Down Expand Up @@ -428,6 +433,80 @@ export const identifyData = [
{
id: 'klaviyo-identify-test-6',
name: 'klaviyo',
description: 'Identify call without user custom Properties',
scenario: 'Business',
successCriteria:
'Response should contain two payloads one for profile updation and other for subscription, response status code should be 200, for the profile updation payload does not have any custom properties in the payload',
feature: 'processor',
module: 'destination',
version: 'v0',
input: {
request: {
body: [
{
destination: destination,
message: generateSimplifiedIdentifyPayload({
sentAt,
userId,
context: {
traits: removeUndefinedAndNullValues({
...commonTraits,
Flagged: undefined,
Residence: undefined,
}),
},
anonymousId,
originalTimestamp,
}),
},
],
},
},
output: {
response: {
status: 200,
body: [
{
output: transformResultBuilder({
userId: '',
method: 'PATCH',
endpoint: commonUserUpdateEndpoint,
headers: commonOutputHeaders,
JSON: {
data: {
type: 'profile',
attributes: removeUndefinedAndNullValues({
...commonOutputUserProps,
properties: undefined,
}),
id: '01GW3PHVY0MTCDGS0A1612HARX',
},
},
}),
statusCode: 200,
},
{
output: transformResultBuilder({
userId: '',
method: 'POST',
endpoint: subscribeEndpoint,
headers: commonOutputHeaders,
JSON: {
data: {
type: 'profile-subscription-bulk-create-job',
attributes: commonOutputSubscriptionProps,
},
},
}),
statusCode: 200,
},
],
},
},
},
{
id: 'klaviyo-identify-test-7',
name: 'klaviyo',
description: 'Identify call without email and phone & enforceEmailAsPrimary enabled from UI',
scenario: 'Business',
successCriteria:
Expand All @@ -445,7 +524,7 @@ export const identifyData = [
userId,
context: {
traits: removeUndefinedAndNullValues({
...commonTraits,
...commonTraits2,
email: undefined,
phone: undefined,
}),
Expand Down

0 comments on commit b28d5d3

Please sign in to comment.