feat(Microsoft Excel 365 Node): Overhaul
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
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 * as transport from '../../../../v2/transport';
|
||||
|
||||
import nock from 'nock';
|
||||
|
||||
jest.mock('../../../../v2/transport', () => {
|
||||
const originalModule = jest.requireActual('../../../../v2/transport');
|
||||
return {
|
||||
...originalModule,
|
||||
microsoftApiRequest: jest.fn(async function (method: string) {
|
||||
if (method === 'POST') {
|
||||
return {
|
||||
style: 'TableStyleMedium2',
|
||||
name: 'Table3',
|
||||
showFilterButton: true,
|
||||
id: '{317CA469-7D1C-4A5D-9B0B-424444BF0336}',
|
||||
highlightLastColumn: false,
|
||||
highlightFirstColumn: false,
|
||||
legacyId: '3',
|
||||
showBandedColumns: false,
|
||||
showBandedRows: true,
|
||||
showHeaders: true,
|
||||
showTotals: false,
|
||||
};
|
||||
}
|
||||
}),
|
||||
};
|
||||
});
|
||||
|
||||
describe('Test MicrosoftExcelV2, table => addTable', () => {
|
||||
const workflows = ['nodes/Microsoft/Excel/test/v2/node/table/addTable.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',
|
||||
'/drive/items/01FUWX3BQ4ATCOZNR265GLA6IJEZDQUE4I/workbook/worksheets/{A0883CFE-D27E-4ECC-B94B-981830AAD55B}/tables/add',
|
||||
{ address: 'A1:D4', hasHeaders: true },
|
||||
);
|
||||
|
||||
expect(result.finished).toEqual(true);
|
||||
};
|
||||
|
||||
for (const testData of tests) {
|
||||
test(testData.description, async () => testNode(testData, nodeTypes));
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,78 @@
|
||||
{
|
||||
"name": "My workflow 5",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "875e8784-eb59-40d8-ba45-129a5e29881c",
|
||||
"name": "When clicking \"Execute Workflow\"",
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [380, 140]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"resource": "table",
|
||||
"operation": "addTable",
|
||||
"workbook": {
|
||||
"__rl": true,
|
||||
"value": "01FUWX3BQ4ATCOZNR265GLA6IJEZDQUE4I",
|
||||
"mode": "list",
|
||||
"cachedResultName": "ПРРО копія"
|
||||
},
|
||||
"worksheet": {
|
||||
"__rl": true,
|
||||
"value": "{A0883CFE-D27E-4ECC-B94B-981830AAD55B}",
|
||||
"mode": "list",
|
||||
"cachedResultName": "Sheet4"
|
||||
},
|
||||
"selectRange": "manual",
|
||||
"range": "A1:D4"
|
||||
},
|
||||
"id": "0e0ac1d2-242c-486a-9287-c70307645acc",
|
||||
"name": "Microsoft Excel 365",
|
||||
"type": "n8n-nodes-base.microsoftExcel",
|
||||
"typeVersion": 2,
|
||||
"position": [860, 140],
|
||||
"credentials": {
|
||||
"microsoftExcelOAuth2Api": {
|
||||
"id": "70",
|
||||
"name": "Microsoft Excel account"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"pinData": {
|
||||
"Microsoft Excel 365": [
|
||||
{
|
||||
"json": {
|
||||
"style": "TableStyleMedium2",
|
||||
"name": "Table3",
|
||||
"showFilterButton": true,
|
||||
"id": "{317CA469-7D1C-4A5D-9B0B-424444BF0336}",
|
||||
"highlightLastColumn": false,
|
||||
"highlightFirstColumn": false,
|
||||
"legacyId": "3",
|
||||
"showBandedColumns": false,
|
||||
"showBandedRows": true,
|
||||
"showHeaders": true,
|
||||
"showTotals": false
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"connections": {
|
||||
"When clicking \"Execute Workflow\"": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Microsoft Excel 365",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"active": false,
|
||||
"settings": {}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
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 * as transport from '../../../../v2/transport';
|
||||
|
||||
import nock from 'nock';
|
||||
|
||||
jest.mock('../../../../v2/transport', () => {
|
||||
const originalModule = jest.requireActual('../../../../v2/transport');
|
||||
return {
|
||||
...originalModule,
|
||||
microsoftApiRequest: jest.fn(async function (method: string, resource: string) {
|
||||
if (method === 'GET') {
|
||||
return {
|
||||
value: [
|
||||
{
|
||||
name: 'id',
|
||||
},
|
||||
{
|
||||
name: 'name',
|
||||
},
|
||||
{
|
||||
name: 'age',
|
||||
},
|
||||
{
|
||||
name: 'data',
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
if (method === 'POST' && resource.includes('createSession')) {
|
||||
return {
|
||||
id: 12345,
|
||||
};
|
||||
}
|
||||
if (method === 'POST' && resource.includes('add')) {
|
||||
return {
|
||||
index: 3,
|
||||
values: [[3, 'Donald', 99, 'data 5']],
|
||||
};
|
||||
}
|
||||
if (method === 'POST' && resource.includes('closeSession')) {
|
||||
return;
|
||||
}
|
||||
}),
|
||||
};
|
||||
});
|
||||
|
||||
describe('Test MicrosoftExcelV2, table => append', () => {
|
||||
const workflows = ['nodes/Microsoft/Excel/test/v2/node/table/append.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(4);
|
||||
|
||||
expect(transport.microsoftApiRequest).toHaveBeenCalledWith(
|
||||
'POST',
|
||||
'/drive/items/01FUWX3BQ4ATCOZNR265GLA6IJEZDQUE4I/workbook/worksheets/{A0883CFE-D27E-4ECC-B94B-981830AAD55B}/tables/{317CA469-7D1C-4A5D-9B0B-424444BF0336}/rows/add',
|
||||
{ values: [['3', 'Donald', '99', 'data 5']] },
|
||||
{},
|
||||
'',
|
||||
{ 'workbook-session-id': 12345 },
|
||||
);
|
||||
|
||||
expect(result.finished).toEqual(true);
|
||||
};
|
||||
|
||||
for (const testData of tests) {
|
||||
test(testData.description, async () => testNode(testData, nodeTypes));
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,104 @@
|
||||
{
|
||||
"name": "My workflow 5",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "875e8784-eb59-40d8-ba45-129a5e29881c",
|
||||
"name": "When clicking \"Execute Workflow\"",
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [380, 140]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"resource": "table",
|
||||
"workbook": {
|
||||
"__rl": true,
|
||||
"value": "01FUWX3BQ4ATCOZNR265GLA6IJEZDQUE4I",
|
||||
"mode": "list",
|
||||
"cachedResultName": "ПРРО копія",
|
||||
"cachedResultUrl": "https://5w1hb7-my.sharepoint.com/personal/michaeldevsandbox_5w1hb7_onmicrosoft_com/_layouts/15/Doc.aspx?sourcedoc=%7BECC4041C-3AB6-4CF7-B079-0926470A1388%7D&file=%D0%9F%D0%A0%D0%A0%D0%9E%20%D0%BA%D0%BE%D0%BF%D1%96%D1%8F.xlsx&action=default&mobileredirect=true&DefaultItemOpen=1"
|
||||
},
|
||||
"worksheet": {
|
||||
"__rl": true,
|
||||
"value": "{A0883CFE-D27E-4ECC-B94B-981830AAD55B}",
|
||||
"mode": "list",
|
||||
"cachedResultName": "Sheet4",
|
||||
"cachedResultUrl": "https://5w1hb7-my.sharepoint.com/personal/michaeldevsandbox_5w1hb7_onmicrosoft_com/_layouts/15/Doc.aspx?sourcedoc=%7BECC4041C-3AB6-4CF7-B079-0926470A1388%7D&file=%D0%9F%D0%A0%D0%A0%D0%9E%20%D0%BA%D0%BE%D0%BF%D1%96%D1%8F.xlsx&action=default&mobileredirect=true&DefaultItemOpen=1&activeCell=Sheet4!A1"
|
||||
},
|
||||
"table": {
|
||||
"__rl": true,
|
||||
"value": "{317CA469-7D1C-4A5D-9B0B-424444BF0336}",
|
||||
"mode": "list",
|
||||
"cachedResultName": "Table3",
|
||||
"cachedResultUrl": "https://5w1hb7-my.sharepoint.com/personal/michaeldevsandbox_5w1hb7_onmicrosoft_com/_layouts/15/Doc.aspx?sourcedoc=%7BECC4041C-3AB6-4CF7-B079-0926470A1388%7D&file=%D0%9F%D0%A0%D0%A0%D0%9E%20%D0%BA%D0%BE%D0%BF%D1%96%D1%8F.xlsx&action=default&mobileredirect=true&DefaultItemOpen=1&activeCell=Sheet4!A1:D4"
|
||||
},
|
||||
"fieldsUi": {
|
||||
"values": [
|
||||
{
|
||||
"column": "id",
|
||||
"fieldValue": "3"
|
||||
},
|
||||
{
|
||||
"column": "name",
|
||||
"fieldValue": "Donald"
|
||||
},
|
||||
{
|
||||
"column": "age",
|
||||
"fieldValue": "99"
|
||||
},
|
||||
{
|
||||
"column": "data",
|
||||
"fieldValue": "data 5"
|
||||
}
|
||||
]
|
||||
},
|
||||
"options": {}
|
||||
},
|
||||
"id": "0e0ac1d2-242c-486a-9287-c70307645acc",
|
||||
"name": "Microsoft Excel 365",
|
||||
"type": "n8n-nodes-base.microsoftExcel",
|
||||
"typeVersion": 2,
|
||||
"position": [860, 140],
|
||||
"credentials": {
|
||||
"microsoftExcelOAuth2Api": {
|
||||
"id": "70",
|
||||
"name": "Microsoft Excel account"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"pinData": {
|
||||
"Microsoft Excel 365": [
|
||||
{
|
||||
"json": {
|
||||
"id": 3,
|
||||
"name": "Donald",
|
||||
"age": 99,
|
||||
"data": "data 5"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"connections": {
|
||||
"When clicking \"Execute Workflow\"": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Microsoft Excel 365",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"active": false,
|
||||
"settings": {},
|
||||
"versionId": "b9eda2d8-e1a5-4a54-aaa9-5e81adaae909",
|
||||
"id": "135",
|
||||
"meta": {
|
||||
"instanceId": "36203ea1ce3cef713fa25999bd9874ae26b9e4c2c3a90a365f2882a154d031d0"
|
||||
},
|
||||
"tags": []
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
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 * as transport from '../../../../v2/transport';
|
||||
|
||||
import nock from 'nock';
|
||||
|
||||
jest.mock('../../../../v2/transport', () => {
|
||||
const originalModule = jest.requireActual('../../../../v2/transport');
|
||||
return {
|
||||
...originalModule,
|
||||
microsoftApiRequest: jest.fn(async function (method: string) {
|
||||
if (method === 'POST') {
|
||||
return {
|
||||
address: 'Sheet4!A1:D5',
|
||||
values: [
|
||||
['id', 'name', 'age', 'data'],
|
||||
[1, 'Sam', 33, 'data 1'],
|
||||
[2, 'Jon', 44, 'data 2'],
|
||||
[3, 'Sam', 34, 'data 4'],
|
||||
[3, 'Donald', 99, 'data 5'],
|
||||
],
|
||||
};
|
||||
}
|
||||
}),
|
||||
};
|
||||
});
|
||||
|
||||
describe('Test MicrosoftExcelV2, table => convertToRange', () => {
|
||||
const workflows = ['nodes/Microsoft/Excel/test/v2/node/table/convertToRange.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',
|
||||
'/drive/items/01FUWX3BQ4ATCOZNR265GLA6IJEZDQUE4I/workbook/worksheets/{A0883CFE-D27E-4ECC-B94B-981830AAD55B}/tables/{6321EE4A-AC21-48AD-87D9-B527637D94B3}/convertToRange',
|
||||
);
|
||||
|
||||
expect(result.finished).toEqual(true);
|
||||
};
|
||||
|
||||
for (const testData of tests) {
|
||||
test(testData.description, async () => testNode(testData, nodeTypes));
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,79 @@
|
||||
{
|
||||
"name": "My workflow 5",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "875e8784-eb59-40d8-ba45-129a5e29881c",
|
||||
"name": "When clicking \"Execute Workflow\"",
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [580, 140]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"resource": "table",
|
||||
"operation": "convertToRange",
|
||||
"workbook": {
|
||||
"__rl": true,
|
||||
"value": "01FUWX3BQ4ATCOZNR265GLA6IJEZDQUE4I",
|
||||
"mode": "list",
|
||||
"cachedResultName": "ПРРО копія"
|
||||
},
|
||||
"worksheet": {
|
||||
"__rl": true,
|
||||
"value": "{A0883CFE-D27E-4ECC-B94B-981830AAD55B}",
|
||||
"mode": "list",
|
||||
"cachedResultName": "Sheet4"
|
||||
},
|
||||
"table": {
|
||||
"__rl": true,
|
||||
"value": "{6321EE4A-AC21-48AD-87D9-B527637D94B3}",
|
||||
"mode": "list",
|
||||
"cachedResultName": "Table3"
|
||||
}
|
||||
},
|
||||
"id": "0e0ac1d2-242c-486a-9287-c70307645acc",
|
||||
"name": "Microsoft Excel 365",
|
||||
"type": "n8n-nodes-base.microsoftExcel",
|
||||
"typeVersion": 2,
|
||||
"position": [860, 140],
|
||||
"credentials": {
|
||||
"microsoftExcelOAuth2Api": {
|
||||
"id": "70",
|
||||
"name": "Microsoft Excel account"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"pinData": {
|
||||
"Microsoft Excel 365": [
|
||||
{
|
||||
"json": {
|
||||
"address": "Sheet4!A1:D5",
|
||||
"values": [
|
||||
["id", "name", "age", "data"],
|
||||
[1, "Sam", 33, "data 1"],
|
||||
[2, "Jon", 44, "data 2"],
|
||||
[3, "Sam", 34, "data 4"],
|
||||
[3, "Donald", 99, "data 5"]
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"connections": {
|
||||
"When clicking \"Execute Workflow\"": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Microsoft Excel 365",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"active": false,
|
||||
"settings": {}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
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 * as transport from '../../../../v2/transport';
|
||||
|
||||
import nock from 'nock';
|
||||
|
||||
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 MicrosoftExcelV2, table => deleteTable', () => {
|
||||
const workflows = ['nodes/Microsoft/Excel/test/v2/node/table/deleteTable.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',
|
||||
'/drive/items/01FUWX3BQ4ATCOZNR265GLA6IJEZDQUE4I/workbook/worksheets/{A0883CFE-D27E-4ECC-B94B-981830AAD55B}/tables/{92FBE3F5-3180-47EE-8549-40892C38DA7F}',
|
||||
);
|
||||
|
||||
expect(result.finished).toEqual(true);
|
||||
};
|
||||
|
||||
for (const testData of tests) {
|
||||
test(testData.description, async () => testNode(testData, nodeTypes));
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,72 @@
|
||||
{
|
||||
"name": "My workflow 5",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "875e8784-eb59-40d8-ba45-129a5e29881c",
|
||||
"name": "When clicking \"Execute Workflow\"",
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [580, 140]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"resource": "table",
|
||||
"operation": "deleteTable",
|
||||
"workbook": {
|
||||
"__rl": true,
|
||||
"value": "01FUWX3BQ4ATCOZNR265GLA6IJEZDQUE4I",
|
||||
"mode": "list",
|
||||
"cachedResultName": "ПРРО копія"
|
||||
},
|
||||
"worksheet": {
|
||||
"__rl": true,
|
||||
"value": "{A0883CFE-D27E-4ECC-B94B-981830AAD55B}",
|
||||
"mode": "list",
|
||||
"cachedResultName": "Sheet4"
|
||||
},
|
||||
"table": {
|
||||
"__rl": true,
|
||||
"value": "{92FBE3F5-3180-47EE-8549-40892C38DA7F}",
|
||||
"mode": "list",
|
||||
"cachedResultName": "Table3"
|
||||
}
|
||||
},
|
||||
"id": "0e0ac1d2-242c-486a-9287-c70307645acc",
|
||||
"name": "Microsoft Excel 365",
|
||||
"type": "n8n-nodes-base.microsoftExcel",
|
||||
"typeVersion": 2,
|
||||
"position": [860, 140],
|
||||
"credentials": {
|
||||
"microsoftExcelOAuth2Api": {
|
||||
"id": "70",
|
||||
"name": "Microsoft Excel account"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"pinData": {
|
||||
"Microsoft Excel 365": [
|
||||
{
|
||||
"json": {
|
||||
"success": true
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"connections": {
|
||||
"When clicking \"Execute Workflow\"": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Microsoft Excel 365",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"active": false,
|
||||
"settings": {}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
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 * as transport from '../../../../v2/transport';
|
||||
|
||||
import nock from 'nock';
|
||||
|
||||
jest.mock('../../../../v2/transport', () => {
|
||||
const originalModule = jest.requireActual('../../../../v2/transport');
|
||||
return {
|
||||
...originalModule,
|
||||
microsoftApiRequestAllItemsSkip: jest.fn(async function () {
|
||||
return [
|
||||
{
|
||||
name: 'country',
|
||||
},
|
||||
{
|
||||
name: 'browser',
|
||||
},
|
||||
{
|
||||
name: 'session_duration',
|
||||
},
|
||||
{
|
||||
name: 'visits',
|
||||
},
|
||||
];
|
||||
}),
|
||||
};
|
||||
});
|
||||
|
||||
describe('Test MicrosoftExcelV2, table => getColumns', () => {
|
||||
const workflows = ['nodes/Microsoft/Excel/test/v2/node/table/getColumns.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.microsoftApiRequestAllItemsSkip).toHaveBeenCalledTimes(1);
|
||||
expect(transport.microsoftApiRequestAllItemsSkip).toHaveBeenCalledWith(
|
||||
'value',
|
||||
'GET',
|
||||
'/drive/items/01FUWX3BQ4ATCOZNR265GLA6IJEZDQUE4I/workbook/worksheets/{00000000-0001-0000-0000-000000000000}/tables/{613E8967-D581-44ED-81D3-82A01AA6A05C}/columns',
|
||||
{},
|
||||
{},
|
||||
);
|
||||
|
||||
expect(result.finished).toEqual(true);
|
||||
};
|
||||
|
||||
for (const testData of tests) {
|
||||
test(testData.description, async () => testNode(testData, nodeTypes));
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,88 @@
|
||||
{
|
||||
"name": "My workflow 5",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "875e8784-eb59-40d8-ba45-129a5e29881c",
|
||||
"name": "When clicking \"Execute Workflow\"",
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [580, 140]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"resource": "table",
|
||||
"operation": "getColumns",
|
||||
"workbook": {
|
||||
"__rl": true,
|
||||
"value": "01FUWX3BQ4ATCOZNR265GLA6IJEZDQUE4I",
|
||||
"mode": "list",
|
||||
"cachedResultName": "ПРРО копія"
|
||||
},
|
||||
"worksheet": {
|
||||
"__rl": true,
|
||||
"value": "{00000000-0001-0000-0000-000000000000}",
|
||||
"mode": "list",
|
||||
"cachedResultName": "Sheet1"
|
||||
},
|
||||
"table": {
|
||||
"__rl": true,
|
||||
"value": "{613E8967-D581-44ED-81D3-82A01AA6A05C}",
|
||||
"mode": "list",
|
||||
"cachedResultName": "Table1"
|
||||
},
|
||||
"returnAll": true
|
||||
},
|
||||
"id": "0e0ac1d2-242c-486a-9287-c70307645acc",
|
||||
"name": "Microsoft Excel 365",
|
||||
"type": "n8n-nodes-base.microsoftExcel",
|
||||
"typeVersion": 2,
|
||||
"position": [860, 140],
|
||||
"credentials": {
|
||||
"microsoftExcelOAuth2Api": {
|
||||
"id": "70",
|
||||
"name": "Microsoft Excel account"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"pinData": {
|
||||
"Microsoft Excel 365": [
|
||||
{
|
||||
"json": {
|
||||
"name": "country"
|
||||
}
|
||||
},
|
||||
{
|
||||
"json": {
|
||||
"name": "browser"
|
||||
}
|
||||
},
|
||||
{
|
||||
"json": {
|
||||
"name": "session_duration"
|
||||
}
|
||||
},
|
||||
{
|
||||
"json": {
|
||||
"name": "visits"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"connections": {
|
||||
"When clicking \"Execute Workflow\"": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Microsoft Excel 365",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"active": false,
|
||||
"settings": {}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
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 * as transport from '../../../../v2/transport';
|
||||
|
||||
import nock from 'nock';
|
||||
|
||||
jest.mock('../../../../v2/transport', () => {
|
||||
const originalModule = jest.requireActual('../../../../v2/transport');
|
||||
return {
|
||||
...originalModule,
|
||||
microsoftApiRequest: jest.fn(async function (method: string) {
|
||||
if (method === 'GET') {
|
||||
return {
|
||||
value: [
|
||||
{
|
||||
index: 0,
|
||||
values: [['uk', 'firefox', 1, 1]],
|
||||
},
|
||||
{
|
||||
index: 1,
|
||||
values: [['us', 'chrome', 1, 12]],
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
}),
|
||||
microsoftApiRequestAllItemsSkip: jest.fn(async function () {
|
||||
return [
|
||||
{
|
||||
name: 'country',
|
||||
},
|
||||
{
|
||||
name: 'browser',
|
||||
},
|
||||
{
|
||||
name: 'session_duration',
|
||||
},
|
||||
{
|
||||
name: 'visits',
|
||||
},
|
||||
];
|
||||
}),
|
||||
};
|
||||
});
|
||||
|
||||
describe('Test MicrosoftExcelV2, table => getRows', () => {
|
||||
const workflows = ['nodes/Microsoft/Excel/test/v2/node/table/getRows.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',
|
||||
'/drive/items/01FUWX3BQ4ATCOZNR265GLA6IJEZDQUE4I/workbook/worksheets/{00000000-0001-0000-0000-000000000000}/tables/{613E8967-D581-44ED-81D3-82A01AA6A05C}/rows',
|
||||
{},
|
||||
{ $top: 2 },
|
||||
);
|
||||
|
||||
expect(transport.microsoftApiRequestAllItemsSkip).toHaveBeenCalledTimes(1);
|
||||
expect(transport.microsoftApiRequestAllItemsSkip).toHaveBeenCalledWith(
|
||||
'value',
|
||||
'GET',
|
||||
'/drive/items/01FUWX3BQ4ATCOZNR265GLA6IJEZDQUE4I/workbook/worksheets/{00000000-0001-0000-0000-000000000000}/tables/{613E8967-D581-44ED-81D3-82A01AA6A05C}/columns',
|
||||
{},
|
||||
{ $select: 'name' },
|
||||
);
|
||||
|
||||
expect(result.finished).toEqual(true);
|
||||
};
|
||||
|
||||
for (const testData of tests) {
|
||||
test(testData.description, async () => testNode(testData, nodeTypes));
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,85 @@
|
||||
{
|
||||
"name": "My workflow 5",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "875e8784-eb59-40d8-ba45-129a5e29881c",
|
||||
"name": "When clicking \"Execute Workflow\"",
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [580, 140]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"resource": "table",
|
||||
"operation": "getRows",
|
||||
"workbook": {
|
||||
"__rl": true,
|
||||
"value": "01FUWX3BQ4ATCOZNR265GLA6IJEZDQUE4I",
|
||||
"mode": "list",
|
||||
"cachedResultName": "ПРРО копія"
|
||||
},
|
||||
"worksheet": {
|
||||
"__rl": true,
|
||||
"value": "{00000000-0001-0000-0000-000000000000}",
|
||||
"mode": "list",
|
||||
"cachedResultName": "Sheet1"
|
||||
},
|
||||
"table": {
|
||||
"__rl": true,
|
||||
"value": "{613E8967-D581-44ED-81D3-82A01AA6A05C}",
|
||||
"mode": "list",
|
||||
"cachedResultName": "Table1"
|
||||
},
|
||||
"limit": 2,
|
||||
"filters": {}
|
||||
},
|
||||
"id": "0e0ac1d2-242c-486a-9287-c70307645acc",
|
||||
"name": "Microsoft Excel 365",
|
||||
"type": "n8n-nodes-base.microsoftExcel",
|
||||
"typeVersion": 2,
|
||||
"position": [860, 140],
|
||||
"credentials": {
|
||||
"microsoftExcelOAuth2Api": {
|
||||
"id": "70",
|
||||
"name": "Microsoft Excel account"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"pinData": {
|
||||
"Microsoft Excel 365": [
|
||||
{
|
||||
"json": {
|
||||
"country": "uk",
|
||||
"browser": "firefox",
|
||||
"session_duration": 1,
|
||||
"visits": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"json": {
|
||||
"country": "us",
|
||||
"browser": "chrome",
|
||||
"session_duration": 1,
|
||||
"visits": 12
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"connections": {
|
||||
"When clicking \"Execute Workflow\"": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Microsoft Excel 365",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"active": false,
|
||||
"settings": {}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
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 * as transport from '../../../../v2/transport';
|
||||
|
||||
import nock from 'nock';
|
||||
|
||||
jest.mock('../../../../v2/transport', () => {
|
||||
const originalModule = jest.requireActual('../../../../v2/transport');
|
||||
return {
|
||||
...originalModule,
|
||||
microsoftApiRequestAllItemsSkip: jest.fn(async function (
|
||||
_property: string,
|
||||
_method: string,
|
||||
endpoint: string,
|
||||
) {
|
||||
if (endpoint.includes('columns')) {
|
||||
return [
|
||||
{
|
||||
name: 'country',
|
||||
},
|
||||
{
|
||||
name: 'browser',
|
||||
},
|
||||
{
|
||||
name: 'session_duration',
|
||||
},
|
||||
{
|
||||
name: 'visits',
|
||||
},
|
||||
];
|
||||
}
|
||||
if (endpoint.includes('rows')) {
|
||||
return [
|
||||
{
|
||||
index: 0,
|
||||
values: [['uk', 'firefox', 1, 1]],
|
||||
},
|
||||
{
|
||||
index: 1,
|
||||
values: [['us', 'chrome', 1, 12]],
|
||||
},
|
||||
{
|
||||
index: 2,
|
||||
values: [['test', 'test', 55, 123]],
|
||||
},
|
||||
{
|
||||
index: 3,
|
||||
values: [['ua', 'chrome', 1, 3]],
|
||||
},
|
||||
{
|
||||
index: 4,
|
||||
values: [['ua', 'firefox', 1, 4]],
|
||||
},
|
||||
{
|
||||
index: 5,
|
||||
values: [['uk', 'chrome', 1, 55]],
|
||||
},
|
||||
];
|
||||
}
|
||||
}),
|
||||
};
|
||||
});
|
||||
|
||||
describe('Test MicrosoftExcelV2, table => lookup', () => {
|
||||
const workflows = ['nodes/Microsoft/Excel/test/v2/node/table/lookup.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.microsoftApiRequestAllItemsSkip).toHaveBeenCalledTimes(2);
|
||||
expect(transport.microsoftApiRequestAllItemsSkip).toHaveBeenCalledWith(
|
||||
'value',
|
||||
'GET',
|
||||
'/drive/items/01FUWX3BQ4ATCOZNR265GLA6IJEZDQUE4I/workbook/worksheets/{00000000-0001-0000-0000-000000000000}/tables/{613E8967-D581-44ED-81D3-82A01AA6A05C}/rows',
|
||||
{},
|
||||
{},
|
||||
);
|
||||
expect(transport.microsoftApiRequestAllItemsSkip).toHaveBeenCalledWith(
|
||||
'value',
|
||||
'GET',
|
||||
'/drive/items/01FUWX3BQ4ATCOZNR265GLA6IJEZDQUE4I/workbook/worksheets/{00000000-0001-0000-0000-000000000000}/tables/{613E8967-D581-44ED-81D3-82A01AA6A05C}/columns',
|
||||
{},
|
||||
{ $select: 'name' },
|
||||
);
|
||||
|
||||
expect(result.finished).toEqual(true);
|
||||
};
|
||||
|
||||
for (const testData of tests) {
|
||||
test(testData.description, async () => testNode(testData, nodeTypes));
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,88 @@
|
||||
{
|
||||
"name": "My workflow 5",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "875e8784-eb59-40d8-ba45-129a5e29881c",
|
||||
"name": "When clicking \"Execute Workflow\"",
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [580, 140]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"resource": "table",
|
||||
"operation": "lookup",
|
||||
"workbook": {
|
||||
"__rl": true,
|
||||
"value": "01FUWX3BQ4ATCOZNR265GLA6IJEZDQUE4I",
|
||||
"mode": "list",
|
||||
"cachedResultName": "ПРРО копія"
|
||||
},
|
||||
"worksheet": {
|
||||
"__rl": true,
|
||||
"value": "{00000000-0001-0000-0000-000000000000}",
|
||||
"mode": "list",
|
||||
"cachedResultName": "Sheet1"
|
||||
},
|
||||
"table": {
|
||||
"__rl": true,
|
||||
"value": "{613E8967-D581-44ED-81D3-82A01AA6A05C}",
|
||||
"mode": "list",
|
||||
"cachedResultName": "Table1"
|
||||
},
|
||||
"lookupColumn": "country",
|
||||
"lookupValue": "uk",
|
||||
"options": {
|
||||
"returnAllMatches": true
|
||||
}
|
||||
},
|
||||
"id": "0e0ac1d2-242c-486a-9287-c70307645acc",
|
||||
"name": "Microsoft Excel 365",
|
||||
"type": "n8n-nodes-base.microsoftExcel",
|
||||
"typeVersion": 2,
|
||||
"position": [860, 140],
|
||||
"credentials": {
|
||||
"microsoftExcelOAuth2Api": {
|
||||
"id": "70",
|
||||
"name": "Microsoft Excel account"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"pinData": {
|
||||
"Microsoft Excel 365": [
|
||||
{
|
||||
"json": {
|
||||
"country": "uk",
|
||||
"browser": "firefox",
|
||||
"session_duration": 1,
|
||||
"visits": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"json": {
|
||||
"country": "uk",
|
||||
"browser": "chrome",
|
||||
"session_duration": 1,
|
||||
"visits": 55
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"connections": {
|
||||
"When clicking \"Execute Workflow\"": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Microsoft Excel 365",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"active": false,
|
||||
"settings": {}
|
||||
}
|
||||
Reference in New Issue
Block a user