From d1d09a8b97bd461c9a2969e3452c3f7cbecd68cb Mon Sep 17 00:00:00 2001 From: Sayan Das Date: Wed, 5 Feb 2025 00:15:35 +0530 Subject: [PATCH 1/2] Switched to built-in AbortController and updated snapshots --- packages/core/package.json | 1 - .../core/src/__tests__/request-client.test.ts | 1 - packages/core/src/request-client.ts | 1 - .../__snapshots__/index.test.ts.snap | 32 +++++++++++++-- .../__snapshots__/index.test.ts.snap | 40 ++++++++++++++++--- yarn.lock | 14 +------ 6 files changed, 64 insertions(+), 25 deletions(-) diff --git a/packages/core/package.json b/packages/core/package.json index e73e6b715e..e66195540f 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -84,7 +84,6 @@ "@segment/ajv-human-errors": "^2.14.0", "@segment/destination-subscriptions": "^3.36.0", "@types/node": "^18.11.15", - "abort-controller": "^3.0.0", "aggregate-error": "^3.1.0", "ajv": "^8.6.3", "ajv-formats": "^2.1.1", diff --git a/packages/core/src/__tests__/request-client.test.ts b/packages/core/src/__tests__/request-client.test.ts index 8d2a1c24d3..b995a801b4 100644 --- a/packages/core/src/__tests__/request-client.test.ts +++ b/packages/core/src/__tests__/request-client.test.ts @@ -1,5 +1,4 @@ /* eslint-disable @typescript-eslint/no-empty-function */ -import AbortController from 'abort-controller' import createTestServer from 'create-test-server' import createInstance from '../request-client' import { Response } from '../fetch' diff --git a/packages/core/src/request-client.ts b/packages/core/src/request-client.ts index 1646e5e491..2b3d7fb040 100644 --- a/packages/core/src/request-client.ts +++ b/packages/core/src/request-client.ts @@ -1,4 +1,3 @@ -import AbortController from 'abort-controller' import { CustomError } from 'ts-custom-error' import fetch, { Headers, Request, Response } from './fetch' import { isObject } from './real-type-of' diff --git a/packages/destination-actions/src/destinations/amazon-amc/syncAudiencesToDSP/__tests__/__snapshots__/index.test.ts.snap b/packages/destination-actions/src/destinations/amazon-amc/syncAudiencesToDSP/__tests__/__snapshots__/index.test.ts.snap index fc3209aa5a..c3a9bd030a 100644 --- a/packages/destination-actions/src/destinations/amazon-amc/syncAudiencesToDSP/__tests__/__snapshots__/index.test.ts.snap +++ b/packages/destination-actions/src/destinations/amazon-amc/syncAudiencesToDSP/__tests__/__snapshots__/index.test.ts.snap @@ -28,7 +28,13 @@ Object { }, }, "method": "POST", - "signal": AbortSignal {}, + "signal": AbortSignal { + Symbol(kEvents): Map {}, + Symbol(events.maxEventTargetListeners): 10, + Symbol(events.maxEventTargetListenersWarned): false, + Symbol(kAborted): false, + Symbol(kReason): undefined, + }, "statsContext": Object {}, "throwHttpErrors": true, "timeout": 10000, @@ -63,7 +69,13 @@ Object { }, }, "method": "POST", - "signal": AbortSignal {}, + "signal": AbortSignal { + Symbol(kEvents): Map {}, + Symbol(events.maxEventTargetListeners): 10, + Symbol(events.maxEventTargetListenersWarned): false, + Symbol(kAborted): false, + Symbol(kReason): undefined, + }, "statsContext": Object {}, "throwHttpErrors": true, "timeout": 10000, @@ -98,7 +110,13 @@ Object { }, }, "method": "POST", - "signal": AbortSignal {}, + "signal": AbortSignal { + Symbol(kEvents): Map {}, + Symbol(events.maxEventTargetListeners): 10, + Symbol(events.maxEventTargetListenersWarned): false, + Symbol(kAborted): false, + Symbol(kReason): undefined, + }, "statsContext": Object {}, "throwHttpErrors": true, "timeout": 10000, @@ -133,7 +151,13 @@ Object { }, }, "method": "POST", - "signal": AbortSignal {}, + "signal": AbortSignal { + Symbol(kEvents): Map {}, + Symbol(events.maxEventTargetListeners): 10, + Symbol(events.maxEventTargetListenersWarned): false, + Symbol(kAborted): false, + Symbol(kReason): undefined, + }, "statsContext": Object {}, "throwHttpErrors": true, "timeout": 10000, diff --git a/packages/destination-actions/src/destinations/hubspot/upsertContact/__tests__/__snapshots__/index.test.ts.snap b/packages/destination-actions/src/destinations/hubspot/upsertContact/__tests__/__snapshots__/index.test.ts.snap index 81fd85adf7..90516dec21 100644 --- a/packages/destination-actions/src/destinations/hubspot/upsertContact/__tests__/__snapshots__/index.test.ts.snap +++ b/packages/destination-actions/src/destinations/hubspot/upsertContact/__tests__/__snapshots__/index.test.ts.snap @@ -35,7 +35,13 @@ Object { ], }, "method": "POST", - "signal": AbortSignal {}, + "signal": AbortSignal { + Symbol(kEvents): Map {}, + Symbol(events.maxEventTargetListeners): 10, + Symbol(events.maxEventTargetListenersWarned): false, + Symbol(kAborted): false, + Symbol(kReason): undefined, + }, "skipResponseCloning": true, "statsContext": Object {}, "throwHttpErrors": true, @@ -126,7 +132,13 @@ Object { ], }, "method": "POST", - "signal": AbortSignal {}, + "signal": AbortSignal { + Symbol(kEvents): Map {}, + Symbol(events.maxEventTargetListeners): 10, + Symbol(events.maxEventTargetListenersWarned): false, + Symbol(kAborted): false, + Symbol(kReason): undefined, + }, "skipResponseCloning": true, "statsContext": Object {}, "throwHttpErrors": true, @@ -274,7 +286,13 @@ Object { ], }, "method": "POST", - "signal": AbortSignal {}, + "signal": AbortSignal { + Symbol(kEvents): Map {}, + Symbol(events.maxEventTargetListeners): 10, + Symbol(events.maxEventTargetListenersWarned): false, + Symbol(kAborted): false, + Symbol(kReason): undefined, + }, "skipResponseCloning": true, "statsContext": Object {}, "throwHttpErrors": true, @@ -368,7 +386,13 @@ Object { ], }, "method": "POST", - "signal": AbortSignal {}, + "signal": AbortSignal { + Symbol(kEvents): Map {}, + Symbol(events.maxEventTargetListeners): 10, + Symbol(events.maxEventTargetListenersWarned): false, + Symbol(kAborted): false, + Symbol(kReason): undefined, + }, "skipResponseCloning": true, "statsContext": Object {}, "throwHttpErrors": true, @@ -491,7 +515,13 @@ Object { ], }, "method": "POST", - "signal": AbortSignal {}, + "signal": AbortSignal { + Symbol(kEvents): Map {}, + Symbol(events.maxEventTargetListeners): 10, + Symbol(events.maxEventTargetListenersWarned): false, + Symbol(kAborted): false, + Symbol(kReason): undefined, + }, "skipResponseCloning": true, "statsContext": Object {}, "throwHttpErrors": true, diff --git a/yarn.lock b/yarn.lock index 513ad61cde..eaa27ffe57 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5666,13 +5666,6 @@ abbrev@^2.0.0: resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-2.0.0.tgz#cf59829b8b4f03f89dda2771cb7f3653828c89bf" integrity sha512-6/mh1E2u2YgEsCHdY0Yx5oW+61gZU+1vXaoiHHrpKeuRNNgFvS+/jrwHiQhB5apAf5oB7UB7E19ol2R2LKH8hQ== -abort-controller@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/abort-controller/-/abort-controller-3.0.0.tgz#eaf54d53b62bae4138e809ca225c8439a6efb392" - integrity sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg== - dependencies: - event-target-shim "^5.0.0" - accepts@~1.3.4, accepts@~1.3.5, accepts@~1.3.7: version "1.3.7" resolved "https://registry.yarnpkg.com/accepts/-/accepts-1.3.7.tgz#531bc726517a3b2b41f850021c6cc15eaab507cd" @@ -8675,11 +8668,6 @@ event-emitter@^0.3.5: d "1" es5-ext "~0.10.14" -event-target-shim@^5.0.0: - version "5.0.1" - resolved "https://registry.yarnpkg.com/event-target-shim/-/event-target-shim-5.0.1.tgz#5d4d3ebdf9583d63a5333ce2deb7480ab2b05789" - integrity sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ== - eventemitter3@^4.0.0, eventemitter3@^4.0.4: version "4.0.7" resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-4.0.7.tgz#2de9b68f6528d5644ef5c59526a1b4a07306169f" @@ -17359,4 +17347,4 @@ zip-stream@^4.1.0: dependencies: archiver-utils "^2.1.0" compress-commons "^4.1.0" - readable-stream "^3.6.0" \ No newline at end of file + readable-stream "^3.6.0" From 32d73b6815303b47a56e503f1020751134bd04c1 Mon Sep 17 00:00:00 2001 From: Sayan Das Date: Wed, 5 Feb 2025 00:15:35 +0530 Subject: [PATCH 2/2] Updated unit tests exposing response.options directly --- .../__snapshots__/index.test.ts.snap | 191 +++-------- .../__tests__/index.test.ts | 8 +- .../__snapshots__/index.test.ts.snap | 302 ++---------------- .../upsertContact/__tests__/index.test.ts | 18 +- 4 files changed, 94 insertions(+), 425 deletions(-) diff --git a/packages/destination-actions/src/destinations/amazon-amc/syncAudiencesToDSP/__tests__/__snapshots__/index.test.ts.snap b/packages/destination-actions/src/destinations/amazon-amc/syncAudiencesToDSP/__tests__/__snapshots__/index.test.ts.snap index c3a9bd030a..d702be20f5 100644 --- a/packages/destination-actions/src/destinations/amazon-amc/syncAudiencesToDSP/__tests__/__snapshots__/index.test.ts.snap +++ b/packages/destination-actions/src/destinations/amazon-amc/syncAudiencesToDSP/__tests__/__snapshots__/index.test.ts.snap @@ -1,165 +1,60 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`AmazonAds.syncAudiencesToDSP Normalise and Hash input with extra characters and spaces 1`] = ` -Object { - "afterResponse": Array [ - [Function], - [Function], - [Function], - ], - "beforeRequest": Array [ - [Function], - ], - "body": "{\\"records\\":[{\\"externalUserId\\":\\"test-kochar-01\\",\\"countryCode\\":\\"US\\",\\"action\\":\\"CREATE\\",\\"hashedPII\\":[{\\"address\\":\\"ebb357a6f604e4d893f034561b06fff712d9dbb7082c4b1808418115c5628017\\",\\"postal\\":\\"516b1543763b8b04f15897aeac07eba66f4e36fdac6945bacb6bdac57e44598a\\",\\"phone\\":\\"e1bfd73a5dc6262163ec42add4ebe0229f929db9b23644c1485dbccd05a36363\\",\\"city\\":\\"61a01e4b10bf579b267bdc16858c932339e8388537363c9c0961bcf5520c8897\\",\\"state\\":\\"7e8eea5cc60980270c9ceb75ce8c087d48d726110fd3d17921f774eefd8e18d8\\",\\"email\\":\\"c551027f06bd3f307ccd6abb61edc500def2680944c010e932ab5b27a3a8f151\\"}]}],\\"audienceId\\":379909525712777677}", - "headers": Headers { - Symbol(map): Object { - "amazon-advertising-api-clientid": Array [ - "", - ], - "authorization": Array [ - "Bearer undefined", - ], - "content-type": Array [ - "application/vnd.amcaudiences.v1+json", - ], - "user-agent": Array [ - "Segment (Actions)", - ], - }, - }, - "method": "POST", - "signal": AbortSignal { - Symbol(kEvents): Map {}, - Symbol(events.maxEventTargetListeners): 10, - Symbol(events.maxEventTargetListenersWarned): false, - Symbol(kAborted): false, - Symbol(kReason): undefined, - }, - "statsContext": Object {}, - "throwHttpErrors": true, - "timeout": 10000, -} -`; +exports[`AmazonAds.syncAudiencesToDSP Normalise and Hash input with extra characters and spaces 1`] = `"{\\"records\\":[{\\"externalUserId\\":\\"test-kochar-01\\",\\"countryCode\\":\\"US\\",\\"action\\":\\"CREATE\\",\\"hashedPII\\":[{\\"address\\":\\"ebb357a6f604e4d893f034561b06fff712d9dbb7082c4b1808418115c5628017\\",\\"postal\\":\\"516b1543763b8b04f15897aeac07eba66f4e36fdac6945bacb6bdac57e44598a\\",\\"phone\\":\\"e1bfd73a5dc6262163ec42add4ebe0229f929db9b23644c1485dbccd05a36363\\",\\"city\\":\\"61a01e4b10bf579b267bdc16858c932339e8388537363c9c0961bcf5520c8897\\",\\"state\\":\\"7e8eea5cc60980270c9ceb75ce8c087d48d726110fd3d17921f774eefd8e18d8\\",\\"email\\":\\"c551027f06bd3f307ccd6abb61edc500def2680944c010e932ab5b27a3a8f151\\"}]}],\\"audienceId\\":379909525712777677}"`; exports[`AmazonAds.syncAudiencesToDSP Normalise and Hash personally-identifiable input provided with SHA-256 1`] = ` -Object { - "afterResponse": Array [ - [Function], - [Function], - [Function], - ], - "beforeRequest": Array [ - [Function], - ], - "body": "{\\"records\\":[{\\"externalUserId\\":\\"test-kochar-01\\",\\"countryCode\\":\\"US\\",\\"action\\":\\"CREATE\\",\\"hashedPII\\":[{\\"firstname\\":\\"44104fcaef8476724152090d6d7bd9afa8ca5b385f6a99d3c6cf36b943b9872d\\",\\"phone\\":\\"63af7d494c194a90e1cf1db5371c13f97db650161aa803e67182c0dbaf668c7b\\",\\"state\\":\\"92db9c574d420b2437b29d898d55604f61df6c17f5163e53337f2169dd70d38d\\",\\"email\\":\\"c551027f06bd3f307ccd6abb61edc500def2680944c010e932ab5b27a3a8f151\\"}]}],\\"audienceId\\":379909525712777677}", - "headers": Headers { - Symbol(map): Object { - "amazon-advertising-api-clientid": Array [ - "", - ], - "authorization": Array [ - "Bearer undefined", - ], - "content-type": Array [ - "application/vnd.amcaudiences.v1+json", - ], - "user-agent": Array [ - "Segment (Actions)", - ], - }, +Headers { + Symbol(map): Object { + "amazon-advertising-api-clientid": Array [ + "", + ], + "authorization": Array [ + "Bearer undefined", + ], + "content-type": Array [ + "application/vnd.amcaudiences.v1+json", + ], + "user-agent": Array [ + "Segment (Actions)", + ], }, - "method": "POST", - "signal": AbortSignal { - Symbol(kEvents): Map {}, - Symbol(events.maxEventTargetListeners): 10, - Symbol(events.maxEventTargetListenersWarned): false, - Symbol(kAborted): false, - Symbol(kReason): undefined, - }, - "statsContext": Object {}, - "throwHttpErrors": true, - "timeout": 10000, } `; exports[`AmazonAds.syncAudiencesToDSP Should add user to audience when Event is Audience Entered 1`] = ` -Object { - "afterResponse": Array [ - [Function], - [Function], - [Function], - ], - "beforeRequest": Array [ - [Function], - ], - "body": "{\\"records\\":[{\\"externalUserId\\":\\"test-kochar-01\\",\\"countryCode\\":\\"US\\",\\"action\\":\\"CREATE\\",\\"hashedPII\\":[{\\"email\\":\\"c551027f06bd3f307ccd6abb61edc500def2680944c010e932ab5b27a3a8f151\\"}]}],\\"audienceId\\":379909525712777677}", - "headers": Headers { - Symbol(map): Object { - "amazon-advertising-api-clientid": Array [ - "", - ], - "authorization": Array [ - "Bearer undefined", - ], - "content-type": Array [ - "application/vnd.amcaudiences.v1+json", - ], - "user-agent": Array [ - "Segment (Actions)", - ], - }, - }, - "method": "POST", - "signal": AbortSignal { - Symbol(kEvents): Map {}, - Symbol(events.maxEventTargetListeners): 10, - Symbol(events.maxEventTargetListenersWarned): false, - Symbol(kAborted): false, - Symbol(kReason): undefined, +Headers { + Symbol(map): Object { + "amazon-advertising-api-clientid": Array [ + "", + ], + "authorization": Array [ + "Bearer undefined", + ], + "content-type": Array [ + "application/vnd.amcaudiences.v1+json", + ], + "user-agent": Array [ + "Segment (Actions)", + ], }, - "statsContext": Object {}, - "throwHttpErrors": true, - "timeout": 10000, } `; exports[`AmazonAds.syncAudiencesToDSP Should delete user from audience when Event is Audience Exited 1`] = ` -Object { - "afterResponse": Array [ - [Function], - [Function], - [Function], - ], - "beforeRequest": Array [ - [Function], - ], - "body": "{\\"records\\":[{\\"externalUserId\\":\\"test-kochar-01\\",\\"countryCode\\":\\"US\\",\\"action\\":\\"DELETE\\",\\"hashedPII\\":[{\\"email\\":\\"c551027f06bd3f307ccd6abb61edc500def2680944c010e932ab5b27a3a8f151\\"}]}],\\"audienceId\\":379909525712777677}", - "headers": Headers { - Symbol(map): Object { - "amazon-advertising-api-clientid": Array [ - "", - ], - "authorization": Array [ - "Bearer undefined", - ], - "content-type": Array [ - "application/vnd.amcaudiences.v1+json", - ], - "user-agent": Array [ - "Segment (Actions)", - ], - }, - }, - "method": "POST", - "signal": AbortSignal { - Symbol(kEvents): Map {}, - Symbol(events.maxEventTargetListeners): 10, - Symbol(events.maxEventTargetListenersWarned): false, - Symbol(kAborted): false, - Symbol(kReason): undefined, +Headers { + Symbol(map): Object { + "amazon-advertising-api-clientid": Array [ + "", + ], + "authorization": Array [ + "Bearer undefined", + ], + "content-type": Array [ + "application/vnd.amcaudiences.v1+json", + ], + "user-agent": Array [ + "Segment (Actions)", + ], }, - "statsContext": Object {}, - "throwHttpErrors": true, - "timeout": 10000, } `; diff --git a/packages/destination-actions/src/destinations/amazon-amc/syncAudiencesToDSP/__tests__/index.test.ts b/packages/destination-actions/src/destinations/amazon-amc/syncAudiencesToDSP/__tests__/index.test.ts index dd9aa7fa9e..461b5e74eb 100644 --- a/packages/destination-actions/src/destinations/amazon-amc/syncAudiencesToDSP/__tests__/index.test.ts +++ b/packages/destination-actions/src/destinations/amazon-amc/syncAudiencesToDSP/__tests__/index.test.ts @@ -137,7 +137,7 @@ describe('AmazonAds.syncAudiencesToDSP', () => { expect(response[0].options.body).toBe( '{"records":[{"externalUserId":"test-kochar-01","countryCode":"US","action":"CREATE","hashedPII":[{"email":"c551027f06bd3f307ccd6abb61edc500def2680944c010e932ab5b27a3a8f151"}]}],"audienceId":379909525712777677}' ) - expect(response[0].options).toMatchSnapshot() + expect(response[0].options.headers).toMatchSnapshot() }) it('Normalise and Hash personally-identifiable input provided with SHA-256', async () => { @@ -168,7 +168,7 @@ describe('AmazonAds.syncAudiencesToDSP', () => { expect(response[0].options.body).toBe( '{"records":[{"externalUserId":"test-kochar-01","countryCode":"US","action":"CREATE","hashedPII":[{"firstname":"44104fcaef8476724152090d6d7bd9afa8ca5b385f6a99d3c6cf36b943b9872d","phone":"63af7d494c194a90e1cf1db5371c13f97db650161aa803e67182c0dbaf668c7b","state":"92db9c574d420b2437b29d898d55604f61df6c17f5163e53337f2169dd70d38d","email":"c551027f06bd3f307ccd6abb61edc500def2680944c010e932ab5b27a3a8f151"}]}],"audienceId":379909525712777677}' ) - expect(response[0].options).toMatchSnapshot() + expect(response[0].options.headers).toMatchSnapshot() }) it('Normalise and Hash input with extra characters and spaces', async () => { @@ -204,7 +204,7 @@ describe('AmazonAds.syncAudiencesToDSP', () => { expect(response[0].options.body).toBe( '{"records":[{"externalUserId":"test-kochar-01","countryCode":"US","action":"CREATE","hashedPII":[{"address":"ebb357a6f604e4d893f034561b06fff712d9dbb7082c4b1808418115c5628017","postal":"516b1543763b8b04f15897aeac07eba66f4e36fdac6945bacb6bdac57e44598a","phone":"e1bfd73a5dc6262163ec42add4ebe0229f929db9b23644c1485dbccd05a36363","city":"61a01e4b10bf579b267bdc16858c932339e8388537363c9c0961bcf5520c8897","state":"7e8eea5cc60980270c9ceb75ce8c087d48d726110fd3d17921f774eefd8e18d8","email":"c551027f06bd3f307ccd6abb61edc500def2680944c010e932ab5b27a3a8f151"}]}],"audienceId":379909525712777677}' ) - expect(response[0].options).toMatchSnapshot() + expect(response[0].options.body).toMatchSnapshot() }) it('Should delete user from audience when Event is Audience Exited', async () => { @@ -228,7 +228,7 @@ describe('AmazonAds.syncAudiencesToDSP', () => { expect(response[0].options.body).toBe( '{"records":[{"externalUserId":"test-kochar-01","countryCode":"US","action":"DELETE","hashedPII":[{"email":"c551027f06bd3f307ccd6abb61edc500def2680944c010e932ab5b27a3a8f151"}]}],"audienceId":379909525712777677}' ) - expect(response[0].options).toMatchSnapshot() + expect(response[0].options.headers).toMatchSnapshot() }) it('should throw an error when an event has invalid externalUserId', async () => { await expect( diff --git a/packages/destination-actions/src/destinations/hubspot/upsertContact/__tests__/__snapshots__/index.test.ts.snap b/packages/destination-actions/src/destinations/hubspot/upsertContact/__tests__/__snapshots__/index.test.ts.snap index 90516dec21..f3f8f399d8 100644 --- a/packages/destination-actions/src/destinations/hubspot/upsertContact/__tests__/__snapshots__/index.test.ts.snap +++ b/packages/destination-actions/src/destinations/hubspot/upsertContact/__tests__/__snapshots__/index.test.ts.snap @@ -1,55 +1,10 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`HubSpot.upsertContactBatch Should update contact on the basis of secondary email if it's not getting mapped with Primary email addresses 1`] = ` -Object { - "afterResponse": Array [ - [Function], - [Function], - [Function], - ], - "beforeRequest": Array [ - [Function], - ], - "body": "{\\"properties\\":[\\"email\\",\\"lifecyclestage\\",\\"hs_additional_emails\\"],\\"idProperty\\":\\"email\\",\\"inputs\\":[{\\"id\\":\\"secondaryemail@gmail.com\\"}]}", - "headers": Headers { - Symbol(map): Object { - "authorization": Array [ - "Bearer undefined", - ], - "user-agent": Array [ - "Segment (Actions)", - ], - }, - }, - "json": Object { - "idProperty": "email", - "inputs": Array [ - Object { - "id": "secondaryemail@gmail.com", - }, - ], - "properties": Array [ - "email", - "lifecyclestage", - "hs_additional_emails", - ], - }, - "method": "POST", - "signal": AbortSignal { - Symbol(kEvents): Map {}, - Symbol(events.maxEventTargetListeners): 10, - Symbol(events.maxEventTargetListenersWarned): false, - Symbol(kAborted): false, - Symbol(kReason): undefined, - }, - "skipResponseCloning": true, - "statsContext": Object {}, - "throwHttpErrors": true, - "timeout": 10000, -} -`; +exports[`HubSpot.upsertContactBatch Should update contact on the basis of secondary email if it's not getting mapped with Primary email addresses 1`] = `"{\\"properties\\":[\\"email\\",\\"lifecyclestage\\",\\"hs_additional_emails\\"],\\"idProperty\\":\\"email\\",\\"inputs\\":[{\\"id\\":\\"secondaryemail@gmail.com\\"}]}"`; + +exports[`HubSpot.upsertContactBatch Should update contact on the basis of secondary email if it's not getting mapped with Primary email addresses 2`] = `"{\\"inputs\\":[{\\"id\\":\\"113\\",\\"properties\\":{\\"company\\":\\"Some Company\\",\\"phone\\":\\"+13134561129\\",\\"address\\":\\"Vancover st\\",\\"city\\":\\"San Francisco\\",\\"state\\":\\"California\\",\\"country\\":\\"USA\\",\\"zip\\":\\"600001\\",\\"website\\":\\"somecompany.com\\",\\"graduation_date\\":1664533942262}}]}"`; -exports[`HubSpot.upsertContactBatch Should update contact on the basis of secondary email if it's not getting mapped with Primary email addresses 2`] = ` +exports[`HubSpot.upsertContactBatch Should update contact on the basis of secondary email if it's not getting mapped with Primary email addresses 3`] = ` Object { "errors": Array [], "numErrors": 0, @@ -69,7 +24,7 @@ Object { } `; -exports[`HubSpot.upsertContactBatch Should update contact on the basis of secondary email if it's not getting mapped with Primary email addresses 3`] = ` +exports[`HubSpot.upsertContactBatch Should update contact on the basis of secondary email if it's not getting mapped with Primary email addresses 4`] = ` Object { "results": Array [ Object { @@ -88,65 +43,13 @@ Object { } `; -exports[`HubSpot.upsertContactBatch should create and update contact successfully 1`] = ` -Object { - "afterResponse": Array [ - [Function], - [Function], - [Function], - ], - "beforeRequest": Array [ - [Function], - ], - "body": "{\\"properties\\":[\\"email\\",\\"lifecyclestage\\",\\"hs_additional_emails\\"],\\"idProperty\\":\\"email\\",\\"inputs\\":[{\\"id\\":\\"userone@somecompany.com\\"},{\\"id\\":\\"usertwo@somecompany.com\\"},{\\"id\\":\\"userthree@somecompany.com\\"},{\\"id\\":\\"userfour@somecompany.com\\"}]}", - "headers": Headers { - Symbol(map): Object { - "authorization": Array [ - "Bearer undefined", - ], - "user-agent": Array [ - "Segment (Actions)", - ], - }, - }, - "json": Object { - "idProperty": "email", - "inputs": Array [ - Object { - "id": "userone@somecompany.com", - }, - Object { - "id": "usertwo@somecompany.com", - }, - Object { - "id": "userthree@somecompany.com", - }, - Object { - "id": "userfour@somecompany.com", - }, - ], - "properties": Array [ - "email", - "lifecyclestage", - "hs_additional_emails", - ], - }, - "method": "POST", - "signal": AbortSignal { - Symbol(kEvents): Map {}, - Symbol(events.maxEventTargetListeners): 10, - Symbol(events.maxEventTargetListenersWarned): false, - Symbol(kAborted): false, - Symbol(kReason): undefined, - }, - "skipResponseCloning": true, - "statsContext": Object {}, - "throwHttpErrors": true, - "timeout": 10000, -} -`; +exports[`HubSpot.upsertContactBatch should create and update contact successfully 1`] = `"{\\"properties\\":[\\"email\\",\\"lifecyclestage\\",\\"hs_additional_emails\\"],\\"idProperty\\":\\"email\\",\\"inputs\\":[{\\"id\\":\\"userone@somecompany.com\\"},{\\"id\\":\\"usertwo@somecompany.com\\"},{\\"id\\":\\"userthree@somecompany.com\\"},{\\"id\\":\\"userfour@somecompany.com\\"}]}"`; + +exports[`HubSpot.upsertContactBatch should create and update contact successfully 2`] = `"{\\"inputs\\":[{\\"properties\\":{\\"company\\":\\"Some Company\\",\\"phone\\":\\"+13134561129\\",\\"address\\":\\"Vancover st\\",\\"city\\":\\"San Francisco\\",\\"state\\":\\"California\\",\\"country\\":\\"USA\\",\\"zip\\":\\"600001\\",\\"email\\":\\"userone@somecompany.com\\",\\"website\\":\\"somecompany.com\\",\\"graduation_date\\":1664533942262}},{\\"properties\\":{\\"company\\":\\"Some Company\\",\\"phone\\":\\"+13134561129\\",\\"address\\":\\"Vancover st\\",\\"city\\":\\"San Francisco\\",\\"state\\":\\"California\\",\\"country\\":\\"USA\\",\\"zip\\":\\"600001\\",\\"email\\":\\"usertwo@somecompany.com\\",\\"website\\":\\"somecompany.com\\",\\"graduation_date\\":1664533942262}}]}"`; + +exports[`HubSpot.upsertContactBatch should create and update contact successfully 3`] = `"{\\"inputs\\":[{\\"id\\":\\"103\\",\\"properties\\":{\\"company\\":\\"Some Company\\",\\"phone\\":\\"+13134561129\\",\\"address\\":\\"Vancover st\\",\\"city\\":\\"San Francisco\\",\\"state\\":\\"California\\",\\"country\\":\\"USA\\",\\"zip\\":\\"600001\\",\\"website\\":\\"somecompany.com\\",\\"graduation_date\\":1664533942262}},{\\"id\\":\\"104\\",\\"properties\\":{\\"company\\":\\"Some Company\\",\\"phone\\":\\"+13134561129\\",\\"address\\":\\"Vancover st\\",\\"city\\":\\"San Francisco\\",\\"state\\":\\"California\\",\\"country\\":\\"USA\\",\\"zip\\":\\"600001\\",\\"website\\":\\"somecompany.com\\",\\"graduation_date\\":1664533942262}}]}"`; -exports[`HubSpot.upsertContactBatch should create and update contact successfully 2`] = ` +exports[`HubSpot.upsertContactBatch should create and update contact successfully 4`] = ` Object { "errors": Array [ Object { @@ -188,7 +91,7 @@ Object { } `; -exports[`HubSpot.upsertContactBatch should create and update contact successfully 3`] = ` +exports[`HubSpot.upsertContactBatch should create and update contact successfully 5`] = ` Object { "results": Array [ Object { @@ -218,7 +121,7 @@ Object { } `; -exports[`HubSpot.upsertContactBatch should create and update contact successfully 4`] = ` +exports[`HubSpot.upsertContactBatch should create and update contact successfully 6`] = ` Object { "results": Array [ Object { @@ -248,59 +151,11 @@ Object { } `; -exports[`HubSpot.upsertContactBatch should create contact successfully 1`] = ` -Object { - "afterResponse": Array [ - [Function], - [Function], - [Function], - ], - "beforeRequest": Array [ - [Function], - ], - "body": "{\\"properties\\":[\\"email\\",\\"lifecyclestage\\",\\"hs_additional_emails\\"],\\"idProperty\\":\\"email\\",\\"inputs\\":[{\\"id\\":\\"userone@somecompany.com\\"},{\\"id\\":\\"usertwo@somecompany.com\\"}]}", - "headers": Headers { - Symbol(map): Object { - "authorization": Array [ - "Bearer undefined", - ], - "user-agent": Array [ - "Segment (Actions)", - ], - }, - }, - "json": Object { - "idProperty": "email", - "inputs": Array [ - Object { - "id": "userone@somecompany.com", - }, - Object { - "id": "usertwo@somecompany.com", - }, - ], - "properties": Array [ - "email", - "lifecyclestage", - "hs_additional_emails", - ], - }, - "method": "POST", - "signal": AbortSignal { - Symbol(kEvents): Map {}, - Symbol(events.maxEventTargetListeners): 10, - Symbol(events.maxEventTargetListenersWarned): false, - Symbol(kAborted): false, - Symbol(kReason): undefined, - }, - "skipResponseCloning": true, - "statsContext": Object {}, - "throwHttpErrors": true, - "timeout": 10000, -} -`; +exports[`HubSpot.upsertContactBatch should create contact successfully 1`] = `"{\\"properties\\":[\\"email\\",\\"lifecyclestage\\",\\"hs_additional_emails\\"],\\"idProperty\\":\\"email\\",\\"inputs\\":[{\\"id\\":\\"userone@somecompany.com\\"},{\\"id\\":\\"usertwo@somecompany.com\\"}]}"`; + +exports[`HubSpot.upsertContactBatch should create contact successfully 2`] = `"{\\"inputs\\":[{\\"properties\\":{\\"company\\":\\"Some Company\\",\\"phone\\":\\"+13134561129\\",\\"address\\":\\"Vancover st\\",\\"city\\":\\"San Francisco\\",\\"state\\":\\"California\\",\\"country\\":\\"USA\\",\\"zip\\":\\"600001\\",\\"email\\":\\"userone@somecompany.com\\",\\"website\\":\\"somecompany.com\\",\\"graduation_date\\":1664533942262}},{\\"properties\\":{\\"company\\":\\"Some Company\\",\\"phone\\":\\"+13134561129\\",\\"address\\":\\"Vancover st\\",\\"city\\":\\"San Francisco\\",\\"state\\":\\"California\\",\\"country\\":\\"USA\\",\\"zip\\":\\"600001\\",\\"email\\":\\"usertwo@somecompany.com\\",\\"website\\":\\"somecompany.com\\",\\"graduation_date\\":1664533942262}}]}"`; -exports[`HubSpot.upsertContactBatch should create contact successfully 2`] = ` +exports[`HubSpot.upsertContactBatch should create contact successfully 3`] = ` Object { "errors": Array [ Object { @@ -321,7 +176,7 @@ Object { } `; -exports[`HubSpot.upsertContactBatch should create contact successfully 3`] = ` +exports[`HubSpot.upsertContactBatch should create contact successfully 4`] = ` Object { "results": Array [ Object { @@ -351,56 +206,15 @@ Object { } `; -exports[`HubSpot.upsertContactBatch should reset lifecyclestage and update if lifecyclestage is to be moved backwards 1`] = ` -Object { - "afterResponse": Array [ - [Function], - [Function], - [Function], - ], - "beforeRequest": Array [ - [Function], - ], - "body": "{\\"properties\\":[\\"email\\",\\"lifecyclestage\\",\\"hs_additional_emails\\"],\\"idProperty\\":\\"email\\",\\"inputs\\":[{\\"id\\":\\"userone@somecompany.com\\"}]}", - "headers": Headers { - Symbol(map): Object { - "authorization": Array [ - "Bearer undefined", - ], - "user-agent": Array [ - "Segment (Actions)", - ], - }, - }, - "json": Object { - "idProperty": "email", - "inputs": Array [ - Object { - "id": "userone@somecompany.com", - }, - ], - "properties": Array [ - "email", - "lifecyclestage", - "hs_additional_emails", - ], - }, - "method": "POST", - "signal": AbortSignal { - Symbol(kEvents): Map {}, - Symbol(events.maxEventTargetListeners): 10, - Symbol(events.maxEventTargetListenersWarned): false, - Symbol(kAborted): false, - Symbol(kReason): undefined, - }, - "skipResponseCloning": true, - "statsContext": Object {}, - "throwHttpErrors": true, - "timeout": 10000, -} -`; +exports[`HubSpot.upsertContactBatch should reset lifecyclestage and update if lifecyclestage is to be moved backwards 1`] = `"{\\"properties\\":[\\"email\\",\\"lifecyclestage\\",\\"hs_additional_emails\\"],\\"idProperty\\":\\"email\\",\\"inputs\\":[{\\"id\\":\\"userone@somecompany.com\\"}]}"`; + +exports[`HubSpot.upsertContactBatch should reset lifecyclestage and update if lifecyclestage is to be moved backwards 2`] = `"{\\"inputs\\":[{\\"id\\":\\"103\\",\\"properties\\":{\\"company\\":\\"Some Company\\",\\"phone\\":\\"+13134561129\\",\\"address\\":\\"Vancover st\\",\\"city\\":\\"San Francisco\\",\\"state\\":\\"California\\",\\"country\\":\\"USA\\",\\"zip\\":\\"600001\\",\\"website\\":\\"somecompany.com\\",\\"lifecyclestage\\":\\"subscriber\\",\\"graduation_date\\":1664533942262}}]}"`; + +exports[`HubSpot.upsertContactBatch should reset lifecyclestage and update if lifecyclestage is to be moved backwards 3`] = `"{\\"inputs\\":[{\\"id\\":\\"103\\",\\"properties\\":{\\"lifecyclestage\\":\\"\\"}}]}"`; -exports[`HubSpot.upsertContactBatch should reset lifecyclestage and update if lifecyclestage is to be moved backwards 2`] = ` +exports[`HubSpot.upsertContactBatch should reset lifecyclestage and update if lifecyclestage is to be moved backwards 4`] = `"{\\"inputs\\":[{\\"id\\":\\"103\\",\\"properties\\":{\\"lifecyclestage\\":\\"subscriber\\"}}]}"`; + +exports[`HubSpot.upsertContactBatch should reset lifecyclestage and update if lifecyclestage is to be moved backwards 5`] = ` Object { "errors": Array [], "numErrors": 0, @@ -420,7 +234,7 @@ Object { } `; -exports[`HubSpot.upsertContactBatch should reset lifecyclestage and update if lifecyclestage is to be moved backwards 3`] = ` +exports[`HubSpot.upsertContactBatch should reset lifecyclestage and update if lifecyclestage is to be moved backwards 6`] = ` Object { "results": Array [ Object { @@ -439,7 +253,7 @@ Object { } `; -exports[`HubSpot.upsertContactBatch should reset lifecyclestage and update if lifecyclestage is to be moved backwards 4`] = ` +exports[`HubSpot.upsertContactBatch should reset lifecyclestage and update if lifecyclestage is to be moved backwards 7`] = ` Object { "results": Array [ Object { @@ -458,7 +272,7 @@ Object { } `; -exports[`HubSpot.upsertContactBatch should reset lifecyclestage and update if lifecyclestage is to be moved backwards 5`] = ` +exports[`HubSpot.upsertContactBatch should reset lifecyclestage and update if lifecyclestage is to be moved backwards 8`] = ` Object { "results": Array [ Object { @@ -477,59 +291,11 @@ Object { } `; -exports[`HubSpot.upsertContactBatch should update contact successfully 1`] = ` -Object { - "afterResponse": Array [ - [Function], - [Function], - [Function], - ], - "beforeRequest": Array [ - [Function], - ], - "body": "{\\"properties\\":[\\"email\\",\\"lifecyclestage\\",\\"hs_additional_emails\\"],\\"idProperty\\":\\"email\\",\\"inputs\\":[{\\"id\\":\\"userthree@somecompany.com\\"},{\\"id\\":\\"userfour@somecompany.com\\"}]}", - "headers": Headers { - Symbol(map): Object { - "authorization": Array [ - "Bearer undefined", - ], - "user-agent": Array [ - "Segment (Actions)", - ], - }, - }, - "json": Object { - "idProperty": "email", - "inputs": Array [ - Object { - "id": "userthree@somecompany.com", - }, - Object { - "id": "userfour@somecompany.com", - }, - ], - "properties": Array [ - "email", - "lifecyclestage", - "hs_additional_emails", - ], - }, - "method": "POST", - "signal": AbortSignal { - Symbol(kEvents): Map {}, - Symbol(events.maxEventTargetListeners): 10, - Symbol(events.maxEventTargetListenersWarned): false, - Symbol(kAborted): false, - Symbol(kReason): undefined, - }, - "skipResponseCloning": true, - "statsContext": Object {}, - "throwHttpErrors": true, - "timeout": 10000, -} -`; +exports[`HubSpot.upsertContactBatch should update contact successfully 1`] = `"{\\"properties\\":[\\"email\\",\\"lifecyclestage\\",\\"hs_additional_emails\\"],\\"idProperty\\":\\"email\\",\\"inputs\\":[{\\"id\\":\\"userthree@somecompany.com\\"},{\\"id\\":\\"userfour@somecompany.com\\"}]}"`; -exports[`HubSpot.upsertContactBatch should update contact successfully 2`] = ` +exports[`HubSpot.upsertContactBatch should update contact successfully 2`] = `"{\\"inputs\\":[{\\"id\\":\\"103\\",\\"properties\\":{\\"company\\":\\"Some Company\\",\\"phone\\":\\"+13134561129\\",\\"address\\":\\"Vancover st\\",\\"city\\":\\"San Francisco\\",\\"state\\":\\"California\\",\\"country\\":\\"USA\\",\\"zip\\":\\"600001\\",\\"website\\":\\"somecompany.com\\",\\"graduation_date\\":1664533942262}},{\\"id\\":\\"104\\",\\"properties\\":{\\"company\\":\\"Some Company\\",\\"phone\\":\\"+13134561129\\",\\"address\\":\\"Vancover st\\",\\"city\\":\\"San Francisco\\",\\"state\\":\\"California\\",\\"country\\":\\"USA\\",\\"zip\\":\\"600001\\",\\"website\\":\\"somecompany.com\\",\\"graduation_date\\":1664533942262}}]}"`; + +exports[`HubSpot.upsertContactBatch should update contact successfully 3`] = ` Object { "errors": Array [], "numErrors": 0, @@ -559,7 +325,7 @@ Object { } `; -exports[`HubSpot.upsertContactBatch should update contact successfully 3`] = ` +exports[`HubSpot.upsertContactBatch should update contact successfully 4`] = ` Object { "results": Array [ Object { diff --git a/packages/destination-actions/src/destinations/hubspot/upsertContact/__tests__/index.test.ts b/packages/destination-actions/src/destinations/hubspot/upsertContact/__tests__/index.test.ts index ba5ce29c0a..713e0499fc 100644 --- a/packages/destination-actions/src/destinations/hubspot/upsertContact/__tests__/index.test.ts +++ b/packages/destination-actions/src/destinations/hubspot/upsertContact/__tests__/index.test.ts @@ -554,7 +554,8 @@ describe('HubSpot.upsertContactBatch', () => { events }) - expect(testBatchResponses[0].options).toMatchSnapshot() + expect(testBatchResponses[0].options.body).toMatchSnapshot() + expect(testBatchResponses[1].options.body).toMatchSnapshot() expect(testBatchResponses[0].data).toMatchSnapshot() expect(testBatchResponses[1].data).toMatchSnapshot() }) @@ -586,7 +587,8 @@ describe('HubSpot.upsertContactBatch', () => { events }) - expect(testBatchResponses[0].options).toMatchSnapshot() + expect(testBatchResponses[0].options.body).toMatchSnapshot() + expect(testBatchResponses[1].options.body).toMatchSnapshot() expect(testBatchResponses[0].data).toMatchSnapshot() expect(testBatchResponses[1].data).toMatchSnapshot() }) @@ -623,7 +625,9 @@ describe('HubSpot.upsertContactBatch', () => { events }) - expect(testBatchResponses[0].options).toMatchSnapshot() + expect(testBatchResponses[0].options.body).toMatchSnapshot() + expect(testBatchResponses[1].options.body).toMatchSnapshot() + expect(testBatchResponses[2].options.body).toMatchSnapshot() expect(testBatchResponses[0].data).toMatchSnapshot() expect(testBatchResponses[1].data).toMatchSnapshot() expect(testBatchResponses[2].data).toMatchSnapshot() @@ -711,7 +715,10 @@ describe('HubSpot.upsertContactBatch', () => { events }) - expect(testBatchResponses[0].options).toMatchSnapshot() + expect(testBatchResponses[0].options.body).toMatchSnapshot() + expect(testBatchResponses[1].options.body).toMatchSnapshot() + expect(testBatchResponses[2].options.body).toMatchSnapshot() + expect(testBatchResponses[3].options.body).toMatchSnapshot() expect(testBatchResponses[0].data).toMatchSnapshot() expect(testBatchResponses[1].data).toMatchSnapshot() expect(testBatchResponses[2].data).toMatchSnapshot() @@ -803,7 +810,8 @@ describe('HubSpot.upsertContactBatch', () => { events }) - expect(testBatchResponses[0].options).toMatchSnapshot() + expect(testBatchResponses[0].options.body).toMatchSnapshot() + expect(testBatchResponses[1].options.body).toMatchSnapshot() expect(testBatchResponses[0].data).toMatchSnapshot() expect(testBatchResponses[1].data).toMatchSnapshot() })