feat(Microsoft Outlook Node): Node overhaul (#4449)
[N8N-4995](https://linear.app/n8n/issue/N8N-4995) --------- Co-authored-by: Giulio Andreini <g.andreini@gmail.com>
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
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';
|
||||
|
||||
jest.mock('../../../../v2/transport', () => {
|
||||
const originalModule = jest.requireActual('../../../../v2/transport');
|
||||
return {
|
||||
...originalModule,
|
||||
microsoftApiRequest: jest.fn(async function (method: string) {
|
||||
if (method === 'POST') {
|
||||
return {
|
||||
'@odata.context':
|
||||
"https://graph.microsoft.com/v1.0/$metadata#users('b834447b-6848-4af9-8390-d2259ce46b74')/calendarGroups('AAAXXXYYYnnnT6b9RLP0CKzHiJrRBwBZf4De-LkrSqpPI8eyjUmAAAAAAAEGAABZf4De-LkrSqpPI8eyjUmAAACLtRu_AAA%3D')/calendars/$entity",
|
||||
id: 'AAAXXXYYYnnnT6b9RLP0CKzHiJrRBwBZf4De-LkrSqpPI8eyjUmAAAAAAAEGAABZf4De-LkrSqpPI8eyjUmAAAFXBBZ_AAA=',
|
||||
name: 'New Calendar',
|
||||
color: 'lightOrange',
|
||||
hexColor: '#fcab73',
|
||||
isDefaultCalendar: false,
|
||||
changeKey: 'WX+A3vy5K0qqTyPHso1JgAABVtwWTA==',
|
||||
canShare: true,
|
||||
canViewPrivateItems: true,
|
||||
canEdit: true,
|
||||
allowedOnlineMeetingProviders: ['teamsForBusiness'],
|
||||
defaultOnlineMeetingProvider: 'teamsForBusiness',
|
||||
isTallyingResponses: false,
|
||||
isRemovable: true,
|
||||
owner: {
|
||||
name: 'User Name',
|
||||
address: 'test@mail.com',
|
||||
},
|
||||
};
|
||||
}
|
||||
}),
|
||||
};
|
||||
});
|
||||
|
||||
describe('Test MicrosoftOutlookV2, calendar => create', () => {
|
||||
const workflows = ['nodes/Microsoft/Outlook/test/v2/node/calendar/create.workflow.json'];
|
||||
const tests = workflowToTests(workflows);
|
||||
|
||||
beforeAll(() => {
|
||||
nock.disableNetConnect();
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
nock.restore();
|
||||
jest.unmock('../../../../v2/transport');
|
||||
});
|
||||
|
||||
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(transport.microsoftApiRequest).toHaveBeenCalledTimes(1);
|
||||
expect(transport.microsoftApiRequest).toHaveBeenCalledWith(
|
||||
'POST',
|
||||
'/calendarGroups/AAAXXXYYYnnnT6b9RLP0CKzHiJrRBwBZf4De-LkrSqpPI8eyjUmAAAAAAAEGAABZf4De-LkrSqpPI8eyjUmAAACLtRu_AAA=/calendars',
|
||||
{ color: 'lightOrange', name: 'New Calendar' },
|
||||
);
|
||||
|
||||
expect(result.finished).toEqual(true);
|
||||
};
|
||||
|
||||
for (const testData of tests) {
|
||||
test(testData.description, async () => testNode(testData, nodeTypes));
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,92 @@
|
||||
{
|
||||
"name": "My workflow 21",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "e524f588-b6a3-4849-8777-b32a8a755ae5",
|
||||
"name": "When clicking \"Execute Workflow\"",
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
820,
|
||||
360
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"resource": "calendar",
|
||||
"operation": "create",
|
||||
"name": "New Calendar",
|
||||
"additionalFields": {
|
||||
"calendarGroup": "AAAXXXYYYnnnT6b9RLP0CKzHiJrRBwBZf4De-LkrSqpPI8eyjUmAAAAAAAEGAABZf4De-LkrSqpPI8eyjUmAAACLtRu_AAA=",
|
||||
"color": "lightOrange"
|
||||
}
|
||||
},
|
||||
"id": "baff6798-0304-4255-bdb0-dd3f2659373b",
|
||||
"name": "Microsoft Outlook",
|
||||
"type": "n8n-nodes-base.microsoftOutlook",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
1040,
|
||||
360
|
||||
],
|
||||
"credentials": {
|
||||
"microsoftOutlookOAuth2Api": {
|
||||
"id": "iXJCki7i5Vz0bdks",
|
||||
"name": "Microsoft Outlook account 2"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"pinData": {
|
||||
"Microsoft Outlook": [
|
||||
{
|
||||
"json": {
|
||||
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('b834447b-6848-4af9-8390-d2259ce46b74')/calendarGroups('AAAXXXYYYnnnT6b9RLP0CKzHiJrRBwBZf4De-LkrSqpPI8eyjUmAAAAAAAEGAABZf4De-LkrSqpPI8eyjUmAAACLtRu_AAA%3D')/calendars/$entity",
|
||||
"id": "AAAXXXYYYnnnT6b9RLP0CKzHiJrRBwBZf4De-LkrSqpPI8eyjUmAAAAAAAEGAABZf4De-LkrSqpPI8eyjUmAAAFXBBZ_AAA=",
|
||||
"name": "New Calendar",
|
||||
"color": "lightOrange",
|
||||
"hexColor": "#fcab73",
|
||||
"isDefaultCalendar": false,
|
||||
"changeKey": "WX+A3vy5K0qqTyPHso1JgAABVtwWTA==",
|
||||
"canShare": true,
|
||||
"canViewPrivateItems": true,
|
||||
"canEdit": true,
|
||||
"allowedOnlineMeetingProviders": [
|
||||
"teamsForBusiness"
|
||||
],
|
||||
"defaultOnlineMeetingProvider": "teamsForBusiness",
|
||||
"isTallyingResponses": false,
|
||||
"isRemovable": true,
|
||||
"owner": {
|
||||
"name": "User Name",
|
||||
"address": "test@mail.com"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"connections": {
|
||||
"When clicking \"Execute Workflow\"": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Microsoft Outlook",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"active": false,
|
||||
"settings": {
|
||||
"executionOrder": "v1"
|
||||
},
|
||||
"versionId": "074cdbef-4193-45b8-970a-9f55b8a0999b",
|
||||
"id": "1CYHzBXQw1nfPGtB",
|
||||
"meta": {
|
||||
"instanceId": "b888bd11cd1ddbb95450babf3e199556799d999b896f650de768b8370ee50363"
|
||||
},
|
||||
"tags": []
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
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';
|
||||
|
||||
jest.mock('../../../../v2/transport', () => {
|
||||
const originalModule = jest.requireActual('../../../../v2/transport');
|
||||
return {
|
||||
...originalModule,
|
||||
microsoftApiRequest: jest.fn(async function (method: string) {
|
||||
if (method === 'DELETE') {
|
||||
return {};
|
||||
}
|
||||
}),
|
||||
};
|
||||
});
|
||||
|
||||
describe('Test MicrosoftOutlookV2, calendar => delete', () => {
|
||||
const workflows = ['nodes/Microsoft/Outlook/test/v2/node/calendar/delete.workflow.json'];
|
||||
const tests = workflowToTests(workflows);
|
||||
|
||||
beforeAll(() => {
|
||||
nock.disableNetConnect();
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
nock.restore();
|
||||
jest.unmock('../../../../v2/transport');
|
||||
});
|
||||
|
||||
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(transport.microsoftApiRequest).toHaveBeenCalledTimes(1);
|
||||
expect(transport.microsoftApiRequest).toHaveBeenCalledWith(
|
||||
'DELETE',
|
||||
'/calendars/AAAXXXYYYnnnT6b9RLP0CKzHiJrRBwBZf4De-LkrSqpPI8eyjUmAAAAAAAEGAABZf4De-LkrSqpPI8eyjUmAAACLtRvIAAA=',
|
||||
);
|
||||
|
||||
expect(result.finished).toEqual(true);
|
||||
};
|
||||
|
||||
for (const testData of tests) {
|
||||
test(testData.description, async () => testNode(testData, nodeTypes));
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,74 @@
|
||||
{
|
||||
"name": "My workflow 21",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "e524f588-b6a3-4849-8777-b32a8a755ae5",
|
||||
"name": "When clicking \"Execute Workflow\"",
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
820,
|
||||
360
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"resource": "calendar",
|
||||
"operation": "delete",
|
||||
"calendarId": {
|
||||
"__rl": true,
|
||||
"value": "AAAXXXYYYnnnT6b9RLP0CKzHiJrRBwBZf4De-LkrSqpPI8eyjUmAAAAAAAEGAABZf4De-LkrSqpPI8eyjUmAAACLtRvIAAA=",
|
||||
"mode": "list",
|
||||
"cachedResultName": "Foo"
|
||||
}
|
||||
},
|
||||
"id": "baff6798-0304-4255-bdb0-dd3f2659373b",
|
||||
"name": "Microsoft Outlook",
|
||||
"type": "n8n-nodes-base.microsoftOutlook",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
1040,
|
||||
360
|
||||
],
|
||||
"credentials": {
|
||||
"microsoftOutlookOAuth2Api": {
|
||||
"id": "iXJCki7i5Vz0bdks",
|
||||
"name": "Microsoft Outlook account 2"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"pinData": {
|
||||
"Microsoft Outlook": [
|
||||
{
|
||||
"json": {
|
||||
"success": true
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"connections": {
|
||||
"When clicking \"Execute Workflow\"": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Microsoft Outlook",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"active": false,
|
||||
"settings": {
|
||||
"executionOrder": "v1"
|
||||
},
|
||||
"versionId": "888e5578-c726-4a84-9658-321ba04fd0c7",
|
||||
"id": "1CYHzBXQw1nfPGtB",
|
||||
"meta": {
|
||||
"instanceId": "b888bd11cd1ddbb95450babf3e199556799d999b896f650de768b8370ee50363"
|
||||
},
|
||||
"tags": []
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
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';
|
||||
|
||||
jest.mock('../../../../v2/transport', () => {
|
||||
const originalModule = jest.requireActual('../../../../v2/transport');
|
||||
return {
|
||||
...originalModule,
|
||||
microsoftApiRequest: jest.fn(async function (method: string) {
|
||||
if (method === 'GET') {
|
||||
return {
|
||||
'@odata.context':
|
||||
"https://graph.microsoft.com/v1.0/$metadata#users('b834447b-6848-4af9-8390-d2259ce46b74')/calendars/$entity",
|
||||
id: 'AAAXXXYYYnnnT6b9RLP0CKzHiJrRBwBZf4De-LkrSqpPI8eyjUmAAAAAAAEGAABZf4De-LkrSqpPI8eyjUmAAACLtRvGAAA=',
|
||||
name: 'Foo Calendar',
|
||||
color: 'lightGreen',
|
||||
hexColor: '#87d28e',
|
||||
isDefaultCalendar: false,
|
||||
changeKey: 'WX+A3vy5K0qqTyPHso1JgAAAi67hiw==',
|
||||
canShare: true,
|
||||
canViewPrivateItems: true,
|
||||
canEdit: true,
|
||||
allowedOnlineMeetingProviders: ['teamsForBusiness'],
|
||||
defaultOnlineMeetingProvider: 'teamsForBusiness',
|
||||
isTallyingResponses: false,
|
||||
isRemovable: true,
|
||||
owner: {
|
||||
name: 'User Name',
|
||||
address: 'test@mail.com',
|
||||
},
|
||||
};
|
||||
}
|
||||
}),
|
||||
};
|
||||
});
|
||||
|
||||
describe('Test MicrosoftOutlookV2, calendar => get', () => {
|
||||
const workflows = ['nodes/Microsoft/Outlook/test/v2/node/calendar/get.workflow.json'];
|
||||
const tests = workflowToTests(workflows);
|
||||
|
||||
beforeAll(() => {
|
||||
nock.disableNetConnect();
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
nock.restore();
|
||||
jest.unmock('../../../../v2/transport');
|
||||
});
|
||||
|
||||
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(transport.microsoftApiRequest).toHaveBeenCalledTimes(1);
|
||||
expect(transport.microsoftApiRequest).toHaveBeenCalledWith(
|
||||
'GET',
|
||||
'/calendars/AAAXXXYYYnnnT6b9RLP0CKzHiJrRBwBZf4De-LkrSqpPI8eyjUmAAAAAAAEGAABZf4De-LkrSqpPI8eyjUmAAACLtRvGAAA=',
|
||||
undefined,
|
||||
{},
|
||||
);
|
||||
|
||||
expect(result.finished).toEqual(true);
|
||||
};
|
||||
|
||||
for (const testData of tests) {
|
||||
test(testData.description, async () => testNode(testData, nodeTypes));
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,93 @@
|
||||
{
|
||||
"name": "My workflow 21",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "e524f588-b6a3-4849-8777-b32a8a755ae5",
|
||||
"name": "When clicking \"Execute Workflow\"",
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
820,
|
||||
360
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"resource": "calendar",
|
||||
"operation": "get",
|
||||
"calendarId": {
|
||||
"__rl": true,
|
||||
"value": "AAAXXXYYYnnnT6b9RLP0CKzHiJrRBwBZf4De-LkrSqpPI8eyjUmAAAAAAAEGAABZf4De-LkrSqpPI8eyjUmAAACLtRvGAAA=",
|
||||
"mode": "list",
|
||||
"cachedResultName": "Foo Calendar"
|
||||
}
|
||||
},
|
||||
"id": "baff6798-0304-4255-bdb0-dd3f2659373b",
|
||||
"name": "Microsoft Outlook",
|
||||
"type": "n8n-nodes-base.microsoftOutlook",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
1040,
|
||||
360
|
||||
],
|
||||
"credentials": {
|
||||
"microsoftOutlookOAuth2Api": {
|
||||
"id": "iXJCki7i5Vz0bdks",
|
||||
"name": "Microsoft Outlook account 2"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"pinData": {
|
||||
"Microsoft Outlook": [
|
||||
{
|
||||
"json": {
|
||||
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('b834447b-6848-4af9-8390-d2259ce46b74')/calendars/$entity",
|
||||
"id": "AAAXXXYYYnnnT6b9RLP0CKzHiJrRBwBZf4De-LkrSqpPI8eyjUmAAAAAAAEGAABZf4De-LkrSqpPI8eyjUmAAACLtRvGAAA=",
|
||||
"name": "Foo Calendar",
|
||||
"color": "lightGreen",
|
||||
"hexColor": "#87d28e",
|
||||
"isDefaultCalendar": false,
|
||||
"changeKey": "WX+A3vy5K0qqTyPHso1JgAAAi67hiw==",
|
||||
"canShare": true,
|
||||
"canViewPrivateItems": true,
|
||||
"canEdit": true,
|
||||
"allowedOnlineMeetingProviders": [
|
||||
"teamsForBusiness"
|
||||
],
|
||||
"defaultOnlineMeetingProvider": "teamsForBusiness",
|
||||
"isTallyingResponses": false,
|
||||
"isRemovable": true,
|
||||
"owner": {
|
||||
"name": "User Name",
|
||||
"address": "test@mail.com"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"connections": {
|
||||
"When clicking \"Execute Workflow\"": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Microsoft Outlook",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"active": false,
|
||||
"settings": {
|
||||
"executionOrder": "v1"
|
||||
},
|
||||
"versionId": "33e1fc57-ac36-453b-b01e-d79784b4a4bb",
|
||||
"id": "1CYHzBXQw1nfPGtB",
|
||||
"meta": {
|
||||
"instanceId": "b888bd11cd1ddbb95450babf3e199556799d999b896f650de768b8370ee50363"
|
||||
},
|
||||
"tags": []
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
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';
|
||||
|
||||
jest.mock('../../../../v2/transport', () => {
|
||||
const originalModule = jest.requireActual('../../../../v2/transport');
|
||||
return {
|
||||
...originalModule,
|
||||
microsoftApiRequest: jest.fn(async function (method: string) {
|
||||
if (method === 'GET') {
|
||||
return {
|
||||
value: [
|
||||
{
|
||||
id: 'AAAXXXYYYnnnT6b9RLP0CKzHiJrRBwBZf4De-LkrSqpPI8eyjUmAAAAAAAEGAABZf4De-LkrSqpPI8eyjUmAAAAJ9-JDAAA=',
|
||||
name: 'Calendar',
|
||||
color: 'auto',
|
||||
hexColor: '',
|
||||
isDefaultCalendar: true,
|
||||
changeKey: 'WX+A3vy5K0qqTyPHso1JgAAACfdHfw==',
|
||||
canShare: true,
|
||||
canViewPrivateItems: true,
|
||||
canEdit: true,
|
||||
allowedOnlineMeetingProviders: ['teamsForBusiness'],
|
||||
defaultOnlineMeetingProvider: 'teamsForBusiness',
|
||||
isTallyingResponses: true,
|
||||
isRemovable: false,
|
||||
owner: {
|
||||
name: 'User Name',
|
||||
address: 'test@mail.com',
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'AAAXXXYYYnnnT6b9RLP0CKzHiJrRBwBZf4De-LkrSqpPI8eyjUmAAAAAAAEGAABZf4De-LkrSqpPI8eyjUmAAACLtRvBAAA=',
|
||||
name: 'Third calendar',
|
||||
color: 'lightYellow',
|
||||
hexColor: '#fde300',
|
||||
isDefaultCalendar: false,
|
||||
changeKey: 'WX+A3vy5K0qqTyPHso1JgAAAi67hIw==',
|
||||
canShare: true,
|
||||
canViewPrivateItems: true,
|
||||
canEdit: true,
|
||||
allowedOnlineMeetingProviders: ['teamsForBusiness'],
|
||||
defaultOnlineMeetingProvider: 'teamsForBusiness',
|
||||
isTallyingResponses: false,
|
||||
isRemovable: true,
|
||||
owner: {
|
||||
name: 'User Name',
|
||||
address: 'test@mail.com',
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
}),
|
||||
};
|
||||
});
|
||||
|
||||
describe('Test MicrosoftOutlookV2, calendar => getAll', () => {
|
||||
const workflows = ['nodes/Microsoft/Outlook/test/v2/node/calendar/getAll.workflow.json'];
|
||||
const tests = workflowToTests(workflows);
|
||||
|
||||
beforeAll(() => {
|
||||
nock.disableNetConnect();
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
nock.restore();
|
||||
jest.unmock('../../../../v2/transport');
|
||||
});
|
||||
|
||||
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(transport.microsoftApiRequest).toHaveBeenCalledTimes(1);
|
||||
expect(transport.microsoftApiRequest).toHaveBeenCalledWith('GET', '/calendars', undefined, {
|
||||
$filter: 'canEdit eq true',
|
||||
$top: 2,
|
||||
});
|
||||
|
||||
expect(result.finished).toEqual(true);
|
||||
};
|
||||
|
||||
for (const testData of tests) {
|
||||
test(testData.description, async () => testNode(testData, nodeTypes));
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,112 @@
|
||||
{
|
||||
"name": "My workflow 21",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "e524f588-b6a3-4849-8777-b32a8a755ae5",
|
||||
"name": "When clicking \"Execute Workflow\"",
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
820,
|
||||
360
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"resource": "calendar",
|
||||
"limit": 2,
|
||||
"filters": {
|
||||
"custom": "canEdit eq true"
|
||||
}
|
||||
},
|
||||
"id": "baff6798-0304-4255-bdb0-dd3f2659373b",
|
||||
"name": "Microsoft Outlook",
|
||||
"type": "n8n-nodes-base.microsoftOutlook",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
1040,
|
||||
360
|
||||
],
|
||||
"credentials": {
|
||||
"microsoftOutlookOAuth2Api": {
|
||||
"id": "iXJCki7i5Vz0bdks",
|
||||
"name": "Microsoft Outlook account 2"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"pinData": {
|
||||
"Microsoft Outlook": [
|
||||
{
|
||||
"json": {
|
||||
"id": "AAAXXXYYYnnnT6b9RLP0CKzHiJrRBwBZf4De-LkrSqpPI8eyjUmAAAAAAAEGAABZf4De-LkrSqpPI8eyjUmAAAAJ9-JDAAA=",
|
||||
"name": "Calendar",
|
||||
"color": "auto",
|
||||
"hexColor": "",
|
||||
"isDefaultCalendar": true,
|
||||
"changeKey": "WX+A3vy5K0qqTyPHso1JgAAACfdHfw==",
|
||||
"canShare": true,
|
||||
"canViewPrivateItems": true,
|
||||
"canEdit": true,
|
||||
"allowedOnlineMeetingProviders": [
|
||||
"teamsForBusiness"
|
||||
],
|
||||
"defaultOnlineMeetingProvider": "teamsForBusiness",
|
||||
"isTallyingResponses": true,
|
||||
"isRemovable": false,
|
||||
"owner": {
|
||||
"name": "User Name",
|
||||
"address": "test@mail.com"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"json": {
|
||||
"id": "AAAXXXYYYnnnT6b9RLP0CKzHiJrRBwBZf4De-LkrSqpPI8eyjUmAAAAAAAEGAABZf4De-LkrSqpPI8eyjUmAAACLtRvBAAA=",
|
||||
"name": "Third calendar",
|
||||
"color": "lightYellow",
|
||||
"hexColor": "#fde300",
|
||||
"isDefaultCalendar": false,
|
||||
"changeKey": "WX+A3vy5K0qqTyPHso1JgAAAi67hIw==",
|
||||
"canShare": true,
|
||||
"canViewPrivateItems": true,
|
||||
"canEdit": true,
|
||||
"allowedOnlineMeetingProviders": [
|
||||
"teamsForBusiness"
|
||||
],
|
||||
"defaultOnlineMeetingProvider": "teamsForBusiness",
|
||||
"isTallyingResponses": false,
|
||||
"isRemovable": true,
|
||||
"owner": {
|
||||
"name": "User Name",
|
||||
"address": "test@mail.com"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"connections": {
|
||||
"When clicking \"Execute Workflow\"": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Microsoft Outlook",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"active": false,
|
||||
"settings": {
|
||||
"executionOrder": "v1"
|
||||
},
|
||||
"versionId": "8f4e7775-0476-4506-a183-1365265b446a",
|
||||
"id": "1CYHzBXQw1nfPGtB",
|
||||
"meta": {
|
||||
"instanceId": "b888bd11cd1ddbb95450babf3e199556799d999b896f650de768b8370ee50363"
|
||||
},
|
||||
"tags": []
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
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';
|
||||
|
||||
jest.mock('../../../../v2/transport', () => {
|
||||
const originalModule = jest.requireActual('../../../../v2/transport');
|
||||
return {
|
||||
...originalModule,
|
||||
microsoftApiRequest: jest.fn(async function (method: string) {
|
||||
if (method === 'PATCH') {
|
||||
return {
|
||||
'@odata.context':
|
||||
"https://graph.microsoft.com/v1.0/$metadata#users('b834447b-6848-4af9-8390-d2259ce46b74')/calendars/$entity",
|
||||
id: 'AAAXXXYYYnnnT6b9RLP0CKzHiJrRBwBZf4De-LkrSqpPI8eyjUmAAAAAAAEGAABZf4De-LkrSqpPI8eyjUmAAACLtRvGAAA=',
|
||||
name: 'Foo',
|
||||
color: 'lightOrange',
|
||||
hexColor: '#fcab73',
|
||||
isDefaultCalendar: false,
|
||||
changeKey: 'WX+A3vy5K0qqTyPHso1JgAABVtwYKA==',
|
||||
canShare: true,
|
||||
canViewPrivateItems: true,
|
||||
canEdit: true,
|
||||
allowedOnlineMeetingProviders: ['teamsForBusiness'],
|
||||
defaultOnlineMeetingProvider: 'teamsForBusiness',
|
||||
isTallyingResponses: false,
|
||||
isRemovable: true,
|
||||
owner: {
|
||||
name: 'User Name',
|
||||
address: 'test@mail.com',
|
||||
},
|
||||
};
|
||||
}
|
||||
}),
|
||||
};
|
||||
});
|
||||
|
||||
describe('Test MicrosoftOutlookV2, calendar => update', () => {
|
||||
const workflows = ['nodes/Microsoft/Outlook/test/v2/node/calendar/update.workflow.json'];
|
||||
const tests = workflowToTests(workflows);
|
||||
|
||||
beforeAll(() => {
|
||||
nock.disableNetConnect();
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
nock.restore();
|
||||
jest.unmock('../../../../v2/transport');
|
||||
});
|
||||
|
||||
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(transport.microsoftApiRequest).toHaveBeenCalledTimes(1);
|
||||
expect(transport.microsoftApiRequest).toHaveBeenCalledWith(
|
||||
'PATCH',
|
||||
'/calendars/AAAXXXYYYnnnT6b9RLP0CKzHiJrRBwBZf4De-LkrSqpPI8eyjUmAAAAAAAEGAABZf4De-LkrSqpPI8eyjUmAAACLtRvGAAA=',
|
||||
{ color: 'lightOrange', isDefaultCalendar: false, name: 'Foo' },
|
||||
);
|
||||
|
||||
expect(result.finished).toEqual(true);
|
||||
};
|
||||
|
||||
for (const testData of tests) {
|
||||
test(testData.description, async () => testNode(testData, nodeTypes));
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,98 @@
|
||||
{
|
||||
"name": "My workflow 21",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "e524f588-b6a3-4849-8777-b32a8a755ae5",
|
||||
"name": "When clicking \"Execute Workflow\"",
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
820,
|
||||
360
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"resource": "calendar",
|
||||
"operation": "update",
|
||||
"calendarId": {
|
||||
"__rl": true,
|
||||
"value": "AAAXXXYYYnnnT6b9RLP0CKzHiJrRBwBZf4De-LkrSqpPI8eyjUmAAAAAAAEGAABZf4De-LkrSqpPI8eyjUmAAACLtRvGAAA=",
|
||||
"mode": "list",
|
||||
"cachedResultName": "Foo Calendar"
|
||||
},
|
||||
"updateFields": {
|
||||
"color": "lightOrange",
|
||||
"isDefaultCalendar": false,
|
||||
"name": "Foo"
|
||||
}
|
||||
},
|
||||
"id": "baff6798-0304-4255-bdb0-dd3f2659373b",
|
||||
"name": "Microsoft Outlook",
|
||||
"type": "n8n-nodes-base.microsoftOutlook",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
1040,
|
||||
360
|
||||
],
|
||||
"credentials": {
|
||||
"microsoftOutlookOAuth2Api": {
|
||||
"id": "iXJCki7i5Vz0bdks",
|
||||
"name": "Microsoft Outlook account 2"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"pinData": {
|
||||
"Microsoft Outlook": [
|
||||
{
|
||||
"json": {
|
||||
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('b834447b-6848-4af9-8390-d2259ce46b74')/calendars/$entity",
|
||||
"id": "AAAXXXYYYnnnT6b9RLP0CKzHiJrRBwBZf4De-LkrSqpPI8eyjUmAAAAAAAEGAABZf4De-LkrSqpPI8eyjUmAAACLtRvGAAA=",
|
||||
"name": "Foo",
|
||||
"color": "lightOrange",
|
||||
"hexColor": "#fcab73",
|
||||
"isDefaultCalendar": false,
|
||||
"changeKey": "WX+A3vy5K0qqTyPHso1JgAABVtwYKA==",
|
||||
"canShare": true,
|
||||
"canViewPrivateItems": true,
|
||||
"canEdit": true,
|
||||
"allowedOnlineMeetingProviders": [
|
||||
"teamsForBusiness"
|
||||
],
|
||||
"defaultOnlineMeetingProvider": "teamsForBusiness",
|
||||
"isTallyingResponses": false,
|
||||
"isRemovable": true,
|
||||
"owner": {
|
||||
"name": "User Name",
|
||||
"address": "test@mail.com"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"connections": {
|
||||
"When clicking \"Execute Workflow\"": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Microsoft Outlook",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"active": false,
|
||||
"settings": {
|
||||
"executionOrder": "v1"
|
||||
},
|
||||
"versionId": "f8e68e5f-8c26-4c1f-b11b-8b4e4aeaa61f",
|
||||
"id": "1CYHzBXQw1nfPGtB",
|
||||
"meta": {
|
||||
"instanceId": "b888bd11cd1ddbb95450babf3e199556799d999b896f650de768b8370ee50363"
|
||||
},
|
||||
"tags": []
|
||||
}
|
||||
Reference in New Issue
Block a user