first commit
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import { NodeTestHarness } from '@nodes-testing/node-test-harness';
|
||||
import nock from 'nock';
|
||||
|
||||
describe('Test DiscordV2, channel => create', () => {
|
||||
nock('https://discord.com/api/v10')
|
||||
.post('/guilds/1168516062791340136/channels', { name: 'third', type: '0' })
|
||||
.reply(200, {
|
||||
id: '1168528323006181417',
|
||||
type: 0,
|
||||
last_message_id: null,
|
||||
flags: 0,
|
||||
guild_id: '1168516062791340136',
|
||||
name: 'third',
|
||||
parent_id: null,
|
||||
rate_limit_per_user: 0,
|
||||
topic: null,
|
||||
position: 3,
|
||||
permission_overwrites: [],
|
||||
nsfw: false,
|
||||
});
|
||||
|
||||
new NodeTestHarness().setupTests({
|
||||
workflowFiles: ['create.workflow.json'],
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,106 @@
|
||||
{
|
||||
"name": "discord overhaul tests",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "254a9d9b-43bf-4f6e-a761-d78146a05838",
|
||||
"name": "When clicking \"Execute Workflow\"",
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
-660,
|
||||
560
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"guildId": {
|
||||
"__rl": true,
|
||||
"value": "1168516062791340136",
|
||||
"mode": "list",
|
||||
"cachedResultName": "TEST server",
|
||||
"cachedResultUrl": "https://discord.com/channels/1168516062791340136"
|
||||
},
|
||||
"name": "third",
|
||||
"options": {}
|
||||
},
|
||||
"id": "7e638897-0581-42e6-8b89-494908e0ae75",
|
||||
"name": "Bot test",
|
||||
"type": "n8n-nodes-base.discord",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
-420,
|
||||
560
|
||||
],
|
||||
"credentials": {
|
||||
"discordBotApi": {
|
||||
"id": "KaIz8dqE3Vy1E3iL",
|
||||
"name": "Discord Bot account"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "10450e91-8642-4b92-af15-9d5ad161b527",
|
||||
"name": "No Operation, do nothing",
|
||||
"type": "n8n-nodes-base.noOp",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
-200,
|
||||
560
|
||||
]
|
||||
}
|
||||
],
|
||||
"pinData": {
|
||||
"No Operation, do nothing": [
|
||||
{
|
||||
"json": {
|
||||
"id": "1168528323006181417",
|
||||
"type": 0,
|
||||
"last_message_id": null,
|
||||
"flags": 0,
|
||||
"guild_id": "1168516062791340136",
|
||||
"name": "third",
|
||||
"parent_id": null,
|
||||
"rate_limit_per_user": 0,
|
||||
"topic": null,
|
||||
"position": 3,
|
||||
"permission_overwrites": [],
|
||||
"nsfw": false
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"connections": {
|
||||
"When clicking \"Execute Workflow\"": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Bot test",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Bot test": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "No Operation, do nothing",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"active": false,
|
||||
"settings": {},
|
||||
"versionId": "df4fbb47-eb25-4564-b9ad-f16931e35665",
|
||||
"id": "4DdFKgGmLX07cXvG",
|
||||
"meta": {
|
||||
"instanceId": "b888bd11cd1ddbb95450babf3e199556799d999b896f650de768b8370ee50363"
|
||||
},
|
||||
"tags": []
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { NodeTestHarness } from '@nodes-testing/node-test-harness';
|
||||
import nock from 'nock';
|
||||
|
||||
describe('Test DiscordV2, channel => deleteChannel', () => {
|
||||
nock('https://discord.com/api/v10')
|
||||
.delete('/channels/1168528323006181417')
|
||||
.reply(200, { success: true });
|
||||
|
||||
new NodeTestHarness().setupTests({
|
||||
workflowFiles: ['deleteChannel.workflow.json'],
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,101 @@
|
||||
{
|
||||
"name": "discord overhaul tests",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "254a9d9b-43bf-4f6e-a761-d78146a05838",
|
||||
"name": "When clicking \"Execute Workflow\"",
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
-660,
|
||||
560
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"operation": "deleteChannel",
|
||||
"guildId": {
|
||||
"__rl": true,
|
||||
"value": "1168516062791340136",
|
||||
"mode": "list",
|
||||
"cachedResultName": "TEST server",
|
||||
"cachedResultUrl": "https://discord.com/channels/1168516062791340136"
|
||||
},
|
||||
"channelId": {
|
||||
"__rl": true,
|
||||
"value": "1168528323006181417",
|
||||
"mode": "list",
|
||||
"cachedResultName": "third",
|
||||
"cachedResultUrl": "https://discord.com/channels/1168516062791340136/1168528323006181417"
|
||||
}
|
||||
},
|
||||
"id": "7e638897-0581-42e6-8b89-494908e0ae75",
|
||||
"name": "Bot test",
|
||||
"type": "n8n-nodes-base.discord",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
-420,
|
||||
560
|
||||
],
|
||||
"credentials": {
|
||||
"discordBotApi": {
|
||||
"id": "KaIz8dqE3Vy1E3iL",
|
||||
"name": "Discord Bot account"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "10450e91-8642-4b92-af15-9d5ad161b527",
|
||||
"name": "No Operation, do nothing",
|
||||
"type": "n8n-nodes-base.noOp",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
-200,
|
||||
560
|
||||
]
|
||||
}
|
||||
],
|
||||
"pinData": {
|
||||
"No Operation, do nothing": [
|
||||
{
|
||||
"json": {
|
||||
"success": true
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"connections": {
|
||||
"When clicking \"Execute Workflow\"": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Bot test",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Bot test": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "No Operation, do nothing",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"active": false,
|
||||
"settings": {},
|
||||
"versionId": "f0027d0b-87f7-4a39-bc9c-2838078eed60",
|
||||
"id": "4DdFKgGmLX07cXvG",
|
||||
"meta": {
|
||||
"instanceId": "b888bd11cd1ddbb95450babf3e199556799d999b896f650de768b8370ee50363"
|
||||
},
|
||||
"tags": []
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
import { NodeTestHarness } from '@nodes-testing/node-test-harness';
|
||||
import nock from 'nock';
|
||||
|
||||
describe('Test DiscordV2, channel => get', () => {
|
||||
nock('https://discord.com/api/v10')
|
||||
.persist()
|
||||
.get('/users/@me/guilds')
|
||||
.reply(200, [{ id: '1168516062791340136' }])
|
||||
.get('/channels/1168516240332034067')
|
||||
.reply(200, {
|
||||
id: '1168516240332034067',
|
||||
type: 0,
|
||||
last_message_id: null,
|
||||
flags: 0,
|
||||
guild_id: '1168516062791340136',
|
||||
name: 'first',
|
||||
parent_id: '1168516063340789831',
|
||||
rate_limit_per_user: 0,
|
||||
topic: null,
|
||||
position: 1,
|
||||
permission_overwrites: [],
|
||||
nsfw: false,
|
||||
});
|
||||
|
||||
new NodeTestHarness().setupTests({
|
||||
workflowFiles: ['get.workflow.json'],
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,113 @@
|
||||
{
|
||||
"name": "discord overhaul copy",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "fe1dd916-f466-40c7-9dfa-dfec59219a86",
|
||||
"name": "When clicking \"Execute Workflow\"",
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
-560,
|
||||
780
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"authentication": "oAuth2",
|
||||
"operation": "get",
|
||||
"guildId": {
|
||||
"__rl": true,
|
||||
"value": "1168516062791340136",
|
||||
"mode": "list",
|
||||
"cachedResultName": "TEST server",
|
||||
"cachedResultUrl": "https://discord.com/channels/1168516062791340136"
|
||||
},
|
||||
"channelId": {
|
||||
"__rl": true,
|
||||
"value": "1168516240332034067",
|
||||
"mode": "list",
|
||||
"cachedResultName": "first",
|
||||
"cachedResultUrl": "https://discord.com/channels/1168516062791340136/1168516240332034067"
|
||||
}
|
||||
},
|
||||
"id": "09cccc50-10d2-49a1-9b9a-9ba1a11a3657",
|
||||
"name": "OAuth test",
|
||||
"type": "n8n-nodes-base.discord",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
-320,
|
||||
780
|
||||
],
|
||||
"credentials": {
|
||||
"discordOAuth2Api": {
|
||||
"id": "79",
|
||||
"name": "Discord account"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "7f367512-810f-4d5d-9020-0f01a47039f7",
|
||||
"name": "No Operation, do nothing",
|
||||
"type": "n8n-nodes-base.noOp",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
-80,
|
||||
780
|
||||
]
|
||||
}
|
||||
],
|
||||
"pinData": {
|
||||
"No Operation, do nothing": [
|
||||
{
|
||||
"json": {
|
||||
"id": "1168516240332034067",
|
||||
"type": 0,
|
||||
"last_message_id": null,
|
||||
"flags": 0,
|
||||
"guild_id": "1168516062791340136",
|
||||
"name": "first",
|
||||
"parent_id": "1168516063340789831",
|
||||
"rate_limit_per_user": 0,
|
||||
"topic": null,
|
||||
"position": 1,
|
||||
"permission_overwrites": [],
|
||||
"nsfw": false
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"connections": {
|
||||
"When clicking \"Execute Workflow\"": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "OAuth test",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"OAuth test": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "No Operation, do nothing",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"active": false,
|
||||
"settings": {},
|
||||
"versionId": "0089557d-57da-45ea-abd1-c7b57691e10a",
|
||||
"id": "m3OrE6gaFHxa5InI",
|
||||
"meta": {
|
||||
"instanceId": "b888bd11cd1ddbb95450babf3e199556799d999b896f650de768b8370ee50363"
|
||||
},
|
||||
"tags": []
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
import { NodeTestHarness } from '@nodes-testing/node-test-harness';
|
||||
import nock from 'nock';
|
||||
|
||||
describe('Test DiscordV2, channel => getAll', () => {
|
||||
nock('https://discord.com/api/v10')
|
||||
.get('/guilds/1168516062791340136/channels')
|
||||
.reply(200, [
|
||||
{
|
||||
id: '1168516063340789831',
|
||||
type: 4,
|
||||
flags: 0,
|
||||
guild_id: '1168516062791340136',
|
||||
name: 'Text Channels',
|
||||
parent_id: null,
|
||||
position: 0,
|
||||
permission_overwrites: [],
|
||||
},
|
||||
{
|
||||
id: '1168516063340789832',
|
||||
type: 4,
|
||||
flags: 0,
|
||||
guild_id: '1168516062791340136',
|
||||
name: 'Voice Channels',
|
||||
parent_id: null,
|
||||
position: 0,
|
||||
permission_overwrites: [],
|
||||
},
|
||||
{
|
||||
id: '1168516063340789833',
|
||||
type: 0,
|
||||
last_message_id: '1168518371239792720',
|
||||
flags: 0,
|
||||
guild_id: '1168516062791340136',
|
||||
name: 'general',
|
||||
parent_id: '1168516063340789831',
|
||||
rate_limit_per_user: 0,
|
||||
topic: null,
|
||||
position: 0,
|
||||
permission_overwrites: [],
|
||||
nsfw: false,
|
||||
icon_emoji: {
|
||||
id: null,
|
||||
name: '👋',
|
||||
},
|
||||
theme_color: null,
|
||||
},
|
||||
{
|
||||
id: '1168516063340789834',
|
||||
type: 2,
|
||||
last_message_id: null,
|
||||
flags: 0,
|
||||
guild_id: '1168516062791340136',
|
||||
name: 'General',
|
||||
parent_id: '1168516063340789832',
|
||||
rate_limit_per_user: 0,
|
||||
bitrate: 64000,
|
||||
user_limit: 0,
|
||||
rtc_region: null,
|
||||
position: 0,
|
||||
permission_overwrites: [],
|
||||
nsfw: false,
|
||||
icon_emoji: {
|
||||
id: null,
|
||||
name: '🎙️',
|
||||
},
|
||||
theme_color: null,
|
||||
},
|
||||
{
|
||||
id: '1168516240332034067',
|
||||
type: 0,
|
||||
last_message_id: null,
|
||||
flags: 0,
|
||||
guild_id: '1168516062791340136',
|
||||
name: 'first-channel',
|
||||
parent_id: '1168516063340789831',
|
||||
rate_limit_per_user: 30,
|
||||
topic: 'This is channel topic',
|
||||
position: 3,
|
||||
permission_overwrites: [],
|
||||
nsfw: true,
|
||||
},
|
||||
{
|
||||
id: '1168516269079793766',
|
||||
type: 0,
|
||||
last_message_id: null,
|
||||
flags: 0,
|
||||
guild_id: '1168516062791340136',
|
||||
name: 'second',
|
||||
parent_id: '1168516063340789831',
|
||||
rate_limit_per_user: 0,
|
||||
topic: null,
|
||||
position: 2,
|
||||
permission_overwrites: [],
|
||||
nsfw: false,
|
||||
},
|
||||
]);
|
||||
|
||||
new NodeTestHarness().setupTests({
|
||||
workflowFiles: ['getAll.workflow.json'],
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,191 @@
|
||||
{
|
||||
"name": "discord overhaul tests",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "254a9d9b-43bf-4f6e-a761-d78146a05838",
|
||||
"name": "When clicking \"Execute Workflow\"",
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
-660,
|
||||
560
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"operation": "getAll",
|
||||
"guildId": {
|
||||
"__rl": true,
|
||||
"value": "1168516062791340136",
|
||||
"mode": "list",
|
||||
"cachedResultName": "TEST server",
|
||||
"cachedResultUrl": "https://discord.com/channels/1168516062791340136"
|
||||
},
|
||||
"returnAll": true,
|
||||
"options": {}
|
||||
},
|
||||
"id": "7e638897-0581-42e6-8b89-494908e0ae75",
|
||||
"name": "Bot test",
|
||||
"type": "n8n-nodes-base.discord",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
-420,
|
||||
560
|
||||
],
|
||||
"credentials": {
|
||||
"discordBotApi": {
|
||||
"id": "KaIz8dqE3Vy1E3iL",
|
||||
"name": "Discord Bot account"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "10450e91-8642-4b92-af15-9d5ad161b527",
|
||||
"name": "No Operation, do nothing",
|
||||
"type": "n8n-nodes-base.noOp",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
-200,
|
||||
560
|
||||
]
|
||||
}
|
||||
],
|
||||
"pinData": {
|
||||
"No Operation, do nothing": [
|
||||
{
|
||||
"json": {
|
||||
"id": "1168516063340789831",
|
||||
"type": 4,
|
||||
"flags": 0,
|
||||
"guild_id": "1168516062791340136",
|
||||
"name": "Text Channels",
|
||||
"parent_id": null,
|
||||
"position": 0,
|
||||
"permission_overwrites": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"json": {
|
||||
"id": "1168516063340789832",
|
||||
"type": 4,
|
||||
"flags": 0,
|
||||
"guild_id": "1168516062791340136",
|
||||
"name": "Voice Channels",
|
||||
"parent_id": null,
|
||||
"position": 0,
|
||||
"permission_overwrites": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"json": {
|
||||
"id": "1168516063340789833",
|
||||
"type": 0,
|
||||
"last_message_id": "1168518371239792720",
|
||||
"flags": 0,
|
||||
"guild_id": "1168516062791340136",
|
||||
"name": "general",
|
||||
"parent_id": "1168516063340789831",
|
||||
"rate_limit_per_user": 0,
|
||||
"topic": null,
|
||||
"position": 0,
|
||||
"permission_overwrites": [],
|
||||
"nsfw": false,
|
||||
"icon_emoji": {
|
||||
"id": null,
|
||||
"name": "👋"
|
||||
},
|
||||
"theme_color": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"json": {
|
||||
"id": "1168516063340789834",
|
||||
"type": 2,
|
||||
"last_message_id": null,
|
||||
"flags": 0,
|
||||
"guild_id": "1168516062791340136",
|
||||
"name": "General",
|
||||
"parent_id": "1168516063340789832",
|
||||
"rate_limit_per_user": 0,
|
||||
"bitrate": 64000,
|
||||
"user_limit": 0,
|
||||
"rtc_region": null,
|
||||
"position": 0,
|
||||
"permission_overwrites": [],
|
||||
"nsfw": false,
|
||||
"icon_emoji": {
|
||||
"id": null,
|
||||
"name": "🎙️"
|
||||
},
|
||||
"theme_color": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"json": {
|
||||
"id": "1168516240332034067",
|
||||
"type": 0,
|
||||
"last_message_id": null,
|
||||
"flags": 0,
|
||||
"guild_id": "1168516062791340136",
|
||||
"name": "first-channel",
|
||||
"parent_id": "1168516063340789831",
|
||||
"rate_limit_per_user": 30,
|
||||
"topic": "This is channel topic",
|
||||
"position": 3,
|
||||
"permission_overwrites": [],
|
||||
"nsfw": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"json": {
|
||||
"id": "1168516269079793766",
|
||||
"type": 0,
|
||||
"last_message_id": null,
|
||||
"flags": 0,
|
||||
"guild_id": "1168516062791340136",
|
||||
"name": "second",
|
||||
"parent_id": "1168516063340789831",
|
||||
"rate_limit_per_user": 0,
|
||||
"topic": null,
|
||||
"position": 2,
|
||||
"permission_overwrites": [],
|
||||
"nsfw": false
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"connections": {
|
||||
"When clicking \"Execute Workflow\"": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Bot test",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Bot test": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "No Operation, do nothing",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"active": false,
|
||||
"settings": {},
|
||||
"versionId": "905c7383-202e-4391-97a5-e2c579421c17",
|
||||
"id": "4DdFKgGmLX07cXvG",
|
||||
"meta": {
|
||||
"instanceId": "b888bd11cd1ddbb95450babf3e199556799d999b896f650de768b8370ee50363"
|
||||
},
|
||||
"tags": []
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import { NodeTestHarness } from '@nodes-testing/node-test-harness';
|
||||
import nock from 'nock';
|
||||
|
||||
describe('Test DiscordV2, channel => update', () => {
|
||||
nock('https://discord.com/api/v10').patch('/channels/1168516240332034067').reply(200, {
|
||||
id: '1168516240332034067',
|
||||
type: 0,
|
||||
last_message_id: null,
|
||||
flags: 0,
|
||||
guild_id: '1168516062791340136',
|
||||
name: 'first-channel',
|
||||
parent_id: '1168516063340789831',
|
||||
rate_limit_per_user: 30,
|
||||
topic: 'This is channel topic',
|
||||
position: 3,
|
||||
permission_overwrites: [],
|
||||
nsfw: true,
|
||||
});
|
||||
|
||||
new NodeTestHarness().setupTests({
|
||||
workflowFiles: ['update.workflow.json'],
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,126 @@
|
||||
{
|
||||
"name": "discord overhaul tests",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "254a9d9b-43bf-4f6e-a761-d78146a05838",
|
||||
"name": "When clicking \"Execute Workflow\"",
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
-660,
|
||||
560
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"operation": "update",
|
||||
"guildId": {
|
||||
"__rl": true,
|
||||
"value": "1168516062791340136",
|
||||
"mode": "list",
|
||||
"cachedResultName": "TEST server",
|
||||
"cachedResultUrl": "https://discord.com/channels/1168516062791340136"
|
||||
},
|
||||
"channelId": {
|
||||
"__rl": true,
|
||||
"value": "1168516240332034067",
|
||||
"mode": "list",
|
||||
"cachedResultName": "first",
|
||||
"cachedResultUrl": "https://discord.com/channels/1168516062791340136/1168516240332034067"
|
||||
},
|
||||
"name": "First Channel",
|
||||
"options": {
|
||||
"nsfw": true,
|
||||
"categoryId": {
|
||||
"__rl": true,
|
||||
"value": "1168516063340789831",
|
||||
"mode": "list",
|
||||
"cachedResultName": "Text Channels",
|
||||
"cachedResultUrl": "https://discord.com/channels/1168516062791340136/1168516063340789831"
|
||||
},
|
||||
"position": 3,
|
||||
"rate_limit_per_user": 30,
|
||||
"topic": "This is channel topic"
|
||||
}
|
||||
},
|
||||
"id": "7e638897-0581-42e6-8b89-494908e0ae75",
|
||||
"name": "Bot test",
|
||||
"type": "n8n-nodes-base.discord",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
-420,
|
||||
560
|
||||
],
|
||||
"credentials": {
|
||||
"discordBotApi": {
|
||||
"id": "KaIz8dqE3Vy1E3iL",
|
||||
"name": "Discord Bot account"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "10450e91-8642-4b92-af15-9d5ad161b527",
|
||||
"name": "No Operation, do nothing",
|
||||
"type": "n8n-nodes-base.noOp",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
-200,
|
||||
560
|
||||
]
|
||||
}
|
||||
],
|
||||
"pinData": {
|
||||
"No Operation, do nothing": [
|
||||
{
|
||||
"json": {
|
||||
"id": "1168516240332034067",
|
||||
"type": 0,
|
||||
"last_message_id": null,
|
||||
"flags": 0,
|
||||
"guild_id": "1168516062791340136",
|
||||
"name": "first-channel",
|
||||
"parent_id": "1168516063340789831",
|
||||
"rate_limit_per_user": 30,
|
||||
"topic": "This is channel topic",
|
||||
"position": 3,
|
||||
"permission_overwrites": [],
|
||||
"nsfw": true
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"connections": {
|
||||
"When clicking \"Execute Workflow\"": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Bot test",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Bot test": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "No Operation, do nothing",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"active": false,
|
||||
"settings": {},
|
||||
"versionId": "fc822909-732e-444f-9537-54b7a85a7bd7",
|
||||
"id": "4DdFKgGmLX07cXvG",
|
||||
"meta": {
|
||||
"instanceId": "b888bd11cd1ddbb95450babf3e199556799d999b896f650de768b8370ee50363"
|
||||
},
|
||||
"tags": []
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
import { NodeTestHarness } from '@nodes-testing/node-test-harness';
|
||||
import nock from 'nock';
|
||||
|
||||
describe('Test DiscordV2, member => getAll', () => {
|
||||
nock('https://discord.com/api/v10')
|
||||
.get('/guilds/1168516062791340136/members?limit=2')
|
||||
.reply(200, [
|
||||
{
|
||||
user: {
|
||||
id: '470936827994570762',
|
||||
username: 'michael',
|
||||
avatar: null,
|
||||
discriminator: '0',
|
||||
public_flags: 0,
|
||||
premium_type: 0,
|
||||
flags: 0,
|
||||
banner: null,
|
||||
accent_color: null,
|
||||
global_name: 'Michael',
|
||||
avatar_decoration_data: null,
|
||||
banner_color: null,
|
||||
},
|
||||
roles: [],
|
||||
},
|
||||
{
|
||||
user: {
|
||||
id: '1070667629972430879',
|
||||
username: 'n8n-node-overhaul',
|
||||
avatar: null,
|
||||
discriminator: '1037',
|
||||
public_flags: 0,
|
||||
premium_type: 0,
|
||||
flags: 0,
|
||||
bot: true,
|
||||
banner: null,
|
||||
accent_color: null,
|
||||
global_name: null,
|
||||
avatar_decoration_data: null,
|
||||
banner_color: null,
|
||||
},
|
||||
roles: ['1168518368526077992'],
|
||||
},
|
||||
]);
|
||||
|
||||
new NodeTestHarness().setupTests({
|
||||
workflowFiles: ['getAll.workflow.json'],
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,134 @@
|
||||
{
|
||||
"name": "discord overhaul tests",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "254a9d9b-43bf-4f6e-a761-d78146a05838",
|
||||
"name": "When clicking \"Execute Workflow\"",
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
-660,
|
||||
560
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"resource": "member",
|
||||
"guildId": {
|
||||
"__rl": true,
|
||||
"value": "1168516062791340136",
|
||||
"mode": "list",
|
||||
"cachedResultName": "TEST server",
|
||||
"cachedResultUrl": "https://discord.com/channels/1168516062791340136"
|
||||
},
|
||||
"limit": 2,
|
||||
"options": {
|
||||
"simplify": true
|
||||
}
|
||||
},
|
||||
"id": "7e638897-0581-42e6-8b89-494908e0ae75",
|
||||
"name": "Bot test",
|
||||
"type": "n8n-nodes-base.discord",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
-420,
|
||||
560
|
||||
],
|
||||
"credentials": {
|
||||
"discordBotApi": {
|
||||
"id": "KaIz8dqE3Vy1E3iL",
|
||||
"name": "Discord Bot account"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "10450e91-8642-4b92-af15-9d5ad161b527",
|
||||
"name": "No Operation, do nothing",
|
||||
"type": "n8n-nodes-base.noOp",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
-200,
|
||||
560
|
||||
]
|
||||
}
|
||||
],
|
||||
"pinData": {
|
||||
"No Operation, do nothing": [
|
||||
{
|
||||
"json": {
|
||||
"user": {
|
||||
"id": "470936827994570762",
|
||||
"username": "michael",
|
||||
"avatar": null,
|
||||
"discriminator": "0",
|
||||
"public_flags": 0,
|
||||
"premium_type": 0,
|
||||
"flags": 0,
|
||||
"banner": null,
|
||||
"accent_color": null,
|
||||
"global_name": "Michael",
|
||||
"avatar_decoration_data": null,
|
||||
"banner_color": null
|
||||
},
|
||||
"roles": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"json": {
|
||||
"user": {
|
||||
"id": "1070667629972430879",
|
||||
"username": "n8n-node-overhaul",
|
||||
"avatar": null,
|
||||
"discriminator": "1037",
|
||||
"public_flags": 0,
|
||||
"premium_type": 0,
|
||||
"flags": 0,
|
||||
"bot": true,
|
||||
"banner": null,
|
||||
"accent_color": null,
|
||||
"global_name": null,
|
||||
"avatar_decoration_data": null,
|
||||
"banner_color": null
|
||||
},
|
||||
"roles": [
|
||||
"1168518368526077992"
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"connections": {
|
||||
"When clicking \"Execute Workflow\"": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Bot test",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Bot test": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "No Operation, do nothing",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"active": false,
|
||||
"settings": {},
|
||||
"versionId": "61375773-2f25-4eae-9ef6-e64e69fc9714",
|
||||
"id": "4DdFKgGmLX07cXvG",
|
||||
"meta": {
|
||||
"instanceId": "b888bd11cd1ddbb95450babf3e199556799d999b896f650de768b8370ee50363"
|
||||
},
|
||||
"tags": []
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { NodeTestHarness } from '@nodes-testing/node-test-harness';
|
||||
import nock from 'nock';
|
||||
|
||||
describe('Test DiscordV2, member => roleAdd', () => {
|
||||
nock('https://discord.com/api/v10')
|
||||
.put('/guilds/1168516062791340136/members/470936827994570762/roles/1168772374540320890')
|
||||
.reply(200, { success: true });
|
||||
|
||||
new NodeTestHarness().setupTests({
|
||||
workflowFiles: ['roleAdd.workflow.json'],
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,104 @@
|
||||
{
|
||||
"name": "discord overhaul tests",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "254a9d9b-43bf-4f6e-a761-d78146a05838",
|
||||
"name": "When clicking \"Execute Workflow\"",
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
-660,
|
||||
560
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"resource": "member",
|
||||
"operation": "roleAdd",
|
||||
"guildId": {
|
||||
"__rl": true,
|
||||
"value": "1168516062791340136",
|
||||
"mode": "list",
|
||||
"cachedResultName": "TEST server",
|
||||
"cachedResultUrl": "https://discord.com/channels/1168516062791340136"
|
||||
},
|
||||
"userId": {
|
||||
"__rl": true,
|
||||
"value": "470936827994570762",
|
||||
"mode": "list",
|
||||
"cachedResultName": "michael"
|
||||
},
|
||||
"role": [
|
||||
"1168772374540320890"
|
||||
]
|
||||
},
|
||||
"id": "7e638897-0581-42e6-8b89-494908e0ae75",
|
||||
"name": "Bot test",
|
||||
"type": "n8n-nodes-base.discord",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
-420,
|
||||
560
|
||||
],
|
||||
"credentials": {
|
||||
"discordBotApi": {
|
||||
"id": "KaIz8dqE3Vy1E3iL",
|
||||
"name": "Discord Bot account"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "10450e91-8642-4b92-af15-9d5ad161b527",
|
||||
"name": "No Operation, do nothing",
|
||||
"type": "n8n-nodes-base.noOp",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
-200,
|
||||
560
|
||||
]
|
||||
}
|
||||
],
|
||||
"pinData": {
|
||||
"No Operation, do nothing": [
|
||||
{
|
||||
"json": {
|
||||
"success": true
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"connections": {
|
||||
"When clicking \"Execute Workflow\"": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Bot test",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Bot test": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "No Operation, do nothing",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"active": false,
|
||||
"settings": {},
|
||||
"versionId": "ad26d0d9-faf3-4070-8909-8c2b6f0749f9",
|
||||
"id": "4DdFKgGmLX07cXvG",
|
||||
"meta": {
|
||||
"instanceId": "b888bd11cd1ddbb95450babf3e199556799d999b896f650de768b8370ee50363"
|
||||
},
|
||||
"tags": []
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import { NodeTestHarness } from '@nodes-testing/node-test-harness';
|
||||
import nock from 'nock';
|
||||
|
||||
describe('Test DiscordV2, member => roleRemove', () => {
|
||||
nock('https://discord.com/api/v10')
|
||||
.persist()
|
||||
.delete(/\/guilds\/1168516062791340136\/members\/470936827994570762\/roles\/\d+/)
|
||||
.reply(200, { success: true });
|
||||
|
||||
new NodeTestHarness().setupTests({
|
||||
workflowFiles: ['roleRemove.workflow.json'],
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,106 @@
|
||||
{
|
||||
"name": "discord overhaul tests",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "254a9d9b-43bf-4f6e-a761-d78146a05838",
|
||||
"name": "When clicking \"Execute Workflow\"",
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
-660,
|
||||
560
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"resource": "member",
|
||||
"operation": "roleRemove",
|
||||
"guildId": {
|
||||
"__rl": true,
|
||||
"value": "1168516062791340136",
|
||||
"mode": "list",
|
||||
"cachedResultName": "TEST server",
|
||||
"cachedResultUrl": "https://discord.com/channels/1168516062791340136"
|
||||
},
|
||||
"userId": {
|
||||
"__rl": true,
|
||||
"value": "470936827994570762",
|
||||
"mode": "list",
|
||||
"cachedResultName": "michael"
|
||||
},
|
||||
"role": [
|
||||
"1168773588963299428",
|
||||
"1168773645800308756",
|
||||
"1168772374540320890"
|
||||
]
|
||||
},
|
||||
"id": "7e638897-0581-42e6-8b89-494908e0ae75",
|
||||
"name": "Bot test",
|
||||
"type": "n8n-nodes-base.discord",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
-420,
|
||||
560
|
||||
],
|
||||
"credentials": {
|
||||
"discordBotApi": {
|
||||
"id": "KaIz8dqE3Vy1E3iL",
|
||||
"name": "Discord Bot account"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "10450e91-8642-4b92-af15-9d5ad161b527",
|
||||
"name": "No Operation, do nothing",
|
||||
"type": "n8n-nodes-base.noOp",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
-200,
|
||||
560
|
||||
]
|
||||
}
|
||||
],
|
||||
"pinData": {
|
||||
"No Operation, do nothing": [
|
||||
{
|
||||
"json": {
|
||||
"success": true
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"connections": {
|
||||
"When clicking \"Execute Workflow\"": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Bot test",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Bot test": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "No Operation, do nothing",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"active": false,
|
||||
"settings": {},
|
||||
"versionId": "e3780e00-5acb-4c2f-8c4f-85a9fb6698c9",
|
||||
"id": "4DdFKgGmLX07cXvG",
|
||||
"meta": {
|
||||
"instanceId": "b888bd11cd1ddbb95450babf3e199556799d999b896f650de768b8370ee50363"
|
||||
},
|
||||
"tags": []
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { NodeTestHarness } from '@nodes-testing/node-test-harness';
|
||||
import nock from 'nock';
|
||||
|
||||
describe('Test DiscordV2, message => deleteMessage', () => {
|
||||
nock('https://discord.com/api/v10')
|
||||
.delete('/channels/1168516240332034067/messages/1168776343194972210')
|
||||
.reply(200, { success: true });
|
||||
|
||||
new NodeTestHarness().setupTests({
|
||||
workflowFiles: ['deleteMessage.workflow.json'],
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,103 @@
|
||||
{
|
||||
"name": "discord overhaul tests",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "254a9d9b-43bf-4f6e-a761-d78146a05838",
|
||||
"name": "When clicking \"Execute Workflow\"",
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
-660,
|
||||
560
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"resource": "message",
|
||||
"operation": "deleteMessage",
|
||||
"guildId": {
|
||||
"__rl": true,
|
||||
"value": "1168516062791340136",
|
||||
"mode": "list",
|
||||
"cachedResultName": "TEST server",
|
||||
"cachedResultUrl": "https://discord.com/channels/1168516062791340136"
|
||||
},
|
||||
"channelId": {
|
||||
"__rl": true,
|
||||
"value": "1168516240332034067",
|
||||
"mode": "list",
|
||||
"cachedResultName": "first-channel",
|
||||
"cachedResultUrl": "https://discord.com/channels/1168516062791340136/1168516240332034067"
|
||||
},
|
||||
"messageId": "1168776343194972210"
|
||||
},
|
||||
"id": "7e638897-0581-42e6-8b89-494908e0ae75",
|
||||
"name": "Bot test",
|
||||
"type": "n8n-nodes-base.discord",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
-420,
|
||||
560
|
||||
],
|
||||
"credentials": {
|
||||
"discordBotApi": {
|
||||
"id": "KaIz8dqE3Vy1E3iL",
|
||||
"name": "Discord Bot account"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "10450e91-8642-4b92-af15-9d5ad161b527",
|
||||
"name": "No Operation, do nothing",
|
||||
"type": "n8n-nodes-base.noOp",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
-200,
|
||||
560
|
||||
]
|
||||
}
|
||||
],
|
||||
"pinData": {
|
||||
"No Operation, do nothing": [
|
||||
{
|
||||
"json": {
|
||||
"success": true
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"connections": {
|
||||
"When clicking \"Execute Workflow\"": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Bot test",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Bot test": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "No Operation, do nothing",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"active": false,
|
||||
"settings": {},
|
||||
"versionId": "15dbf56e-707a-4b5c-814c-ecf78d96d87f",
|
||||
"id": "4DdFKgGmLX07cXvG",
|
||||
"meta": {
|
||||
"instanceId": "b888bd11cd1ddbb95450babf3e199556799d999b896f650de768b8370ee50363"
|
||||
},
|
||||
"tags": []
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
import { NodeTestHarness } from '@nodes-testing/node-test-harness';
|
||||
import nock from 'nock';
|
||||
|
||||
describe('Test DiscordV2, message => get', () => {
|
||||
nock('https://discord.com/api/v10')
|
||||
.get('/channels/1168516240332034067/messages/1168777380144369718')
|
||||
.reply(200, {
|
||||
id: '1168777380144369718',
|
||||
channel_id: '1168516240332034067',
|
||||
author: {
|
||||
id: '1070667629972430879',
|
||||
username: 'n8n-node-overhaul',
|
||||
avatar: null,
|
||||
discriminator: '1037',
|
||||
public_flags: 0,
|
||||
premium_type: 0,
|
||||
flags: 0,
|
||||
bot: true,
|
||||
banner: null,
|
||||
accent_color: null,
|
||||
global_name: null,
|
||||
avatar_decoration_data: null,
|
||||
banner_color: null,
|
||||
},
|
||||
content: 'msg 3',
|
||||
timestamp: '2023-10-31T05:04:02.260000+00:00',
|
||||
type: 0,
|
||||
});
|
||||
|
||||
new NodeTestHarness().setupTests({
|
||||
workflowFiles: ['get.workflow.json'],
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,125 @@
|
||||
{
|
||||
"name": "discord overhaul tests",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "254a9d9b-43bf-4f6e-a761-d78146a05838",
|
||||
"name": "When clicking \"Execute Workflow\"",
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
-660,
|
||||
560
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"resource": "message",
|
||||
"operation": "get",
|
||||
"guildId": {
|
||||
"__rl": true,
|
||||
"value": "1168516062791340136",
|
||||
"mode": "list",
|
||||
"cachedResultName": "TEST server",
|
||||
"cachedResultUrl": "https://discord.com/channels/1168516062791340136"
|
||||
},
|
||||
"channelId": {
|
||||
"__rl": true,
|
||||
"value": "1168516240332034067",
|
||||
"mode": "list",
|
||||
"cachedResultName": "first-channel",
|
||||
"cachedResultUrl": "https://discord.com/channels/1168516062791340136/1168516240332034067"
|
||||
},
|
||||
"messageId": "1168777380144369718",
|
||||
"options": {
|
||||
"simplify": true
|
||||
}
|
||||
},
|
||||
"id": "7e638897-0581-42e6-8b89-494908e0ae75",
|
||||
"name": "Bot test",
|
||||
"type": "n8n-nodes-base.discord",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
-420,
|
||||
560
|
||||
],
|
||||
"credentials": {
|
||||
"discordBotApi": {
|
||||
"id": "KaIz8dqE3Vy1E3iL",
|
||||
"name": "Discord Bot account"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "10450e91-8642-4b92-af15-9d5ad161b527",
|
||||
"name": "No Operation, do nothing",
|
||||
"type": "n8n-nodes-base.noOp",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
-200,
|
||||
560
|
||||
]
|
||||
}
|
||||
],
|
||||
"pinData": {
|
||||
"No Operation, do nothing": [
|
||||
{
|
||||
"json": {
|
||||
"id": "1168777380144369718",
|
||||
"channel_id": "1168516240332034067",
|
||||
"author": {
|
||||
"id": "1070667629972430879",
|
||||
"username": "n8n-node-overhaul",
|
||||
"avatar": null,
|
||||
"discriminator": "1037",
|
||||
"public_flags": 0,
|
||||
"premium_type": 0,
|
||||
"flags": 0,
|
||||
"bot": true,
|
||||
"banner": null,
|
||||
"accent_color": null,
|
||||
"global_name": null,
|
||||
"avatar_decoration_data": null,
|
||||
"banner_color": null
|
||||
},
|
||||
"content": "msg 3",
|
||||
"timestamp": "2023-10-31T05:04:02.260000+00:00",
|
||||
"type": 0
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"connections": {
|
||||
"When clicking \"Execute Workflow\"": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Bot test",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Bot test": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "No Operation, do nothing",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"active": false,
|
||||
"settings": {},
|
||||
"versionId": "876e52a8-2fb3-4efc-9ef0-123807be3806",
|
||||
"id": "4DdFKgGmLX07cXvG",
|
||||
"meta": {
|
||||
"instanceId": "b888bd11cd1ddbb95450babf3e199556799d999b896f650de768b8370ee50363"
|
||||
},
|
||||
"tags": []
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
import { NodeTestHarness } from '@nodes-testing/node-test-harness';
|
||||
import nock from 'nock';
|
||||
|
||||
describe('Test DiscordV2, message => getAll', () => {
|
||||
nock('https://discord.com/api/v10')
|
||||
.get('/channels/1168516240332034067/messages?limit=1')
|
||||
.reply(200, [
|
||||
{
|
||||
id: '1168784010269433998',
|
||||
type: 0,
|
||||
content: 'msg 4',
|
||||
channel_id: '1168516240332034067',
|
||||
author: {
|
||||
id: '1070667629972430879',
|
||||
username: 'n8n-node-overhaul',
|
||||
avatar: null,
|
||||
discriminator: '1037',
|
||||
public_flags: 0,
|
||||
premium_type: 0,
|
||||
flags: 0,
|
||||
bot: true,
|
||||
banner: null,
|
||||
accent_color: null,
|
||||
global_name: null,
|
||||
avatar_decoration_data: null,
|
||||
banner_color: null,
|
||||
},
|
||||
attachments: [],
|
||||
embeds: [
|
||||
{
|
||||
type: 'rich',
|
||||
title: 'Some Title',
|
||||
description: 'description',
|
||||
color: 2112935,
|
||||
timestamp: '2023-10-30T22:00:00+00:00',
|
||||
author: {
|
||||
name: 'Me',
|
||||
},
|
||||
},
|
||||
],
|
||||
mentions: [],
|
||||
mention_roles: [],
|
||||
pinned: false,
|
||||
mention_everyone: false,
|
||||
tts: false,
|
||||
timestamp: '2023-10-31T05:30:23.005000+00:00',
|
||||
edited_timestamp: null,
|
||||
flags: 0,
|
||||
components: [],
|
||||
},
|
||||
]);
|
||||
|
||||
new NodeTestHarness().setupTests({
|
||||
workflowFiles: ['getAll.workflow.json'],
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,144 @@
|
||||
{
|
||||
"name": "discord overhaul tests",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "254a9d9b-43bf-4f6e-a761-d78146a05838",
|
||||
"name": "When clicking \"Execute Workflow\"",
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
-660,
|
||||
560
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"resource": "message",
|
||||
"operation": "getAll",
|
||||
"guildId": {
|
||||
"__rl": true,
|
||||
"value": "1168516062791340136",
|
||||
"mode": "list",
|
||||
"cachedResultName": "TEST server",
|
||||
"cachedResultUrl": "https://discord.com/channels/1168516062791340136"
|
||||
},
|
||||
"channelId": {
|
||||
"__rl": true,
|
||||
"value": "1168516240332034067",
|
||||
"mode": "list",
|
||||
"cachedResultName": "first-channel",
|
||||
"cachedResultUrl": "https://discord.com/channels/1168516062791340136/1168516240332034067"
|
||||
},
|
||||
"limit": 1,
|
||||
"options": {}
|
||||
},
|
||||
"id": "7e638897-0581-42e6-8b89-494908e0ae75",
|
||||
"name": "Bot test",
|
||||
"type": "n8n-nodes-base.discord",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
-420,
|
||||
560
|
||||
],
|
||||
"credentials": {
|
||||
"discordBotApi": {
|
||||
"id": "KaIz8dqE3Vy1E3iL",
|
||||
"name": "Discord Bot account"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "10450e91-8642-4b92-af15-9d5ad161b527",
|
||||
"name": "No Operation, do nothing",
|
||||
"type": "n8n-nodes-base.noOp",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
-200,
|
||||
560
|
||||
]
|
||||
}
|
||||
],
|
||||
"pinData": {
|
||||
"No Operation, do nothing": [
|
||||
{
|
||||
"json": {
|
||||
"id": "1168784010269433998",
|
||||
"type": 0,
|
||||
"content": "msg 4",
|
||||
"channel_id": "1168516240332034067",
|
||||
"author": {
|
||||
"id": "1070667629972430879",
|
||||
"username": "n8n-node-overhaul",
|
||||
"avatar": null,
|
||||
"discriminator": "1037",
|
||||
"public_flags": 0,
|
||||
"premium_type": 0,
|
||||
"flags": 0,
|
||||
"bot": true,
|
||||
"banner": null,
|
||||
"accent_color": null,
|
||||
"global_name": null,
|
||||
"avatar_decoration_data": null,
|
||||
"banner_color": null
|
||||
},
|
||||
"attachments": [],
|
||||
"embeds": [
|
||||
{
|
||||
"type": "rich",
|
||||
"title": "Some Title",
|
||||
"description": "description",
|
||||
"color": 2112935,
|
||||
"timestamp": "2023-10-30T22:00:00+00:00",
|
||||
"author": {
|
||||
"name": "Me"
|
||||
}
|
||||
}
|
||||
],
|
||||
"mentions": [],
|
||||
"mention_roles": [],
|
||||
"pinned": false,
|
||||
"mention_everyone": false,
|
||||
"tts": false,
|
||||
"timestamp": "2023-10-31T05:30:23.005000+00:00",
|
||||
"edited_timestamp": null,
|
||||
"flags": 0,
|
||||
"components": []
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"connections": {
|
||||
"When clicking \"Execute Workflow\"": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Bot test",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Bot test": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "No Operation, do nothing",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"active": false,
|
||||
"settings": {},
|
||||
"versionId": "fd45b651-cad2-4985-bcee-9c87efeb9af5",
|
||||
"id": "4DdFKgGmLX07cXvG",
|
||||
"meta": {
|
||||
"instanceId": "b888bd11cd1ddbb95450babf3e199556799d999b896f650de768b8370ee50363"
|
||||
},
|
||||
"tags": []
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { NodeTestHarness } from '@nodes-testing/node-test-harness';
|
||||
import nock from 'nock';
|
||||
|
||||
describe('Test DiscordV2, message => react', () => {
|
||||
nock('https://discord.com/api/v10')
|
||||
.put('/channels/1168516240332034067/messages/1168777380144369718/reactions/%F0%9F%98%80/@me')
|
||||
.reply(200, { success: true });
|
||||
|
||||
new NodeTestHarness().setupTests({
|
||||
workflowFiles: ['react.workflow.json'],
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,104 @@
|
||||
{
|
||||
"name": "discord overhaul tests",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "254a9d9b-43bf-4f6e-a761-d78146a05838",
|
||||
"name": "When clicking \"Execute Workflow\"",
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
-660,
|
||||
560
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"resource": "message",
|
||||
"operation": "react",
|
||||
"guildId": {
|
||||
"__rl": true,
|
||||
"value": "1168516062791340136",
|
||||
"mode": "list",
|
||||
"cachedResultName": "TEST server",
|
||||
"cachedResultUrl": "https://discord.com/channels/1168516062791340136"
|
||||
},
|
||||
"channelId": {
|
||||
"__rl": true,
|
||||
"value": "1168516240332034067",
|
||||
"mode": "list",
|
||||
"cachedResultName": "first-channel",
|
||||
"cachedResultUrl": "https://discord.com/channels/1168516062791340136/1168516240332034067"
|
||||
},
|
||||
"messageId": "1168777380144369718",
|
||||
"emoji": "😀"
|
||||
},
|
||||
"id": "7e638897-0581-42e6-8b89-494908e0ae75",
|
||||
"name": "Bot test",
|
||||
"type": "n8n-nodes-base.discord",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
-420,
|
||||
560
|
||||
],
|
||||
"credentials": {
|
||||
"discordBotApi": {
|
||||
"id": "KaIz8dqE3Vy1E3iL",
|
||||
"name": "Discord Bot account"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "10450e91-8642-4b92-af15-9d5ad161b527",
|
||||
"name": "No Operation, do nothing",
|
||||
"type": "n8n-nodes-base.noOp",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
-200,
|
||||
560
|
||||
]
|
||||
}
|
||||
],
|
||||
"pinData": {
|
||||
"No Operation, do nothing": [
|
||||
{
|
||||
"json": {
|
||||
"success": true
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"connections": {
|
||||
"When clicking \"Execute Workflow\"": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Bot test",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Bot test": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "No Operation, do nothing",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"active": false,
|
||||
"settings": {},
|
||||
"versionId": "cf2de495-fe80-4a98-9d06-c251ea1661ad",
|
||||
"id": "4DdFKgGmLX07cXvG",
|
||||
"meta": {
|
||||
"instanceId": "b888bd11cd1ddbb95450babf3e199556799d999b896f650de768b8370ee50363"
|
||||
},
|
||||
"tags": []
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
import { NodeTestHarness } from '@nodes-testing/node-test-harness';
|
||||
import nock from 'nock';
|
||||
|
||||
describe('Test DiscordV2, message => send', () => {
|
||||
nock('https://discord.com/api/v10')
|
||||
.post('/channels/1168516240332034067/messages', {
|
||||
content: 'msg 4',
|
||||
embeds: [
|
||||
{
|
||||
author: { name: 'Me' },
|
||||
color: 2112935,
|
||||
description: 'description',
|
||||
timestamp: '2023-10-30T22:00:00.000Z',
|
||||
title: 'Some Title',
|
||||
},
|
||||
],
|
||||
})
|
||||
.reply(200, {
|
||||
id: '1168784010269433998',
|
||||
type: 0,
|
||||
content: 'msg 4',
|
||||
channel_id: '1168516240332034067',
|
||||
author: {
|
||||
id: '1070667629972430879',
|
||||
username: 'n8n-node-overhaul',
|
||||
avatar: null,
|
||||
discriminator: '1037',
|
||||
public_flags: 0,
|
||||
premium_type: 0,
|
||||
flags: 0,
|
||||
bot: true,
|
||||
banner: null,
|
||||
accent_color: null,
|
||||
global_name: null,
|
||||
avatar_decoration_data: null,
|
||||
banner_color: null,
|
||||
},
|
||||
attachments: [],
|
||||
embeds: [
|
||||
{
|
||||
type: 'rich',
|
||||
title: 'Some Title',
|
||||
description: 'description',
|
||||
color: 2112935,
|
||||
timestamp: '2023-10-30T22:00:00+00:00',
|
||||
author: {
|
||||
name: 'Me',
|
||||
},
|
||||
},
|
||||
],
|
||||
mentions: [],
|
||||
mention_roles: [],
|
||||
pinned: false,
|
||||
mention_everyone: false,
|
||||
tts: false,
|
||||
timestamp: '2023-10-31T05:30:23.005000+00:00',
|
||||
edited_timestamp: null,
|
||||
flags: 0,
|
||||
components: [],
|
||||
referenced_message: null,
|
||||
});
|
||||
|
||||
new NodeTestHarness().setupTests({
|
||||
workflowFiles: ['send.workflow.json'],
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,155 @@
|
||||
{
|
||||
"name": "discord overhaul tests",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "254a9d9b-43bf-4f6e-a761-d78146a05838",
|
||||
"name": "When clicking \"Execute Workflow\"",
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
-660,
|
||||
560
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"resource": "message",
|
||||
"guildId": {
|
||||
"__rl": true,
|
||||
"value": "1168516062791340136",
|
||||
"mode": "list",
|
||||
"cachedResultName": "TEST server",
|
||||
"cachedResultUrl": "https://discord.com/channels/1168516062791340136"
|
||||
},
|
||||
"channelId": {
|
||||
"__rl": true,
|
||||
"value": "1168516240332034067",
|
||||
"mode": "list",
|
||||
"cachedResultName": "first-channel",
|
||||
"cachedResultUrl": "https://discord.com/channels/1168516062791340136/1168516240332034067"
|
||||
},
|
||||
"content": "msg 4",
|
||||
"options": {},
|
||||
"embeds": {
|
||||
"values": [
|
||||
{
|
||||
"description": "description",
|
||||
"author": "Me",
|
||||
"color": "#203DA7",
|
||||
"timestamp": "2023-10-30T22:00:00.000Z",
|
||||
"title": "Some Title"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"id": "7e638897-0581-42e6-8b89-494908e0ae75",
|
||||
"name": "Bot test",
|
||||
"type": "n8n-nodes-base.discord",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
-420,
|
||||
560
|
||||
],
|
||||
"credentials": {
|
||||
"discordBotApi": {
|
||||
"id": "KaIz8dqE3Vy1E3iL",
|
||||
"name": "Discord Bot account"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "10450e91-8642-4b92-af15-9d5ad161b527",
|
||||
"name": "No Operation, do nothing",
|
||||
"type": "n8n-nodes-base.noOp",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
-200,
|
||||
560
|
||||
]
|
||||
}
|
||||
],
|
||||
"pinData": {
|
||||
"No Operation, do nothing": [
|
||||
{
|
||||
"json": {
|
||||
"id": "1168784010269433998",
|
||||
"type": 0,
|
||||
"content": "msg 4",
|
||||
"channel_id": "1168516240332034067",
|
||||
"author": {
|
||||
"id": "1070667629972430879",
|
||||
"username": "n8n-node-overhaul",
|
||||
"avatar": null,
|
||||
"discriminator": "1037",
|
||||
"public_flags": 0,
|
||||
"premium_type": 0,
|
||||
"flags": 0,
|
||||
"bot": true,
|
||||
"banner": null,
|
||||
"accent_color": null,
|
||||
"global_name": null,
|
||||
"avatar_decoration_data": null,
|
||||
"banner_color": null
|
||||
},
|
||||
"attachments": [],
|
||||
"embeds": [
|
||||
{
|
||||
"type": "rich",
|
||||
"title": "Some Title",
|
||||
"description": "description",
|
||||
"color": 2112935,
|
||||
"timestamp": "2023-10-30T22:00:00+00:00",
|
||||
"author": {
|
||||
"name": "Me"
|
||||
}
|
||||
}
|
||||
],
|
||||
"mentions": [],
|
||||
"mention_roles": [],
|
||||
"pinned": false,
|
||||
"mention_everyone": false,
|
||||
"tts": false,
|
||||
"timestamp": "2023-10-31T05:30:23.005000+00:00",
|
||||
"edited_timestamp": null,
|
||||
"flags": 0,
|
||||
"components": [],
|
||||
"referenced_message": null
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"connections": {
|
||||
"When clicking \"Execute Workflow\"": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Bot test",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Bot test": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "No Operation, do nothing",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"active": false,
|
||||
"settings": {},
|
||||
"versionId": "5b208250-62db-4b00-9e02-53392eb838a9",
|
||||
"id": "4DdFKgGmLX07cXvG",
|
||||
"meta": {
|
||||
"instanceId": "b888bd11cd1ddbb95450babf3e199556799d999b896f650de768b8370ee50363"
|
||||
},
|
||||
"tags": []
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
import type { MockProxy } from 'jest-mock-extended';
|
||||
import { mock } from 'jest-mock-extended';
|
||||
import { SEND_AND_WAIT_OPERATION, type IExecuteFunctions } from 'n8n-workflow';
|
||||
|
||||
import { versionDescription } from '../../../../v2/actions/versionDescription';
|
||||
import { DiscordV2 } from '../../../../v2/DiscordV2.node';
|
||||
import * as transport from '../../../../v2/transport/discord.api';
|
||||
|
||||
jest.mock('../../../../v2/transport/discord.api', () => {
|
||||
const originalModule = jest.requireActual('../../../../v2/transport/discord.api');
|
||||
return {
|
||||
...originalModule,
|
||||
discordApiRequest: jest.fn(async function (method: string) {
|
||||
if (method === 'POST') {
|
||||
return {};
|
||||
}
|
||||
}),
|
||||
};
|
||||
});
|
||||
|
||||
describe('Test DiscordV2, message => sendAndWait', () => {
|
||||
let discord: DiscordV2;
|
||||
let mockExecuteFunctions: MockProxy<IExecuteFunctions>;
|
||||
|
||||
beforeEach(() => {
|
||||
discord = new DiscordV2(versionDescription);
|
||||
mockExecuteFunctions = mock<IExecuteFunctions>();
|
||||
mockExecuteFunctions.helpers = {
|
||||
constructExecutionMetaData: jest.fn(() => []),
|
||||
returnJsonArray: jest.fn(() => []),
|
||||
} as any;
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
it('should send message and put execution to wait', async () => {
|
||||
const items = [{ json: { data: 'test' } }];
|
||||
mockExecuteFunctions.getNodeParameter.mockImplementation((key: string) => {
|
||||
if (key === 'operation') return SEND_AND_WAIT_OPERATION;
|
||||
if (key === 'resource') return 'message';
|
||||
if (key === 'authentication') return 'botToken';
|
||||
if (key === 'message') return 'my message';
|
||||
if (key === 'subject') return '';
|
||||
if (key === 'approvalOptions.values') return {};
|
||||
if (key === 'responseType') return 'approval';
|
||||
if (key === 'sendTo') return 'channel';
|
||||
if (key === 'channelId') return 'channelID';
|
||||
if (key === 'options.limitWaitTime.values') return {};
|
||||
});
|
||||
|
||||
mockExecuteFunctions.putExecutionToWait.mockImplementation();
|
||||
mockExecuteFunctions.getInputData.mockReturnValue(items);
|
||||
mockExecuteFunctions.getInstanceId.mockReturnValue('instanceId');
|
||||
|
||||
mockExecuteFunctions.evaluateExpression.mockReturnValueOnce('http://localhost/waiting-webhook');
|
||||
mockExecuteFunctions.evaluateExpression.mockReturnValueOnce('nodeID');
|
||||
|
||||
mockExecuteFunctions.getSignedResumeUrl.mockReturnValue(
|
||||
'http://localhost/waiting-webhook/nodeID?approved=true&token=abc',
|
||||
);
|
||||
|
||||
const result = await discord.execute.call(mockExecuteFunctions);
|
||||
|
||||
expect(result).toEqual([items]);
|
||||
expect(transport.discordApiRequest).toHaveBeenCalledTimes(1);
|
||||
expect(mockExecuteFunctions.putExecutionToWait).toHaveBeenCalledTimes(1);
|
||||
|
||||
expect(transport.discordApiRequest).toHaveBeenCalledWith(
|
||||
'POST',
|
||||
'/channels/channelID/messages',
|
||||
{
|
||||
components: [
|
||||
{
|
||||
components: [
|
||||
{
|
||||
label: 'Approve',
|
||||
style: 5,
|
||||
type: 2,
|
||||
url: 'http://localhost/waiting-webhook/nodeID?approved=true&token=abc',
|
||||
},
|
||||
],
|
||||
type: 1,
|
||||
},
|
||||
],
|
||||
embeds: [
|
||||
{
|
||||
color: 5814783,
|
||||
description:
|
||||
'my message\n\n_This message was sent automatically with _[n8n](https://n8n.io/?utm_source=n8n-internal&utm_medium=powered_by&utm_campaign=n8n-nodes-base.discord_instanceId)',
|
||||
},
|
||||
],
|
||||
},
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,56 @@
|
||||
import { NodeTestHarness } from '@nodes-testing/node-test-harness';
|
||||
import nock from 'nock';
|
||||
|
||||
describe('Test DiscordV2, webhook => sendLegacy', () => {
|
||||
const credentials = {
|
||||
discordWebhookApi: {
|
||||
webhookUri: 'https://discord.com/webhook',
|
||||
},
|
||||
};
|
||||
|
||||
nock(credentials.discordWebhookApi.webhookUri)
|
||||
.post('?wait=true')
|
||||
.reply(200, {
|
||||
id: '1168768986385747999',
|
||||
type: 0,
|
||||
content: 'TEST Message',
|
||||
channel_id: '1074646335082479626',
|
||||
author: {
|
||||
id: '1153265494955135077',
|
||||
username: 'TEST_USER',
|
||||
avatar: null,
|
||||
discriminator: '0000',
|
||||
public_flags: 0,
|
||||
flags: 0,
|
||||
bot: true,
|
||||
global_name: null,
|
||||
},
|
||||
attachments: [],
|
||||
embeds: [
|
||||
{
|
||||
type: 'rich',
|
||||
description: 'some description',
|
||||
color: 10930459,
|
||||
timestamp: '2023-10-17T21:00:00+00:00',
|
||||
author: {
|
||||
name: 'Michael',
|
||||
},
|
||||
},
|
||||
],
|
||||
mentions: [],
|
||||
mention_roles: [],
|
||||
pinned: false,
|
||||
mention_everyone: false,
|
||||
tts: true,
|
||||
timestamp: '2023-10-31T04:30:41.032000+00:00',
|
||||
edited_timestamp: null,
|
||||
flags: 4096,
|
||||
components: [],
|
||||
webhook_id: '1153265494955135077',
|
||||
});
|
||||
|
||||
new NodeTestHarness().setupTests({
|
||||
credentials,
|
||||
workflowFiles: ['sendLegacy.workflow.json'],
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,141 @@
|
||||
{
|
||||
"name": "discord overhaul tests copy",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "8fb04834-2c97-4f21-9300-0f38b0e82f08",
|
||||
"name": "When clicking \"Execute Workflow\"",
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
-660,
|
||||
560
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"authentication": "webhook",
|
||||
"content": "TEST Message",
|
||||
"options": {
|
||||
"flags": [
|
||||
"SUPPRESS_NOTIFICATIONS"
|
||||
],
|
||||
"tts": true,
|
||||
"username": "TEST_USER",
|
||||
"wait": true
|
||||
},
|
||||
"embeds": {
|
||||
"values": [
|
||||
{
|
||||
"description": "some description",
|
||||
"author": "Michael",
|
||||
"color": "#A6C91B",
|
||||
"timestamp": "2023-10-17T21:00:00.000Z"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"id": "61f96217-f6b3-4989-be70-77b723e8e169",
|
||||
"name": "Bot test",
|
||||
"type": "n8n-nodes-base.discord",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
-420,
|
||||
560
|
||||
],
|
||||
"credentials": {
|
||||
"discordWebhookApi": {
|
||||
"id": "86",
|
||||
"name": "Discord account 3"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "c9c936f7-7dee-40d2-bcf6-255cc9d6d5e8",
|
||||
"name": "No Operation, do nothing",
|
||||
"type": "n8n-nodes-base.noOp",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
-200,
|
||||
560
|
||||
]
|
||||
}
|
||||
],
|
||||
"pinData": {
|
||||
"No Operation, do nothing": [
|
||||
{
|
||||
"json": {
|
||||
"id": "1168768986385747999",
|
||||
"type": 0,
|
||||
"content": "TEST Message",
|
||||
"channel_id": "1074646335082479626",
|
||||
"author": {
|
||||
"id": "1153265494955135077",
|
||||
"username": "TEST_USER",
|
||||
"avatar": null,
|
||||
"discriminator": "0000",
|
||||
"public_flags": 0,
|
||||
"flags": 0,
|
||||
"bot": true,
|
||||
"global_name": null
|
||||
},
|
||||
"attachments": [],
|
||||
"embeds": [
|
||||
{
|
||||
"type": "rich",
|
||||
"description": "some description",
|
||||
"color": 10930459,
|
||||
"timestamp": "2023-10-17T21:00:00+00:00",
|
||||
"author": {
|
||||
"name": "Michael"
|
||||
}
|
||||
}
|
||||
],
|
||||
"mentions": [],
|
||||
"mention_roles": [],
|
||||
"pinned": false,
|
||||
"mention_everyone": false,
|
||||
"tts": true,
|
||||
"timestamp": "2023-10-31T04:30:41.032000+00:00",
|
||||
"edited_timestamp": null,
|
||||
"flags": 4096,
|
||||
"components": [],
|
||||
"webhook_id": "1153265494955135077"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"connections": {
|
||||
"When clicking \"Execute Workflow\"": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Bot test",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Bot test": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "No Operation, do nothing",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"active": false,
|
||||
"settings": {},
|
||||
"versionId": "a4deab55-3791-4e57-b879-d804cd839348",
|
||||
"id": "Hpl0rsKs6xAbHVO4",
|
||||
"meta": {
|
||||
"instanceId": "b888bd11cd1ddbb95450babf3e199556799d999b896f650de768b8370ee50363"
|
||||
},
|
||||
"tags": []
|
||||
}
|
||||
@@ -0,0 +1,192 @@
|
||||
import { NodeOperationError, type IExecuteFunctions, type INode } from 'n8n-workflow';
|
||||
|
||||
import * as transport from '../../v2//transport/discord.api';
|
||||
import {
|
||||
createSimplifyFunction,
|
||||
prepareOptions,
|
||||
prepareEmbeds,
|
||||
checkAccessToGuild,
|
||||
setupChannelGetter,
|
||||
parseDiscordError,
|
||||
} from '../../v2/helpers/utils';
|
||||
|
||||
const node: INode = {
|
||||
id: '1',
|
||||
name: 'Discord node',
|
||||
typeVersion: 2,
|
||||
type: 'n8n-nodes-base.discord',
|
||||
position: [60, 760],
|
||||
parameters: {
|
||||
resource: 'channel',
|
||||
operation: 'get',
|
||||
},
|
||||
};
|
||||
|
||||
describe('Test Discord > createSimplifyFunction', () => {
|
||||
it('should create function', () => {
|
||||
const result = createSimplifyFunction(['message_reference']);
|
||||
expect(result).toBeDefined();
|
||||
expect(typeof result).toBe('function');
|
||||
});
|
||||
|
||||
it('should return object containing only specified fields', () => {
|
||||
const simplify = createSimplifyFunction(['id', 'name']);
|
||||
const data = {
|
||||
id: '123',
|
||||
name: 'test',
|
||||
type: 'test',
|
||||
randomField: 'test',
|
||||
};
|
||||
const result = simplify(data);
|
||||
expect(result).toEqual({
|
||||
id: '123',
|
||||
name: 'test',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Test Discord > prepareOptions', () => {
|
||||
it('should return correct flag value', () => {
|
||||
const result = prepareOptions({
|
||||
flags: ['SUPPRESS_EMBEDS', 'SUPPRESS_NOTIFICATIONS'],
|
||||
});
|
||||
expect(result.flags).toBe((1 << 2) + (1 << 12));
|
||||
});
|
||||
|
||||
it('should convert message_reference', () => {
|
||||
const result = prepareOptions(
|
||||
{
|
||||
message_reference: '123456',
|
||||
},
|
||||
'789000',
|
||||
);
|
||||
expect(result.message_reference).toEqual({
|
||||
message_id: '123456',
|
||||
guild_id: '789000',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Test Discord > prepareEmbeds', () => {
|
||||
it('should return return empty object removing empty strings', () => {
|
||||
const embeds = [
|
||||
{
|
||||
test1: 'test',
|
||||
test2: 'test',
|
||||
description: 'test',
|
||||
},
|
||||
];
|
||||
|
||||
const executeFunction = {};
|
||||
|
||||
const result = prepareEmbeds.call(executeFunction as unknown as IExecuteFunctions, embeds);
|
||||
|
||||
expect(result).toEqual(embeds);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Test Discord > checkAccessToGuild', () => {
|
||||
it('should throw error', () => {
|
||||
const guildId = '123456';
|
||||
const guilds = [
|
||||
{
|
||||
id: '789000',
|
||||
},
|
||||
];
|
||||
|
||||
expect(() => {
|
||||
checkAccessToGuild(node, guildId, guilds);
|
||||
}).toThrow('You do not have access to the guild with the id 123456');
|
||||
});
|
||||
|
||||
it('should pass', () => {
|
||||
const guildId = '123456';
|
||||
const guilds = [
|
||||
{
|
||||
id: '123456',
|
||||
},
|
||||
{
|
||||
id: '789000',
|
||||
},
|
||||
];
|
||||
|
||||
expect(() => {
|
||||
checkAccessToGuild(node, guildId, guilds);
|
||||
}).not.toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
describe('Test Discord > setupChannelGetter & checkAccessToChannel', () => {
|
||||
const discordApiRequestSpy = jest.spyOn(transport, 'discordApiRequest');
|
||||
discordApiRequestSpy.mockImplementation(async (method: string) => {
|
||||
if (method === 'GET') {
|
||||
return {
|
||||
guild_id: '123456',
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
it('should setup channel getter and get channel id', async () => {
|
||||
const fakeExecuteFunction = (auth: string) => {
|
||||
return {
|
||||
getNodeParameter: (parameter: string) => {
|
||||
if (parameter === 'authentication') return auth;
|
||||
if (parameter === 'channelId') return '42';
|
||||
},
|
||||
getNode: () => node,
|
||||
} as unknown as IExecuteFunctions;
|
||||
};
|
||||
|
||||
const userGuilds = [
|
||||
{
|
||||
id: '789000',
|
||||
},
|
||||
];
|
||||
|
||||
try {
|
||||
const getChannel = await setupChannelGetter.call(fakeExecuteFunction('oAuth2'), userGuilds);
|
||||
await getChannel(0);
|
||||
} catch (error) {
|
||||
expect(error.message).toBe('You do not have access to the guild with the id 123456');
|
||||
}
|
||||
|
||||
const getChannel = await setupChannelGetter.call(fakeExecuteFunction('botToken'), userGuilds);
|
||||
const channelId = await getChannel(0);
|
||||
expect(channelId).toBe('42');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Test Discord > parseDiscordError', () => {
|
||||
const errorMessage =
|
||||
'400 - {"message":"Invalid Form Body","code":50035,"errors":{"embeds":{"0":{"description":{"_errors":[{"code":"BASE_TYPE_REQUIRED","message":"This field is required"}]}}}}}';
|
||||
|
||||
it('should parse error with description', () => {
|
||||
const error = {
|
||||
cause: {
|
||||
error: 'Invalid Form Body',
|
||||
},
|
||||
description: errorMessage,
|
||||
};
|
||||
const executeFunction = {
|
||||
getNode: () => {},
|
||||
} as unknown as IExecuteFunctions;
|
||||
|
||||
const result = parseDiscordError.call(executeFunction, error);
|
||||
expect(result).toBeInstanceOf(NodeOperationError);
|
||||
expect(result.message).toBe('Invalid Form Body');
|
||||
});
|
||||
|
||||
it('should parse error with messages array', () => {
|
||||
const error = {
|
||||
cause: undefined,
|
||||
messages: [errorMessage],
|
||||
};
|
||||
const executeFunction = {
|
||||
getNode: () => {},
|
||||
} as unknown as IExecuteFunctions;
|
||||
|
||||
const result = parseDiscordError.call(executeFunction, error);
|
||||
expect(result).toBeInstanceOf(NodeOperationError);
|
||||
expect(result.message).toBe('Invalid Form Body');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user