Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Microsoft Teams Node): Overhaul #7477

Merged
merged 36 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
2d5d03f
:zap: setup
michael-radency Oct 20, 2023
1be3217
Merge branch 'master' of https://github.com/n8n-io/n8n into node-179-…
michael-radency Oct 20, 2023
a4fb103
Merge branch 'master' of https://github.com/n8n-io/n8n into node-179-…
michael-radency Oct 21, 2023
983397f
:zap: RLCs added in https://github.com/n8n-io/n8n/pull/4539/files
michael-radency Oct 23, 2023
63f80d4
:zap: channel > create, teamsRLC > added url to From List items, By U…
michael-radency Oct 23, 2023
4fb5f29
Merge branch 'master' of https://github.com/n8n-io/n8n into node-179-…
michael-radency Oct 23, 2023
653b332
:zap: channel resource update
michael-radency Oct 23, 2023
80d945f
Merge branch 'master' of https://github.com/n8n-io/n8n into node-179-…
michael-radency Oct 23, 2023
99b8a5f
:zap: cnannel and chat message resources
michael-radency Oct 23, 2023
b7ac72e
:zap: task resource
michael-radency Oct 24, 2023
d44a735
Merge branch 'master' of https://github.com/n8n-io/n8n into node-179-…
michael-radency Oct 24, 2023
7375f02
:zap: merge fixes
michael-radency Oct 24, 2023
9edad4f
Merge branch 'master' of https://github.com/n8n-io/n8n into node-179-…
michael-radency Oct 25, 2023
60d6424
:zap: better parsing api error
michael-radency Oct 26, 2023
cb202ee
:zap: tests WIP
michael-radency Oct 26, 2023
eb5f84e
Merge branch 'master' of https://github.com/n8n-io/n8n into node-179-…
michael-radency Oct 26, 2023
d4e583e
Merge branch 'master' of https://github.com/n8n-io/n8n into node-179-…
michael-radency Oct 26, 2023
b07a37f
:zap: channel and channelMessage tests
michael-radency Oct 26, 2023
948d969
Merge branch 'master' of https://github.com/n8n-io/n8n into node-179-…
michael-radency Oct 26, 2023
e585d20
:zap: chatMessage and task tests
michael-radency Oct 27, 2023
b1403f4
Merge branch 'master' of https://github.com/n8n-io/n8n into node-179-…
michael-radency Oct 27, 2023
47dc0b7
Various copy updates.
gandreini Jan 11, 2024
d8d88e1
Merge branch 'node-179-microsoft-teams-node-overhaul' of https://gith…
michael-radency Jan 12, 2024
e813d45
Merge branch 'master' of https://github.com/n8n-io/n8n into node-179-…
michael-radency Jan 12, 2024
b6f5472
:zap: merge fix
michael-radency Jan 12, 2024
f02f2c1
Copy fixes.
gandreini Jan 12, 2024
85d7fc2
:zap: removed byUrl from channel and chat RLC, updated error for not …
michael-radency Jan 12, 2024
a24a831
Merge branch 'master' of https://github.com/n8n-io/n8n into node-179-…
michael-radency Jan 12, 2024
bca5775
Merge branch 'node-179-microsoft-teams-node-overhaul' of https://gith…
michael-radency Jan 12, 2024
d21fd04
Merge branch 'master' of https://github.com/n8n-io/n8n into node-179-…
michael-radency Jan 12, 2024
61b8bb8
:zap: removed group source, error fix for incorect id
michael-radency Jan 12, 2024
6efebb3
Merge branch 'master' of https://github.com/n8n-io/n8n into node-179-…
michael-radency Jan 13, 2024
635fb57
:zap: dueDateTime fix, tests fix
michael-radency Jan 13, 2024
d3e11db
Merge branch 'master' of https://github.com/n8n-io/n8n into node-179-…
michael-radency Jan 22, 2024
87bc4ba
:zap: update assignTo fix, linter fixes
michael-radency Jan 22, 2024
0296220
:zap: linter fixes
michael-radency Jan 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
692 changes: 24 additions & 668 deletions packages/nodes-base/nodes/Microsoft/Teams/MicrosoftTeams.node.ts

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import type { INodeTypes } from 'n8n-workflow';
import { getResultNodeData, setup, workflowToTests } from '@test/nodes/Helpers';
import type { WorkflowTestData } from '@test/nodes/types';
import { executeWorkflow } from '@test/nodes/ExecuteWorkflow';

