Skip to content

Commit

Permalink
Updated tests and dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
sayan-das-in committed Feb 5, 2025
1 parent 487278c commit 4132911
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 22 deletions.
2 changes: 1 addition & 1 deletion packages/destination-actions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"liquidjs": "^10.16.7",
"lodash": "^4.17.21",
"lru-cache": "10.4.3",
"ssh2-sftp-client": "^11.0.0"
"ssh2-sftp-client": "^10.0.3"
},
"jest": {
"preset": "ts-jest",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,9 @@ describe('Amplitude', () => {
expect(responses.length).toBe(1)
expect(responses[0].status).toBe(200)
expect(responses[0].data).toMatchObject({})
expect(responses[0].options.body).toMatchInlineSnapshot(`URLSearchParams {}`)
expect(responses[0].options.body.toString()).toMatchInlineSnapshot(
`"api_key=undefined&mapping=%5B%7B%22user_id%22%3A%22some-previous-user-id%22%2C%22global_user_id%22%3A%22some-user-id%22%7D%5D"`
)
})

it('should send data to the EU endpoint', async () => {
Expand All @@ -812,7 +814,9 @@ describe('Amplitude', () => {
expect(responses.length).toBe(1)
expect(responses[0].status).toBe(200)
expect(responses[0].data).toMatchObject({})
expect(responses[0].options.body).toMatchInlineSnapshot(`URLSearchParams {}`)
expect(responses[0].options.body.toString()).toMatchInlineSnapshot(
`"api_key=&mapping=%5B%7B%22user_id%22%3A%22some-previous-user-id%22%2C%22global_user_id%22%3A%22some-user-id%22%7D%5D"`
)
})
})

Expand Down Expand Up @@ -1979,7 +1983,9 @@ describe('Amplitude', () => {
expect(responses.length).toBe(1)
expect(responses[0].status).toBe(200)
expect(responses[0].data).toMatchObject({})
expect(responses[0].options.body).toMatchInlineSnapshot(`URLSearchParams {}`)
expect(responses[0].options.body.toString()).toMatchInlineSnapshot(
`"api_key=undefined&identification=%7B%22os_name%22%3A%22iOS%22%2C%22os_version%22%3A%229%22%2C%22device_manufacturer%22%3A%22Apple%22%2C%22device_model%22%3A%22iPhone%22%2C%22device_type%22%3A%22mobile%22%2C%22user_id%22%3A%22some-user-id%22%2C%22device_id%22%3A%22some-anonymous-id%22%2C%22user_properties%22%3A%7B%22some-trait-key%22%3A%22some-trait-value%22%7D%2C%22country%22%3A%22United+States%22%2C%22city%22%3A%22San+Francisco%22%2C%22language%22%3A%22en-US%22%2C%22platform%22%3A%22Web%22%2C%22library%22%3A%22segment%22%7D&options=undefined"`
)
})

it('should support referrer and utm user_properties', async () => {
Expand Down Expand Up @@ -2010,7 +2016,9 @@ describe('Amplitude', () => {
expect(responses.length).toBe(1)
expect(responses[0].status).toBe(200)
expect(responses[0].data).toMatchObject({})
expect(responses[0].options.body).toMatchInlineSnapshot(`URLSearchParams {}`)
expect(responses[0].options.body.toString()).toMatchInlineSnapshot(
`"api_key=undefined&identification=%7B%22user_id%22%3A%22some-user-id%22%2C%22device_id%22%3A%22some-anonymous-id%22%2C%22user_properties%22%3A%7B%22some-trait-key%22%3A%22some-trait-value%22%2C%22%24set%22%3A%7B%22utm_source%22%3A%22Newsletter%22%2C%22utm_medium%22%3A%22email%22%2C%22utm_campaign%22%3A%22TPS+Innovation+Newsletter%22%2C%22utm_term%22%3A%22tps+reports%22%2C%22utm_content%22%3A%22image+link%22%2C%22referrer%22%3A%22some-referrer%22%7D%2C%22%24setOnce%22%3A%7B%22initial_utm_source%22%3A%22Newsletter%22%2C%22initial_utm_medium%22%3A%22email%22%2C%22initial_utm_campaign%22%3A%22TPS+Innovation+Newsletter%22%2C%22initial_utm_term%22%3A%22tps+reports%22%2C%22initial_utm_content%22%3A%22image+link%22%2C%22initial_referrer%22%3A%22some-referrer%22%7D%7D%2C%22library%22%3A%22segment%22%7D&options=undefined"`
)
})

it('shouldnt append $ keys to user_properties if referrer/utm are not specified', async () => {
Expand All @@ -2029,7 +2037,9 @@ describe('Amplitude', () => {
expect(responses.length).toBe(1)
expect(responses[0].status).toBe(200)
expect(responses[0].data).toMatchObject({})
expect(responses[0].options.body).toMatchInlineSnapshot(`URLSearchParams {}`)
expect(responses[0].options.body.toString()).toMatchInlineSnapshot(
`"api_key=undefined&identification=%7B%22os_name%22%3A%22iOS%22%2C%22os_version%22%3A%229%22%2C%22device_manufacturer%22%3A%22Apple%22%2C%22device_model%22%3A%22iPhone%22%2C%22device_type%22%3A%22mobile%22%2C%22user_id%22%3A%22some-user-id%22%2C%22device_id%22%3A%22some-anonymous-id%22%2C%22user_properties%22%3A%7B%22some-trait-key%22%3A%22some-trait-value%22%7D%2C%22country%22%3A%22United+States%22%2C%22city%22%3A%22San+Francisco%22%2C%22language%22%3A%22en-US%22%2C%22platform%22%3A%22Web%22%2C%22library%22%3A%22segment%22%7D&options=undefined"`
)
})

it('should support parsing userAgent when the setting is true', async () => {
Expand Down Expand Up @@ -2060,7 +2070,9 @@ describe('Amplitude', () => {
expect(responses.length).toBe(1)
expect(responses[0].status).toBe(200)
expect(responses[0].data).toMatchObject({})
expect(responses[0].options.body).toMatchInlineSnapshot(`URLSearchParams {}`)
expect(responses[0].options.body.toString()).toMatchInlineSnapshot(
`"api_key=undefined&identification=%7B%22os_name%22%3A%22Mac+OS%22%2C%22os_version%22%3A%2253%22%2C%22device_model%22%3A%22Mac+OS%22%2C%22user_id%22%3A%22some-user-id%22%2C%22device_id%22%3A%22foo%22%2C%22user_properties%22%3A%7B%22some-trait-key%22%3A%22some-trait-value%22%7D%2C%22library%22%3A%22segment%22%7D&options=undefined"`
)
})

it('should not send parsed user agent properties when setting is false', async () => {
Expand Down Expand Up @@ -2091,7 +2103,9 @@ describe('Amplitude', () => {
expect(responses.length).toBe(1)
expect(responses[0].status).toBe(200)
expect(responses[0].data).toMatchObject({})
expect(responses[0].options.body).toMatchInlineSnapshot(`URLSearchParams {}`)
expect(responses[0].options.body.toString()).toMatchInlineSnapshot(
`"api_key=undefined&identification=%7B%22user_id%22%3A%22some-user-id%22%2C%22device_id%22%3A%22foo%22%2C%22user_properties%22%3A%7B%22some-trait-key%22%3A%22some-trait-value%22%7D%2C%22library%22%3A%22segment%22%7D&options=undefined"`
)
})

it('should change casing for device type when value is android', async () => {
Expand All @@ -2110,7 +2124,9 @@ describe('Amplitude', () => {

nock('https://api2.amplitude.com').post('/identify').reply(200, {})
const responses = await testDestination.testAction('identifyUser', { event, mapping, useDefaultMappings: true })
expect(responses[0].options.body).toMatchInlineSnapshot(`URLSearchParams {}`)
expect(responses[0].options.body.toString()).toMatchInlineSnapshot(
`"api_key=undefined&identification=%7B%22user_id%22%3A%22user1234%22%2C%22device_id%22%3A%22foo%22%2C%22user_properties%22%3A%7B%7D%2C%22platform%22%3A%22Android%22%2C%22library%22%3A%22segment%22%7D&options=undefined"`
)
})

it('should change casing for device type when value is ios', async () => {
Expand All @@ -2129,7 +2145,9 @@ describe('Amplitude', () => {

nock('https://api2.amplitude.com').post('/identify').reply(200, {})
const responses = await testDestination.testAction('identifyUser', { event, mapping, useDefaultMappings: true })
expect(responses[0].options.body).toMatchInlineSnapshot(`URLSearchParams {}`)
expect(responses[0].options.body.toString()).toMatchInlineSnapshot(
`"api_key=undefined&identification=%7B%22user_id%22%3A%22user1234%22%2C%22device_id%22%3A%22foo%22%2C%22user_properties%22%3A%7B%7D%2C%22platform%22%3A%22iOS%22%2C%22library%22%3A%22segment%22%7D&options=undefined"`
)
})

it('should send data to the EU endpoint', async () => {
Expand All @@ -2156,7 +2174,9 @@ describe('Amplitude', () => {
expect(responses.length).toBe(1)
expect(responses[0].status).toBe(200)
expect(responses[0].data).toMatchObject({})
expect(responses[0].options.body).toMatchInlineSnapshot(`URLSearchParams {}`)
expect(responses[0].options.body.toString()).toMatchInlineSnapshot(
`"api_key=&identification=%7B%22os_name%22%3A%22iOS%22%2C%22os_version%22%3A%229%22%2C%22device_manufacturer%22%3A%22Apple%22%2C%22device_model%22%3A%22iPhone%22%2C%22device_type%22%3A%22mobile%22%2C%22user_id%22%3A%22some-user-id%22%2C%22device_id%22%3A%22some-anonymous-id%22%2C%22user_properties%22%3A%7B%22some-trait-key%22%3A%22some-trait-value%22%7D%2C%22country%22%3A%22United+States%22%2C%22city%22%3A%22San+Francisco%22%2C%22language%22%3A%22en-US%22%2C%22platform%22%3A%22Web%22%2C%22library%22%3A%22segment%22%7D&options=undefined"`
)
})

it('should give precedence to OS properties over userAgent properties', async () => {
Expand Down Expand Up @@ -2191,7 +2211,9 @@ describe('Amplitude', () => {
expect(responses.length).toBe(1)
expect(responses[0].status).toBe(200)
expect(responses[0].data).toMatchObject({})
expect(responses[0].options.body).toMatchInlineSnapshot(`URLSearchParams {}`)
expect(responses[0].options.body.toString()).toMatchInlineSnapshot(
`"api_key=undefined&identification=%7B%22os_name%22%3A%22iPhone+OS%22%2C%22os_version%22%3A%228.1.3%22%2C%22device_model%22%3A%22Mac+OS%22%2C%22user_id%22%3A%22some-user-id%22%2C%22device_id%22%3A%22foo%22%2C%22user_properties%22%3A%7B%22some-trait-key%22%3A%22some-trait-value%22%7D%2C%22library%22%3A%22segment%22%7D&options=undefined"`
)
})
})

Expand Down Expand Up @@ -2224,7 +2246,9 @@ describe('Amplitude', () => {

expect(response.status).toBe(200)
expect(response.data).toMatchObject({})
expect(response.options.body).toMatchInlineSnapshot(`URLSearchParams {}`)
expect(response.options.body.toString()).toMatchInlineSnapshot(
`"api_key=undefined&identification=%5B%7B%22device_id%22%3A%22some-anonymous-id%22%2C%22groups%22%3A%7B%22some-type%22%3A%22some-value%22%7D%2C%22insert_id%22%3A%22some-insert-id%22%2C%22library%22%3A%22segment%22%2C%22time%22%3A1618245157710%2C%22user_id%22%3A%22some-user-id%22%2C%22user_properties%22%3A%7B%22some-type%22%3A%22some-value%22%7D%7D%5D&options=undefined"`
)
})

it('should fire groupidentify call to Amplitude', async () => {
Expand All @@ -2239,7 +2263,9 @@ describe('Amplitude', () => {

expect(response.status).toBe(200)
expect(response.data).toMatchObject({})
expect(response.options.body).toMatchInlineSnapshot(`URLSearchParams {}`)
expect(response.options.body.toString()).toMatchInlineSnapshot(
`"api_key=undefined&identification=%5B%7B%22group_properties%22%3A%7B%22some-trait-key%22%3A%22some-trait-value%22%7D%2C%22group_value%22%3A%22some-value%22%2C%22group_type%22%3A%22some-type%22%2C%22library%22%3A%22segment%22%7D%5D&options=undefined"`
)
})

it('should fire identify call to Amplitude EU endpoint', async () => {
Expand All @@ -2259,7 +2285,9 @@ describe('Amplitude', () => {

expect(response.status).toBe(200)
expect(response.data).toMatchObject({})
expect(response.options.body).toMatchInlineSnapshot(`URLSearchParams {}`)
expect(response.options.body.toString()).toMatchInlineSnapshot(
`"api_key=&identification=%5B%7B%22device_id%22%3A%22some-anonymous-id%22%2C%22groups%22%3A%7B%22some-type%22%3A%22some-value%22%7D%2C%22insert_id%22%3A%22some-insert-id%22%2C%22library%22%3A%22segment%22%2C%22time%22%3A1618245157710%2C%22user_id%22%3A%22some-user-id%22%2C%22user_properties%22%3A%7B%22some-type%22%3A%22some-value%22%7D%7D%5D&options=undefined"`
)
})

it('should fire groupidentify call to Amplitude EU endpoint', async () => {
Expand All @@ -2279,7 +2307,9 @@ describe('Amplitude', () => {

expect(response.status).toBe(200)
expect(response.data).toMatchObject({})
expect(response.options.body).toMatchInlineSnapshot(`URLSearchParams {}`)
expect(response.options.body.toString()).toMatchInlineSnapshot(
`"api_key=&identification=%5B%7B%22group_properties%22%3A%7B%22some-trait-key%22%3A%22some-trait-value%22%7D%2C%22group_value%22%3A%22some-value%22%2C%22group_type%22%3A%22some-type%22%2C%22library%22%3A%22segment%22%7D%5D&options=undefined"`
)
})
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ describe('shared', () => {
expect(r.ops.length).toEqual(5)
expect(r.processConsent).toEqual(true)
expect(r.toJsonString()).toMatchInlineSnapshot(
`"{\\"ops\\":[{\\"userId\\":\\"CAESEHIV8HXNp0pFdHgi2rElMfk\\",\\"userIdType\\":\\"GOOGLE_USER_ID\\",\\"userListId\\":\\"456\\",\\"delete\\":false},{\\"userId\\":\\"3b6e47b3-1437-4ba2-b3c9-446e4d0cd1e5\\",\\"userIdType\\":\\"IDFA\\",\\"userListId\\":\\"456\\",\\"delete\\":false},{\\"userId\\":\\"my-anon-id-42\\",\\"userIdType\\":\\"PARTNER_PROVIDED_ID\\",\\"userListId\\":\\"456\\",\\"delete\\":false},{\\"userId\\":\\"my-anon-id-43\\",\\"userIdType\\":\\"PARTNER_PROVIDED_ID\\",\\"userListId\\":\\"456\\",\\"delete\\":false},{\\"userId\\":\\"XNp0pFdHgi2rElMfk\\",\\"userIdType\\":\\"GOOGLE_USER_ID\\",\\"userListId\\":\\"456\\",\\"delete\\":false}],\\"processConsent\\":true}"`
`"{\\"ops\\":[{\\"userId\\":\\"CAESEHIV8HXNp0pFdHgi2rElMfk\\",\\"userListId\\":\\"456\\",\\"delete\\":false,\\"userIdType\\":\\"GOOGLE_USER_ID\\"},{\\"userId\\":\\"3b6e47b3-1437-4ba2-b3c9-446e4d0cd1e5\\",\\"userListId\\":\\"456\\",\\"delete\\":false,\\"userIdType\\":\\"IDFA\\"},{\\"userId\\":\\"my-anon-id-42\\",\\"userListId\\":\\"456\\",\\"delete\\":false,\\"userIdType\\":\\"PARTNER_PROVIDED_ID\\"},{\\"userId\\":\\"my-anon-id-43\\",\\"userListId\\":\\"456\\",\\"delete\\":false,\\"userIdType\\":\\"PARTNER_PROVIDED_ID\\"},{\\"userId\\":\\"XNp0pFdHgi2rElMfk\\",\\"userListId\\":\\"456\\",\\"delete\\":false,\\"userIdType\\":\\"GOOGLE_USER_ID\\"}],\\"processConsent\\":true}"`
)
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ describe('Twilio', () => {
expect(responses.length).toBe(1)
expect(responses[0].status).toBe(201)

expect(responses[0].options.body).toMatchInlineSnapshot(`URLSearchParams {}`)
expect(responses[0].options.body.toString()).toMatchInlineSnapshot(
`"From=%2B12056065576&To=%2B17758638863&Body=Hello%2C+World%21&MediaUrl=https%3A%2F%2Fdemo.twilio.com%2Fowl.png"`
)

expect(responses[0].request.headers).toMatchInlineSnapshot(`
Headers {
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -16187,10 +16187,10 @@ sprintf-js@~1.0.2:
resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c"
integrity sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=

ssh2-sftp-client@^11.0.0:
version "11.0.0"
resolved "https://registry.yarnpkg.com/ssh2-sftp-client/-/ssh2-sftp-client-11.0.0.tgz#86909d9b02ab09cb47ec45a1c287c97dafd44b3d"
integrity sha512-lOjgNYtioYquhtgyHwPryFNhllkuENjvCKkUXo18w/Q4UpEffCnEUBfiOTlwFdKIhG1rhrOGnA6DeKPSF2CP6w==
ssh2-sftp-client@^10.0.3:
version "10.0.3"
resolved "https://registry.yarnpkg.com/ssh2-sftp-client/-/ssh2-sftp-client-10.0.3.tgz#aa8f9b875b745a0b6108692f576343437e428a86"
integrity sha512-Wlhasz/OCgrlqC8IlBZhF19Uw/X/dHI8ug4sFQybPE+0sDztvgvDf7Om6o7LbRLe68E7XkFZf3qMnqAvqn1vkQ==
dependencies:
concat-stream "^2.0.0"
promise-retry "^2.0.1"
Expand Down

0 comments on commit 4132911

Please sign in to comment.