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": {}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
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 === 'POST' && resource.includes('createSession')) {
|
||||
return {
|
||||
id: 12345,
|
||||
};
|
||||
}
|
||||
if (method === 'POST' && resource.includes('add')) {
|
||||
return {
|
||||
id: '{266ADAB7-25B6-4F28-A2D1-FD5BFBD7A4F0}',
|
||||
name: 'Sheet42',
|
||||
position: 8,
|
||||
visibility: 'Visible',
|
||||
};
|
||||
}
|
||||
if (method === 'POST' && resource.includes('closeSession')) {
|
||||
return;
|
||||
}
|
||||
}),
|
||||
};
|
||||
});
|
||||
|
||||
describe('Test MicrosoftExcelV2, workbook => addWorksheet', () => {
|
||||
const workflows = ['nodes/Microsoft/Excel/test/v2/node/workbook/addWorksheet.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(3);
|
||||
expect(transport.microsoftApiRequest).toHaveBeenCalledWith(
|
||||
'POST',
|
||||
'/drive/items/01FUWX3BQ4ATCOZNR265GLA6IJEZDQUE4I/workbook/createSession',
|
||||
{ persistChanges: true },
|
||||
);
|
||||
expect(transport.microsoftApiRequest).toHaveBeenCalledWith(
|
||||
'POST',
|
||||
'/drive/items/01FUWX3BQ4ATCOZNR265GLA6IJEZDQUE4I/workbook/worksheets/add',
|
||||
{ name: 'Sheet42' },
|
||||
{},
|
||||
'',
|
||||
{ 'workbook-session-id': 12345 },
|
||||
);
|
||||
expect(transport.microsoftApiRequest).toHaveBeenCalledWith(
|
||||
'POST',
|
||||
'/drive/items/01FUWX3BQ4ATCOZNR265GLA6IJEZDQUE4I/workbook/closeSession',
|
||||
{},
|
||||
{},
|
||||
'',
|
||||
{ 'workbook-session-id': 12345 },
|
||||
);
|
||||
|
||||
expect(result.finished).toEqual(true);
|
||||
};
|
||||
|
||||
for (const testData of tests) {
|
||||
test(testData.description, async () => testNode(testData, nodeTypes));
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,65 @@
|
||||
{
|
||||
"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": {
|
||||
"operation": "addWorksheet",
|
||||
"workbook": {
|
||||
"__rl": true,
|
||||
"value": "01FUWX3BQ4ATCOZNR265GLA6IJEZDQUE4I",
|
||||
"mode": "list",
|
||||
"cachedResultName": "ПРРО копія"
|
||||
},
|
||||
"additionalFields": {
|
||||
"name": "Sheet42"
|
||||
}
|
||||
},
|
||||
"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": "{266ADAB7-25B6-4F28-A2D1-FD5BFBD7A4F0}",
|
||||
"name": "Sheet42",
|
||||
"position": 8,
|
||||
"visibility": "Visible"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"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, workbook => deleteWorkbook', () => {
|
||||
const workflows = ['nodes/Microsoft/Excel/test/v2/node/workbook/deleteWorkbook.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/01FUWX3BXJLISGF2CFWBGYPHXFCXPXOJUK',
|
||||
);
|
||||
|
||||
expect(result.finished).toEqual(true);
|
||||
};
|
||||
|
||||
for (const testData of tests) {
|
||||
test(testData.description, async () => testNode(testData, nodeTypes));
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,59 @@
|
||||
{
|
||||
"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": {
|
||||
"operation": "deleteWorkbook",
|
||||
"workbook": {
|
||||
"__rl": true,
|
||||
"value": "01FUWX3BXJLISGF2CFWBGYPHXFCXPXOJUK",
|
||||
"mode": "list",
|
||||
"cachedResultName": "Book"
|
||||
}
|
||||
},
|
||||
"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,74 @@
|
||||
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: [
|
||||
{
|
||||
'@odata.type': '#microsoft.graph.driveItem',
|
||||
name: 'ПРРО копія.xlsx',
|
||||
},
|
||||
,
|
||||
{
|
||||
'@odata.type': '#microsoft.graph.driveItem',
|
||||
name: 'Book 3.xlsx',
|
||||
},
|
||||
,
|
||||
],
|
||||
};
|
||||
}
|
||||
}),
|
||||
};
|
||||
});
|
||||
|
||||
describe('Test MicrosoftExcelV2, workbook => getAll', () => {
|
||||
const workflows = ['nodes/Microsoft/Excel/test/v2/node/workbook/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',
|
||||
"/drive/root/search(q='.xlsx')",
|
||||
{},
|
||||
{ $select: 'name', $top: 2 },
|
||||
);
|
||||
|
||||
expect(result.finished).toEqual(true);
|
||||
};
|
||||
|
||||
for (const testData of tests) {
|
||||
test(testData.description, async () => testNode(testData, nodeTypes));
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,63 @@
|
||||
{
|
||||
"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": {
|
||||
"limit": 2,
|
||||
"filters": {
|
||||
"fields": "name"
|
||||
}
|
||||
},
|
||||
"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": {
|
||||
"@odata.type": "#microsoft.graph.driveItem",
|
||||
"name": "ПРРО копія.xlsx"
|
||||
}
|
||||
},
|
||||
{
|
||||
"json": {
|
||||
"@odata.type": "#microsoft.graph.driveItem",
|
||||
"name": "Book 3.xlsx"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"connections": {
|
||||
"When clicking \"Execute Workflow\"": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Microsoft Excel 365",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"active": false,
|
||||
"settings": {}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars */
|
||||
import type { IDataObject } from 'n8n-workflow';
|
||||
|
||||
import { equalityTest, setup, workflowToTests } from '../../../../../../../test/nodes/Helpers';
|
||||
|
||||
// eslint-disable-next-line unused-imports/no-unused-imports
|
||||
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,
|
||||
body?: IDataObject,
|
||||
qs?: IDataObject,
|
||||
uri?: string,
|
||||
headers?: IDataObject,
|
||||
) {
|
||||
if (method === 'GET' && resource.includes('usedRange')) {
|
||||
return {
|
||||
address: 'Sheet4!A1:D6',
|
||||
values: [
|
||||
['id', 'name', 'age', 'data'],
|
||||
[1, 'Sam', 33, 'data 1'],
|
||||
[2, 'Jon', 44, 'data 2'],
|
||||
[3, 'Ron', 55, 'data 3'],
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
if (method === 'PATCH' && resource.includes('{A0883CFE-D27E-4ECC-B94B-981830AAD55B}')) {
|
||||
return {
|
||||
values: [[4, 'Sam', 34, 'data 4']],
|
||||
};
|
||||
}
|
||||
|
||||
if (method === 'PATCH' && resource.includes('{426949D7-797F-43A9-A8A4-8FE283495A82}')) {
|
||||
return {
|
||||
values: [[4, 'Don', 37, 'data 44']],
|
||||
};
|
||||
}
|
||||
}),
|
||||
};
|
||||
});
|
||||
|
||||
describe('Test MicrosoftExcelV2, worksheet => append', () => {
|
||||
const workflows = ['nodes/Microsoft/Excel/test/v2/node/worksheet/append.workflow.json'];
|
||||
const tests = workflowToTests(workflows);
|
||||
|
||||
beforeAll(() => {
|
||||
nock.disableNetConnect();
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
nock.restore();
|
||||
jest.unmock('../../../../v2/transport');
|
||||
});
|
||||
|
||||
const nodeTypes = setup(tests);
|
||||
|
||||
for (const testData of tests) {
|
||||
test(testData.description, async () => equalityTest(testData, nodeTypes));
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,166 @@
|
||||
{
|
||||
"name": "microsoft excel 365 - tests",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "2e1ec8f6-a2e2-4aa9-909c-d0a279584131",
|
||||
"name": "When clicking \"Execute Workflow\"",
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [800, 260]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"resource": "worksheet",
|
||||
"operation": "append",
|
||||
"workbook": {
|
||||
"__rl": true,
|
||||
"value": "01FUWX3BQ4ATCOZNR265GLA6IJEZDQUE4I",
|
||||
"mode": "list",
|
||||
"cachedResultName": "ПРРО копія"
|
||||
},
|
||||
"worksheet": {
|
||||
"__rl": true,
|
||||
"value": "={A0883CFE-D27E-4ECC-B94B-981830AAD55B}",
|
||||
"mode": "id"
|
||||
},
|
||||
"fieldsUi": {
|
||||
"values": [
|
||||
{
|
||||
"column": "id",
|
||||
"fieldValue": "4"
|
||||
},
|
||||
{
|
||||
"column": "name",
|
||||
"fieldValue": "Sam"
|
||||
},
|
||||
{
|
||||
"column": "age",
|
||||
"fieldValue": "34"
|
||||
},
|
||||
{
|
||||
"column": "data",
|
||||
"fieldValue": "data 4"
|
||||
}
|
||||
]
|
||||
},
|
||||
"options": {}
|
||||
},
|
||||
"id": "86f2a240-3acf-45c2-b97f-63dd655d296b",
|
||||
"name": "Microsoft Excel 365",
|
||||
"type": "n8n-nodes-base.microsoftExcel",
|
||||
"typeVersion": 2,
|
||||
"position": [1280, 260],
|
||||
"credentials": {
|
||||
"microsoftExcelOAuth2Api": {
|
||||
"id": "70",
|
||||
"name": "Microsoft Excel account"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"resource": "worksheet",
|
||||
"operation": "append",
|
||||
"workbook": {
|
||||
"__rl": true,
|
||||
"value": "01FUWX3BQ4ATCOZNR265GLA6IJEZDQUE4I",
|
||||
"mode": "list",
|
||||
"cachedResultName": "ПРРО копія"
|
||||
},
|
||||
"worksheet": {
|
||||
"__rl": true,
|
||||
"value": "{426949D7-797F-43A9-A8A4-8FE283495A82}",
|
||||
"mode": "list",
|
||||
"cachedResultName": "Sheet5"
|
||||
},
|
||||
"dataMode": "autoMap",
|
||||
"options": {}
|
||||
},
|
||||
"id": "531949d8-1ffa-4e1c-ae3e-032360b74f06",
|
||||
"name": "Microsoft Excel 3651",
|
||||
"type": "n8n-nodes-base.microsoftExcel",
|
||||
"typeVersion": 2,
|
||||
"position": [1280, 500],
|
||||
"credentials": {
|
||||
"microsoftExcelOAuth2Api": {
|
||||
"id": "70",
|
||||
"name": "Microsoft Excel account"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"jsCode": "return {\n id: 4,\n name: 'Don',\n age: 37,\n data: 'data 44',\n};"
|
||||
},
|
||||
"id": "2919f9b9-e3ac-42cd-a792-774738fd2195",
|
||||
"name": "Code",
|
||||
"type": "n8n-nodes-base.code",
|
||||
"typeVersion": 1,
|
||||
"position": [1080, 500]
|
||||
}
|
||||
],
|
||||
"pinData": {
|
||||
"Microsoft Excel 3651": [
|
||||
{
|
||||
"json": {
|
||||
"id": 4,
|
||||
"name": "Don",
|
||||
"age": 37,
|
||||
"data": "data 44"
|
||||
}
|
||||
}
|
||||
],
|
||||
"Microsoft Excel 365": [
|
||||
{
|
||||
"json": {
|
||||
"id": 4,
|
||||
"name": "Sam",
|
||||
"age": 34,
|
||||
"data": "data 4"
|
||||
}
|
||||
}
|
||||
],
|
||||
"Code": [
|
||||
{
|
||||
"json": {
|
||||
"id": 4,
|
||||
"name": "Don",
|
||||
"age": 37,
|
||||
"data": "data 44"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"connections": {
|
||||
"When clicking \"Execute Workflow\"": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Microsoft Excel 365",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
},
|
||||
{
|
||||
"node": "Code",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Code": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Microsoft Excel 3651",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"active": false,
|
||||
"settings": {}
|
||||
}
|
||||
@@ -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 {
|
||||
values: [
|
||||
{
|
||||
json: {
|
||||
success: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
}),
|
||||
};
|
||||
});
|
||||
|
||||
describe('Test MicrosoftExcelV2, worksheet => clear', () => {
|
||||
const workflows = ['nodes/Microsoft/Excel/test/v2/node/worksheet/clear.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/{F7AF92FE-D42D-452F-8E4A-901B1D1EBF3F}/range/clear',
|
||||
{ applyTo: 'All' },
|
||||
);
|
||||
|
||||
expect(result.finished).toEqual(true);
|
||||
};
|
||||
|
||||
for (const testData of tests) {
|
||||
test(testData.description, async () => testNode(testData, nodeTypes));
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,66 @@
|
||||
{
|
||||
"name": "My workflow 5",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "f0857ec9-0709-4657-a2f4-059837c94060",
|
||||
"name": "When clicking \"Execute Workflow\"",
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [540, 220]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"resource": "worksheet",
|
||||
"operation": "clear",
|
||||
"workbook": {
|
||||
"__rl": true,
|
||||
"value": "01FUWX3BQ4ATCOZNR265GLA6IJEZDQUE4I",
|
||||
"mode": "list",
|
||||
"cachedResultName": "ПРРО копія"
|
||||
},
|
||||
"worksheet": {
|
||||
"__rl": true,
|
||||
"value": "{F7AF92FE-D42D-452F-8E4A-901B1D1EBF3F}",
|
||||
"mode": "list",
|
||||
"cachedResultName": "Sheet2"
|
||||
}
|
||||
},
|
||||
"id": "426ed055-0c9b-4ae2-a9fe-a6cce875d5ee",
|
||||
"name": "Microsoft Excel 365",
|
||||
"type": "n8n-nodes-base.microsoftExcel",
|
||||
"typeVersion": 2,
|
||||
"position": [1020, 220],
|
||||
"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,67 @@
|
||||
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 {
|
||||
values: [
|
||||
{
|
||||
json: {
|
||||
success: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
}),
|
||||
};
|
||||
});
|
||||
|
||||
describe('Test MicrosoftExcelV2, worksheet => deleteWorksheet', () => {
|
||||
const workflows = ['nodes/Microsoft/Excel/test/v2/node/worksheet/deleteWorksheet.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/{88D9C37A-4180-4B23-8996-BF11F32EB63C}',
|
||||
);
|
||||
|
||||
expect(result.finished).toEqual(true);
|
||||
};
|
||||
|
||||
for (const testData of tests) {
|
||||
test(testData.description, async () => testNode(testData, nodeTypes));
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,66 @@
|
||||
{
|
||||
"name": "My workflow 5",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "f0857ec9-0709-4657-a2f4-059837c94060",
|
||||
"name": "When clicking \"Execute Workflow\"",
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [540, 220]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"resource": "worksheet",
|
||||
"operation": "deleteWorksheet",
|
||||
"workbook": {
|
||||
"__rl": true,
|
||||
"value": "01FUWX3BQ4ATCOZNR265GLA6IJEZDQUE4I",
|
||||
"mode": "list",
|
||||
"cachedResultName": "ПРРО копія"
|
||||
},
|
||||
"worksheet": {
|
||||
"__rl": true,
|
||||
"value": "{88D9C37A-4180-4B23-8996-BF11F32EB63C}",
|
||||
"mode": "list",
|
||||
"cachedResultName": "188"
|
||||
}
|
||||
},
|
||||
"id": "426ed055-0c9b-4ae2-a9fe-a6cce875d5ee",
|
||||
"name": "Microsoft Excel 365",
|
||||
"type": "n8n-nodes-base.microsoftExcel",
|
||||
"typeVersion": 2,
|
||||
"position": [1020, 220],
|
||||
"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,76 @@
|
||||
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: [
|
||||
{
|
||||
id: '{00000000-0001-0000-0000-000000000000}',
|
||||
name: 'Sheet1',
|
||||
},
|
||||
{
|
||||
id: '{F7AF92FE-D42D-452F-8E4A-901B1D1EBF3F}',
|
||||
name: 'Sheet2',
|
||||
},
|
||||
{
|
||||
id: '{BF7BD843-4912-4B81-A0AC-4FBBC2783E20}',
|
||||
name: 'foo2',
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
}),
|
||||
};
|
||||
});
|
||||
|
||||
describe('Test MicrosoftExcelV2, worksheet => getAll', () => {
|
||||
const workflows = ['nodes/Microsoft/Excel/test/v2/node/worksheet/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',
|
||||
'/drive/items/01FUWX3BQ4ATCOZNR265GLA6IJEZDQUE4I/workbook/worksheets',
|
||||
{},
|
||||
{ $select: 'name', $top: 3 },
|
||||
);
|
||||
|
||||
expect(result.finished).toEqual(true);
|
||||
};
|
||||
|
||||
for (const testData of tests) {
|
||||
test(testData.description, async () => testNode(testData, nodeTypes));
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,76 @@
|
||||
{
|
||||
"name": "My workflow 5",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "f0857ec9-0709-4657-a2f4-059837c94060",
|
||||
"name": "When clicking \"Execute Workflow\"",
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [540, 220]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"resource": "worksheet",
|
||||
"workbook": {
|
||||
"__rl": true,
|
||||
"value": "01FUWX3BQ4ATCOZNR265GLA6IJEZDQUE4I",
|
||||
"mode": "list",
|
||||
"cachedResultName": "ПРРО копія"
|
||||
},
|
||||
"limit": 3,
|
||||
"filters": {
|
||||
"fields": "name"
|
||||
}
|
||||
},
|
||||
"id": "426ed055-0c9b-4ae2-a9fe-a6cce875d5ee",
|
||||
"name": "Microsoft Excel 365",
|
||||
"type": "n8n-nodes-base.microsoftExcel",
|
||||
"typeVersion": 2,
|
||||
"position": [1020, 220],
|
||||
"credentials": {
|
||||
"microsoftExcelOAuth2Api": {
|
||||
"id": "70",
|
||||
"name": "Microsoft Excel account"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"pinData": {
|
||||
"Microsoft Excel 365": [
|
||||
{
|
||||
"json": {
|
||||
"id": "{00000000-0001-0000-0000-000000000000}",
|
||||
"name": "Sheet1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"json": {
|
||||
"id": "{F7AF92FE-D42D-452F-8E4A-901B1D1EBF3F}",
|
||||
"name": "Sheet2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"json": {
|
||||
"id": "{BF7BD843-4912-4B81-A0AC-4FBBC2783E20}",
|
||||
"name": "foo2"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"connections": {
|
||||
"When clicking \"Execute Workflow\"": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Microsoft Excel 365",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"active": false,
|
||||
"settings": {}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
import { equalityTest, setup, workflowToTests } from '../../../../../../../test/nodes/Helpers';
|
||||
|
||||
// eslint-disable-next-line unused-imports/no-unused-imports
|
||||
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' && resource.includes('usedRange')) {
|
||||
return {
|
||||
values: [
|
||||
['id', 'name', 'age', 'data'],
|
||||
[1, 'Sam', 33, 'data 1'],
|
||||
[2, 'Jon', 44, 'data 2'],
|
||||
[3, 'Ron', 55, 'data 3'],
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
values: [
|
||||
['id', 'name', 'age', 'data'],
|
||||
[1, 'Sam', 33, 'data 1'],
|
||||
[2, 'Jon', 44, 'data 2'],
|
||||
],
|
||||
};
|
||||
}
|
||||
}),
|
||||
};
|
||||
});
|
||||
|
||||
describe('Test MicrosoftExcelV2, worksheet => readRows', () => {
|
||||
const workflows = ['nodes/Microsoft/Excel/test/v2/node/worksheet/readRows.workflow.json'];
|
||||
const tests = workflowToTests(workflows);
|
||||
|
||||
beforeAll(() => {
|
||||
nock.disableNetConnect();
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
nock.restore();
|
||||
jest.unmock('../../../../v2/transport');
|
||||
});
|
||||
|
||||
const nodeTypes = setup(tests);
|
||||
|
||||
for (const testData of tests) {
|
||||
test(testData.description, async () => equalityTest(testData, nodeTypes));
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,137 @@
|
||||
{
|
||||
"name": "microsoft excel 365 - read rows",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "2e1ec8f6-a2e2-4aa9-909c-d0a279584131",
|
||||
"name": "When clicking \"Execute Workflow\"",
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [820, 380]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"resource": "worksheet",
|
||||
"operation": "readRows",
|
||||
"workbook": {
|
||||
"__rl": true,
|
||||
"value": "01FUWX3BQ4ATCOZNR265GLA6IJEZDQUE4I",
|
||||
"mode": "list",
|
||||
"cachedResultName": "ПРРО копія"
|
||||
},
|
||||
"worksheet": {
|
||||
"__rl": true,
|
||||
"value": "{A0883CFE-D27E-4ECC-B94B-981830AAD55B}",
|
||||
"mode": "list",
|
||||
"cachedResultName": "Sheet4"
|
||||
},
|
||||
"options": {}
|
||||
},
|
||||
"id": "86f2a240-3acf-45c2-b97f-63dd655d296b",
|
||||
"name": "Microsoft Excel 365",
|
||||
"type": "n8n-nodes-base.microsoftExcel",
|
||||
"typeVersion": 2,
|
||||
"position": [1100, 260],
|
||||
"credentials": {
|
||||
"microsoftExcelOAuth2Api": {
|
||||
"id": "70",
|
||||
"name": "Microsoft Excel account"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"resource": "worksheet",
|
||||
"operation": "readRows",
|
||||
"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"
|
||||
},
|
||||
"useRange": true,
|
||||
"range": "A1:D3",
|
||||
"dataStartRow": 2,
|
||||
"options": {}
|
||||
},
|
||||
"id": "8ce6ab42-8f38-452b-90da-598d8a958c2b",
|
||||
"name": "Microsoft Excel 3651",
|
||||
"type": "n8n-nodes-base.microsoftExcel",
|
||||
"typeVersion": 2,
|
||||
"position": [1100, 520],
|
||||
"credentials": {
|
||||
"microsoftExcelOAuth2Api": {
|
||||
"id": "70",
|
||||
"name": "Microsoft Excel account"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"pinData": {
|
||||
"Microsoft Excel 365": [
|
||||
{
|
||||
"json": {
|
||||
"id": 1,
|
||||
"name": "Sam",
|
||||
"age": 33,
|
||||
"data": "data 1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"json": {
|
||||
"id": 2,
|
||||
"name": "Jon",
|
||||
"age": 44,
|
||||
"data": "data 2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"json": {
|
||||
"id": 3,
|
||||
"name": "Ron",
|
||||
"age": 55,
|
||||
"data": "data 3"
|
||||
}
|
||||
}
|
||||
],
|
||||
"Microsoft Excel 3651": [
|
||||
{
|
||||
"json": {
|
||||
"id": 2,
|
||||
"name": "Jon",
|
||||
"age": 44,
|
||||
"data": "data 2"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"connections": {
|
||||
"When clicking \"Execute Workflow\"": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Microsoft Excel 365",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
},
|
||||
{
|
||||
"node": "Microsoft Excel 3651",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"active": false,
|
||||
"settings": {},
|
||||
"tags": []
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
import { equalityTest, setup, workflowToTests } from '../../../../../../../test/nodes/Helpers';
|
||||
|
||||
// eslint-disable-next-line unused-imports/no-unused-imports
|
||||
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' && resource.includes('usedRange')) {
|
||||
return {
|
||||
address: 'Sheet4!A1:D6',
|
||||
values: [
|
||||
['id', 'name', 'age', 'data'],
|
||||
[1, 'Sam', 33, 'data 1'],
|
||||
[2, 'Jon', 44, 'data 2'],
|
||||
[3, 'Ron', 55, 'data 3'],
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
if (method === 'PATCH' && resource.includes('{A0883CFE-D27E-4ECC-B94B-981830AAD55B}')) {
|
||||
return {
|
||||
values: [
|
||||
['id', 'name', 'age', 'data'],
|
||||
[1, 'Sam', 33, 'data 1'],
|
||||
[2, 'Jon', 44, 'data 2'],
|
||||
[3, 'Sam', 34, 'data 4'],
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
if (method === 'PATCH' && resource.includes('{426949D7-797F-43A9-A8A4-8FE283495A82}')) {
|
||||
return {
|
||||
values: [
|
||||
['id', 'name', 'age', 'data'],
|
||||
[1, 'Sam', 33, 'data 1'],
|
||||
[2, 'Jon', 44, 'data 2'],
|
||||
[3, 'Don', 37, 'data 44'],
|
||||
],
|
||||
};
|
||||
}
|
||||
}),
|
||||
};
|
||||
});
|
||||
|
||||
describe('Test MicrosoftExcelV2, worksheet => update', () => {
|
||||
const workflows = ['nodes/Microsoft/Excel/test/v2/node/worksheet/update.workflow.json'];
|
||||
const tests = workflowToTests(workflows);
|
||||
|
||||
beforeAll(() => {
|
||||
nock.disableNetConnect();
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
nock.restore();
|
||||
jest.unmock('../../../../v2/transport');
|
||||
});
|
||||
|
||||
const nodeTypes = setup(tests);
|
||||
|
||||
for (const testData of tests) {
|
||||
test(testData.description, async () => equalityTest(testData, nodeTypes));
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,154 @@
|
||||
{
|
||||
"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": "worksheet",
|
||||
"operation": "update",
|
||||
"workbook": {
|
||||
"__rl": true,
|
||||
"value": "01FUWX3BQ4ATCOZNR265GLA6IJEZDQUE4I",
|
||||
"mode": "list",
|
||||
"cachedResultName": "ПРРО копія"
|
||||
},
|
||||
"worksheet": {
|
||||
"__rl": true,
|
||||
"value": "={A0883CFE-D27E-4ECC-B94B-981830AAD55B}",
|
||||
"mode": "id"
|
||||
},
|
||||
"columnToMatchOn": "id",
|
||||
"valueToMatchOn": "3",
|
||||
"fieldsUi": {
|
||||
"values": [
|
||||
{
|
||||
"column": "name",
|
||||
"fieldValue": "Sam"
|
||||
},
|
||||
{
|
||||
"column": "age",
|
||||
"fieldValue": "34"
|
||||
},
|
||||
{
|
||||
"column": "data",
|
||||
"fieldValue": "data 4"
|
||||
}
|
||||
]
|
||||
},
|
||||
"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"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"resource": "worksheet",
|
||||
"operation": "update",
|
||||
"workbook": {
|
||||
"__rl": true,
|
||||
"value": "01FUWX3BQ4ATCOZNR265GLA6IJEZDQUE4I",
|
||||
"mode": "list",
|
||||
"cachedResultName": "ПРРО копія"
|
||||
},
|
||||
"worksheet": {
|
||||
"__rl": true,
|
||||
"value": "={426949D7-797F-43A9-A8A4-8FE283495A82}",
|
||||
"mode": "id"
|
||||
},
|
||||
"dataMode": "autoMap",
|
||||
"columnToMatchOn": "id",
|
||||
"options": {}
|
||||
},
|
||||
"id": "d3209da3-cfaf-40a6-a318-c66c2931a28a",
|
||||
"name": "Microsoft Excel 3651",
|
||||
"type": "n8n-nodes-base.microsoftExcel",
|
||||
"typeVersion": 2,
|
||||
"position": [860, 380],
|
||||
"credentials": {
|
||||
"microsoftExcelOAuth2Api": {
|
||||
"id": "70",
|
||||
"name": "Microsoft Excel account"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"jsCode": "return {\n id: 3,\n name: 'Don',\n age: 37,\n data: 'data 44',\n};"
|
||||
},
|
||||
"id": "eb908630-7324-46a5-890d-b5cfccf17cb2",
|
||||
"name": "Code",
|
||||
"type": "n8n-nodes-base.code",
|
||||
"typeVersion": 1,
|
||||
"position": [660, 380]
|
||||
}
|
||||
],
|
||||
"pinData": {
|
||||
"Microsoft Excel 365": [
|
||||
{
|
||||
"json": {
|
||||
"id": 3,
|
||||
"name": "Sam",
|
||||
"age": 34,
|
||||
"data": "data 4"
|
||||
}
|
||||
}
|
||||
],
|
||||
"Microsoft Excel 3651": [
|
||||
{
|
||||
"json": {
|
||||
"id": 3,
|
||||
"name": "Don",
|
||||
"age": 37,
|
||||
"data": "data 44"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"connections": {
|
||||
"When clicking \"Execute Workflow\"": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Microsoft Excel 365",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
},
|
||||
{
|
||||
"node": "Code",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Code": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Microsoft Excel 3651",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"active": false,
|
||||
"settings": {}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
import { equalityTest, setup, workflowToTests } from '../../../../../../../test/nodes/Helpers';
|
||||
|
||||
// eslint-disable-next-line unused-imports/no-unused-imports
|
||||
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' && resource.includes('usedRange')) {
|
||||
return {
|
||||
address: 'Sheet4!A1:D6',
|
||||
values: [
|
||||
['id', 'name', 'age', 'data'],
|
||||
[1, 'Sam', 33, 'data 1'],
|
||||
[2, 'Jon', 44, 'data 2'],
|
||||
[3, 'Ron', 55, 'data 3'],
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
if (method === 'PATCH' && resource.includes('{A0883CFE-D27E-4ECC-B94B-981830AAD55B}')) {
|
||||
return {
|
||||
values: [
|
||||
['id', 'name', 'age', 'data'],
|
||||
[1, 'Sam', 33, 'data 1'],
|
||||
[2, 'Jon', 44, 'data 2'],
|
||||
[3, 'Ron', 55, 'data 3'],
|
||||
[4, 'Sam', 34, 'data 4'],
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
if (method === 'PATCH' && resource.includes('{426949D7-797F-43A9-A8A4-8FE283495A82}')) {
|
||||
return {
|
||||
values: [
|
||||
['id', 'name', 'age', 'data'],
|
||||
[1, 'Sam', 33, 'data 1'],
|
||||
[2, 'Jon', 44, 'data 2'],
|
||||
[3, 'Ron', 55, 'data 3'],
|
||||
[4, 'Don', 37, 'data 44'],
|
||||
],
|
||||
};
|
||||
}
|
||||
}),
|
||||
};
|
||||
});
|
||||
|
||||
describe('Test MicrosoftExcelV2, worksheet => upsert', () => {
|
||||
const workflows = ['nodes/Microsoft/Excel/test/v2/node/worksheet/upsert.workflow.json'];
|
||||
const tests = workflowToTests(workflows);
|
||||
|
||||
beforeAll(() => {
|
||||
nock.disableNetConnect();
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
nock.restore();
|
||||
jest.unmock('../../../../v2/transport');
|
||||
});
|
||||
|
||||
const nodeTypes = setup(tests);
|
||||
|
||||
for (const testData of tests) {
|
||||
test(testData.description, async () => equalityTest(testData, nodeTypes));
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,162 @@
|
||||
{
|
||||
"name": "My workflow 5",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "f0857ec9-0709-4657-a2f4-059837c94060",
|
||||
"name": "When clicking \"Execute Workflow\"",
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [540, 220]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"resource": "worksheet",
|
||||
"operation": "upsert",
|
||||
"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": "id"
|
||||
},
|
||||
"columnToMatchOn": "id",
|
||||
"valueToMatchOn": "4",
|
||||
"fieldsUi": {
|
||||
"values": [
|
||||
{
|
||||
"column": "name",
|
||||
"fieldValue": "Sam"
|
||||
},
|
||||
{
|
||||
"column": "age",
|
||||
"fieldValue": "34"
|
||||
},
|
||||
{
|
||||
"column": "data",
|
||||
"fieldValue": "data 4"
|
||||
}
|
||||
]
|
||||
},
|
||||
"options": {}
|
||||
},
|
||||
"id": "426ed055-0c9b-4ae2-a9fe-a6cce875d5ee",
|
||||
"name": "Microsoft Excel 365",
|
||||
"type": "n8n-nodes-base.microsoftExcel",
|
||||
"typeVersion": 2,
|
||||
"position": [1020, 220],
|
||||
"credentials": {
|
||||
"microsoftExcelOAuth2Api": {
|
||||
"id": "70",
|
||||
"name": "Microsoft Excel account"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"resource": "worksheet",
|
||||
"operation": "upsert",
|
||||
"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": "={426949D7-797F-43A9-A8A4-8FE283495A82}",
|
||||
"mode": "id"
|
||||
},
|
||||
"dataMode": "autoMap",
|
||||
"columnToMatchOn": "id",
|
||||
"options": {}
|
||||
},
|
||||
"id": "0b10bfae-4e15-48c5-a2e6-7bec1c2687ec",
|
||||
"name": "Microsoft Excel 3651",
|
||||
"type": "n8n-nodes-base.microsoftExcel",
|
||||
"typeVersion": 2,
|
||||
"position": [1020, 460],
|
||||
"credentials": {
|
||||
"microsoftExcelOAuth2Api": {
|
||||
"id": "70",
|
||||
"name": "Microsoft Excel account"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"jsCode": "return {\n id: 4,\n name: 'Don',\n age: 37,\n data: 'data 44',\n};"
|
||||
},
|
||||
"id": "93453ccb-5ac3-425b-8ac4-d20f0dfe9bab",
|
||||
"name": "Code",
|
||||
"type": "n8n-nodes-base.code",
|
||||
"typeVersion": 1,
|
||||
"position": [820, 460]
|
||||
}
|
||||
],
|
||||
"pinData": {
|
||||
"Microsoft Excel 365": [
|
||||
{
|
||||
"json": {
|
||||
"id": 4,
|
||||
"name": "Sam",
|
||||
"age": 34,
|
||||
"data": "data 4"
|
||||
}
|
||||
}
|
||||
],
|
||||
"Microsoft Excel 3651": [
|
||||
{
|
||||
"json": {
|
||||
"id": 4,
|
||||
"name": "Don",
|
||||
"age": 37,
|
||||
"data": "data 44"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"connections": {
|
||||
"When clicking \"Execute Workflow\"": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Microsoft Excel 365",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
},
|
||||
{
|
||||
"node": "Code",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Code": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Microsoft Excel 3651",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"active": false,
|
||||
"settings": {},
|
||||
"versionId": "f24273bf-ef07-49da-960b-a68b63961d4a",
|
||||
"id": "135",
|
||||
"meta": {
|
||||
"instanceId": "36203ea1ce3cef713fa25999bd9874ae26b9e4c2c3a90a365f2882a154d031d0"
|
||||
},
|
||||
"tags": []
|
||||
}
|
||||
Reference in New Issue
Block a user