From 095a563e9fac8b860f4b3ce777dfa09b75362633 Mon Sep 17 00:00:00 2001 From: Sai Sankeerth Date: Tue, 24 Oct 2023 05:33:15 +0100 Subject: [PATCH] chore: clean-up vero tests Signed-off-by: Sai Sankeerth --- test/__tests__/data/vero.json | 559 -------------------- test/__tests__/data/vero_router_input.json | 88 --- test/__tests__/data/vero_router_output.json | 175 ------ test/__tests__/vero.test.js | 46 -- 4 files changed, 868 deletions(-) delete mode 100644 test/__tests__/data/vero.json delete mode 100644 test/__tests__/data/vero_router_input.json delete mode 100644 test/__tests__/data/vero_router_output.json delete mode 100644 test/__tests__/vero.test.js diff --git a/test/__tests__/data/vero.json b/test/__tests__/data/vero.json deleted file mode 100644 index 7a524a7da0..0000000000 --- a/test/__tests__/data/vero.json +++ /dev/null @@ -1,559 +0,0 @@ -[ - { - "description": "Identify Call with userId only", - "input": { - "destination": { - "Config": { - "authToken": "testAuthToken" - } - }, - "message": { - "context": { - "traits": { - "homwTown": "kanpur", - "age": "24" - } - }, - "type": "Identify", - "userId": "yash001", - "originalTimestamp": "2019-10-14T09:03:17.562Z" - } - }, - "output": [ - { - "version": "1", - "type": "REST", - "method": "POST", - "endpoint": "https://api.getvero.com/api/v2/users/track", - "headers": {}, - "params": {}, - "body": { - "JSON": { - "id": "yash001", - "data": { - "homwTown": "kanpur", - "age": "24" - }, - "auth_token": "testAuthToken" - }, - "JSON_ARRAY": {}, - "XML": {}, - "FORM": {} - }, - "files": {} - } - ] - }, - { - "description": "Identify Call with both userId and email", - "input": { - "destination": { - "Config": { - "authToken": "testAuthToken" - } - }, - "message": { - "context": { - "traits": { - "email": "user1001@tech.com" - } - }, - "type": "Identify", - "userId": "user1001" - } - }, - "output": [ - { - "version": "1", - "type": "REST", - "method": "POST", - "endpoint": "https://api.getvero.com/api/v2/users/track", - "headers": {}, - "params": {}, - "body": { - "JSON": { - "id": "user1001", - "email": "user1001@tech.com", - "data": {}, - "auth_token": "testAuthToken" - }, - "JSON_ARRAY": {}, - "XML": {}, - "FORM": {} - }, - "files": {} - } - ] - }, - { - "description": "Identify Call with anonymousId and email only", - "input": { - "destination": { - "Config": { - "authToken": "testAuthToken" - } - }, - "message": { - "context": { - "traits": { - "email": "user1002@tech.com" - } - }, - "type": "Identify", - "anonymousId": "b4ffheww8eisndbdjgdewifewfgerwibderv" - } - }, - "output": [ - { - "version": "1", - "type": "REST", - "method": "POST", - "endpoint": "https://api.getvero.com/api/v2/users/track", - "headers": {}, - "params": {}, - "body": { - "JSON": { - "id": "b4ffheww8eisndbdjgdewifewfgerwibderv", - "email": "user1002@tech.com", - "data": {}, - "auth_token": "testAuthToken" - }, - "JSON_ARRAY": {}, - "XML": {}, - "FORM": {} - }, - "files": {} - } - ] - }, - { - "description": "Add tags in identify call", - "input": { - "destination": { - "Config": { - "authToken": "testAuthToken" - } - }, - "message": { - "context": { - "traits": { - "address": "Caravela Beach Goa", - "homwTown": "Mawsynram", - "email": "user1005@tech.com" - } - }, - "integrations": { - "vero": { - "tags": { - "add": ["a", "b"] - } - } - }, - "type": "Identify", - "userId": "fprediruser001" - } - }, - "output": [ - { - "version": "1", - "type": "REST", - "method": "POST", - "endpoint": "https://api.getvero.com/api/v2/users/track", - "headers": {}, - "params": {}, - "body": { - "JSON": { - "id": "fprediruser001", - "email": "user1005@tech.com", - "data": { - "address": "Caravela Beach Goa", - "homwTown": "Mawsynram" - }, - "auth_token": "testAuthToken" - }, - "JSON_ARRAY": {}, - "XML": {}, - "FORM": {} - }, - "files": {} - }, - { - "version": "1", - "type": "REST", - "method": "PUT", - "endpoint": "https://api.getvero.com/api/v2/users/tags/edit", - "headers": {}, - "params": {}, - "body": { - "JSON": { - "auth_token": "testAuthToken", - "id": "fprediruser001", - "add": ["a", "b"] - }, - "JSON_ARRAY": {}, - "XML": {}, - "FORM": {} - }, - "files": {} - } - ] - }, - { - "description": "Track Call with nonexistent userId- Creates new user with event", - "input": { - "destination": { - "Config": { - "authToken": "testAuthToken" - } - }, - "message": { - "event": "Random event with nonexisting userId and email", - "properties": { - "movieWatched": 3, - "gamesPlayed": 4, - "email": "eventIdn01@sample.com" - }, - "type": "track", - "userId": "eventIdn01" - } - }, - "output": [ - { - "version": "1", - "type": "REST", - "method": "POST", - "endpoint": "https://api.getvero.com/api/v2/events/track", - "headers": {}, - "params": {}, - "body": { - "JSON": { - "identity": { - "id": "eventIdn01", - "email": "eventIdn01@sample.com" - }, - "event_name": "Random event with nonexisting userId and email", - "data": { - "movieWatched": 3, - "gamesPlayed": 4, - "email": "eventIdn01@sample.com" - }, - "auth_token": "testAuthToken" - }, - "JSON_ARRAY": {}, - "XML": {}, - "FORM": {} - }, - "files": {} - } - ] - }, - { - "description": "Track Call with already existing userId and removing tags", - "input": { - "destination": { - "Config": { - "authToken": "testAuthToken" - } - }, - "message": { - "event": "Random event with existing userId and some tags removed", - "properties": { - "movieWatched": 3, - "gamesPlayed": 4, - "email": "eventIdn01@sample.com" - }, - "integrations": { - "Vero": { - "tags": { - "remove": ["a"] - } - } - }, - "type": "track", - "userId": "fprediruser001" - } - }, - "output": [ - { - "version": "1", - "type": "REST", - "method": "POST", - "endpoint": "https://api.getvero.com/api/v2/events/track", - "headers": {}, - "params": {}, - "body": { - "JSON": { - "identity": { - "id": "fprediruser001", - "email": "eventIdn01@sample.com" - }, - "event_name": "Random event with existing userId and some tags removed", - "data": { - "movieWatched": 3, - "gamesPlayed": 4, - "email": "eventIdn01@sample.com" - }, - "auth_token": "testAuthToken" - }, - "JSON_ARRAY": {}, - "XML": {}, - "FORM": {} - }, - "files": {} - }, - { - "version": "1", - "type": "REST", - "method": "PUT", - "endpoint": "https://api.getvero.com/api/v2/users/tags/edit", - "headers": {}, - "params": {}, - "body": { - "JSON": { - "auth_token": "testAuthToken", - "id": "fprediruser001", - "remove": ["a"] - }, - "JSON_ARRAY": {}, - "XML": {}, - "FORM": {} - }, - "files": {} - } - ] - }, - { - "description": "Alias Call - Merge two user profiles", - "input": { - "destination": { - "Config": { - "authToken": "testAuthToken" - } - }, - "message": { - "type": "alias", - "userId": "sample101", - "previousId": "newsamplel01" - } - }, - "output": { - "version": "1", - "type": "REST", - "method": "PUT", - "endpoint": "https://api.getvero.com/api/v2/users/reidentify", - "headers": {}, - "params": {}, - "body": { - "JSON": { - "new_id": "sample101", - "id": "newsamplel01", - "auth_token": "testAuthToken" - }, - "JSON_ARRAY": {}, - "XML": {}, - "FORM": {} - }, - "files": {} - } - }, - { - "description": "Identify Call with valid channels", - "input": { - "destination": { - "Config": { - "authToken": "testAuthToken" - } - }, - "message": { - "context": { - "traits": { - "email": "user1001@tech.com" - }, - "os": { - "name": "android" - }, - "device": { - "token": "qwertyuioiuytrewwertyu", - "name": "Mi" - } - }, - "type": "Identify", - "userId": "user1001" - } - }, - "output": [ - { - "version": "1", - "type": "REST", - "method": "POST", - "endpoint": "https://api.getvero.com/api/v2/users/track", - "headers": {}, - "params": {}, - "body": { - "JSON": { - "id": "user1001", - "email": "user1001@tech.com", - "channels": { - "platform": "android", - "address": "qwertyuioiuytrewwertyu", - "device": "Mi", - "type": "push" - }, - "data": {}, - "auth_token": "testAuthToken" - }, - "JSON_ARRAY": {}, - "XML": {}, - "FORM": {} - }, - "files": {} - } - ] - }, - { - "description": "Identify Call with invalid channels", - "input": { - "destination": { - "Config": { - "authToken": "testAuthToken" - } - }, - "message": { - "context": { - "traits": { - "email": "user1001@tech.com" - }, - "device": { - "token": "qwertyuioiuytrewwertyu", - "name": "Mi" - } - }, - "type": "Identify", - "userId": "user1001" - } - }, - "output": [ - { - "version": "1", - "type": "REST", - "method": "POST", - "endpoint": "https://api.getvero.com/api/v2/users/track", - "headers": {}, - "params": {}, - "body": { - "JSON": { - "id": "user1001", - "email": "user1001@tech.com", - "data": {}, - "auth_token": "testAuthToken" - }, - "JSON_ARRAY": {}, - "XML": {}, - "FORM": {} - }, - "files": {} - } - ] - }, - { - "description": "Track Call to unsubscribe a userId", - "input": { - "destination": { - "Config": { - "authToken": "testAuthToken" - } - }, - "message": { - "event": "unsubscribe", - "type": "track", - "userId": "eventIdn01" - } - }, - "output": { - "version": "1", - "type": "REST", - "method": "POST", - "endpoint": "https://api.getvero.com/api/v2/users/unsubscribe", - "headers": {}, - "params": {}, - "body": { - "JSON": { - "id": "eventIdn01", - "auth_token": "testAuthToken" - }, - "JSON_ARRAY": {}, - "XML": {}, - "FORM": {} - }, - "files": {} - } - }, - { - "description": "Page Call with an existing userID", - "input": { - "destination": { - "Config": { - "authToken": "testAuthToken" - } - }, - "message": { - "name": "Rudderstack", - "properties": { - "title": "rudderstack", - "path": "/" - }, - "type": "page", - "userId": "eventIdn01" - } - }, - "output": { - "version": "1", - "type": "REST", - "method": "POST", - "endpoint": "https://api.getvero.com/api/v2/events/track", - "headers": {}, - "params": {}, - "body": { - "JSON": { - "identity": { - "id": "eventIdn01" - }, - "event_name": "Viewed Rudderstack Page", - "data": { - "title": "rudderstack", - "path": "/" - }, - "auth_token": "testAuthToken" - }, - "JSON_ARRAY": {}, - "XML": {}, - "FORM": {} - }, - "files": {} - } - }, - { - "description": "Error flow - message type not supported", - "input": { - "destination": { - "Config": { - "authToken": "testAuthToken" - } - }, - "message": { - "groupId": "1234", - "traits": { - "name": "MyGroup", - "industry": "IT", - "employees": 450, - "plan": "basic" - }, - "type": "group", - "userId": "eventIdn01" - } - }, - "output": { - "error": "Event type group is not supported" - } - } -] diff --git a/test/__tests__/data/vero_router_input.json b/test/__tests__/data/vero_router_input.json deleted file mode 100644 index 749ea11dfd..0000000000 --- a/test/__tests__/data/vero_router_input.json +++ /dev/null @@ -1,88 +0,0 @@ -[ - { - "destination": { - "Config": { - "authToken": "testAuthToken" - } - }, - "metadata": { - "jobId": 1 - }, - "message": { - "context": { - "traits": { - "email": "user001@tech.com" - } - }, - "type": "Identify", - "userId": "user001" - } - }, - { - "destination": { - "Config": { - "authToken": "testAuthToken" - } - }, - "metadata": { - "jobId": 2 - }, - "message": { - "context": { - "traits": { - "email": "user002@tech.com" - } - }, - "type": "Identify", - "anonymousId": "b4ffheww8eisndbdjgdewifewfgerwibderv" - } - }, - { - "destination": { - "Config": { - "authToken": "testAuthToken" - } - }, - "metadata": { - "jobId": 3 - }, - "message": { - "context": { - "traits": { - "address": "Caravela Beach Goa", - "homwTown": "Mawsynram", - "email": "user005@tech.com" - } - }, - "integrations": { - "vero": { - "tags": { - "add": ["a", "b"] - } - } - }, - "type": "Identify", - "userId": "fprediruser001" - } - }, - { - "destination": { - "Config": { - "authToken": "testAuthToken" - } - }, - "metadata": { - "jobId": 4 - }, - "message": { - "event": "Random event with nonexisting userId and email", - "properties": { - "movieWatched": 3, - "gamesPlayed": 4, - "email": "eventIdn02@sample.com" - }, - "type": "track", - "userId": "eventIdn01" - } - } -] diff --git a/test/__tests__/data/vero_router_output.json b/test/__tests__/data/vero_router_output.json deleted file mode 100644 index 293b351251..0000000000 --- a/test/__tests__/data/vero_router_output.json +++ /dev/null @@ -1,175 +0,0 @@ -[ - { - "batched": false, - "batchedRequest": [ - { - "version": "1", - "type": "REST", - "method": "POST", - "endpoint": "https://api.getvero.com/api/v2/users/track", - "headers": {}, - "params": {}, - "body": { - "JSON": { - "id": "user001", - "email": "user001@tech.com", - "data": {}, - "auth_token": "testAuthToken" - }, - "JSON_ARRAY": {}, - "XML": {}, - "FORM": {} - }, - "files": {} - } - ], - "destination": { - "Config": { - "authToken": "testAuthToken" - } - }, - "metadata": [ - { - "jobId": 1 - } - ], - "statusCode": 200 - }, - { - "batched": false, - "batchedRequest": [ - { - "version": "1", - "type": "REST", - "method": "POST", - "endpoint": "https://api.getvero.com/api/v2/users/track", - "headers": {}, - "params": {}, - "body": { - "JSON": { - "id": "b4ffheww8eisndbdjgdewifewfgerwibderv", - "email": "user002@tech.com", - "data": {}, - "auth_token": "testAuthToken" - }, - "JSON_ARRAY": {}, - "XML": {}, - "FORM": {} - }, - "files": {} - } - ], - "destination": { - "Config": { - "authToken": "testAuthToken" - } - }, - "metadata": [ - { - "jobId": 2 - } - ], - "statusCode": 200 - }, - { - "batched": false, - "batchedRequest": [ - { - "version": "1", - "type": "REST", - "method": "POST", - "endpoint": "https://api.getvero.com/api/v2/users/track", - "headers": {}, - "params": {}, - "body": { - "JSON": { - "id": "fprediruser001", - "email": "user005@tech.com", - "data": { - "address": "Caravela Beach Goa", - "homwTown": "Mawsynram" - }, - "auth_token": "testAuthToken" - }, - "JSON_ARRAY": {}, - "XML": {}, - "FORM": {} - }, - "files": {} - }, - { - "version": "1", - "type": "REST", - "method": "PUT", - "endpoint": "https://api.getvero.com/api/v2/users/tags/edit", - "headers": {}, - "params": {}, - "body": { - "JSON": { - "auth_token": "testAuthToken", - "id": "fprediruser001", - "add": ["a", "b"] - }, - "JSON_ARRAY": {}, - "XML": {}, - "FORM": {} - }, - "files": {} - } - ], - "destination": { - "Config": { - "authToken": "testAuthToken" - } - }, - "metadata": [ - { - "jobId": 3 - } - ], - "statusCode": 200 - }, - { - "batched": false, - "batchedRequest": [ - { - "version": "1", - "type": "REST", - "method": "POST", - "endpoint": "https://api.getvero.com/api/v2/events/track", - "headers": {}, - "params": {}, - "body": { - "JSON": { - "identity": { - "id": "eventIdn01", - "email": "eventIdn02@sample.com" - }, - "event_name": "Random event with nonexisting userId and email", - "data": { - "movieWatched": 3, - "gamesPlayed": 4, - "email": "eventIdn02@sample.com" - }, - "auth_token": "testAuthToken" - }, - "JSON_ARRAY": {}, - "XML": {}, - "FORM": {} - }, - "files": {} - } - ], - "destination": { - "Config": { - "authToken": "testAuthToken" - } - }, - "metadata": [ - { - "jobId": 4 - } - ], - "statusCode": 200 - } -] diff --git a/test/__tests__/vero.test.js b/test/__tests__/vero.test.js deleted file mode 100644 index b0b1d130ff..0000000000 --- a/test/__tests__/vero.test.js +++ /dev/null @@ -1,46 +0,0 @@ -const integration = "vero"; -const name = "vero"; - -const fs = require("fs"); -const path = require("path"); - -const version = "v0"; -const transformer = require(`../../src/${version}/destinations/${integration}/transform`); - -// Processor Test Data -const testDataFile = fs.readFileSync( - path.resolve(__dirname, `./data/${integration}.json`) -); -const testData = JSON.parse(testDataFile); - -// Router Test Data -const inputRouterDataFile = fs.readFileSync( - path.resolve(__dirname, `./data/${integration}_router_input.json`) -); -const outputRouterDataFile = fs.readFileSync( - path.resolve(__dirname, `./data/${integration}_router_output.json`) -); -const inputRouterData = JSON.parse(inputRouterDataFile); -const expectedRouterData = JSON.parse(outputRouterDataFile); - -describe(`${name} Tests`, () => { - describe("Processor", () => { - testData.forEach((dataPoint, index) => { - it(`${index}. ${integration} - ${dataPoint.description}`, async () => { - try { - const output = await transformer.process(dataPoint.input); - expect(output).toEqual(dataPoint.output); - } catch (error) { - expect(error.message).toEqual(dataPoint.output.error); - } - }); - }); - }); - - describe("Router Tests", () => { - it("Payload", async () => { - const routerOutput = await transformer.processRouterDest(inputRouterData); - expect(routerOutput).toEqual(expectedRouterData); - }); - }); -});