import nock from 'nock';

import * as transport from '../../../../v2/transport';

const microsoftApiRequestSpy = jest.spyOn(transport, 'microsoftApiRequest');

microsoftApiRequestSpy.mockImplementation(async (method: string) => {
if (method === 'POST') {
return {
'@odata.context':
"https://graph.microsoft.com/v1.0/$metadata#teams('1644e7fe-547e-4223-a24f-922395865343')/channels/$entity",
id: '19:16259efabba44a66916d91dd91862a6f@thread.tacv2',
createdDateTime: '2023-10-26T05:37:43.4798824Z',
displayName: 'New Channel',
description: 'new channel description',
isFavoriteByDefault: null,
email: '',
webUrl:
'https://teams.microsoft.com/l/channel/19%3a16259efabba44a66916d91dd91862a6f%40thread.tacv2/New+Channel?groupId=1644e7fe-547e-4223-a24f-922395865343&tenantId=tenantId-111-222-333',
membershipType: 'private',
};
}
});

describe('Test MicrosoftTeamsV2, channel => create', () => {
const workflows = ['nodes/Microsoft/Teams/test/v2/node/channel/create.workflow.json'];
const tests = workflowToTests(workflows);

beforeAll(() => {
nock.disableNetConnect();
});

afterAll(() => {
nock.restore();
jest.resetAllMocks();
});

const nodeTypes = setup(tests);

const testNode = async (testData: WorkflowTestData, types: INodeTypes) => {
const { result } = await executeWorkflow(testData, types);

const resultNodeData = getResultNodeData(result, testData);

resultNodeData.forEach(({ nodeName, resultData }) => {
return expect(resultData).toEqual(testData.output.nodeData[nodeName]);
});

expect(microsoftApiRequestSpy).toHaveBeenCalledTimes(1);
expect(microsoftApiRequestSpy).toHaveBeenCalledWith(
'POST',
'/v1.0/teams/1644e7fe-547e-4223-a24f-922395865343/channels',
{
description: 'new channel description',
displayName: 'New Channel',
membershipType: 'private',
},
);

expect(result.finished).toEqual(true);
};

for (const testData of tests) {
test(testData.description, async () => await testNode(testData, nodeTypes));
}
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
{
"name": "My workflow 35",
"nodes": [
{
"parameters": {},
"id": "6666-9999-77777",
"name": "When clicking \"Execute Workflow\"",
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [
880,
380
]
},
{
"parameters": {
"teamId": {
"__rl": true,
"value": "1644e7fe-547e-4223-a24f-922395865343",
"mode": "list",
"cachedResultName": "5w1hb7"
},
"name": "New Channel",
"options": {
"description": "new channel description",
"type": "private"
}
},
"id": "6666-5555-77777",
"name": "Microsoft Teams",
"type": "n8n-nodes-base.microsoftTeams",
"typeVersion": 2,
"position": [
1100,
380
],
"credentials": {
"microsoftTeamsOAuth2Api": {
"id": "6isd5ytvA0qV78eK",
"name": "Microsoft Teams account"
}
}
},
{
"parameters": {},
"id": "9d1a2e59-c71c-486c-b3ac-dec6adbc26b3",
"name": "No Operation, do nothing",
"type": "n8n-nodes-base.noOp",
"typeVersion": 1,
"position": [
1400,
380
]
}
],
"pinData": {
"No Operation, do nothing": [
{
"json": {
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#teams('1644e7fe-547e-4223-a24f-922395865343')/channels/$entity",
"id": "19:16259efabba44a66916d91dd91862a6f@thread.tacv2",
"createdDateTime": "2023-10-26T05:37:43.4798824Z",
"displayName": "New Channel",
"description": "new channel description",
"isFavoriteByDefault": null,
"email": "",
"webUrl": "https://teams.microsoft.com/l/channel/19%3a16259efabba44a66916d91dd91862a6f%40thread.tacv2/New+Channel?groupId=1644e7fe-547e-4223-a24f-922395865343&tenantId=tenantId-111-222-333",
"membershipType": "private"
}
}
]
},
"connections": {
"When clicking \"Execute Workflow\"": {
"main": [
[
{
"node": "Microsoft Teams",
"type": "main",
"index": 0
}
]
]
},
"Microsoft Teams": {
"main": [
[
{
"node": "No Operation, do nothing",
"type": "main",
"index": 0
}
]
]
}
},
"active": false,
"settings": {
"executionOrder": "v1"
},
"versionId": "ec0b4e3d-2fd7-4fac-90e5-f18ecd620a8f",
"id": "i3NYGF0LXV4qDFV9",
"meta": {
"instanceId": "b888bd11cd1ddbb95450babf3e199556799d999b896f650de768b8370ee50363"
},
"tags": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import type { INodeTypes } from 'n8n-workflow';
import nock from 'nock';
import * as transport from '../../../../v2/transport';
import { getResultNodeData, setup, workflowToTests } from '@test/nodes/Helpers';
import type { WorkflowTestData } from '@test/nodes/types';
import { executeWorkflow } from '@test/nodes/ExecuteWorkflow';

const microsoftApiRequestSpy = jest.spyOn(transport, 'microsoftApiRequest');

microsoftApiRequestSpy.mockImplementation(async (method: string) => {
if (method === 'DELETE') {
return {};
}
});

describe('Test MicrosoftTeamsV2, channel => deleteChannel', () => {
const workflows = ['nodes/Microsoft/Teams/test/v2/node/channel/deleteChannel.workflow.json'];
const tests = workflowToTests(workflows);

beforeAll(() => {
nock.disableNetConnect();
});

afterAll(() => {
nock.restore();
jest.resetAllMocks();
});

const nodeTypes = setup(tests);

const testNode = async (testData: WorkflowTestData, types: INodeTypes) => {
const { result } = await executeWorkflow(testData, types);

const resultNodeData = getResultNodeData(result, testData);

resultNodeData.forEach(({ nodeName, resultData }) => {
return expect(resultData).toEqual(testData.output.nodeData[nodeName]);
});

expect(microsoftApiRequestSpy).toHaveBeenCalledTimes(1);
expect(microsoftApiRequestSpy).toHaveBeenCalledWith(
'DELETE',
'/v1.0/teams/1644e7fe-547e-4223-a24f-922395865343/channels/19:16259efabba44a66916d91dd91862a6f@thread.tacv2',
);

expect(result.finished).toEqual(true);
};

for (const testData of tests) {
test(testData.description, async () => await testNode(testData, nodeTypes));
}
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
{
"name": "My workflow 35",
"nodes": [
{
"parameters": {},
"id": "6666-9999-77777",
"name": "When clicking \"Execute Workflow\"",
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [
880,
380
]
},
{
"parameters": {
"operation": "deleteChannel",
"teamId": {
"__rl": true,
"value": "1644e7fe-547e-4223-a24f-922395865343",
"mode": "list",
"cachedResultName": "5w1hb7"
},
"channelId": {
"__rl": true,
"value": "19:16259efabba44a66916d91dd91862a6f@thread.tacv2",
"mode": "list",
"cachedResultName": "New Channel",
"cachedResultUrl": "https://teams.microsoft.com/l/channel/19%3A16259efabba44a66916d91dd91862a6f%40thread.tacv2/New%20Channel?groupId=1644e7fe-547e-4223-a24f-922395865343&tenantId=tenantId-111-222-333&allowXTenantAccess=False"
}
},
"id": "6666-5555-77777",
"name": "Microsoft Teams",
"type": "n8n-nodes-base.microsoftTeams",
"typeVersion": 2,
"position": [
1100,
380
],
"credentials": {
"microsoftTeamsOAuth2Api": {
"id": "6isd5ytvA0qV78eK",
"name": "Microsoft Teams account"
}
}
},
{
"parameters": {},
"id": "9d1a2e59-c71c-486c-b3ac-dec6adbc26b3",
"name": "No Operation, do nothing",
"type": "n8n-nodes-base.noOp",
"typeVersion": 1,
"position": [
1400,
380
]
}
],
"pinData": {
"No Operation, do nothing": [
{
"json": {
"success": true
}
}
]
},
"connections": {
"When clicking \"Execute Workflow\"": {
"main": [
[
{
"node": "Microsoft Teams",
"type": "main",
"index": 0
}
]
]
},
"Microsoft Teams": {
"main": [
[
{
"node": "No Operation, do nothing",
"type": "main",
"index": 0
}
]
]
}
},
"active": false,
"settings": {
"executionOrder": "v1"
},
"versionId": "fb9028a2-b502-45f1-b907-825e8d754991",
"id": "i3NYGF0LXV4qDFV9",
"meta": {
"instanceId": "b888bd11cd1ddbb95450babf3e199556799d999b896f650de768b8370ee50363"
},
"tags": []
}
Loading
Loading