Skip to content

Commit

Permalink
added test cases and small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
anantjain45823 committed Sep 10, 2023
1 parent b35af16 commit f54278a
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 15 deletions.
12 changes: 9 additions & 3 deletions src/configurations/destinations/slack/db-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
"transformAt": "processor",
"transformAtV1": "processor",
"saveDestinationResponse": true,
"includeKeys": ["oneTrustCookieCategories"],
"includeKeys": [
"oneTrustCookieCategories"
],
"excludeKeys": [],
"supportedSourceTypes": [
"android",
Expand All @@ -20,10 +22,14 @@
"cordova",
"shopify"
],
"supportedMessageTypes": ["identify", "track"],
"supportedMessageTypes": [
"identify",
"track"
],
"destConfig": {
"defaultConfig": [
"eventChannelSettings",
"incomingWebhooksType",
"identifyTemplate",
"eventTemplateSettings",
"webhookUrl",
Expand All @@ -33,4 +39,4 @@
},
"secretKeys": []
}
}
}
28 changes: 24 additions & 4 deletions src/configurations/destinations/slack/schema.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"configSchema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"required": ["webhookUrl"],
"required": [
"webhookUrl"
],
"type": "object",
"properties": {
"eventChannelSettings": {
Expand All @@ -13,14 +15,29 @@
"type": "string",
"pattern": "(^\\{\\{.*\\|\\|(.*)\\}\\}$)|(^env[.].+)|^(.{0,100})$"
},
"eventChannel": {
"type": "string",
"pattern": "(^\\{\\{.*\\|\\|(.*)\\}\\}$)|(^env[.].+)|^(.{0,100})$"
},
"eventChannelWebhook": {
"type": "string",
"pattern": "(^\\{\\{.*\\|\\|(.*)\\}\\}$)|(^env[.].+)|(?!.*\\.ngrok\\.io)^(.{0,100})$"
},
"eventRegex": { "type": "boolean", "default": false }
"eventRegex": {
"type": "boolean",
"default": false
}
}
}
},
"incomingWebhooksType": {
"type": "string",
"enum": [
"legacy",
"modern"
],
"default": "legacy"
},
"identifyTemplate": {
"type": "string",
"pattern": "(^\\{\\{.*\\|\\|(.*)\\}\\}$)|(^env[.].+)|^(.{0,1000})$"
Expand All @@ -38,7 +55,10 @@
"type": "string",
"pattern": "(^\\{\\{.*\\|\\|(.*)\\}\\}$)|(^env[.].+)|^(.{0,1000})$"
},
"eventRegex": { "type": "boolean", "default": false }
"eventRegex": {
"type": "boolean",
"default": false
}
}
}
},
Expand Down Expand Up @@ -72,4 +92,4 @@
}
}
}
}
}
30 changes: 30 additions & 0 deletions src/configurations/destinations/slack/ui-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,27 @@
{
"title": "Event Channels",
"fields": [
{
"type": "singleSelect",
"label": "Type of incoming webhooks",
"value": "incomingWebhooksType",
"mode": "single",
"options": [
{
"name": "Legacy (Will be deprecated soon)",
"value": "legacy"
},
{
"name": "Modern (through app)",
"value": "modern"
}
],
"defaultOption": {
"name": "US",
"value": "legacy"
},
"footerNote": "If legacy is choosed then channel mapping will be done based on channel name else it will be done based on channel webhook"
},
{
"type": "dynamicCustomForm",
"value": "eventChannelSettings",
Expand All @@ -25,6 +46,15 @@
"required": false,
"placeholder": "e.g: https://hooks.slack.com/services/placeholder_1/placeholder_2/placeholder_3"
},
{
"type": "textInput",
"label": "Event Channel Name",
"value": "eventChannel",
"regex": "(^\\{\\{.*\\|\\|(.*)\\}\\}$)|(^env[.].+)|(?!.*\\.ngrok\\.io)^(.{0,100})$",
"regexErrorMessage": "Invalid Event Channel Webhook",
"required": false,
"placeholder": "e.g: ABCDEFG"
},
{
"type": "checkbox",
"label": "Regex Matching",
Expand Down
57 changes: 49 additions & 8 deletions test/data/validation/destinations/slack.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,26 @@
"config": {
"identifyTemplate": "",
"webhookUrl": "",
"eventChannelSettings": [{ "eventName": "", "eventChannelWebhook": "", "eventRegex": false }],
"eventTemplateSettings": [{ "eventName": "", "eventTemplate": "", "eventRegex": false }],
"whitelistedTraitsSettings": [{ "trait": "" }]
"eventChannelSettings": [
{
"eventName": "",
"eventChannel": "",
"eventChannelWebhook": "",
"eventRegex": false
}
],
"eventTemplateSettings": [
{
"eventName": "",
"eventTemplate": "",
"eventRegex": false
}
],
"whitelistedTraitsSettings": [
{
"trait": ""
}
]
},
"result": true
},
Expand All @@ -14,7 +31,12 @@
"identifyTemplate": "",
"webhookUrl": "https://hooks.slack.com/services/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",
"eventChannelSettings": [
{ "eventName": "XYZ", "eventChannelWebhook": "https://hooks.slack.com/services/e1/e2/e3", "eventRegex": false }
{
"eventName": "XYZ",
"eventChannel": "@srikanth",
"eventChannelWebhook": "https://hooks.slack.com/services/e1/e2/e3",
"eventRegex": false
}
],
"eventTemplateSettings": [
{
Expand All @@ -23,17 +45,32 @@
"eventRegex": false
}
],
"whitelistedTraitsSettings": [{ "trait": "" }]
"whitelistedTraitsSettings": [
{
"trait": ""
}
]
},
"result": true
},
{
"config": {
"identifyTemplate": "",
"webhookUrl": ""
},
"result": true
},
{ "config": { "identifyTemplate": "", "webhookUrl": "" }, "result": true },
{
"config": {
"identifyTemplate": "",
"webhookUrl": "https://hooks.slack.com/services/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",
"eventChannelSettings": [
{ "eventName": "XYZ", "eventChannelWebhook": "https://hooks.slack.com/services/e1/e2/e3", "eventRegex": false }
{
"eventName": "XYZ",
"eventChannel": "@srikanth",
"eventChannelWebhook": "https://hooks.slack.com/services/e1/e2/e3",
"eventRegex": false
}
],
"eventTemplateSettings": [
{
Expand All @@ -42,7 +79,11 @@
"eventRegex": "false"
}
],
"whitelistedTraitsSettings": [{ "trait": "" }]
"whitelistedTraitsSettings": [
{
"trait": ""
}
]
},
"result": false,
"err": [
Expand Down

0 comments on commit f54278a

Please sign in to comment.