Skip to content

Commit

Permalink
chore: update utils to generate simplified payloads for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
utsabc committed Jan 16, 2024
1 parent 09fa0fd commit 7ae320c
Show file tree
Hide file tree
Showing 5 changed files with 300 additions and 181 deletions.
54 changes: 30 additions & 24 deletions test/integrations/destinations/klaviyo/processor/groupTestData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,24 @@ export const groupTestData = [
body: [
{
destination,
message: generateGroupPayload({
userId: 'user123',
groupId: 'XUepkK',
traits: {
subscribe: true,
},
context: {
message: generateGroupPayload(
{
userId: 'user123',
groupId: 'XUepkK',
traits: {
email: '[email protected]',
phone: '+12 345 678 900',
consent: ['email'],
subscribe: true,
},
context: {
traits: {
email: '[email protected]',
phone: '+12 345 678 900',
consent: ['email'],
},
},
timestamp: '2020-01-21T00:21:34.208Z',
},
timestamp: '2020-01-21T00:21:34.208Z',
}),
true,
),
},
],
},
Expand Down Expand Up @@ -94,21 +97,24 @@ export const groupTestData = [
body: [
{
destination,
message: generateGroupPayload({
userId: 'user123',
groupId: '',
traits: {
subscribe: true,
},
context: {
message: generateGroupPayload(
{
userId: 'user123',
groupId: '',
traits: {
email: '[email protected]',
phone: '+12 345 678 900',
consent: 'email',
subscribe: true,
},
context: {
traits: {
email: '[email protected]',
phone: '+12 345 678 900',
consent: 'email',
},
},
timestamp: '2020-01-21T00:21:34.208Z',
},
timestamp: '2020-01-21T00:21:34.208Z',
}),
true,
),
},
],
},
Expand Down
167 changes: 94 additions & 73 deletions test/integrations/destinations/klaviyo/processor/identifyTestData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,17 @@ export const identifyData = [
body: [
{
destination,
message: generateIndentifyPayload({
context: {
traits: commonTraits,
message: generateIndentifyPayload(
{
context: {
traits: commonTraits,
},
anonymousId,
userId,
sentAt,
},
anonymousId,
userId,
sentAt,
}),
true,
),
},
],
},
Expand Down Expand Up @@ -166,24 +169,27 @@ export const identifyData = [
body: [
{
destination: overrideDestination(destination, { flattenProperties: true }),
message: generateIndentifyPayload({
sentAt,
userId,
context: {
traits: {
...commonTraits,
friend: {
names: {
first: 'Alice',
last: 'Smith',
message: generateIndentifyPayload(
{
sentAt,
userId,
context: {
traits: {
...commonTraits,
friend: {
names: {
first: 'Alice',
last: 'Smith',
},
age: 25,
},
age: 25,
},
},
anonymousId,
originalTimestamp,
},
anonymousId,
originalTimestamp,
}),
true,
),
},
],
},
Expand Down Expand Up @@ -255,18 +261,21 @@ export const identifyData = [
privateApiKey: 'dummyPrivateApiKeyforfailure',
},
},
message: generateIndentifyPayload({
sentAt,
userId,
context: {
traits: {
...commonTraits,
email: '[email protected]',
message: generateIndentifyPayload(
{
sentAt,
userId,
context: {
traits: {
...commonTraits,
email: '[email protected]',
},
},
anonymousId,
originalTimestamp,
},
anonymousId,
originalTimestamp,
}),
true,
),
},
],
},
Expand Down Expand Up @@ -307,18 +316,21 @@ export const identifyData = [
body: [
{
destination,
message: generateIndentifyPayload({
sentAt,
userId,
context: {
traits: {
...commonTraits,
properties: { ...commonTraits.properties, subscribe: false },
message: generateIndentifyPayload(
{
sentAt,
userId,
context: {
traits: {
...commonTraits,
properties: { ...commonTraits.properties, subscribe: false },
},
},
anonymousId,
originalTimestamp,
},
anonymousId,
originalTimestamp,
}),
true,
),
},
],
},
Expand Down Expand Up @@ -362,15 +374,18 @@ export const identifyData = [
body: [
{
destination: overrideDestination(destination, { enforceEmailAsPrimary: true }),
message: generateIndentifyPayload({
sentAt,
userId,
context: {
traits: commonTraits,
message: generateIndentifyPayload(
{
sentAt,
userId,
context: {
traits: commonTraits,
},
anonymousId,
originalTimestamp,
},
anonymousId,
originalTimestamp,
}),
true,
),
},
],
},
Expand Down Expand Up @@ -437,19 +452,22 @@ export const identifyData = [
body: [
{
destination: destination,
message: generateIndentifyPayload({
sentAt,
userId,
context: {
traits: removeUndefinedAndNullValues({
...commonTraits,
Flagged: undefined,
Residence: undefined,
}),
message: generateIndentifyPayload(
{
sentAt,
userId,
context: {
traits: removeUndefinedAndNullValues({
...commonTraits,
Flagged: undefined,
Residence: undefined,
}),
},
anonymousId,
originalTimestamp,
},
anonymousId,
originalTimestamp,
}),
true,
),
},
],
},
Expand Down Expand Up @@ -511,19 +529,22 @@ export const identifyData = [
body: [
{
destination: overrideDestination(destination, { enforceEmailAsPrimary: true }),
message: generateIndentifyPayload({
sentAt,
userId,
context: {
traits: removeUndefinedAndNullValues({
...commonTraits,
email: undefined,
phone: undefined,
}),
message: generateIndentifyPayload(
{
sentAt,
userId,
context: {
traits: removeUndefinedAndNullValues({
...commonTraits,
email: undefined,
phone: undefined,
}),
},
anonymousId,
originalTimestamp,
},
anonymousId,
originalTimestamp,
}),
true,
),
},
],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export const screenTestData = [
originalTimestamp: '2021-01-25T15:32:56.409Z',
},
'screen',
true,
),
},
],
Expand Down
Loading

0 comments on commit 7ae320c

Please sign in to comment.