Skip to content

Commit 211d60c

Browse files
committed
Updated tests
1 parent 9743b63 commit 211d60c

File tree

2 files changed

+70
-10
lines changed

2 files changed

+70
-10
lines changed

packages/destination-actions/src/destinations/braze/__tests__/__snapshots__/braze.test.ts.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`Braze Cloud Mode (Actions) trackEvent should require one of braze_id, user_alias, or external_id 1`] = `"One of \\"external_id\\" or \\"user_alias\\" or \\"braze_id\\" is required."`;
3+
exports[`Braze Cloud Mode (Actions) trackEvent should require one of braze_id, user_alias, or external_id 1`] = `"One of \\"external_id\\" or \\"user_alias\\" or \\"braze_id\\" or \\"email\\" is required."`;
44

55
exports[`Braze Cloud Mode (Actions) trackEvent should work with batched events 1`] = `
66
Headers {
@@ -75,7 +75,7 @@ Headers {
7575
}
7676
`;
7777

78-
exports[`Braze Cloud Mode (Actions) trackPurchase should require one of braze_id, user_alias, or external_id 1`] = `"One of \\"external_id\\" or \\"user_alias\\" or \\"braze_id\\" is required."`;
78+
exports[`Braze Cloud Mode (Actions) trackPurchase should require one of braze_id, user_alias, or external_id 1`] = `"One of \\"external_id\\" or \\"user_alias\\" or \\"braze_id\\" or \\"email\\" is required."`;
7979

8080
exports[`Braze Cloud Mode (Actions) trackPurchase should work with default mappings 1`] = `
8181
Headers {

packages/destination-actions/src/destinations/braze/__tests__/multistatus.test.ts

Lines changed: 68 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,15 @@ describe('MultiStatus', () => {
4646
externalId: 'test-external-id'
4747
}
4848
}),
49+
// Valid Event
50+
createTestEvent({
51+
type: 'identify',
52+
receivedAt,
53+
traits: {
54+
name: 'Example User Two',
55+
56+
}
57+
}),
4958
// Event without any user identifier
5059
createTestEvent({
5160
type: 'identify',
@@ -68,11 +77,17 @@ describe('MultiStatus', () => {
6877
body: 'success'
6978
})
7079

71-
// The third event fails as pre-request validation fails for not having a valid user identifier
80+
// The second event doesn't fail as there is no error reported by Braze API
7281
expect(response[1]).toMatchObject({
82+
status: 200,
83+
body: 'success'
84+
})
85+
86+
// The third event fails as pre-request validation fails for not having a valid user identifier
87+
expect(response[2]).toMatchObject({
7388
status: 400,
7489
errortype: 'PAYLOAD_VALIDATION_FAILED',
75-
errormessage: 'One of "external_id" or "user_alias" or "braze_id" is required.',
90+
errormessage: 'One of "external_id" or "user_alias" or "braze_id" or "email" is required.',
7691
errorreporter: 'DESTINATION'
7792
})
7893
})
@@ -201,6 +216,9 @@ describe('MultiStatus', () => {
201216
describe('trackPurchase', () => {
202217
const mapping = {
203218
time: receivedAt,
219+
email: {
220+
'@path': '$.properties.email'
221+
},
204222
external_id: {
205223
'@path': '$.properties.externalId'
206224
},
@@ -236,6 +254,28 @@ describe('MultiStatus', () => {
236254
]
237255
}
238256
}),
257+
createTestEvent({
258+
event: 'Order Completed',
259+
type: 'track',
260+
receivedAt,
261+
properties: {
262+
263+
products: [
264+
{
265+
product_id: 'test-product-id',
266+
currency: 'USD',
267+
price: 99.99,
268+
quantity: 1
269+
},
270+
{
271+
product_id: 'test-product-id',
272+
currency: 'USD',
273+
price: 99.99,
274+
quantity: 1
275+
}
276+
]
277+
}
278+
}),
239279
// Event with no product
240280
createTestEvent({
241281
event: 'Order Completed',
@@ -276,19 +316,24 @@ describe('MultiStatus', () => {
276316
body: 'success'
277317
})
278318

279-
// The second event fails as it doesn't have any products
280319
expect(response[1]).toMatchObject({
320+
status: 200,
321+
body: 'success'
322+
})
323+
324+
// The third event fails as it doesn't have any products
325+
expect(response[2]).toMatchObject({
281326
status: 400,
282327
errortype: 'PAYLOAD_VALIDATION_FAILED',
283328
errormessage: 'This event was not sent to Braze because it did not contain any products.',
284329
errorreporter: 'DESTINATION'
285330
})
286331

287-
// The third event fails as pre-request validation fails for not having a valid user identifier
288-
expect(response[2]).toMatchObject({
332+
// The forth event fails as pre-request validation fails for not having a valid user identifier
333+
expect(response[3]).toMatchObject({
289334
status: 400,
290335
errortype: 'PAYLOAD_VALIDATION_FAILED',
291-
errormessage: 'One of "external_id" or "user_alias" or "braze_id" is required.',
336+
errormessage: 'One of "external_id" or "user_alias" or "braze_id" or "email" is required.',
292337
errorreporter: 'DESTINATION'
293338
})
294339
})
@@ -542,6 +587,15 @@ describe('MultiStatus', () => {
542587
externalId: 'test-external-id'
543588
}
544589
}),
590+
createTestEvent({
591+
type: 'identify',
592+
receivedAt,
593+
traits: {
594+
firstName: 'Example',
595+
lastName: 'User',
596+
597+
}
598+
}),
545599
// Event without any user identifier
546600
createTestEvent({
547601
type: 'identify',
@@ -565,11 +619,17 @@ describe('MultiStatus', () => {
565619
body: 'success'
566620
})
567621

568-
// The third event fails as pre-request validation fails for not having a valid user identifier
622+
// The second event doesn't fail as there is no error reported by Braze API
569623
expect(response[1]).toMatchObject({
624+
status: 200,
625+
body: 'success'
626+
})
627+
628+
// The third event fails as pre-request validation fails for not having a valid user identifier
629+
expect(response[2]).toMatchObject({
570630
status: 400,
571631
errortype: 'PAYLOAD_VALIDATION_FAILED',
572-
errormessage: 'One of "external_id" or "user_alias" or "braze_id" is required.',
632+
errormessage: 'One of "external_id" or "user_alias" or "braze_id" or "email" is required.',
573633
errorreporter: 'DESTINATION'
574634
})
575635
})

0 commit comments

Comments
 (0)