first commit
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
export const credentials = {
|
||||
microsoftSharePointOAuth2Api: {
|
||||
grantType: 'authorizationCode',
|
||||
authUrl: 'https://login.microsoftonline.com/common/oauth2/v2.0/authorize',
|
||||
accessTokenUrl: 'https://login.microsoftonline.com/common/oauth2/v2.0/token',
|
||||
clientId: 'CLIENT_ID',
|
||||
clientSecret: 'CLIENT_SECRET',
|
||||
scope: 'openid offline_access https://mydomain.sharepoint.com/.default',
|
||||
authQueryParameters: 'response_mode=query',
|
||||
authentication: 'body',
|
||||
oauthTokenData: {
|
||||
token_type: 'Bearer',
|
||||
scope:
|
||||
'https://mydomain.sharepoint.com/Sites.Manage.All https://mydomain.sharepoint.com/Sites.Read.All https://mydomain.sharepoint.com/Sites.ReadWrite.All https://mydomain.sharepoint.com/Sites.Selected https://mydomain.sharepoint.com/User.Read https://mydomain.sharepoint.com/.default',
|
||||
expires_in: 4763,
|
||||
ext_expires_in: 4763,
|
||||
access_token: 'ACCESSTOKEN',
|
||||
refresh_token: 'REFRESHTOKEN',
|
||||
id_token: 'IDTOKEN',
|
||||
callbackQueryString: {
|
||||
session_state: 'SESSIONSTATE',
|
||||
},
|
||||
},
|
||||
subdomain: 'mydomain',
|
||||
baseUrl: 'https://mydomain.sharepoint.com/_api/v2.0',
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,36 @@
|
||||
import { CredentialsHelper } from '@nodes-testing/credentials-helper';
|
||||
import { NodeTestHarness } from '@nodes-testing/node-test-harness';
|
||||
|
||||
import { credentials } from '../credentials';
|
||||
|
||||
describe('Microsoft SharePoint Node', () => {
|
||||
const { baseUrl } = credentials.microsoftSharePointOAuth2Api;
|
||||
jest.spyOn(CredentialsHelper.prototype, 'getParentTypes').mockReturnValueOnce(['oAuth2Api']);
|
||||
new NodeTestHarness().setupTests({
|
||||
credentials,
|
||||
workflowFiles: ['oauth2.workflow.json'],
|
||||
nock: {
|
||||
baseUrl,
|
||||
mocks: [
|
||||
{
|
||||
method: 'get',
|
||||
path: '/sites/site1/lists/list1?%24select=id%2Cname%2CdisplayName%2Cdescription%2CcreatedDateTime%2ClastModifiedDateTime%2CwebUrl',
|
||||
statusCode: 200,
|
||||
requestHeaders: { Authorization: 'Bearer ACCESSTOKEN' },
|
||||
responseBody: {
|
||||
'@odata.context':
|
||||
'https://mydomain.sharepoint.com/sites/site1/_api/v2.0/$metadata#lists/$entity',
|
||||
'@odata.etag': '"58a279af-1f06-4392-a5ed-2b37fa1d6c1d,5"',
|
||||
createdDateTime: '2025-03-12T19:38:40Z',
|
||||
description: 'My List 1',
|
||||
id: '58a279af-1f06-4392-a5ed-2b37fa1d6c1d',
|
||||
lastModifiedDateTime: '2025-03-12T22:18:18Z',
|
||||
name: 'list1',
|
||||
webUrl: 'https://mydomain.sharepoint.com/sites/site1/Lists/name%20list',
|
||||
displayName: 'list1',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,70 @@
|
||||
{
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [0, 0],
|
||||
"id": "d8d29d0a-bb31-4094-a252-8008932f5425",
|
||||
"name": "When clicking ‘Test workflow’"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"resource": "list",
|
||||
"operation": "get",
|
||||
"site": {
|
||||
"__rl": true,
|
||||
"value": "site1",
|
||||
"mode": "list",
|
||||
"cachedResultName": "site1"
|
||||
},
|
||||
"list": {
|
||||
"__rl": true,
|
||||
"value": "list1",
|
||||
"mode": "list",
|
||||
"cachedResultName": "list1"
|
||||
},
|
||||
"requestOptions": {}
|
||||
},
|
||||
"type": "n8n-nodes-base.microsoftSharePoint",
|
||||
"typeVersion": 1,
|
||||
"position": [200, 0],
|
||||
"id": "0e19be10-9d94-4654-89e9-432daa8102cb",
|
||||
"name": "Microsoft SharePoint",
|
||||
"credentials": {
|
||||
"microsoftSharePointOAuth2Api": {
|
||||
"id": "cXXnMCWyk397M5qJ",
|
||||
"name": "Microsoft SharePoint account"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"connections": {
|
||||
"When clicking ‘Test workflow’": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Microsoft SharePoint",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"pinData": {
|
||||
"Microsoft SharePoint": [
|
||||
{
|
||||
"json": {
|
||||
"createdDateTime": "2025-03-12T19:38:40Z",
|
||||
"description": "My List 1",
|
||||
"id": "58a279af-1f06-4392-a5ed-2b37fa1d6c1d",
|
||||
"lastModifiedDateTime": "2025-03-12T22:18:18Z",
|
||||
"name": "list1",
|
||||
"webUrl": "https://mydomain.sharepoint.com/sites/site1/Lists/name%20list",
|
||||
"displayName": "list1"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
import { NodeTestHarness } from '@nodes-testing/node-test-harness';
|
||||
|
||||
import { credentials } from '../credentials';
|
||||
|
||||
describe('Microsoft SharePoint Node', () => {
|
||||
const { baseUrl } = credentials.microsoftSharePointOAuth2Api;
|
||||
new NodeTestHarness().setupTests({
|
||||
credentials,
|
||||
workflowFiles: ['download.workflow.json'],
|
||||
assertBinaryData: true,
|
||||
nock: {
|
||||
baseUrl,
|
||||
mocks: [
|
||||
{
|
||||
method: 'get',
|
||||
path: '/sites/site1/drive/items/item1/content',
|
||||
statusCode: 200,
|
||||
responseBody: {},
|
||||
responseHeaders: {
|
||||
'content-type': 'application/json',
|
||||
'content-disposition':
|
||||
"attachment; filename*=UTF-8''weird%20file%20%E2%82%AC%20name.json",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,76 @@
|
||||
{
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [0, 0],
|
||||
"id": "37ab6212-d506-4b53-b63e-14b6a2a05907",
|
||||
"name": "When clicking ‘Test workflow’"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"site": {
|
||||
"__rl": true,
|
||||
"value": "site1",
|
||||
"mode": "list",
|
||||
"cachedResultName": "site1"
|
||||
},
|
||||
"folder": {
|
||||
"__rl": true,
|
||||
"value": "folder1",
|
||||
"mode": "list",
|
||||
"cachedResultName": "folder1"
|
||||
},
|
||||
"file": {
|
||||
"__rl": true,
|
||||
"value": "item1",
|
||||
"mode": "list",
|
||||
"cachedResultName": "file.json"
|
||||
},
|
||||
"requestOptions": {}
|
||||
},
|
||||
"type": "n8n-nodes-base.microsoftSharePoint",
|
||||
"typeVersion": 1,
|
||||
"position": [220, 0],
|
||||
"id": "f9037af8-4f52-4f9f-b8ae-de860f890792",
|
||||
"name": "Microsoft SharePoint",
|
||||
"credentials": {
|
||||
"microsoftSharePointOAuth2Api": {
|
||||
"id": "cXXnMCWyk397M5qJ",
|
||||
"name": "Microsoft SharePoint account"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"connections": {
|
||||
"When clicking ‘Test workflow’": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Microsoft SharePoint",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"pinData": {
|
||||
"Microsoft SharePoint": [
|
||||
{
|
||||
"binary": {
|
||||
"data": {
|
||||
"data": "e30=",
|
||||
"fileExtension": "json",
|
||||
"fileSize": "2 B",
|
||||
"fileType": "json",
|
||||
"mimeType": "application/json",
|
||||
"fileName": "weird file € name.json"
|
||||
}
|
||||
},
|
||||
"json": {}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
import { NodeTestHarness } from '@nodes-testing/node-test-harness';
|
||||
|
||||
import { credentials } from '../credentials';
|
||||
|
||||
describe('Microsoft SharePoint Node', () => {
|
||||
const { baseUrl } = credentials.microsoftSharePointOAuth2Api;
|
||||
new NodeTestHarness().setupTests({
|
||||
credentials,
|
||||
workflowFiles: ['update.workflow.json'],
|
||||
nock: {
|
||||
baseUrl,
|
||||
mocks: [
|
||||
{
|
||||
method: 'patch',
|
||||
path: '/sites/site1/drive/items/item1',
|
||||
statusCode: 200,
|
||||
responseBody: {
|
||||
'@odata.context':
|
||||
'https://mydomain.sharepoint.com/sites/site1/_api/v2.0/$metadata#items/$entity',
|
||||
'@content.downloadUrl':
|
||||
'https://mydomain.sharepoint.com/sites/site1/_layouts/15/download.aspx?UniqueId=d86f89ab-378e-43bc-8d46-18d2f52bd603',
|
||||
createdBy: {
|
||||
application: {
|
||||
id: 'b9c26603-3c9b-4050-b848-27dfab0a52fa',
|
||||
displayName: 'sharepoint-n8n-test',
|
||||
},
|
||||
user: {
|
||||
email: 'john@doe.onmicrosoft.com',
|
||||
id: '5f7afebb-121d-4664-882b-a09fe6584ce0',
|
||||
displayName: 'John Doe',
|
||||
},
|
||||
},
|
||||
createdDateTime: '2025-03-13T19:23:53Z',
|
||||
eTag: '"{D86F89AB-378E-43BC-8D46-18D2F52BD603},3"',
|
||||
id: '01SPEVVYFLRFX5RDRXXRBY2RQY2L2SXVQD',
|
||||
lastModifiedBy: {
|
||||
application: {
|
||||
id: 'b9c26603-3c9b-4050-b848-27dfab0a52fa',
|
||||
displayName: 'sharepoint-n8n-test',
|
||||
},
|
||||
user: {
|
||||
email: 'john@doe.onmicrosoft.com',
|
||||
id: '5f7afebb-121d-4664-882b-a09fe6584ce0',
|
||||
displayName: 'John Doe',
|
||||
},
|
||||
},
|
||||
lastModifiedDateTime: '2025-03-24T19:48:25Z',
|
||||
name: 'file2.json',
|
||||
parentReference: {
|
||||
driveType: 'documentLibrary',
|
||||
driveId: 'b!HXyh83lynUOhdUenWLZcmP1mvjoj7J9Gq8YzLjqVv3W_vPrVy_93T7lzoXbjRjzK',
|
||||
id: '01SPEVVYBKV2ZKHGJASRA2HC7MOGBMUMAA',
|
||||
name: 'folder1',
|
||||
path: '/drive/root:/folder1',
|
||||
siteId: 'f3a17c1d-7279-439d-a175-47a758b65c98',
|
||||
},
|
||||
webUrl:
|
||||
'https://mydomain.sharepoint.com/sites/site1/Shared%20Documents/folder1/file2.json',
|
||||
cTag: '"c:{D86F89AB-378E-43BC-8D46-18D2F52BD603},2"',
|
||||
file: {
|
||||
hashes: {
|
||||
quickXorHash: 'jY7BcIP9Th3EZ4PMCLrv4DnQTY4=',
|
||||
},
|
||||
irmEffectivelyEnabled: false,
|
||||
irmEnabled: false,
|
||||
mimeType: 'application/json',
|
||||
},
|
||||
fileSystemInfo: {
|
||||
createdDateTime: '2025-03-13T19:23:53Z',
|
||||
lastModifiedDateTime: '2025-03-24T19:48:25Z',
|
||||
},
|
||||
shared: {
|
||||
effectiveRoles: ['write'],
|
||||
scope: 'users',
|
||||
},
|
||||
size: 37,
|
||||
},
|
||||
},
|
||||
{
|
||||
method: 'put',
|
||||
path: '/sites/site1/drive/items/item1/content',
|
||||
statusCode: 200,
|
||||
responseBody: {
|
||||
'@odata.context':
|
||||
'https://mydomain.sharepoint.com/sites/site1/_api/v2.0/$metadata#items/$entity',
|
||||
'@content.downloadUrl':
|
||||
'https://mydomain.sharepoint.com/sites/site1/_layouts/15/download.aspx?UniqueId=d86f89ab-378e-43bc-8d46-18d2f52bd603',
|
||||
createdBy: {
|
||||
application: {
|
||||
id: 'b9c26603-3c9b-4050-b848-27dfab0a52fa',
|
||||
displayName: 'sharepoint-n8n-test',
|
||||
},
|
||||
user: {
|
||||
email: 'john@doe.onmicrosoft.com',
|
||||
id: '5f7afebb-121d-4664-882b-a09fe6584ce0',
|
||||
displayName: 'John Doe',
|
||||
},
|
||||
},
|
||||
createdDateTime: '2025-03-13T19:23:53Z',
|
||||
eTag: '"{D86F89AB-378E-43BC-8D46-18D2F52BD603},3"',
|
||||
id: '01SPEVVYFLRFX5RDRXXRBY2RQY2L2SXVQD',
|
||||
lastModifiedBy: {
|
||||
application: {
|
||||
id: 'b9c26603-3c9b-4050-b848-27dfab0a52fa',
|
||||
displayName: 'sharepoint-n8n-test',
|
||||
},
|
||||
user: {
|
||||
email: 'john@doe.onmicrosoft.com',
|
||||
id: '5f7afebb-121d-4664-882b-a09fe6584ce0',
|
||||
displayName: 'John Doe',
|
||||
},
|
||||
},
|
||||
lastModifiedDateTime: '2025-03-24T19:48:35Z',
|
||||
name: 'file2.json',
|
||||
parentReference: {
|
||||
driveType: 'documentLibrary',
|
||||
driveId: 'b!HXyh83lynUOhdUenWLZcmP1mvjoj7J9Gq8YzLjqVv3W_vPrVy_93T7lzoXbjRjzK',
|
||||
id: '01SPEVVYBKV2ZKHGJASRA2HC7MOGBMUMAA',
|
||||
name: 'folder1',
|
||||
path: '/drive/root:/folder1',
|
||||
siteId: 'f3a17c1d-7279-439d-a175-47a758b65c98',
|
||||
},
|
||||
webUrl:
|
||||
'https://mydomain.sharepoint.com/sites/site1/Shared%20Documents/folder1/file2.json',
|
||||
cTag: '"c:{D86F89AB-378E-43BC-8D46-18D2F52BD603},2"',
|
||||
file: {
|
||||
hashes: {
|
||||
quickXorHash: 'jY7BcIP9Th3EZ4PMCLrv4DnQTY4=',
|
||||
},
|
||||
irmEffectivelyEnabled: false,
|
||||
irmEnabled: false,
|
||||
mimeType: 'application/json',
|
||||
},
|
||||
fileSystemInfo: {
|
||||
createdDateTime: '2025-03-13T19:23:53Z',
|
||||
lastModifiedDateTime: '2025-03-24T19:48:25Z',
|
||||
},
|
||||
shared: {
|
||||
effectiveRoles: ['write'],
|
||||
scope: 'users',
|
||||
},
|
||||
size: 37,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,175 @@
|
||||
{
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [0, 0],
|
||||
"id": "37ab6212-d506-4b53-b63e-14b6a2a05907",
|
||||
"name": "When clicking ‘Test workflow’"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"operation": "update",
|
||||
"site": {
|
||||
"__rl": true,
|
||||
"value": "site1",
|
||||
"mode": "list",
|
||||
"cachedResultName": "site1"
|
||||
},
|
||||
"folder": {
|
||||
"__rl": true,
|
||||
"value": "folder1",
|
||||
"mode": "list",
|
||||
"cachedResultName": "folder1"
|
||||
},
|
||||
"file": {
|
||||
"__rl": true,
|
||||
"value": "item1",
|
||||
"mode": "list",
|
||||
"cachedResultName": "file1.json"
|
||||
},
|
||||
"fileName": "file2.json",
|
||||
"changeFileContent": true,
|
||||
"fileContents": "data",
|
||||
"requestOptions": {}
|
||||
},
|
||||
"type": "n8n-nodes-base.microsoftSharePoint",
|
||||
"typeVersion": 1,
|
||||
"position": [660, 0],
|
||||
"id": "f9037af8-4f52-4f9f-b8ae-de860f890792",
|
||||
"name": "Microsoft SharePoint",
|
||||
"credentials": {
|
||||
"microsoftSharePointOAuth2Api": {
|
||||
"id": "cXXnMCWyk397M5qJ",
|
||||
"name": "Microsoft SharePoint account"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"mode": "jsonToBinary",
|
||||
"convertAllData": false,
|
||||
"options": {
|
||||
"useRawData": true
|
||||
}
|
||||
},
|
||||
"name": "Move Binary Data",
|
||||
"type": "n8n-nodes-base.moveBinaryData",
|
||||
"typeVersion": 1,
|
||||
"position": [440, 0],
|
||||
"id": "9cba2be3-50e0-4ae2-b7a6-2f0caefb50ef"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"mode": "raw",
|
||||
"jsonOutput": "{\n \"data\": {\n \"my_field_1\": \"value\",\n \"my_field_2\": 1\n }\n}\n",
|
||||
"options": {}
|
||||
},
|
||||
"type": "n8n-nodes-base.set",
|
||||
"typeVersion": 3.4,
|
||||
"position": [220, 0],
|
||||
"id": "fdafc0d5-58dd-4f9e-a76b-0a3cb0e9a794",
|
||||
"name": "Edit Fields"
|
||||
}
|
||||
],
|
||||
"connections": {
|
||||
"When clicking ‘Test workflow’": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Edit Fields",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Move Binary Data": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Microsoft SharePoint",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Edit Fields": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Move Binary Data",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"pinData": {
|
||||
"Microsoft SharePoint": [
|
||||
{
|
||||
"json": {
|
||||
"@content.downloadUrl": "https://mydomain.sharepoint.com/sites/site1/_layouts/15/download.aspx?UniqueId=d86f89ab-378e-43bc-8d46-18d2f52bd603",
|
||||
"@odata.context": "https://mydomain.sharepoint.com/sites/site1/_api/v2.0/$metadata#items/$entity",
|
||||
"cTag": "\"c:{D86F89AB-378E-43BC-8D46-18D2F52BD603},2\"",
|
||||
"createdBy": {
|
||||
"application": {
|
||||
"displayName": "sharepoint-n8n-test",
|
||||
"id": "b9c26603-3c9b-4050-b848-27dfab0a52fa"
|
||||
},
|
||||
"user": {
|
||||
"displayName": "John Doe",
|
||||
"email": "john@doe.onmicrosoft.com",
|
||||
"id": "5f7afebb-121d-4664-882b-a09fe6584ce0"
|
||||
}
|
||||
},
|
||||
"createdDateTime": "2025-03-13T19:23:53Z",
|
||||
"eTag": "\"{D86F89AB-378E-43BC-8D46-18D2F52BD603},3\"",
|
||||
"file": {
|
||||
"hashes": {
|
||||
"quickXorHash": "jY7BcIP9Th3EZ4PMCLrv4DnQTY4="
|
||||
},
|
||||
"irmEffectivelyEnabled": false,
|
||||
"irmEnabled": false,
|
||||
"mimeType": "application/json"
|
||||
},
|
||||
"fileSystemInfo": {
|
||||
"createdDateTime": "2025-03-13T19:23:53Z",
|
||||
"lastModifiedDateTime": "2025-03-24T19:48:25Z"
|
||||
},
|
||||
"id": "01SPEVVYFLRFX5RDRXXRBY2RQY2L2SXVQD",
|
||||
"lastModifiedBy": {
|
||||
"application": {
|
||||
"displayName": "sharepoint-n8n-test",
|
||||
"id": "b9c26603-3c9b-4050-b848-27dfab0a52fa"
|
||||
},
|
||||
"user": {
|
||||
"displayName": "John Doe",
|
||||
"email": "john@doe.onmicrosoft.com",
|
||||
"id": "5f7afebb-121d-4664-882b-a09fe6584ce0"
|
||||
}
|
||||
},
|
||||
"lastModifiedDateTime": "2025-03-24T19:48:35Z",
|
||||
"name": "file2.json",
|
||||
"parentReference": {
|
||||
"driveId": "b!HXyh83lynUOhdUenWLZcmP1mvjoj7J9Gq8YzLjqVv3W_vPrVy_93T7lzoXbjRjzK",
|
||||
"driveType": "documentLibrary",
|
||||
"id": "01SPEVVYBKV2ZKHGJASRA2HC7MOGBMUMAA",
|
||||
"name": "folder1",
|
||||
"path": "/drive/root:/folder1",
|
||||
"siteId": "f3a17c1d-7279-439d-a175-47a758b65c98"
|
||||
},
|
||||
"shared": {
|
||||
"effectiveRoles": ["write"],
|
||||
"scope": "users"
|
||||
},
|
||||
"size": 37,
|
||||
"webUrl": "https://mydomain.sharepoint.com/sites/site1/Shared%20Documents/folder1/file2.json"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
import { NodeTestHarness } from '@nodes-testing/node-test-harness';
|
||||
|
||||
import { credentials } from '../credentials';
|
||||
|
||||
describe('Microsoft SharePoint Node', () => {
|
||||
const { baseUrl } = credentials.microsoftSharePointOAuth2Api;
|
||||
new NodeTestHarness().setupTests({
|
||||
credentials,
|
||||
workflowFiles: ['upload.workflow.json'],
|
||||
nock: {
|
||||
baseUrl,
|
||||
mocks: [
|
||||
{
|
||||
method: 'put',
|
||||
path: '/sites/site1/drive/items/folder1:/file1.json:/content',
|
||||
statusCode: 201,
|
||||
responseBody: {
|
||||
'@odata.context':
|
||||
'https://mydomain.sharepoint.com/sites/site1/_api/v2.0/$metadata#items/$entity',
|
||||
'@content.downloadUrl':
|
||||
'https://mydomain.sharepoint.com/sites/site1/_layouts/15/download.aspx?UniqueId=d86f89ab-378e-43bc-8d46-18d2f52bd603',
|
||||
createdBy: {
|
||||
application: {
|
||||
id: 'b9c26603-3c9b-4050-b848-27dfab0a52fa',
|
||||
displayName: 'sharepoint-n8n-test',
|
||||
},
|
||||
user: {
|
||||
email: 'john@doe.onmicrosoft.com',
|
||||
id: '5f7afebb-121d-4664-882b-a09fe6584ce0',
|
||||
displayName: 'John Doe',
|
||||
},
|
||||
},
|
||||
createdDateTime: '2025-03-13T19:23:53Z',
|
||||
eTag: '"{D86F89AB-378E-43BC-8D46-18D2F52BD603},3"',
|
||||
id: '01SPEVVYFLRFX5RDRXXRBY2RQY2L2SXVQD',
|
||||
lastModifiedBy: {
|
||||
application: {
|
||||
id: 'b9c26603-3c9b-4050-b848-27dfab0a52fa',
|
||||
displayName: 'sharepoint-n8n-test',
|
||||
},
|
||||
user: {
|
||||
email: 'john@doe.onmicrosoft.com',
|
||||
id: '5f7afebb-121d-4664-882b-a09fe6584ce0',
|
||||
displayName: 'John Doe',
|
||||
},
|
||||
},
|
||||
lastModifiedDateTime: '2025-03-24T19:48:25Z',
|
||||
name: 'file2.json',
|
||||
parentReference: {
|
||||
driveType: 'documentLibrary',
|
||||
driveId: 'b!HXyh83lynUOhdUenWLZcmP1mvjoj7J9Gq8YzLjqVv3W_vPrVy_93T7lzoXbjRjzK',
|
||||
id: '01SPEVVYBKV2ZKHGJASRA2HC7MOGBMUMAA',
|
||||
name: 'folder1',
|
||||
path: '/drive/root:/folder1',
|
||||
siteId: 'f3a17c1d-7279-439d-a175-47a758b65c98',
|
||||
},
|
||||
webUrl:
|
||||
'https://mydomain.sharepoint.com/sites/site1/Shared%20Documents/folder1/file1.json',
|
||||
cTag: '"c:{D86F89AB-378E-43BC-8D46-18D2F52BD603},2"',
|
||||
file: {
|
||||
hashes: {
|
||||
quickXorHash: 'jY7BcIP9Th3EZ4PMCLrv4DnQTY4=',
|
||||
},
|
||||
irmEffectivelyEnabled: false,
|
||||
irmEnabled: false,
|
||||
mimeType: 'application/json',
|
||||
},
|
||||
fileSystemInfo: {
|
||||
createdDateTime: '2025-03-13T19:23:53Z',
|
||||
lastModifiedDateTime: '2025-03-24T19:48:25Z',
|
||||
},
|
||||
shared: {
|
||||
effectiveRoles: ['write'],
|
||||
scope: 'users',
|
||||
},
|
||||
size: 37,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,168 @@
|
||||
{
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [0, 0],
|
||||
"id": "37ab6212-d506-4b53-b63e-14b6a2a05907",
|
||||
"name": "When clicking ‘Test workflow’"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"operation": "upload",
|
||||
"site": {
|
||||
"__rl": true,
|
||||
"value": "site1",
|
||||
"mode": "list",
|
||||
"cachedResultName": "site1"
|
||||
},
|
||||
"folder": {
|
||||
"__rl": true,
|
||||
"value": "folder1",
|
||||
"mode": "list",
|
||||
"cachedResultName": "folder1"
|
||||
},
|
||||
"fileName": "file1.json",
|
||||
"fileContents": "data",
|
||||
"requestOptions": {}
|
||||
},
|
||||
"type": "n8n-nodes-base.microsoftSharePoint",
|
||||
"typeVersion": 1,
|
||||
"position": [660, 0],
|
||||
"id": "f9037af8-4f52-4f9f-b8ae-de860f890792",
|
||||
"name": "Microsoft SharePoint",
|
||||
"credentials": {
|
||||
"microsoftSharePointOAuth2Api": {
|
||||
"id": "cXXnMCWyk397M5qJ",
|
||||
"name": "Microsoft SharePoint account"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"mode": "jsonToBinary",
|
||||
"convertAllData": false,
|
||||
"options": {
|
||||
"useRawData": true
|
||||
}
|
||||
},
|
||||
"name": "Move Binary Data",
|
||||
"type": "n8n-nodes-base.moveBinaryData",
|
||||
"typeVersion": 1,
|
||||
"position": [440, 0],
|
||||
"id": "9cba2be3-50e0-4ae2-b7a6-2f0caefb50ef"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"mode": "raw",
|
||||
"jsonOutput": "{\n \"data\": {\n \"my_field_1\": \"value\",\n \"my_field_2\": 1\n }\n}\n",
|
||||
"options": {}
|
||||
},
|
||||
"type": "n8n-nodes-base.set",
|
||||
"typeVersion": 3.4,
|
||||
"position": [220, 0],
|
||||
"id": "fdafc0d5-58dd-4f9e-a76b-0a3cb0e9a794",
|
||||
"name": "Edit Fields"
|
||||
}
|
||||
],
|
||||
"connections": {
|
||||
"When clicking ‘Test workflow’": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Edit Fields",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Move Binary Data": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Microsoft SharePoint",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Edit Fields": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Move Binary Data",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"pinData": {
|
||||
"Microsoft SharePoint": [
|
||||
{
|
||||
"json": {
|
||||
"@content.downloadUrl": "https://mydomain.sharepoint.com/sites/site1/_layouts/15/download.aspx?UniqueId=d86f89ab-378e-43bc-8d46-18d2f52bd603",
|
||||
"@odata.context": "https://mydomain.sharepoint.com/sites/site1/_api/v2.0/$metadata#items/$entity",
|
||||
"cTag": "\"c:{D86F89AB-378E-43BC-8D46-18D2F52BD603},2\"",
|
||||
"createdBy": {
|
||||
"application": {
|
||||
"displayName": "sharepoint-n8n-test",
|
||||
"id": "b9c26603-3c9b-4050-b848-27dfab0a52fa"
|
||||
},
|
||||
"user": {
|
||||
"displayName": "John Doe",
|
||||
"email": "john@doe.onmicrosoft.com",
|
||||
"id": "5f7afebb-121d-4664-882b-a09fe6584ce0"
|
||||
}
|
||||
},
|
||||
"createdDateTime": "2025-03-13T19:23:53Z",
|
||||
"eTag": "\"{D86F89AB-378E-43BC-8D46-18D2F52BD603},3\"",
|
||||
"file": {
|
||||
"hashes": {
|
||||
"quickXorHash": "jY7BcIP9Th3EZ4PMCLrv4DnQTY4="
|
||||
},
|
||||
"irmEffectivelyEnabled": false,
|
||||
"irmEnabled": false,
|
||||
"mimeType": "application/json"
|
||||
},
|
||||
"fileSystemInfo": {
|
||||
"createdDateTime": "2025-03-13T19:23:53Z",
|
||||
"lastModifiedDateTime": "2025-03-24T19:48:25Z"
|
||||
},
|
||||
"id": "01SPEVVYFLRFX5RDRXXRBY2RQY2L2SXVQD",
|
||||
"lastModifiedBy": {
|
||||
"application": {
|
||||
"displayName": "sharepoint-n8n-test",
|
||||
"id": "b9c26603-3c9b-4050-b848-27dfab0a52fa"
|
||||
},
|
||||
"user": {
|
||||
"displayName": "John Doe",
|
||||
"email": "john@doe.onmicrosoft.com",
|
||||
"id": "5f7afebb-121d-4664-882b-a09fe6584ce0"
|
||||
}
|
||||
},
|
||||
"lastModifiedDateTime": "2025-03-24T19:48:25Z",
|
||||
"name": "file2.json",
|
||||
"parentReference": {
|
||||
"driveId": "b!HXyh83lynUOhdUenWLZcmP1mvjoj7J9Gq8YzLjqVv3W_vPrVy_93T7lzoXbjRjzK",
|
||||
"driveType": "documentLibrary",
|
||||
"id": "01SPEVVYBKV2ZKHGJASRA2HC7MOGBMUMAA",
|
||||
"name": "folder1",
|
||||
"path": "/drive/root:/folder1",
|
||||
"siteId": "f3a17c1d-7279-439d-a175-47a758b65c98"
|
||||
},
|
||||
"shared": {
|
||||
"effectiveRoles": ["write"],
|
||||
"scope": "users"
|
||||
},
|
||||
"size": 37,
|
||||
"webUrl": "https://mydomain.sharepoint.com/sites/site1/Shared%20Documents/folder1/file1.json"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
import type { MockProxy } from 'jest-mock-extended';
|
||||
import { mock } from 'jest-mock-extended';
|
||||
import type { IBinaryData, IExecuteSingleFunctions } from 'n8n-workflow';
|
||||
|
||||
import { downloadFilePostReceive, escapeFilterValue } from '../../helpers/utils';
|
||||
|
||||
describe('Microsoft SharePoint Node', () => {
|
||||
let executeSingleFunctions: MockProxy<IExecuteSingleFunctions>;
|
||||
|
||||
beforeEach(() => {
|
||||
executeSingleFunctions = mock<IExecuteSingleFunctions>();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
jest.resetAllMocks();
|
||||
});
|
||||
|
||||
it('should download file post receive', async () => {
|
||||
const mockResponse = {
|
||||
body: '',
|
||||
statusCode: 200,
|
||||
headers: {
|
||||
'content-disposition': "attachment; filename*=UTF-8''encoded%20name.pdf",
|
||||
'content-type': 'application/pdf',
|
||||
},
|
||||
};
|
||||
const mockPrepareBinaryData = jest.fn().mockReturnValueOnce({
|
||||
data: '',
|
||||
mimeType: 'application/pdf',
|
||||
fileName: 'encoded name.pdf',
|
||||
} as IBinaryData);
|
||||
executeSingleFunctions.helpers.prepareBinaryData = mockPrepareBinaryData;
|
||||
|
||||
const result = await downloadFilePostReceive.call(executeSingleFunctions, [], mockResponse);
|
||||
|
||||
expect(mockPrepareBinaryData).toHaveBeenCalledWith(
|
||||
mockResponse.body,
|
||||
'encoded name.pdf',
|
||||
'application/pdf',
|
||||
);
|
||||
expect(result).toEqual([
|
||||
{
|
||||
json: {},
|
||||
binary: {
|
||||
data: {
|
||||
data: '',
|
||||
mimeType: 'application/pdf',
|
||||
fileName: 'encoded name.pdf',
|
||||
},
|
||||
},
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
describe('escapeFilterValue', () => {
|
||||
it('should escape single quotes', () => {
|
||||
expect(escapeFilterValue("hello' there ''")).toEqual("hello'' there ''''");
|
||||
});
|
||||
it('should not escape double quotes', () => {
|
||||
expect(escapeFilterValue('hello " there ""')).toEqual('hello " there ""');
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,107 @@
|
||||
import { NodeTestHarness } from '@nodes-testing/node-test-harness';
|
||||
|
||||
import { credentials } from '../credentials';
|
||||
|
||||
describe('Microsoft SharePoint Node', () => {
|
||||
const { baseUrl } = credentials.microsoftSharePointOAuth2Api;
|
||||
new NodeTestHarness().setupTests({
|
||||
credentials,
|
||||
workflowFiles: ['create.workflow.json'],
|
||||
nock: {
|
||||
baseUrl,
|
||||
mocks: [
|
||||
{
|
||||
method: 'post',
|
||||
path: '/sites/site1/lists/list1/items',
|
||||
statusCode: 201,
|
||||
requestBody: {
|
||||
fields: {
|
||||
bool: true,
|
||||
Title: 'Title 1',
|
||||
choice: 'Choice 1',
|
||||
datetime: '2025-03-24T00:00:00',
|
||||
number: 1,
|
||||
currency: 1,
|
||||
LikesCount: 1,
|
||||
RatingCount: 1,
|
||||
AverageRating: 1,
|
||||
person: '1',
|
||||
lookup: '1',
|
||||
image:
|
||||
'{"type":"thumbnail","fileName":"file.jpg","nativeFile":{},"fieldName":"Picture","serverUrl":"https://mydomain.sharepoint.com","fieldId":"image","serverRelativeUrl":"/sites/site1/SiteAssets/Lists/list1/file.jpg","id":"image"}',
|
||||
},
|
||||
},
|
||||
responseBody: {
|
||||
'@odata.context':
|
||||
'https://mydomain.sharepoint.com/sites/site1/_api/v2.0/$metadata#listItems/$entity',
|
||||
'@odata.etag': '"625d681e-2ce3-4c2b-a490-7c8404a31427,1"',
|
||||
createdBy: {
|
||||
user: {
|
||||
displayName: 'John Doe',
|
||||
email: 'john@doe.onmicrosoft.com',
|
||||
id: '5f7afebb-121d-4664-882b-a09fe6584ce0',
|
||||
},
|
||||
},
|
||||
createdDateTime: '2025-03-25T20:07:23Z',
|
||||
eTag: '"625d681e-2ce3-4c2b-a490-7c8404a31427,1"',
|
||||
id: '1',
|
||||
lastModifiedBy: {
|
||||
application: {
|
||||
id: 'b9c26603-3c9b-4050-b848-27dfab0a52fa',
|
||||
displayName: 'sharepoint-n8n-test',
|
||||
},
|
||||
user: {
|
||||
displayName: 'John Doe',
|
||||
email: 'john@doe.onmicrosoft.com',
|
||||
id: '5f7afebb-121d-4664-882b-a09fe6584ce0',
|
||||
},
|
||||
},
|
||||
lastModifiedDateTime: '2025-03-25T20:07:23Z',
|
||||
parentReference: {
|
||||
id: '0ead9135-9622-4b6d-b319-6b8810a6dc60',
|
||||
listId: 'list1',
|
||||
siteId: 'site1',
|
||||
},
|
||||
webUrl: 'https://mydomain.sharepoint.com/sites/n8ntest10/Lists/test/41_.000',
|
||||
contentType: {
|
||||
id: '0x0100362657F7588C5C438072A77E0EF184F4000272C0D1046D984B8097B3C00D199EDE',
|
||||
name: 'Item',
|
||||
},
|
||||
'fields@odata.navigationLink': 'sites/site1/lists/list1/items/1/fields',
|
||||
fields: {
|
||||
'@odata.etag': '"625d681e-2ce3-4c2b-a490-7c8404a31427,1"',
|
||||
Title: 'Title 1',
|
||||
choice: 'Choice 1',
|
||||
datetime: '2025-03-24T07:00:00Z',
|
||||
number: 1,
|
||||
bool: true,
|
||||
currency: 1,
|
||||
image:
|
||||
'{"type":"thumbnail","fileName":"file.jpg","nativeFile":{},"fieldName":"Picture","serverUrl":"https://mydomain.sharepoint.com","fieldId":"image","serverRelativeUrl":"/sites/site1/SiteAssets/Lists/list1/file.jpg","id":"image"}',
|
||||
AverageRating: 1,
|
||||
ID: 1,
|
||||
ContentType: 'Item',
|
||||
Modified: '2025-03-25T20:07:23Z',
|
||||
Created: '2025-03-25T20:07:23Z',
|
||||
AuthorLookupId: '1',
|
||||
EditorLookupId: '1',
|
||||
_UIVersionString: '1.0',
|
||||
Attachments: false,
|
||||
Edit: '',
|
||||
LinkTitleNoMenu: 'Title 1',
|
||||
LinkTitle: 'Title 1',
|
||||
ItemChildCount: '0',
|
||||
FolderChildCount: '0',
|
||||
_ComplianceFlags: '',
|
||||
_ComplianceTag: '',
|
||||
_ComplianceTagWrittenTime: '',
|
||||
_ComplianceTagUserId: '',
|
||||
AppAuthorLookupId: '1',
|
||||
AppEditorLookupId: '1',
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,291 @@
|
||||
{
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [0, 0],
|
||||
"id": "37ab6212-d506-4b53-b63e-14b6a2a05907",
|
||||
"name": "When clicking ‘Test workflow’"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"resource": "item",
|
||||
"operation": "create",
|
||||
"site": {
|
||||
"__rl": true,
|
||||
"value": "site1",
|
||||
"mode": "list",
|
||||
"cachedResultName": "site1"
|
||||
},
|
||||
"list": {
|
||||
"__rl": true,
|
||||
"value": "list1",
|
||||
"mode": "list",
|
||||
"cachedResultName": "list1"
|
||||
},
|
||||
"columns": {
|
||||
"mappingMode": "defineBelow",
|
||||
"value": {
|
||||
"bool": true,
|
||||
"Title": "Title 1",
|
||||
"choice": "Choice 1",
|
||||
"datetime": "2025-03-24T00:00:00",
|
||||
"number": 1,
|
||||
"currency": 1,
|
||||
"LikesCount": 1,
|
||||
"RatingCount": 1,
|
||||
"AverageRating": 1,
|
||||
"person": "1",
|
||||
"lookup": "1",
|
||||
"image": "{\"type\":\"thumbnail\",\"fileName\":\"file.jpg\",\"nativeFile\":{},\"fieldName\":\"Picture\",\"serverUrl\":\"https://mydomain.sharepoint.com\",\"fieldId\":\"image\",\"serverRelativeUrl\":\"/sites/site1/SiteAssets/Lists/list1/file.jpg\",\"id\":\"image\"}"
|
||||
},
|
||||
"matchingColumns": [],
|
||||
"schema": [
|
||||
{
|
||||
"id": "Title",
|
||||
"canBeUsedToMatch": true,
|
||||
"defaultMatch": false,
|
||||
"display": true,
|
||||
"displayName": "Title",
|
||||
"readOnly": false,
|
||||
"required": true,
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"id": "choice",
|
||||
"canBeUsedToMatch": false,
|
||||
"defaultMatch": false,
|
||||
"display": true,
|
||||
"displayName": "choice",
|
||||
"readOnly": false,
|
||||
"required": false,
|
||||
"type": "options",
|
||||
"options": [
|
||||
{
|
||||
"name": "Choice 1",
|
||||
"value": "Choice 1"
|
||||
},
|
||||
{
|
||||
"name": "Choice 2",
|
||||
"value": "Choice 2"
|
||||
},
|
||||
{
|
||||
"name": "Choice 3",
|
||||
"value": "Choice 3"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "datetime",
|
||||
"canBeUsedToMatch": false,
|
||||
"defaultMatch": false,
|
||||
"display": true,
|
||||
"displayName": "datetime",
|
||||
"readOnly": false,
|
||||
"required": false,
|
||||
"type": "dateTime"
|
||||
},
|
||||
{
|
||||
"id": "person",
|
||||
"canBeUsedToMatch": false,
|
||||
"defaultMatch": false,
|
||||
"display": true,
|
||||
"displayName": "person",
|
||||
"readOnly": false,
|
||||
"required": false,
|
||||
"type": "string",
|
||||
"removed": false
|
||||
},
|
||||
{
|
||||
"id": "number",
|
||||
"canBeUsedToMatch": false,
|
||||
"defaultMatch": false,
|
||||
"display": true,
|
||||
"displayName": "number",
|
||||
"readOnly": false,
|
||||
"required": false,
|
||||
"type": "number"
|
||||
},
|
||||
{
|
||||
"id": "bool",
|
||||
"canBeUsedToMatch": false,
|
||||
"defaultMatch": false,
|
||||
"display": true,
|
||||
"displayName": "bool",
|
||||
"readOnly": false,
|
||||
"required": false,
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"id": "currency",
|
||||
"canBeUsedToMatch": false,
|
||||
"defaultMatch": false,
|
||||
"display": true,
|
||||
"displayName": "currency",
|
||||
"readOnly": false,
|
||||
"required": false,
|
||||
"type": "number",
|
||||
"removed": false
|
||||
},
|
||||
{
|
||||
"id": "image",
|
||||
"canBeUsedToMatch": false,
|
||||
"defaultMatch": false,
|
||||
"display": true,
|
||||
"displayName": "image",
|
||||
"readOnly": false,
|
||||
"required": false,
|
||||
"type": "object",
|
||||
"removed": false
|
||||
},
|
||||
{
|
||||
"id": "lookup",
|
||||
"canBeUsedToMatch": false,
|
||||
"defaultMatch": false,
|
||||
"display": true,
|
||||
"displayName": "lookup",
|
||||
"readOnly": false,
|
||||
"required": false,
|
||||
"type": "string",
|
||||
"removed": false
|
||||
},
|
||||
{
|
||||
"id": "AverageRating",
|
||||
"canBeUsedToMatch": false,
|
||||
"defaultMatch": false,
|
||||
"display": true,
|
||||
"displayName": "Rating (0-5)",
|
||||
"readOnly": false,
|
||||
"required": false,
|
||||
"type": "number",
|
||||
"removed": false
|
||||
},
|
||||
{
|
||||
"id": "RatingCount",
|
||||
"canBeUsedToMatch": false,
|
||||
"defaultMatch": false,
|
||||
"display": true,
|
||||
"displayName": "Number of Ratings",
|
||||
"readOnly": false,
|
||||
"required": false,
|
||||
"type": "number",
|
||||
"removed": false
|
||||
},
|
||||
{
|
||||
"id": "LikesCount",
|
||||
"canBeUsedToMatch": false,
|
||||
"defaultMatch": false,
|
||||
"display": true,
|
||||
"displayName": "Number of Likes",
|
||||
"readOnly": false,
|
||||
"required": false,
|
||||
"type": "number",
|
||||
"removed": false
|
||||
}
|
||||
],
|
||||
"attemptToConvertTypes": false,
|
||||
"convertFieldsToString": false
|
||||
},
|
||||
"requestOptions": {}
|
||||
},
|
||||
"type": "n8n-nodes-base.microsoftSharePoint",
|
||||
"typeVersion": 1,
|
||||
"position": [220, 0],
|
||||
"id": "f9037af8-4f52-4f9f-b8ae-de860f890792",
|
||||
"name": "Microsoft SharePoint",
|
||||
"credentials": {
|
||||
"microsoftSharePointOAuth2Api": {
|
||||
"id": "cXXnMCWyk397M5qJ",
|
||||
"name": "Microsoft SharePoint account"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"connections": {
|
||||
"When clicking ‘Test workflow’": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Microsoft SharePoint",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"pinData": {
|
||||
"Microsoft SharePoint": [
|
||||
{
|
||||
"json": {
|
||||
"@odata.context": "https://mydomain.sharepoint.com/sites/site1/_api/v2.0/$metadata#listItems/$entity",
|
||||
"@odata.etag": "\"625d681e-2ce3-4c2b-a490-7c8404a31427,1\"",
|
||||
"createdBy": {
|
||||
"user": {
|
||||
"displayName": "John Doe",
|
||||
"email": "john@doe.onmicrosoft.com",
|
||||
"id": "5f7afebb-121d-4664-882b-a09fe6584ce0"
|
||||
}
|
||||
},
|
||||
"createdDateTime": "2025-03-25T20:07:23Z",
|
||||
"eTag": "\"625d681e-2ce3-4c2b-a490-7c8404a31427,1\"",
|
||||
"id": "1",
|
||||
"lastModifiedBy": {
|
||||
"application": {
|
||||
"id": "b9c26603-3c9b-4050-b848-27dfab0a52fa",
|
||||
"displayName": "sharepoint-n8n-test"
|
||||
},
|
||||
"user": {
|
||||
"displayName": "John Doe",
|
||||
"email": "john@doe.onmicrosoft.com",
|
||||
"id": "5f7afebb-121d-4664-882b-a09fe6584ce0"
|
||||
}
|
||||
},
|
||||
"lastModifiedDateTime": "2025-03-25T20:07:23Z",
|
||||
"parentReference": {
|
||||
"id": "0ead9135-9622-4b6d-b319-6b8810a6dc60",
|
||||
"listId": "list1",
|
||||
"siteId": "site1"
|
||||
},
|
||||
"webUrl": "https://mydomain.sharepoint.com/sites/n8ntest10/Lists/test/41_.000",
|
||||
"contentType": {
|
||||
"id": "0x0100362657F7588C5C438072A77E0EF184F4000272C0D1046D984B8097B3C00D199EDE",
|
||||
"name": "Item"
|
||||
},
|
||||
"fields@odata.navigationLink": "sites/site1/lists/list1/items/1/fields",
|
||||
"fields": {
|
||||
"@odata.etag": "\"625d681e-2ce3-4c2b-a490-7c8404a31427,1\"",
|
||||
"Title": "Title 1",
|
||||
"choice": "Choice 1",
|
||||
"datetime": "2025-03-24T07:00:00Z",
|
||||
"number": 1,
|
||||
"bool": true,
|
||||
"currency": 1,
|
||||
"image": "{\"type\":\"thumbnail\",\"fileName\":\"file.jpg\",\"nativeFile\":{},\"fieldName\":\"Picture\",\"serverUrl\":\"https://mydomain.sharepoint.com\",\"fieldId\":\"image\",\"serverRelativeUrl\":\"/sites/site1/SiteAssets/Lists/list1/file.jpg\",\"id\":\"image\"}",
|
||||
"AverageRating": 1,
|
||||
"ID": 1,
|
||||
"ContentType": "Item",
|
||||
"Modified": "2025-03-25T20:07:23Z",
|
||||
"Created": "2025-03-25T20:07:23Z",
|
||||
"AuthorLookupId": "1",
|
||||
"EditorLookupId": "1",
|
||||
"_UIVersionString": "1.0",
|
||||
"Attachments": false,
|
||||
"Edit": "",
|
||||
"LinkTitleNoMenu": "Title 1",
|
||||
"LinkTitle": "Title 1",
|
||||
"ItemChildCount": "0",
|
||||
"FolderChildCount": "0",
|
||||
"_ComplianceFlags": "",
|
||||
"_ComplianceTag": "",
|
||||
"_ComplianceTagWrittenTime": "",
|
||||
"_ComplianceTagUserId": "",
|
||||
"AppAuthorLookupId": "1",
|
||||
"AppEditorLookupId": "1"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import { NodeTestHarness } from '@nodes-testing/node-test-harness';
|
||||
|
||||
import { credentials } from '../credentials';
|
||||
|
||||
describe('Microsoft SharePoint Node', () => {
|
||||
const { baseUrl } = credentials.microsoftSharePointOAuth2Api;
|
||||
new NodeTestHarness().setupTests({
|
||||
credentials,
|
||||
workflowFiles: ['delete.workflow.json'],
|
||||
nock: {
|
||||
baseUrl,
|
||||
mocks: [
|
||||
{
|
||||
method: 'delete',
|
||||
path: '/sites/site1/lists/list1/items/item1',
|
||||
statusCode: 204,
|
||||
responseBody: {},
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,70 @@
|
||||
{
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [0, 0],
|
||||
"id": "d8d29d0a-bb31-4094-a252-8008932f5425",
|
||||
"name": "When clicking ‘Test workflow’"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"resource": "item",
|
||||
"operation": "delete",
|
||||
"site": {
|
||||
"__rl": true,
|
||||
"value": "site1",
|
||||
"mode": "list",
|
||||
"cachedResultName": "site1"
|
||||
},
|
||||
"list": {
|
||||
"__rl": true,
|
||||
"value": "list1",
|
||||
"mode": "list",
|
||||
"cachedResultName": "list1"
|
||||
},
|
||||
"item": {
|
||||
"__rl": true,
|
||||
"value": "item1",
|
||||
"mode": "list",
|
||||
"cachedResultName": "item1"
|
||||
},
|
||||
"requestOptions": {}
|
||||
},
|
||||
"type": "n8n-nodes-base.microsoftSharePoint",
|
||||
"typeVersion": 1,
|
||||
"position": [200, 0],
|
||||
"id": "0e19be10-9d94-4654-89e9-432daa8102cb",
|
||||
"name": "Microsoft SharePoint",
|
||||
"credentials": {
|
||||
"microsoftSharePointOAuth2Api": {
|
||||
"id": "cXXnMCWyk397M5qJ",
|
||||
"name": "Microsoft SharePoint account"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"connections": {
|
||||
"When clicking ‘Test workflow’": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Microsoft SharePoint",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"pinData": {
|
||||
"Microsoft SharePoint": [
|
||||
{
|
||||
"json": {
|
||||
"deleted": true
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
import { NodeTestHarness } from '@nodes-testing/node-test-harness';
|
||||
|
||||
import { credentials } from '../credentials';
|
||||
|
||||
describe('Microsoft SharePoint Node', () => {
|
||||
const { baseUrl } = credentials.microsoftSharePointOAuth2Api;
|
||||
new NodeTestHarness().setupTests({
|
||||
credentials,
|
||||
workflowFiles: ['get.workflow.json'],
|
||||
nock: {
|
||||
baseUrl,
|
||||
mocks: [
|
||||
{
|
||||
method: 'get',
|
||||
path: '/sites/site1/lists/list1/items/item1?%24select=id%2CcreatedDateTime%2ClastModifiedDateTime%2CwebUrl&%24expand=fields%28select%3DTitle%29',
|
||||
statusCode: 200,
|
||||
responseBody: {
|
||||
'@odata.context':
|
||||
'https://mydomain.sharepoint.com/sites/site1/_api/v2.0/$metadata#listItems/$entity',
|
||||
'@odata.etag': '"07bfcdd5-450d-48ce-8dc3-04f7f59edc5f,1"',
|
||||
createdBy: {
|
||||
user: {
|
||||
displayName: 'John Doe',
|
||||
email: 'john@doe.onmicrosoft.com',
|
||||
id: '5f7afebb-121d-4664-882b-a09fe6584ce0',
|
||||
},
|
||||
},
|
||||
createdDateTime: '2025-03-12T22:18:18Z',
|
||||
eTag: '"07bfcdd5-450d-48ce-8dc3-04f7f59edc5f,1"',
|
||||
id: 'item1',
|
||||
lastModifiedBy: {
|
||||
application: {
|
||||
id: 'b9c26603-3c9b-4050-b848-27dfab0a52fa',
|
||||
displayName: 'sharepoint-n8n-test',
|
||||
},
|
||||
user: {
|
||||
displayName: 'John Doe',
|
||||
email: 'john@doe.onmicrosoft.com',
|
||||
id: '5f7afebb-121d-4664-882b-a09fe6584ce0',
|
||||
},
|
||||
},
|
||||
lastModifiedDateTime: '2025-03-12T22:18:18Z',
|
||||
parentReference: {
|
||||
id: '84070a73-ea24-463c-8eb2-0e9afa11c63f',
|
||||
listId: 'list1',
|
||||
siteId: 'site1',
|
||||
},
|
||||
webUrl: 'https://mydomain.sharepoint.com/sites/site1/Lists/name%20list/1_.000',
|
||||
contentType: {
|
||||
id: '0x010010D603DC4CF2DF4BB8A2D75DCB4BB1B30037A4993FB4DEB0439C3DC6DEC95A9DF8',
|
||||
name: 'Item',
|
||||
},
|
||||
'fields@odata.navigationLink': 'sites/site1/lists/list1/items/item1/fields',
|
||||
fields: {
|
||||
'@odata.etag': '"07bfcdd5-450d-48ce-8dc3-04f7f59edc5f,1"',
|
||||
Title: 'Item 1',
|
||||
ID: 'item1',
|
||||
ContentType: 'Item',
|
||||
Modified: '2025-03-12T22:18:18Z',
|
||||
Created: '2025-03-12T22:18:18Z',
|
||||
AuthorLookupId: '7',
|
||||
EditorLookupId: '7',
|
||||
_UIVersionString: '1.0',
|
||||
Attachments: false,
|
||||
Edit: '',
|
||||
LinkTitleNoMenu: 'Item 1',
|
||||
LinkTitle: 'Item 1',
|
||||
ItemChildCount: '0',
|
||||
FolderChildCount: '0',
|
||||
_ComplianceFlags: '',
|
||||
_ComplianceTag: '',
|
||||
_ComplianceTagWrittenTime: '',
|
||||
_ComplianceTagUserId: '',
|
||||
AppAuthorLookupId: '5',
|
||||
AppEditorLookupId: '5',
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,123 @@
|
||||
{
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [0, 0],
|
||||
"id": "d8d29d0a-bb31-4094-a252-8008932f5425",
|
||||
"name": "When clicking ‘Test workflow’"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"resource": "item",
|
||||
"operation": "get",
|
||||
"site": {
|
||||
"__rl": true,
|
||||
"value": "site1",
|
||||
"mode": "list",
|
||||
"cachedResultName": "site1"
|
||||
},
|
||||
"list": {
|
||||
"__rl": true,
|
||||
"value": "list1",
|
||||
"mode": "list",
|
||||
"cachedResultName": "list1"
|
||||
},
|
||||
"item": {
|
||||
"__rl": true,
|
||||
"value": "item1",
|
||||
"mode": "list",
|
||||
"cachedResultName": "item1"
|
||||
},
|
||||
"requestOptions": {}
|
||||
},
|
||||
"type": "n8n-nodes-base.microsoftSharePoint",
|
||||
"typeVersion": 1,
|
||||
"position": [200, 0],
|
||||
"id": "0e19be10-9d94-4654-89e9-432daa8102cb",
|
||||
"name": "Microsoft SharePoint",
|
||||
"credentials": {
|
||||
"microsoftSharePointOAuth2Api": {
|
||||
"id": "cXXnMCWyk397M5qJ",
|
||||
"name": "Microsoft SharePoint account"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"connections": {
|
||||
"When clicking ‘Test workflow’": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Microsoft SharePoint",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"pinData": {
|
||||
"Microsoft SharePoint": [
|
||||
{
|
||||
"json": {
|
||||
"createdBy": {
|
||||
"user": {
|
||||
"displayName": "John Doe",
|
||||
"email": "john@doe.onmicrosoft.com",
|
||||
"id": "5f7afebb-121d-4664-882b-a09fe6584ce0"
|
||||
}
|
||||
},
|
||||
"createdDateTime": "2025-03-12T22:18:18Z",
|
||||
"eTag": "\"07bfcdd5-450d-48ce-8dc3-04f7f59edc5f,1\"",
|
||||
"id": "item1",
|
||||
"lastModifiedBy": {
|
||||
"application": {
|
||||
"id": "b9c26603-3c9b-4050-b848-27dfab0a52fa",
|
||||
"displayName": "sharepoint-n8n-test"
|
||||
},
|
||||
"user": {
|
||||
"displayName": "John Doe",
|
||||
"email": "john@doe.onmicrosoft.com",
|
||||
"id": "5f7afebb-121d-4664-882b-a09fe6584ce0"
|
||||
}
|
||||
},
|
||||
"lastModifiedDateTime": "2025-03-12T22:18:18Z",
|
||||
"parentReference": {
|
||||
"id": "84070a73-ea24-463c-8eb2-0e9afa11c63f",
|
||||
"listId": "list1",
|
||||
"siteId": "site1"
|
||||
},
|
||||
"webUrl": "https://mydomain.sharepoint.com/sites/site1/Lists/name%20list/1_.000",
|
||||
"contentType": {
|
||||
"id": "0x010010D603DC4CF2DF4BB8A2D75DCB4BB1B30037A4993FB4DEB0439C3DC6DEC95A9DF8",
|
||||
"name": "Item"
|
||||
},
|
||||
"fields": {
|
||||
"Title": "Item 1",
|
||||
"ID": "item1",
|
||||
"ContentType": "Item",
|
||||
"Modified": "2025-03-12T22:18:18Z",
|
||||
"Created": "2025-03-12T22:18:18Z",
|
||||
"AuthorLookupId": "7",
|
||||
"EditorLookupId": "7",
|
||||
"_UIVersionString": "1.0",
|
||||
"Attachments": false,
|
||||
"Edit": "",
|
||||
"LinkTitleNoMenu": "Item 1",
|
||||
"LinkTitle": "Item 1",
|
||||
"ItemChildCount": "0",
|
||||
"FolderChildCount": "0",
|
||||
"_ComplianceFlags": "",
|
||||
"_ComplianceTag": "",
|
||||
"_ComplianceTagWrittenTime": "",
|
||||
"_ComplianceTagUserId": "",
|
||||
"AppAuthorLookupId": "5",
|
||||
"AppEditorLookupId": "5"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
import { NodeTestHarness } from '@nodes-testing/node-test-harness';
|
||||
|
||||
import { credentials } from '../credentials';
|
||||
|
||||
describe('Microsoft SharePoint Node', () => {
|
||||
const { baseUrl } = credentials.microsoftSharePointOAuth2Api;
|
||||
new NodeTestHarness().setupTests({
|
||||
credentials,
|
||||
workflowFiles: ['getAll.workflow.json'],
|
||||
nock: {
|
||||
baseUrl,
|
||||
mocks: [
|
||||
{
|
||||
method: 'get',
|
||||
path: '/sites/site1/lists/list1/items?%24select%5B0%5D=contentType&%24select%5B1%5D=createdDateTime&%24select%5B2%5D=createdBy&%24select%5B3%5D=fields&%24select%5B4%5D=id&%24select%5B5%5D=lastModifiedDateTime&%24select%5B6%5D=lastModifiedBy&%24select%5B7%5D=parentReference&%24select%5B8%5D=webUrl',
|
||||
statusCode: 200,
|
||||
responseBody: {
|
||||
value: [
|
||||
{
|
||||
'@odata.context':
|
||||
'https://mydomain.sharepoint.com/sites/site1/_api/v2.0/$metadata#listItems/$entity',
|
||||
'@odata.etag': '"07bfcdd5-450d-48ce-8dc3-04f7f59edc5f,1"',
|
||||
createdBy: {
|
||||
user: {
|
||||
displayName: 'John Doe',
|
||||
email: 'john@doe.onmicrosoft.com',
|
||||
id: '5f7afebb-121d-4664-882b-a09fe6584ce0',
|
||||
},
|
||||
},
|
||||
createdDateTime: '2025-03-12T22:18:18Z',
|
||||
eTag: '"07bfcdd5-450d-48ce-8dc3-04f7f59edc5f,1"',
|
||||
id: 'item1',
|
||||
lastModifiedBy: {
|
||||
application: {
|
||||
id: 'b9c26603-3c9b-4050-b848-27dfab0a52fa',
|
||||
displayName: 'sharepoint-n8n-test',
|
||||
},
|
||||
user: {
|
||||
displayName: 'John Doe',
|
||||
email: 'john@doe.onmicrosoft.com',
|
||||
id: '5f7afebb-121d-4664-882b-a09fe6584ce0',
|
||||
},
|
||||
},
|
||||
lastModifiedDateTime: '2025-03-12T22:18:18Z',
|
||||
parentReference: {
|
||||
id: '84070a73-ea24-463c-8eb2-0e9afa11c63f',
|
||||
listId: 'list1',
|
||||
siteId: 'site1',
|
||||
},
|
||||
webUrl: 'https://mydomain.sharepoint.com/sites/site1/Lists/name%20list/1_.000',
|
||||
contentType: {
|
||||
id: '0x010010D603DC4CF2DF4BB8A2D75DCB4BB1B30037A4993FB4DEB0439C3DC6DEC95A9DF8',
|
||||
name: 'Item',
|
||||
},
|
||||
'fields@odata.navigationLink': 'sites/site1/lists/list1/items/item1/fields',
|
||||
fields: {
|
||||
'@odata.etag': '"07bfcdd5-450d-48ce-8dc3-04f7f59edc5f,1"',
|
||||
Title: 'Item 1',
|
||||
ID: 'item1',
|
||||
ContentType: 'Item',
|
||||
Modified: '2025-03-12T22:18:18Z',
|
||||
Created: '2025-03-12T22:18:18Z',
|
||||
AuthorLookupId: '7',
|
||||
EditorLookupId: '7',
|
||||
_UIVersionString: '1.0',
|
||||
Attachments: false,
|
||||
Edit: '',
|
||||
LinkTitleNoMenu: 'Item 1',
|
||||
LinkTitle: 'Item 1',
|
||||
ItemChildCount: '0',
|
||||
FolderChildCount: '0',
|
||||
_ComplianceFlags: '',
|
||||
_ComplianceTag: '',
|
||||
_ComplianceTagWrittenTime: '',
|
||||
_ComplianceTagUserId: '',
|
||||
AppAuthorLookupId: '5',
|
||||
AppEditorLookupId: '5',
|
||||
},
|
||||
},
|
||||
],
|
||||
'@odata.nextLink':
|
||||
'https://mydomain.sharepoint.com/_api/v2.0/sites(%27site1%27)/lists(%27list1%27)/items?%24skiptoken=UGFnZWQ9VFJVRSZwX0lEPTE&%24top=1&%24expand=fields&%24select%5b0%5d=contentType&%24select%5b1%5d=createdDateTime&%24select%5b2%5d=createdBy&%24select%5b3%5d=fields&%24select%5b4%5d=id&%24select%5b5%5d=lastModifiedDateTime&%24select%5b6%5d=lastModifiedBy&%24select%5b7%5d=parentReference&%24select%5b8%5d=webUrl',
|
||||
},
|
||||
},
|
||||
{
|
||||
method: 'get',
|
||||
path: '/sites(%27site1%27)/lists(%27list1%27)/items?%24skiptoken=UGFnZWQ9VFJVRSZwX0lEPTE&%24top=1&%24expand=fields&%24select%5b0%5d=contentType&%24select%5b1%5d=createdDateTime&%24select%5b2%5d=createdBy&%24select%5b3%5d=fields&%24select%5b4%5d=id&%24select%5b5%5d=lastModifiedDateTime&%24select%5b6%5d=lastModifiedBy&%24select%5b7%5d=parentReference&%24select%5b8%5d=webUrl',
|
||||
statusCode: 200,
|
||||
responseBody: {
|
||||
value: [
|
||||
{
|
||||
'@odata.context':
|
||||
'https://mydomain.sharepoint.com/sites/site1/_api/v2.0/$metadata#listItems/$entity',
|
||||
'@odata.etag': '"07bfcdd5-450d-48ce-8dc3-04f7f59edc5f,1"',
|
||||
createdBy: {
|
||||
user: {
|
||||
displayName: 'John Doe',
|
||||
email: 'john@doe.onmicrosoft.com',
|
||||
id: '5f7afebb-121d-4664-882b-a09fe6584ce0',
|
||||
},
|
||||
},
|
||||
createdDateTime: '2025-03-12T22:18:18Z',
|
||||
eTag: '"07bfcdd5-450d-48ce-8dc3-04f7f59edc5f,1"',
|
||||
id: 'item2',
|
||||
lastModifiedBy: {
|
||||
application: {
|
||||
id: 'b9c26603-3c9b-4050-b848-27dfab0a52fa',
|
||||
displayName: 'sharepoint-n8n-test',
|
||||
},
|
||||
user: {
|
||||
displayName: 'John Doe',
|
||||
email: 'john@doe.onmicrosoft.com',
|
||||
id: '5f7afebb-121d-4664-882b-a09fe6584ce0',
|
||||
},
|
||||
},
|
||||
lastModifiedDateTime: '2025-03-12T22:18:18Z',
|
||||
parentReference: {
|
||||
id: '84070a73-ea24-463c-8eb2-0e9afa11c63f',
|
||||
listId: 'list1',
|
||||
siteId: 'site1',
|
||||
},
|
||||
webUrl: 'https://mydomain.sharepoint.com/sites/site1/Lists/name%20list/1_.000',
|
||||
contentType: {
|
||||
id: '0x010010D603DC4CF2DF4BB8A2D75DCB4BB1B30037A4993FB4DEB0439C3DC6DEC95A9DF8',
|
||||
name: 'Item',
|
||||
},
|
||||
'fields@odata.navigationLink': 'sites/site1/lists/list1/items/item1/fields',
|
||||
fields: {
|
||||
'@odata.etag': '"07bfcdd5-450d-48ce-8dc3-04f7f59edc5f,1"',
|
||||
Title: 'Item 2',
|
||||
ID: 'item2',
|
||||
ContentType: 'Item',
|
||||
Modified: '2025-03-12T22:18:18Z',
|
||||
Created: '2025-03-12T22:18:18Z',
|
||||
AuthorLookupId: '7',
|
||||
EditorLookupId: '7',
|
||||
_UIVersionString: '1.0',
|
||||
Attachments: false,
|
||||
Edit: '',
|
||||
LinkTitleNoMenu: 'Item 2',
|
||||
LinkTitle: 'Item 2',
|
||||
ItemChildCount: '0',
|
||||
FolderChildCount: '0',
|
||||
_ComplianceFlags: '',
|
||||
_ComplianceTag: '',
|
||||
_ComplianceTagWrittenTime: '',
|
||||
_ComplianceTagUserId: '',
|
||||
AppAuthorLookupId: '5',
|
||||
AppEditorLookupId: '5',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,198 @@
|
||||
{
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [0, 0],
|
||||
"id": "d8d29d0a-bb31-4094-a252-8008932f5425",
|
||||
"name": "When clicking ‘Test workflow’"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"resource": "item",
|
||||
"site": {
|
||||
"__rl": true,
|
||||
"value": "site1",
|
||||
"mode": "list",
|
||||
"cachedResultName": "site1"
|
||||
},
|
||||
"list": {
|
||||
"__rl": true,
|
||||
"value": "list1",
|
||||
"mode": "list",
|
||||
"cachedResultName": "list1"
|
||||
},
|
||||
"filter": "fields/Title eq 'item1'",
|
||||
"returnAll": true,
|
||||
"options": {
|
||||
"fields": [
|
||||
"contentType",
|
||||
"createdDateTime",
|
||||
"createdBy",
|
||||
"fields",
|
||||
"id",
|
||||
"lastModifiedDateTime",
|
||||
"lastModifiedBy",
|
||||
"parentReference",
|
||||
"webUrl"
|
||||
]
|
||||
},
|
||||
"simplify": false,
|
||||
"requestOptions": {}
|
||||
},
|
||||
"type": "n8n-nodes-base.microsoftSharePoint",
|
||||
"typeVersion": 1,
|
||||
"position": [200, 0],
|
||||
"id": "0e19be10-9d94-4654-89e9-432daa8102cb",
|
||||
"name": "Microsoft SharePoint",
|
||||
"credentials": {
|
||||
"microsoftSharePointOAuth2Api": {
|
||||
"id": "cXXnMCWyk397M5qJ",
|
||||
"name": "Microsoft SharePoint account"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"connections": {
|
||||
"When clicking ‘Test workflow’": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Microsoft SharePoint",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"pinData": {
|
||||
"Microsoft SharePoint": [
|
||||
{
|
||||
"json": {
|
||||
"@odata.context": "https://mydomain.sharepoint.com/sites/site1/_api/v2.0/$metadata#listItems/$entity",
|
||||
"@odata.etag": "\"07bfcdd5-450d-48ce-8dc3-04f7f59edc5f,1\"",
|
||||
"createdBy": {
|
||||
"user": {
|
||||
"displayName": "John Doe",
|
||||
"email": "john@doe.onmicrosoft.com",
|
||||
"id": "5f7afebb-121d-4664-882b-a09fe6584ce0"
|
||||
}
|
||||
},
|
||||
"createdDateTime": "2025-03-12T22:18:18Z",
|
||||
"eTag": "\"07bfcdd5-450d-48ce-8dc3-04f7f59edc5f,1\"",
|
||||
"id": "item1",
|
||||
"lastModifiedBy": {
|
||||
"application": {
|
||||
"id": "b9c26603-3c9b-4050-b848-27dfab0a52fa",
|
||||
"displayName": "sharepoint-n8n-test"
|
||||
},
|
||||
"user": {
|
||||
"displayName": "John Doe",
|
||||
"email": "john@doe.onmicrosoft.com",
|
||||
"id": "5f7afebb-121d-4664-882b-a09fe6584ce0"
|
||||
}
|
||||
},
|
||||
"lastModifiedDateTime": "2025-03-12T22:18:18Z",
|
||||
"parentReference": {
|
||||
"id": "84070a73-ea24-463c-8eb2-0e9afa11c63f",
|
||||
"listId": "list1",
|
||||
"siteId": "site1"
|
||||
},
|
||||
"webUrl": "https://mydomain.sharepoint.com/sites/site1/Lists/name%20list/1_.000",
|
||||
"contentType": {
|
||||
"id": "0x010010D603DC4CF2DF4BB8A2D75DCB4BB1B30037A4993FB4DEB0439C3DC6DEC95A9DF8",
|
||||
"name": "Item"
|
||||
},
|
||||
"fields@odata.navigationLink": "sites/site1/lists/list1/items/item1/fields",
|
||||
"fields": {
|
||||
"@odata.etag": "\"07bfcdd5-450d-48ce-8dc3-04f7f59edc5f,1\"",
|
||||
"Title": "Item 1",
|
||||
"ID": "item1",
|
||||
"ContentType": "Item",
|
||||
"Modified": "2025-03-12T22:18:18Z",
|
||||
"Created": "2025-03-12T22:18:18Z",
|
||||
"AuthorLookupId": "7",
|
||||
"EditorLookupId": "7",
|
||||
"_UIVersionString": "1.0",
|
||||
"Attachments": false,
|
||||
"Edit": "",
|
||||
"LinkTitleNoMenu": "Item 1",
|
||||
"LinkTitle": "Item 1",
|
||||
"ItemChildCount": "0",
|
||||
"FolderChildCount": "0",
|
||||
"_ComplianceFlags": "",
|
||||
"_ComplianceTag": "",
|
||||
"_ComplianceTagWrittenTime": "",
|
||||
"_ComplianceTagUserId": "",
|
||||
"AppAuthorLookupId": "5",
|
||||
"AppEditorLookupId": "5"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"json": {
|
||||
"@odata.context": "https://mydomain.sharepoint.com/sites/site1/_api/v2.0/$metadata#listItems/$entity",
|
||||
"@odata.etag": "\"07bfcdd5-450d-48ce-8dc3-04f7f59edc5f,1\"",
|
||||
"createdBy": {
|
||||
"user": {
|
||||
"displayName": "John Doe",
|
||||
"email": "john@doe.onmicrosoft.com",
|
||||
"id": "5f7afebb-121d-4664-882b-a09fe6584ce0"
|
||||
}
|
||||
},
|
||||
"createdDateTime": "2025-03-12T22:18:18Z",
|
||||
"eTag": "\"07bfcdd5-450d-48ce-8dc3-04f7f59edc5f,1\"",
|
||||
"id": "item2",
|
||||
"lastModifiedBy": {
|
||||
"application": {
|
||||
"id": "b9c26603-3c9b-4050-b848-27dfab0a52fa",
|
||||
"displayName": "sharepoint-n8n-test"
|
||||
},
|
||||
"user": {
|
||||
"displayName": "John Doe",
|
||||
"email": "john@doe.onmicrosoft.com",
|
||||
"id": "5f7afebb-121d-4664-882b-a09fe6584ce0"
|
||||
}
|
||||
},
|
||||
"lastModifiedDateTime": "2025-03-12T22:18:18Z",
|
||||
"parentReference": {
|
||||
"id": "84070a73-ea24-463c-8eb2-0e9afa11c63f",
|
||||
"listId": "list1",
|
||||
"siteId": "site1"
|
||||
},
|
||||
"webUrl": "https://mydomain.sharepoint.com/sites/site1/Lists/name%20list/1_.000",
|
||||
"contentType": {
|
||||
"id": "0x010010D603DC4CF2DF4BB8A2D75DCB4BB1B30037A4993FB4DEB0439C3DC6DEC95A9DF8",
|
||||
"name": "Item"
|
||||
},
|
||||
"fields@odata.navigationLink": "sites/site1/lists/list1/items/item1/fields",
|
||||
"fields": {
|
||||
"@odata.etag": "\"07bfcdd5-450d-48ce-8dc3-04f7f59edc5f,1\"",
|
||||
"Title": "Item 2",
|
||||
"ID": "item2",
|
||||
"ContentType": "Item",
|
||||
"Modified": "2025-03-12T22:18:18Z",
|
||||
"Created": "2025-03-12T22:18:18Z",
|
||||
"AuthorLookupId": "7",
|
||||
"EditorLookupId": "7",
|
||||
"_UIVersionString": "1.0",
|
||||
"Attachments": false,
|
||||
"Edit": "",
|
||||
"LinkTitleNoMenu": "Item 2",
|
||||
"LinkTitle": "Item 2",
|
||||
"ItemChildCount": "0",
|
||||
"FolderChildCount": "0",
|
||||
"_ComplianceFlags": "",
|
||||
"_ComplianceTag": "",
|
||||
"_ComplianceTagWrittenTime": "",
|
||||
"_ComplianceTagUserId": "",
|
||||
"AppAuthorLookupId": "5",
|
||||
"AppEditorLookupId": "5"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
import { NodeTestHarness } from '@nodes-testing/node-test-harness';
|
||||
|
||||
import { credentials } from '../credentials';
|
||||
|
||||
describe('Microsoft SharePoint Node', () => {
|
||||
const { baseUrl } = credentials.microsoftSharePointOAuth2Api;
|
||||
new NodeTestHarness().setupTests({
|
||||
credentials,
|
||||
workflowFiles: ['getAllLimitSimplify.workflow.json'],
|
||||
nock: {
|
||||
baseUrl,
|
||||
mocks: [
|
||||
{
|
||||
method: 'get',
|
||||
path: '/sites/site1/lists/list1/items?%24top=2&%24select=id%2CcreatedDateTime%2ClastModifiedDateTime%2CwebUrl&%24expand=fields%28select%3DTitle%29',
|
||||
statusCode: 200,
|
||||
responseBody: {
|
||||
value: [
|
||||
{
|
||||
'@odata.context':
|
||||
'https://mydomain.sharepoint.com/sites/site1/_api/v2.0/$metadata#listItems/$entity',
|
||||
'@odata.etag': '"07bfcdd5-450d-48ce-8dc3-04f7f59edc5f,1"',
|
||||
createdDateTime: '2025-03-12T22:18:18Z',
|
||||
id: 'item1',
|
||||
lastModifiedDateTime: '2025-03-12T22:18:18Z',
|
||||
webUrl: 'https://mydomain.sharepoint.com/sites/site1/Lists/name%20list/1_.000',
|
||||
'fields@odata.navigationLink': 'sites/site1/lists/list1/items/item1/fields',
|
||||
fields: {
|
||||
'@odata.etag': '"07bfcdd5-450d-48ce-8dc3-04f7f59edc5f,1"',
|
||||
Title: 'Item 1',
|
||||
},
|
||||
},
|
||||
{
|
||||
'@odata.context':
|
||||
'https://mydomain.sharepoint.com/sites/site1/_api/v2.0/$metadata#listItems/$entity',
|
||||
'@odata.etag': '"07bfcdd5-450d-48ce-8dc3-04f7f59edc5f,1"',
|
||||
createdDateTime: '2025-03-12T22:18:18Z',
|
||||
id: 'item2',
|
||||
lastModifiedDateTime: '2025-03-12T22:18:18Z',
|
||||
webUrl: 'https://mydomain.sharepoint.com/sites/site1/Lists/name%20list/1_.000',
|
||||
'fields@odata.navigationLink': 'sites/site1/lists/list1/items/item1/fields',
|
||||
fields: {
|
||||
'@odata.etag': '"07bfcdd5-450d-48ce-8dc3-04f7f59edc5f,1"',
|
||||
Title: 'Item 2',
|
||||
},
|
||||
},
|
||||
],
|
||||
'@odata.nextLink':
|
||||
'https://mydomain.sharepoint.com/_api/v2.0/sites(%27site1%27)/lists(%27list1%27)/items?%24skiptoken=UGFnZWQ9VFJVRSZwX0lEPTE&%24top=1&%24expand=fields&%24select%5b0%5d=contentType&%24select%5b1%5d=createdDateTime&%24select%5b2%5d=createdBy&%24select%5b3%5d=fields&%24select%5b4%5d=id&%24select%5b5%5d=lastModifiedDateTime&%24select%5b6%5d=lastModifiedBy&%24select%5b7%5d=parentReference&%24select%5b8%5d=webUrl',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
});
|
||||
+82
@@ -0,0 +1,82 @@
|
||||
{
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [0, 0],
|
||||
"id": "d8d29d0a-bb31-4094-a252-8008932f5425",
|
||||
"name": "When clicking ‘Test workflow’"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"resource": "item",
|
||||
"site": {
|
||||
"__rl": true,
|
||||
"value": "site1",
|
||||
"mode": "list",
|
||||
"cachedResultName": "site1"
|
||||
},
|
||||
"list": {
|
||||
"__rl": true,
|
||||
"value": "list1",
|
||||
"mode": "list",
|
||||
"cachedResultName": "list1"
|
||||
},
|
||||
"limit": 2,
|
||||
"options": {},
|
||||
"requestOptions": {}
|
||||
},
|
||||
"type": "n8n-nodes-base.microsoftSharePoint",
|
||||
"typeVersion": 1,
|
||||
"position": [200, 0],
|
||||
"id": "0e19be10-9d94-4654-89e9-432daa8102cb",
|
||||
"name": "Microsoft SharePoint",
|
||||
"credentials": {
|
||||
"microsoftSharePointOAuth2Api": {
|
||||
"id": "cXXnMCWyk397M5qJ",
|
||||
"name": "Microsoft SharePoint account"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"connections": {
|
||||
"When clicking ‘Test workflow’": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Microsoft SharePoint",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"pinData": {
|
||||
"Microsoft SharePoint": [
|
||||
{
|
||||
"json": {
|
||||
"createdDateTime": "2025-03-12T22:18:18Z",
|
||||
"id": "item1",
|
||||
"lastModifiedDateTime": "2025-03-12T22:18:18Z",
|
||||
"webUrl": "https://mydomain.sharepoint.com/sites/site1/Lists/name%20list/1_.000",
|
||||
"fields": {
|
||||
"Title": "Item 1"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"json": {
|
||||
"createdDateTime": "2025-03-12T22:18:18Z",
|
||||
"id": "item2",
|
||||
"lastModifiedDateTime": "2025-03-12T22:18:18Z",
|
||||
"webUrl": "https://mydomain.sharepoint.com/sites/site1/Lists/name%20list/1_.000",
|
||||
"fields": {
|
||||
"Title": "Item 2"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
import { CredentialsHelper } from '@nodes-testing/credentials-helper';
|
||||
import { NodeTestHarness } from '@nodes-testing/node-test-harness';
|
||||
import nock from 'nock';
|
||||
|
||||
import { credentials } from '../credentials';
|
||||
|
||||
describe('Microsoft SharePoint Node - Token Refresh', () => {
|
||||
const { baseUrl } = credentials.microsoftSharePointOAuth2Api;
|
||||
const tokenRefreshUrl = 'https://login.microsoftonline.com';
|
||||
const itemPath =
|
||||
'/sites/site1/lists/list1/items/item1?%24select=id%2CcreatedDateTime%2ClastModifiedDateTime%2CwebUrl&%24expand=fields%28select%3DTitle%29';
|
||||
|
||||
let updateCredentialsSpy: jest.SpyInstance;
|
||||
|
||||
beforeAll(() => {
|
||||
// Mock the credential helper to return oAuth2Api as parent type
|
||||
jest.spyOn(CredentialsHelper.prototype, 'getParentTypes').mockReturnValue(['oAuth2Api']);
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
// Spy on the updateCredentialsOauthTokenData to verify token refresh
|
||||
updateCredentialsSpy = jest
|
||||
.spyOn(CredentialsHelper.prototype, 'updateCredentialsOauthTokenData')
|
||||
.mockResolvedValue();
|
||||
|
||||
// Set up mocks for token refresh scenario
|
||||
// First request: Return 401 Unauthorized (expired token)
|
||||
nock(baseUrl)
|
||||
.get(itemPath)
|
||||
.matchHeader('Authorization', 'Bearer ACCESSTOKEN')
|
||||
.reply(401, {
|
||||
error: {
|
||||
code: 'InvalidAuthenticationToken',
|
||||
message: 'Access token has expired.',
|
||||
},
|
||||
});
|
||||
|
||||
// Token refresh request
|
||||
nock(tokenRefreshUrl).post('/common/oauth2/v2.0/token').reply(200, {
|
||||
token_type: 'Bearer',
|
||||
scope:
|
||||
'https://mydomain.sharepoint.com/Sites.Manage.All https://mydomain.sharepoint.com/.default',
|
||||
expires_in: 3599,
|
||||
ext_expires_in: 3599,
|
||||
access_token: 'NEWACCESSTOKEN',
|
||||
refresh_token: 'NEWREFRESHTOKEN',
|
||||
});
|
||||
|
||||
// Retry request with new token: Return success
|
||||
nock(baseUrl)
|
||||
.get(itemPath)
|
||||
.matchHeader('Authorization', 'Bearer NEWACCESSTOKEN')
|
||||
.reply(200, {
|
||||
'@odata.context':
|
||||
'https://mydomain.sharepoint.com/sites/site1/_api/v2.0/$metadata#listItems/$entity',
|
||||
'@odata.etag': '"07bfcdd5-450d-48ce-8dc3-04f7f59edc5f,1"',
|
||||
id: 'item1',
|
||||
createdDateTime: '2025-03-12T22:18:18Z',
|
||||
lastModifiedDateTime: '2025-03-12T22:18:18Z',
|
||||
webUrl: 'https://mydomain.sharepoint.com/sites/site1/Lists/name%20list/1_.000',
|
||||
'fields@odata.navigationLink': 'sites/site1/lists/list1/items/item1/fields',
|
||||
fields: {
|
||||
'@odata.etag': '"07bfcdd5-450d-48ce-8dc3-04f7f59edc5f,1"',
|
||||
Title: 'Item 1',
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
nock.cleanAll();
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
jest.restoreAllMocks();
|
||||
});
|
||||
|
||||
// Use the harness's setupTests to automatically run the workflow
|
||||
new NodeTestHarness().setupTests({
|
||||
credentials,
|
||||
workflowFiles: ['getTokenRefresh.workflow.json'],
|
||||
customAssertions: () => {
|
||||
// Verify the token was refreshed and saved
|
||||
expect(updateCredentialsSpy).toHaveBeenCalledTimes(1);
|
||||
expect(updateCredentialsSpy.mock.calls[0][1]).toBe('microsoftSharePointOAuth2Api');
|
||||
expect(updateCredentialsSpy.mock.calls[0][2]).toMatchObject({
|
||||
oauthTokenData: expect.objectContaining({
|
||||
access_token: 'NEWACCESSTOKEN',
|
||||
refresh_token: 'NEWREFRESHTOKEN',
|
||||
}),
|
||||
});
|
||||
|
||||
// Verify all nock interceptors were called (401 -> refresh -> retry)
|
||||
expect(nock.isDone()).toBe(true);
|
||||
},
|
||||
});
|
||||
});
|
||||
+76
@@ -0,0 +1,76 @@
|
||||
{
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [0, 0],
|
||||
"id": "d8d29d0a-bb31-4094-a252-8008932f5425",
|
||||
"name": "When clicking 'Test workflow'"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"resource": "item",
|
||||
"operation": "get",
|
||||
"site": {
|
||||
"__rl": true,
|
||||
"value": "site1",
|
||||
"mode": "list",
|
||||
"cachedResultName": "site1"
|
||||
},
|
||||
"list": {
|
||||
"__rl": true,
|
||||
"value": "list1",
|
||||
"mode": "list",
|
||||
"cachedResultName": "list1"
|
||||
},
|
||||
"item": {
|
||||
"__rl": true,
|
||||
"value": "item1",
|
||||
"mode": "list",
|
||||
"cachedResultName": "item1"
|
||||
},
|
||||
"requestOptions": {}
|
||||
},
|
||||
"type": "n8n-nodes-base.microsoftSharePoint",
|
||||
"typeVersion": 1,
|
||||
"position": [200, 0],
|
||||
"id": "0e19be10-9d94-4654-89e9-432daa8102cb",
|
||||
"name": "Microsoft SharePoint",
|
||||
"credentials": {
|
||||
"microsoftSharePointOAuth2Api": {
|
||||
"id": "cXXnMCWyk397M5qJ",
|
||||
"name": "Microsoft SharePoint account"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"connections": {
|
||||
"When clicking 'Test workflow'": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Microsoft SharePoint",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"pinData": {
|
||||
"Microsoft SharePoint": [
|
||||
{
|
||||
"json": {
|
||||
"id": "item1",
|
||||
"createdDateTime": "2025-03-12T22:18:18Z",
|
||||
"lastModifiedDateTime": "2025-03-12T22:18:18Z",
|
||||
"webUrl": "https://mydomain.sharepoint.com/sites/site1/Lists/name%20list/1_.000",
|
||||
"fields": {
|
||||
"Title": "Item 1"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
import { NodeTestHarness } from '@nodes-testing/node-test-harness';
|
||||
|
||||
import { credentials } from '../credentials';
|
||||
|
||||
describe('Microsoft SharePoint Node', () => {
|
||||
const { baseUrl } = credentials.microsoftSharePointOAuth2Api;
|
||||
new NodeTestHarness().setupTests({
|
||||
credentials,
|
||||
workflowFiles: ['update.workflow.json'],
|
||||
nock: {
|
||||
baseUrl,
|
||||
mocks: [
|
||||
{
|
||||
method: 'patch',
|
||||
path: '/sites/site1/lists/list1/items/item1',
|
||||
statusCode: 200,
|
||||
requestBody: {
|
||||
fields: {
|
||||
Title: 'Title 2',
|
||||
},
|
||||
},
|
||||
responseBody: {
|
||||
'@odata.context':
|
||||
'https://mydomain.sharepoint.com/sites/site1/_api/v2.0/$metadata#listItems/$entity',
|
||||
'@odata.etag': '"cc40561f-3d3b-4cfb-b8a9-8af9d71de3f0,2"',
|
||||
createdBy: {
|
||||
user: {
|
||||
displayName: 'John Doe',
|
||||
email: 'john@doe.onmicrosoft.com',
|
||||
id: '5f7afebb-121d-4664-882b-a09fe6584ce0',
|
||||
},
|
||||
},
|
||||
createdDateTime: '2025-03-25T12:26:12Z',
|
||||
eTag: '"cc40561f-3d3b-4cfb-b8a9-8af9d71de3f0,2"',
|
||||
id: 'item1',
|
||||
lastModifiedBy: {
|
||||
application: {
|
||||
id: 'b9c26603-3c9b-4050-b848-27dfab0a52fa',
|
||||
displayName: 'sharepoint-n8n-test',
|
||||
},
|
||||
user: {
|
||||
displayName: 'John Doe',
|
||||
email: 'john@doe.onmicrosoft.com',
|
||||
id: '5f7afebb-121d-4664-882b-a09fe6584ce0',
|
||||
},
|
||||
},
|
||||
lastModifiedDateTime: '2025-03-25T12:26:46Z',
|
||||
parentReference: {
|
||||
id: '84070a73-ea24-463c-8eb2-0e9afa11c63f',
|
||||
listId: 'list1',
|
||||
siteId: 'site1',
|
||||
},
|
||||
webUrl: 'https://mydomain.sharepoint.com/sites/site1/Lists/name%20list/3_.000',
|
||||
contentType: {
|
||||
id: '0x010010D603DC4CF2DF4BB8A2D75DCB4BB1B30037A4993FB4DEB0439C3DC6DEC95A9DF8',
|
||||
name: 'Item',
|
||||
},
|
||||
'fields@odata.navigationLink': 'sites/site1/lists/list1/items/item1/fields',
|
||||
fields: {
|
||||
'@odata.etag': '"cc40561f-3d3b-4cfb-b8a9-8af9d71de3f0,2"',
|
||||
Title: 'Title 2',
|
||||
ID: 'item1',
|
||||
ContentType: 'Item',
|
||||
Modified: '2025-03-25T12:26:46Z',
|
||||
Created: '2025-03-25T12:26:12Z',
|
||||
AuthorLookupId: '7',
|
||||
EditorLookupId: '7',
|
||||
_UIVersionString: '2.0',
|
||||
Attachments: false,
|
||||
Edit: '',
|
||||
LinkTitleNoMenu: 'Title 2',
|
||||
LinkTitle: 'Title 2',
|
||||
ItemChildCount: '0',
|
||||
FolderChildCount: '0',
|
||||
_ComplianceFlags: '',
|
||||
_ComplianceTag: '',
|
||||
_ComplianceTagWrittenTime: '',
|
||||
_ComplianceTagUserId: '',
|
||||
AppAuthorLookupId: '5',
|
||||
AppEditorLookupId: '5',
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,154 @@
|
||||
{
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [0, 0],
|
||||
"id": "d8d29d0a-bb31-4094-a252-8008932f5425",
|
||||
"name": "When clicking ‘Test workflow’"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"resource": "item",
|
||||
"operation": "update",
|
||||
"site": {
|
||||
"__rl": true,
|
||||
"value": "site1",
|
||||
"mode": "list",
|
||||
"cachedResultName": "site1"
|
||||
},
|
||||
"list": {
|
||||
"__rl": true,
|
||||
"value": "list1",
|
||||
"mode": "list",
|
||||
"cachedResultName": "list1"
|
||||
},
|
||||
"columns": {
|
||||
"mappingMode": "defineBelow",
|
||||
"value": {
|
||||
"Title": "Title 2",
|
||||
"id": "item1"
|
||||
},
|
||||
"matchingColumns": ["id"],
|
||||
"schema": [
|
||||
{
|
||||
"id": "Title",
|
||||
"canBeUsedToMatch": false,
|
||||
"defaultMatch": false,
|
||||
"display": true,
|
||||
"displayName": "Title",
|
||||
"readOnly": false,
|
||||
"required": false,
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"id": "id",
|
||||
"canBeUsedToMatch": true,
|
||||
"defaultMatch": false,
|
||||
"display": true,
|
||||
"displayName": "ID",
|
||||
"readOnly": true,
|
||||
"required": true,
|
||||
"type": "string",
|
||||
"removed": false
|
||||
}
|
||||
],
|
||||
"attemptToConvertTypes": false,
|
||||
"convertFieldsToString": false
|
||||
},
|
||||
"requestOptions": {}
|
||||
},
|
||||
"type": "n8n-nodes-base.microsoftSharePoint",
|
||||
"typeVersion": 1,
|
||||
"position": [200, 0],
|
||||
"id": "0e19be10-9d94-4654-89e9-432daa8102cb",
|
||||
"name": "Microsoft SharePoint",
|
||||
"credentials": {
|
||||
"microsoftSharePointOAuth2Api": {
|
||||
"id": "cXXnMCWyk397M5qJ",
|
||||
"name": "Microsoft SharePoint account"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"connections": {
|
||||
"When clicking ‘Test workflow’": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Microsoft SharePoint",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"pinData": {
|
||||
"Microsoft SharePoint": [
|
||||
{
|
||||
"json": {
|
||||
"@odata.context": "https://mydomain.sharepoint.com/sites/site1/_api/v2.0/$metadata#listItems/$entity",
|
||||
"@odata.etag": "\"cc40561f-3d3b-4cfb-b8a9-8af9d71de3f0,2\"",
|
||||
"createdBy": {
|
||||
"user": {
|
||||
"displayName": "John Doe",
|
||||
"email": "john@doe.onmicrosoft.com",
|
||||
"id": "5f7afebb-121d-4664-882b-a09fe6584ce0"
|
||||
}
|
||||
},
|
||||
"createdDateTime": "2025-03-25T12:26:12Z",
|
||||
"eTag": "\"cc40561f-3d3b-4cfb-b8a9-8af9d71de3f0,2\"",
|
||||
"id": "item1",
|
||||
"lastModifiedBy": {
|
||||
"application": {
|
||||
"id": "b9c26603-3c9b-4050-b848-27dfab0a52fa",
|
||||
"displayName": "sharepoint-n8n-test"
|
||||
},
|
||||
"user": {
|
||||
"displayName": "John Doe",
|
||||
"email": "john@doe.onmicrosoft.com",
|
||||
"id": "5f7afebb-121d-4664-882b-a09fe6584ce0"
|
||||
}
|
||||
},
|
||||
"lastModifiedDateTime": "2025-03-25T12:26:46Z",
|
||||
"parentReference": {
|
||||
"id": "84070a73-ea24-463c-8eb2-0e9afa11c63f",
|
||||
"listId": "list1",
|
||||
"siteId": "site1"
|
||||
},
|
||||
"webUrl": "https://mydomain.sharepoint.com/sites/site1/Lists/name%20list/3_.000",
|
||||
"contentType": {
|
||||
"id": "0x010010D603DC4CF2DF4BB8A2D75DCB4BB1B30037A4993FB4DEB0439C3DC6DEC95A9DF8",
|
||||
"name": "Item"
|
||||
},
|
||||
"fields@odata.navigationLink": "sites/site1/lists/list1/items/item1/fields",
|
||||
"fields": {
|
||||
"@odata.etag": "\"cc40561f-3d3b-4cfb-b8a9-8af9d71de3f0,2\"",
|
||||
"Title": "Title 2",
|
||||
"ID": "item1",
|
||||
"ContentType": "Item",
|
||||
"Modified": "2025-03-25T12:26:46Z",
|
||||
"Created": "2025-03-25T12:26:12Z",
|
||||
"AuthorLookupId": "7",
|
||||
"EditorLookupId": "7",
|
||||
"_UIVersionString": "2.0",
|
||||
"Attachments": false,
|
||||
"Edit": "",
|
||||
"LinkTitleNoMenu": "Title 2",
|
||||
"LinkTitle": "Title 2",
|
||||
"ItemChildCount": "0",
|
||||
"FolderChildCount": "0",
|
||||
"_ComplianceFlags": "",
|
||||
"_ComplianceTag": "",
|
||||
"_ComplianceTagWrittenTime": "",
|
||||
"_ComplianceTagUserId": "",
|
||||
"AppAuthorLookupId": "5",
|
||||
"AppEditorLookupId": "5"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
import { NodeTestHarness } from '@nodes-testing/node-test-harness';
|
||||
|
||||
import { credentials } from '../credentials';
|
||||
|
||||
describe('Microsoft SharePoint Node', () => {
|
||||
const { baseUrl } = credentials.microsoftSharePointOAuth2Api;
|
||||
new NodeTestHarness().setupTests({
|
||||
credentials,
|
||||
workflowFiles: ['upsert.workflow.json'],
|
||||
nock: {
|
||||
baseUrl,
|
||||
mocks: [
|
||||
{
|
||||
method: 'get',
|
||||
path: '/sites/site1/lists/list1/items?%24filter=fields%2FTitle%20eq%20%27Title%201%27',
|
||||
statusCode: 200,
|
||||
requestHeaders: {
|
||||
Prefer: 'HonorNonIndexedQueriesWarningMayFailRandomly',
|
||||
},
|
||||
responseBody: {
|
||||
'@odata.context':
|
||||
'https://mydomain.sharepoint.com/sites/site1/_api/v2.0/$metadata#listItems',
|
||||
value: [
|
||||
{
|
||||
'@odata.etag': '"0ea4148a-f8e5-4f2f-a815-2e2be693b164,2"',
|
||||
createdBy: {
|
||||
user: {
|
||||
displayName: 'John Doe',
|
||||
email: 'john@doe.onmicrosoft.com',
|
||||
id: '5f7afebb-121d-4664-882b-a09fe6584ce0',
|
||||
},
|
||||
},
|
||||
createdDateTime: '2025-03-25T12:48:45Z',
|
||||
eTag: '"0ea4148a-f8e5-4f2f-a815-2e2be693b164,2"',
|
||||
id: 'item1',
|
||||
lastModifiedBy: {
|
||||
application: {
|
||||
id: 'b9c26603-3c9b-4050-b848-27dfab0a52fa',
|
||||
displayName: 'sharepoint-n8n-test',
|
||||
},
|
||||
user: {
|
||||
displayName: 'John Doe',
|
||||
email: 'john@doe.onmicrosoft.com',
|
||||
id: '5f7afebb-121d-4664-882b-a09fe6584ce0',
|
||||
},
|
||||
},
|
||||
lastModifiedDateTime: '2025-03-25T13:01:45Z',
|
||||
parentReference: {
|
||||
id: '0ead9135-9622-4b6d-b319-6b8810a6dc60',
|
||||
listId: 'list1',
|
||||
siteId: 'site1',
|
||||
},
|
||||
webUrl: 'https://mydomain.sharepoint.com/sites/site1/Lists/test/19_.000',
|
||||
contentType: {
|
||||
id: '0x0100362657F7588C5C438072A77E0EF184F4000272C0D1046D984B8097B3C00D199EDE',
|
||||
name: 'Item',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
method: 'patch',
|
||||
path: '/sites/site1/lists/list1/items/item1',
|
||||
statusCode: 200,
|
||||
requestBody: {
|
||||
fields: {
|
||||
Title: 'Title 1',
|
||||
},
|
||||
},
|
||||
responseBody: {
|
||||
'@odata.context':
|
||||
'https://mydomain.sharepoint.com/sites/site1/_api/v2.0/$metadata#listItems/$entity',
|
||||
'@odata.etag': '"cc40561f-3d3b-4cfb-b8a9-8af9d71de3f0,2"',
|
||||
createdBy: {
|
||||
user: {
|
||||
displayName: 'John Doe',
|
||||
email: 'john@doe.onmicrosoft.com',
|
||||
id: '5f7afebb-121d-4664-882b-a09fe6584ce0',
|
||||
},
|
||||
},
|
||||
createdDateTime: '2025-03-25T12:26:12Z',
|
||||
eTag: '"cc40561f-3d3b-4cfb-b8a9-8af9d71de3f0,2"',
|
||||
id: 'item1',
|
||||
lastModifiedBy: {
|
||||
application: {
|
||||
id: 'b9c26603-3c9b-4050-b848-27dfab0a52fa',
|
||||
displayName: 'sharepoint-n8n-test',
|
||||
},
|
||||
user: {
|
||||
displayName: 'John Doe',
|
||||
email: 'john@doe.onmicrosoft.com',
|
||||
id: '5f7afebb-121d-4664-882b-a09fe6584ce0',
|
||||
},
|
||||
},
|
||||
lastModifiedDateTime: '2025-03-25T12:26:46Z',
|
||||
parentReference: {
|
||||
id: '84070a73-ea24-463c-8eb2-0e9afa11c63f',
|
||||
listId: 'list1',
|
||||
siteId: 'site1',
|
||||
},
|
||||
webUrl: 'https://mydomain.sharepoint.com/sites/site1/Lists/name%20list/3_.000',
|
||||
contentType: {
|
||||
id: '0x010010D603DC4CF2DF4BB8A2D75DCB4BB1B30037A4993FB4DEB0439C3DC6DEC95A9DF8',
|
||||
name: 'Item',
|
||||
},
|
||||
'fields@odata.navigationLink': 'sites/site1/lists/list1/items/item1/fields',
|
||||
fields: {
|
||||
'@odata.etag': '"cc40561f-3d3b-4cfb-b8a9-8af9d71de3f0,2"',
|
||||
Title: 'Title 1',
|
||||
ID: 'item1',
|
||||
ContentType: 'Item',
|
||||
Modified: '2025-03-25T12:26:46Z',
|
||||
Created: '2025-03-25T12:26:12Z',
|
||||
AuthorLookupId: '7',
|
||||
EditorLookupId: '7',
|
||||
_UIVersionString: '2.0',
|
||||
Attachments: false,
|
||||
Edit: '',
|
||||
LinkTitleNoMenu: 'Title 1',
|
||||
LinkTitle: 'Title 1',
|
||||
ItemChildCount: '0',
|
||||
FolderChildCount: '0',
|
||||
_ComplianceFlags: '',
|
||||
_ComplianceTag: '',
|
||||
_ComplianceTagWrittenTime: '',
|
||||
_ComplianceTagUserId: '',
|
||||
AppAuthorLookupId: '5',
|
||||
AppEditorLookupId: '5',
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,143 @@
|
||||
{
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [0, 0],
|
||||
"id": "d8d29d0a-bb31-4094-a252-8008932f5425",
|
||||
"name": "When clicking ‘Test workflow’"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"resource": "item",
|
||||
"operation": "upsert",
|
||||
"site": {
|
||||
"__rl": true,
|
||||
"value": "site1",
|
||||
"mode": "list",
|
||||
"cachedResultName": "site1"
|
||||
},
|
||||
"list": {
|
||||
"__rl": true,
|
||||
"value": "list1",
|
||||
"mode": "list",
|
||||
"cachedResultName": "list1"
|
||||
},
|
||||
"columns": {
|
||||
"mappingMode": "defineBelow",
|
||||
"value": {
|
||||
"Title": "Title 1"
|
||||
},
|
||||
"matchingColumns": ["Title"],
|
||||
"schema": [
|
||||
{
|
||||
"id": "Title",
|
||||
"canBeUsedToMatch": true,
|
||||
"defaultMatch": false,
|
||||
"display": true,
|
||||
"displayName": "Title",
|
||||
"readOnly": false,
|
||||
"required": true,
|
||||
"type": "string",
|
||||
"removed": false
|
||||
}
|
||||
],
|
||||
"attemptToConvertTypes": false,
|
||||
"convertFieldsToString": false
|
||||
},
|
||||
"requestOptions": {}
|
||||
},
|
||||
"type": "n8n-nodes-base.microsoftSharePoint",
|
||||
"typeVersion": 1,
|
||||
"position": [200, 0],
|
||||
"id": "0e19be10-9d94-4654-89e9-432daa8102cb",
|
||||
"name": "Microsoft SharePoint",
|
||||
"credentials": {
|
||||
"microsoftSharePointOAuth2Api": {
|
||||
"id": "cXXnMCWyk397M5qJ",
|
||||
"name": "Microsoft SharePoint account"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"connections": {
|
||||
"When clicking ‘Test workflow’": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Microsoft SharePoint",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"pinData": {
|
||||
"Microsoft SharePoint": [
|
||||
{
|
||||
"json": {
|
||||
"@odata.context": "https://mydomain.sharepoint.com/sites/site1/_api/v2.0/$metadata#listItems/$entity",
|
||||
"@odata.etag": "\"cc40561f-3d3b-4cfb-b8a9-8af9d71de3f0,2\"",
|
||||
"createdBy": {
|
||||
"user": {
|
||||
"displayName": "John Doe",
|
||||
"email": "john@doe.onmicrosoft.com",
|
||||
"id": "5f7afebb-121d-4664-882b-a09fe6584ce0"
|
||||
}
|
||||
},
|
||||
"createdDateTime": "2025-03-25T12:26:12Z",
|
||||
"eTag": "\"cc40561f-3d3b-4cfb-b8a9-8af9d71de3f0,2\"",
|
||||
"id": "item1",
|
||||
"lastModifiedBy": {
|
||||
"application": {
|
||||
"id": "b9c26603-3c9b-4050-b848-27dfab0a52fa",
|
||||
"displayName": "sharepoint-n8n-test"
|
||||
},
|
||||
"user": {
|
||||
"displayName": "John Doe",
|
||||
"email": "john@doe.onmicrosoft.com",
|
||||
"id": "5f7afebb-121d-4664-882b-a09fe6584ce0"
|
||||
}
|
||||
},
|
||||
"lastModifiedDateTime": "2025-03-25T12:26:46Z",
|
||||
"parentReference": {
|
||||
"id": "84070a73-ea24-463c-8eb2-0e9afa11c63f",
|
||||
"listId": "list1",
|
||||
"siteId": "site1"
|
||||
},
|
||||
"webUrl": "https://mydomain.sharepoint.com/sites/site1/Lists/name%20list/3_.000",
|
||||
"contentType": {
|
||||
"id": "0x010010D603DC4CF2DF4BB8A2D75DCB4BB1B30037A4993FB4DEB0439C3DC6DEC95A9DF8",
|
||||
"name": "Item"
|
||||
},
|
||||
"fields@odata.navigationLink": "sites/site1/lists/list1/items/item1/fields",
|
||||
"fields": {
|
||||
"@odata.etag": "\"cc40561f-3d3b-4cfb-b8a9-8af9d71de3f0,2\"",
|
||||
"Title": "Title 1",
|
||||
"ID": "item1",
|
||||
"ContentType": "Item",
|
||||
"Modified": "2025-03-25T12:26:46Z",
|
||||
"Created": "2025-03-25T12:26:12Z",
|
||||
"AuthorLookupId": "7",
|
||||
"EditorLookupId": "7",
|
||||
"_UIVersionString": "2.0",
|
||||
"Attachments": false,
|
||||
"Edit": "",
|
||||
"LinkTitleNoMenu": "Title 1",
|
||||
"LinkTitle": "Title 1",
|
||||
"ItemChildCount": "0",
|
||||
"FolderChildCount": "0",
|
||||
"_ComplianceFlags": "",
|
||||
"_ComplianceTag": "",
|
||||
"_ComplianceTagWrittenTime": "",
|
||||
"_ComplianceTagUserId": "",
|
||||
"AppAuthorLookupId": "5",
|
||||
"AppEditorLookupId": "5"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
import { NodeTestHarness } from '@nodes-testing/node-test-harness';
|
||||
|
||||
import { credentials } from '../credentials';
|
||||
|
||||
describe('Microsoft SharePoint Node', () => {
|
||||
const { baseUrl } = credentials.microsoftSharePointOAuth2Api;
|
||||
new NodeTestHarness().setupTests({
|
||||
credentials,
|
||||
workflowFiles: ['get.workflow.json'],
|
||||
nock: {
|
||||
baseUrl,
|
||||
mocks: [
|
||||
{
|
||||
method: 'get',
|
||||
path: '/sites/site1/lists/list1?%24select=id%2Cname%2CdisplayName%2Cdescription%2CcreatedDateTime%2ClastModifiedDateTime%2CwebUrl',
|
||||
statusCode: 200,
|
||||
responseBody: {
|
||||
'@odata.context':
|
||||
'https://mydomain.sharepoint.com/sites/site1/_api/v2.0/$metadata#lists/$entity',
|
||||
'@odata.etag': '"58a279af-1f06-4392-a5ed-2b37fa1d6c1d,5"',
|
||||
createdDateTime: '2025-03-12T19:38:40Z',
|
||||
description: 'My List 1',
|
||||
id: '58a279af-1f06-4392-a5ed-2b37fa1d6c1d',
|
||||
lastModifiedDateTime: '2025-03-12T22:18:18Z',
|
||||
name: 'list1',
|
||||
webUrl: 'https://mydomain.sharepoint.com/sites/site1/Lists/name%20list',
|
||||
displayName: 'list1',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,70 @@
|
||||
{
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [0, 0],
|
||||
"id": "d8d29d0a-bb31-4094-a252-8008932f5425",
|
||||
"name": "When clicking ‘Test workflow’"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"resource": "list",
|
||||
"operation": "get",
|
||||
"site": {
|
||||
"__rl": true,
|
||||
"value": "site1",
|
||||
"mode": "list",
|
||||
"cachedResultName": "site1"
|
||||
},
|
||||
"list": {
|
||||
"__rl": true,
|
||||
"value": "list1",
|
||||
"mode": "list",
|
||||
"cachedResultName": "list1"
|
||||
},
|
||||
"requestOptions": {}
|
||||
},
|
||||
"type": "n8n-nodes-base.microsoftSharePoint",
|
||||
"typeVersion": 1,
|
||||
"position": [200, 0],
|
||||
"id": "0e19be10-9d94-4654-89e9-432daa8102cb",
|
||||
"name": "Microsoft SharePoint",
|
||||
"credentials": {
|
||||
"microsoftSharePointOAuth2Api": {
|
||||
"id": "cXXnMCWyk397M5qJ",
|
||||
"name": "Microsoft SharePoint account"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"connections": {
|
||||
"When clicking ‘Test workflow’": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Microsoft SharePoint",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"pinData": {
|
||||
"Microsoft SharePoint": [
|
||||
{
|
||||
"json": {
|
||||
"createdDateTime": "2025-03-12T19:38:40Z",
|
||||
"description": "My List 1",
|
||||
"id": "58a279af-1f06-4392-a5ed-2b37fa1d6c1d",
|
||||
"lastModifiedDateTime": "2025-03-12T22:18:18Z",
|
||||
"name": "list1",
|
||||
"webUrl": "https://mydomain.sharepoint.com/sites/site1/Lists/name%20list",
|
||||
"displayName": "list1"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
import { NodeTestHarness } from '@nodes-testing/node-test-harness';
|
||||
|
||||
import { credentials } from '../credentials';
|
||||
|
||||
describe('Microsoft SharePoint Node', () => {
|
||||
const { baseUrl } = credentials.microsoftSharePointOAuth2Api;
|
||||
new NodeTestHarness().setupTests({
|
||||
credentials,
|
||||
workflowFiles: ['getAll.workflow.json'],
|
||||
nock: {
|
||||
baseUrl,
|
||||
mocks: [
|
||||
{
|
||||
method: 'get',
|
||||
path: '/sites/site1/lists?%24select=id%2Cname%2CdisplayName%2Cdescription%2CcreatedDateTime%2ClastModifiedDateTime%2CwebUrl',
|
||||
statusCode: 200,
|
||||
responseBody: {
|
||||
value: [
|
||||
{
|
||||
'@odata.context':
|
||||
'https://mydomain.sharepoint.com/sites/site1/_api/v2.0/$metadata#lists/$entity',
|
||||
'@odata.etag': '"58a279af-1f06-4392-a5ed-2b37fa1d6c1d,5"',
|
||||
createdDateTime: '2025-03-12T19:38:40Z',
|
||||
description: 'My List 1',
|
||||
id: '58a279af-1f06-4392-a5ed-2b37fa1d6c1d',
|
||||
lastModifiedDateTime: '2025-03-12T22:18:18Z',
|
||||
name: 'list1',
|
||||
webUrl: 'https://mydomain.sharepoint.com/sites/site1/Lists/name%20list',
|
||||
displayName: 'list1',
|
||||
},
|
||||
],
|
||||
'@odata.nextLink':
|
||||
'https://mydomain.sharepoint.com/_api/v2.0/sites(%27mydomain.sharepoint.com,site1%27)/lists?%24skiptoken=aWQ9MjFFQkEzOUMtMkU3My00NzgwLUFBQzEtMTVDNzlDMTk4QjlB&%24top=1&%24select=id%2cname%2cdisplayName%2cdescription%2ccreatedDateTime%2clastModifiedDateTime%2cwebUrl',
|
||||
},
|
||||
},
|
||||
{
|
||||
method: 'get',
|
||||
path: '/sites(%27mydomain.sharepoint.com,site1%27)/lists?%24skiptoken=aWQ9MjFFQkEzOUMtMkU3My00NzgwLUFBQzEtMTVDNzlDMTk4QjlB&%24top=1&%24select=id%2cname%2cdisplayName%2cdescription%2ccreatedDateTime%2clastModifiedDateTime%2cwebUrl',
|
||||
statusCode: 200,
|
||||
responseBody: {
|
||||
value: [
|
||||
{
|
||||
'@odata.context':
|
||||
'https://mydomain.sharepoint.com/sites/site1/_api/v2.0/$metadata#lists/$entity',
|
||||
'@odata.etag': '"58a279af-1f06-4392-a5ed-2b37fa1d6c1d,5"',
|
||||
createdDateTime: '2025-03-12T19:38:40Z',
|
||||
description: 'My List 2',
|
||||
id: '58a279af-1f06-4392-a5ed-2b37fa1d6c1d',
|
||||
lastModifiedDateTime: '2025-03-12T22:18:18Z',
|
||||
name: 'list2',
|
||||
webUrl: 'https://mydomain.sharepoint.com/sites/site1/Lists/name%20list',
|
||||
displayName: 'list2',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,76 @@
|
||||
{
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"typeVersion": 1,
|
||||
"position": [0, 0],
|
||||
"id": "d8d29d0a-bb31-4094-a252-8008932f5425",
|
||||
"name": "When clicking ‘Test workflow’"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"resource": "list",
|
||||
"operation": "getAll",
|
||||
"site": {
|
||||
"__rl": true,
|
||||
"value": "site1",
|
||||
"mode": "list",
|
||||
"cachedResultName": "site1"
|
||||
},
|
||||
"returnAll": true,
|
||||
"requestOptions": {}
|
||||
},
|
||||
"type": "n8n-nodes-base.microsoftSharePoint",
|
||||
"typeVersion": 1,
|
||||
"position": [200, 0],
|
||||
"id": "0e19be10-9d94-4654-89e9-432daa8102cb",
|
||||
"name": "Microsoft SharePoint",
|
||||
"credentials": {
|
||||
"microsoftSharePointOAuth2Api": {
|
||||
"id": "cXXnMCWyk397M5qJ",
|
||||
"name": "Microsoft SharePoint account"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"connections": {
|
||||
"When clicking ‘Test workflow’": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Microsoft SharePoint",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"pinData": {
|
||||
"Microsoft SharePoint": [
|
||||
{
|
||||
"json": {
|
||||
"createdDateTime": "2025-03-12T19:38:40Z",
|
||||
"description": "My List 1",
|
||||
"id": "58a279af-1f06-4392-a5ed-2b37fa1d6c1d",
|
||||
"lastModifiedDateTime": "2025-03-12T22:18:18Z",
|
||||
"name": "list1",
|
||||
"webUrl": "https://mydomain.sharepoint.com/sites/site1/Lists/name%20list",
|
||||
"displayName": "list1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"json": {
|
||||
"createdDateTime": "2025-03-12T19:38:40Z",
|
||||
"description": "My List 2",
|
||||
"id": "58a279af-1f06-4392-a5ed-2b37fa1d6c1d",
|
||||
"lastModifiedDateTime": "2025-03-12T22:18:18Z",
|
||||
"name": "list2",
|
||||
"webUrl": "https://mydomain.sharepoint.com/sites/site1/Lists/name%20list",
|
||||
"displayName": "list2"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,535 @@
|
||||
import type { MockProxy } from 'jest-mock-extended';
|
||||
import { mock } from 'jest-mock-extended';
|
||||
import type { ILoadOptionsFunctions } from 'n8n-workflow';
|
||||
|
||||
import { MicrosoftSharePoint } from '../../MicrosoftSharePoint.node';
|
||||
import { credentials } from '../credentials';
|
||||
|
||||
describe('Microsoft SharePoint Node', () => {
|
||||
describe('List search', () => {
|
||||
let loadOptionsFunctions: MockProxy<ILoadOptionsFunctions>;
|
||||
let mockRequestWithAuthentication: jest.Mock;
|
||||
let node: MicrosoftSharePoint;
|
||||
|
||||
beforeEach(() => {
|
||||
loadOptionsFunctions = mock<ILoadOptionsFunctions>();
|
||||
mockRequestWithAuthentication = jest.fn();
|
||||
loadOptionsFunctions.helpers.httpRequestWithAuthentication = mockRequestWithAuthentication;
|
||||
loadOptionsFunctions.getCredentials.mockResolvedValue(
|
||||
credentials.microsoftSharePointOAuth2Api,
|
||||
);
|
||||
node = new MicrosoftSharePoint();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
jest.resetAllMocks();
|
||||
});
|
||||
|
||||
it('should list search files', async () => {
|
||||
const mockResponse = {
|
||||
'@odata.nextLink':
|
||||
'https://mydomain.sharepoint.com/_api/v2.0/sites(%27mydomain.sharepoint.com,site1%27)/items?%24skiptoken=aWQ9MjFFQkEzOUMtMkU3My00NzgwLUFBQzEtMTVDNzlDMTk4QjlB',
|
||||
value: [
|
||||
{
|
||||
'@odata.etag': '"{70EC0A2F-6C3E-425F-BBE2-1D4E758F90EE},1"',
|
||||
id: '01SPEVVYBPBLWHAPTML5BLXYQ5JZ2Y7EHO',
|
||||
name: 'Folder1',
|
||||
},
|
||||
{
|
||||
'@odata.etag': '"{10F06786-5AAF-434A-8A4E-3ED44DE4A987},6"',
|
||||
id: '01SPEVVYEGM7YBBL22JJBYUTR62RG6JKMH',
|
||||
name: 'file2.jpg',
|
||||
file: {
|
||||
hashes: {
|
||||
quickXorHash: 'uFgaWYgAVo55sg4DIR9BTMzlmH8=',
|
||||
},
|
||||
irmEffectivelyEnabled: false,
|
||||
irmEnabled: false,
|
||||
mimeType: 'image/jpeg',
|
||||
},
|
||||
},
|
||||
{
|
||||
'@odata.etag': '"{0EC452E0-D0F7-4ECF-87D7-B738F865313B},1"',
|
||||
id: '01SPEVVYHAKLCA556QZ5HIPV5XHD4GKMJ3',
|
||||
name: 'file1.txt',
|
||||
file: {
|
||||
hashes: {
|
||||
quickXorHash: 'AAAAAAAAAAAAAAAAAAAAAAAAAAA=',
|
||||
},
|
||||
irmEffectivelyEnabled: false,
|
||||
irmEnabled: false,
|
||||
mimeType: 'text/plain',
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
mockRequestWithAuthentication.mockReturnValue(mockResponse);
|
||||
loadOptionsFunctions.getNodeParameter.mockReturnValueOnce('site');
|
||||
loadOptionsFunctions.getNodeParameter.mockReturnValueOnce('folder');
|
||||
|
||||
const listSearchResult = await node.methods.listSearch.getFiles.call(
|
||||
loadOptionsFunctions,
|
||||
'file',
|
||||
);
|
||||
|
||||
expect(mockRequestWithAuthentication).toHaveBeenCalledTimes(1);
|
||||
expect(mockRequestWithAuthentication.mock.calls[0][1]).toMatchObject({
|
||||
qs: {
|
||||
$filter: "startswith(name, 'file')",
|
||||
},
|
||||
});
|
||||
expect(listSearchResult).toEqual({
|
||||
results: [
|
||||
{ name: 'file1.txt', value: '01SPEVVYHAKLCA556QZ5HIPV5XHD4GKMJ3' },
|
||||
{ name: 'file2.jpg', value: '01SPEVVYEGM7YBBL22JJBYUTR62RG6JKMH' },
|
||||
],
|
||||
paginationToken:
|
||||
'https://mydomain.sharepoint.com/_api/v2.0/sites(%27mydomain.sharepoint.com,site1%27)/items?%24skiptoken=aWQ9MjFFQkEzOUMtMkU3My00NzgwLUFBQzEtMTVDNzlDMTk4QjlB',
|
||||
});
|
||||
});
|
||||
|
||||
it('properly escapes filter parameter', async () => {
|
||||
const mockResponse = {
|
||||
'@odata.nextLink':
|
||||
'https://mydomain.sharepoint.com/_api/v2.0/sites(%27mydomain.sharepoint.com,site1%27)/items?%24skiptoken=aWQ9MjFFQkEzOUMtMkU3My00NzgwLUFBQzEtMTVDNzlDMTk4QjlB',
|
||||
value: [],
|
||||
};
|
||||
mockRequestWithAuthentication.mockReturnValue(mockResponse);
|
||||
loadOptionsFunctions.getNodeParameter.mockReturnValueOnce('site');
|
||||
loadOptionsFunctions.getNodeParameter.mockReturnValueOnce('folder');
|
||||
|
||||
await node.methods.listSearch.getFiles.call(loadOptionsFunctions, "fi'le'");
|
||||
|
||||
expect(mockRequestWithAuthentication).toHaveBeenCalledTimes(1);
|
||||
expect(mockRequestWithAuthentication.mock.calls[0][1]).toMatchObject({
|
||||
qs: {
|
||||
$filter: "startswith(name, 'fi''le''')",
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it('should list search files with pagination', async () => {
|
||||
const mockResponse = {
|
||||
value: [
|
||||
{
|
||||
'@odata.etag': '"{0EC452E0-D0F7-4ECF-87D7-B738F865313B},1"',
|
||||
id: '01SPEVVYHAKLCA556QZ5HIPV5XHD4GKMJ3',
|
||||
name: 'file1.txt',
|
||||
file: {
|
||||
hashes: {
|
||||
quickXorHash: 'AAAAAAAAAAAAAAAAAAAAAAAAAAA=',
|
||||
},
|
||||
irmEffectivelyEnabled: false,
|
||||
irmEnabled: false,
|
||||
mimeType: 'text/plain',
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
mockRequestWithAuthentication.mockReturnValue(mockResponse);
|
||||
loadOptionsFunctions.getNodeParameter.mockReturnValueOnce('site');
|
||||
loadOptionsFunctions.getNodeParameter.mockReturnValueOnce('folder');
|
||||
|
||||
const listSearchResult = await node.methods.listSearch.getFiles.call(
|
||||
loadOptionsFunctions,
|
||||
undefined,
|
||||
'https://mydomain.sharepoint.com/_api/v2.0/sites(%27mydomain.sharepoint.com,site1%27)/items?%24skiptoken=aWQ9MjFFQkEzOUMtMkU3My00NzgwLUFBQzEtMTVDNzlDMTk4QjlB',
|
||||
);
|
||||
|
||||
expect(mockRequestWithAuthentication).toHaveBeenCalledTimes(1);
|
||||
expect(mockRequestWithAuthentication.mock.calls[0][1]).toMatchObject({
|
||||
url: 'https://mydomain.sharepoint.com/_api/v2.0/sites(%27mydomain.sharepoint.com,site1%27)/items?%24skiptoken=aWQ9MjFFQkEzOUMtMkU3My00NzgwLUFBQzEtMTVDNzlDMTk4QjlB',
|
||||
});
|
||||
expect(listSearchResult).toEqual({
|
||||
results: [{ name: 'file1.txt', value: '01SPEVVYHAKLCA556QZ5HIPV5XHD4GKMJ3' }],
|
||||
});
|
||||
});
|
||||
|
||||
it('should list search folders', async () => {
|
||||
const mockResponse = {
|
||||
'@odata.nextLink':
|
||||
'https://mydomain.sharepoint.com/_api/v2.0/sites(%27mydomain.sharepoint.com,site1%27)/items?%24skiptoken=aWQ9MjFFQkEzOUMtMkU3My00NzgwLUFBQzEtMTVDNzlDMTk4QjlB',
|
||||
value: [
|
||||
{
|
||||
'@odata.etag': '"{529A466D-D708-4857-B771-24F467546A2A},1"',
|
||||
id: '01SPEVVYDNI2NFECGXK5ELO4JE6RTVI2RK',
|
||||
name: 'Folder2',
|
||||
folder: {
|
||||
childCount: 1,
|
||||
view: {},
|
||||
},
|
||||
},
|
||||
{
|
||||
'@odata.etag': '"{A3B2AE2A-2099-4194-A38B-EC7182CA3000},1"',
|
||||
id: '01SPEVVYBKV2ZKHGJASRA2HC7MOGBMUMAA',
|
||||
name: 'Folder1',
|
||||
folder: {
|
||||
childCount: 7,
|
||||
view: {},
|
||||
},
|
||||
},
|
||||
{
|
||||
'@odata.etag': '"{A6EF0C5E-0248-482A-AD79-0EFDB6622473},1"',
|
||||
id: '01SPEVVYC6BTX2MSACFJEK26IO7W3GEJDT',
|
||||
name: 'file.txt',
|
||||
},
|
||||
],
|
||||
};
|
||||
mockRequestWithAuthentication.mockReturnValue(mockResponse);
|
||||
loadOptionsFunctions.getNodeParameter.mockReturnValueOnce('site');
|
||||
|
||||
const listSearchResult = await node.methods.listSearch.getFolders.call(
|
||||
loadOptionsFunctions,
|
||||
'folder',
|
||||
);
|
||||
|
||||
expect(mockRequestWithAuthentication).toHaveBeenCalledTimes(1);
|
||||
expect(mockRequestWithAuthentication.mock.calls[0][1]).toMatchObject({
|
||||
qs: {
|
||||
$filter: 'folder ne null',
|
||||
},
|
||||
});
|
||||
expect(listSearchResult).toEqual({
|
||||
results: [
|
||||
{
|
||||
name: 'Folder1',
|
||||
value: '01SPEVVYBKV2ZKHGJASRA2HC7MOGBMUMAA',
|
||||
},
|
||||
{
|
||||
name: 'Folder2',
|
||||
value: '01SPEVVYDNI2NFECGXK5ELO4JE6RTVI2RK',
|
||||
},
|
||||
],
|
||||
paginationToken:
|
||||
'https://mydomain.sharepoint.com/_api/v2.0/sites(%27mydomain.sharepoint.com,site1%27)/items?%24skiptoken=aWQ9MjFFQkEzOUMtMkU3My00NzgwLUFBQzEtMTVDNzlDMTk4QjlB',
|
||||
});
|
||||
});
|
||||
|
||||
it('should list search folders with pagination', async () => {
|
||||
const mockResponse = {
|
||||
value: [
|
||||
{
|
||||
'@odata.etag': '"{A3B2AE2A-2099-4194-A38B-EC7182CA3000},1"',
|
||||
id: '01SPEVVYBKV2ZKHGJASRA2HC7MOGBMUMAA',
|
||||
name: 'Folder1',
|
||||
folder: {
|
||||
childCount: 7,
|
||||
view: {},
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
mockRequestWithAuthentication.mockReturnValue(mockResponse);
|
||||
loadOptionsFunctions.getNodeParameter.mockReturnValueOnce('site');
|
||||
|
||||
const listSearchResult = await node.methods.listSearch.getFolders.call(
|
||||
loadOptionsFunctions,
|
||||
undefined,
|
||||
'https://mydomain.sharepoint.com/_api/v2.0/sites(%27mydomain.sharepoint.com,site1%27)/items?%24skiptoken=aWQ9MjFFQkEzOUMtMkU3My00NzgwLUFBQzEtMTVDNzlDMTk4QjlB',
|
||||
);
|
||||
|
||||
expect(mockRequestWithAuthentication).toHaveBeenCalledTimes(1);
|
||||
expect(mockRequestWithAuthentication.mock.calls[0][1]).toMatchObject({
|
||||
url: 'https://mydomain.sharepoint.com/_api/v2.0/sites(%27mydomain.sharepoint.com,site1%27)/items?%24skiptoken=aWQ9MjFFQkEzOUMtMkU3My00NzgwLUFBQzEtMTVDNzlDMTk4QjlB',
|
||||
});
|
||||
expect(listSearchResult).toEqual({
|
||||
results: [
|
||||
{
|
||||
name: 'Folder1',
|
||||
value: '01SPEVVYBKV2ZKHGJASRA2HC7MOGBMUMAA',
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it('should list search items', async () => {
|
||||
const mockResponse = {
|
||||
'@odata.nextLink':
|
||||
'https://mydomain.sharepoint.com/_api/v2.0/sites(%27mydomain.sharepoint.com,site1%27)/listItems?%24skiptoken=aWQ9MjFFQkEzOUMtMkU3My00NzgwLUFBQzEtMTVDNzlDMTk4QjlB',
|
||||
value: [
|
||||
{
|
||||
'@odata.etag': '"98af0386-66bd-4524-a653-80be05e0f14d,2"',
|
||||
id: '2',
|
||||
'fields@odata.navigationLink': 'fields',
|
||||
fields: {
|
||||
'@odata.etag': '"98af0386-66bd-4524-a653-80be05e0f14d,2"',
|
||||
Title: 'Title 2',
|
||||
},
|
||||
},
|
||||
{
|
||||
'@odata.etag': '"0ea4148a-f8e5-4f2f-a815-2e2be693b164,4"',
|
||||
id: '1',
|
||||
'fields@odata.navigationLink': 'fields',
|
||||
fields: {
|
||||
'@odata.etag': '"0ea4148a-f8e5-4f2f-a815-2e2be693b164,4"',
|
||||
Title: 'Title 1',
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
mockRequestWithAuthentication.mockReturnValue(mockResponse);
|
||||
loadOptionsFunctions.getNodeParameter.mockReturnValueOnce('site');
|
||||
loadOptionsFunctions.getNodeParameter.mockReturnValueOnce('list');
|
||||
|
||||
const listSearchResult = await node.methods.listSearch.getItems.call(
|
||||
loadOptionsFunctions,
|
||||
'Title',
|
||||
);
|
||||
|
||||
expect(mockRequestWithAuthentication).toHaveBeenCalledTimes(1);
|
||||
expect(mockRequestWithAuthentication.mock.calls[0][1]).toMatchObject({
|
||||
qs: {
|
||||
$filter: "fields/Title eq 'Title'",
|
||||
},
|
||||
});
|
||||
expect(listSearchResult).toEqual({
|
||||
results: [
|
||||
{
|
||||
name: 'Title 1',
|
||||
value: '1',
|
||||
},
|
||||
{
|
||||
name: 'Title 2',
|
||||
value: '2',
|
||||
},
|
||||
],
|
||||
paginationToken:
|
||||
'https://mydomain.sharepoint.com/_api/v2.0/sites(%27mydomain.sharepoint.com,site1%27)/listItems?%24skiptoken=aWQ9MjFFQkEzOUMtMkU3My00NzgwLUFBQzEtMTVDNzlDMTk4QjlB',
|
||||
});
|
||||
});
|
||||
|
||||
it('properly escapes filter parameter', async () => {
|
||||
const mockResponse = {
|
||||
'@odata.nextLink':
|
||||
'https://mydomain.sharepoint.com/_api/v2.0/sites(%27mydomain.sharepoint.com,site1%27)/listItems?%24skiptoken=aWQ9MjFFQkEzOUMtMkU3My00NzgwLUFBQzEtMTVDNzlDMTk4QjlB',
|
||||
value: [],
|
||||
};
|
||||
mockRequestWithAuthentication.mockReturnValue(mockResponse);
|
||||
loadOptionsFunctions.getNodeParameter.mockReturnValueOnce('site');
|
||||
loadOptionsFunctions.getNodeParameter.mockReturnValueOnce('list');
|
||||
|
||||
await node.methods.listSearch.getItems.call(loadOptionsFunctions, "Ti'le'");
|
||||
|
||||
expect(mockRequestWithAuthentication).toHaveBeenCalledTimes(1);
|
||||
expect(mockRequestWithAuthentication.mock.calls[0][1]).toMatchObject({
|
||||
qs: {
|
||||
$filter: "fields/Title eq 'Ti''le'''",
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it('should list search items with pagination', async () => {
|
||||
const mockResponse = {
|
||||
value: [
|
||||
{
|
||||
'@odata.etag': '"0ea4148a-f8e5-4f2f-a815-2e2be693b164,4"',
|
||||
id: '1',
|
||||
'fields@odata.navigationLink': 'fields',
|
||||
fields: {
|
||||
'@odata.etag': '"0ea4148a-f8e5-4f2f-a815-2e2be693b164,4"',
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
mockRequestWithAuthentication.mockReturnValue(mockResponse);
|
||||
loadOptionsFunctions.getNodeParameter.mockReturnValueOnce('site');
|
||||
loadOptionsFunctions.getNodeParameter.mockReturnValueOnce('list');
|
||||
|
||||
const listSearchResult = await node.methods.listSearch.getItems.call(
|
||||
loadOptionsFunctions,
|
||||
undefined,
|
||||
'https://mydomain.sharepoint.com/_api/v2.0/sites(%27mydomain.sharepoint.com,site1%27)/listItems?%24skiptoken=aWQ9MjFFQkEzOUMtMkU3My00NzgwLUFBQzEtMTVDNzlDMTk4QjlB',
|
||||
);
|
||||
|
||||
expect(mockRequestWithAuthentication).toHaveBeenCalledTimes(1);
|
||||
expect(mockRequestWithAuthentication.mock.calls[0][1]).toMatchObject({
|
||||
url: 'https://mydomain.sharepoint.com/_api/v2.0/sites(%27mydomain.sharepoint.com,site1%27)/listItems?%24skiptoken=aWQ9MjFFQkEzOUMtMkU3My00NzgwLUFBQzEtMTVDNzlDMTk4QjlB',
|
||||
});
|
||||
expect(listSearchResult).toEqual({
|
||||
results: [
|
||||
{
|
||||
name: '1',
|
||||
value: '1',
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it('should list search lists', async () => {
|
||||
const mockResponse = {
|
||||
'@odata.nextLink':
|
||||
'https://mydomain.sharepoint.com/_api/v2.0/sites(%27mydomain.sharepoint.com,site1%27)/lists?%24skiptoken=aWQ9MjFFQkEzOUMtMkU3My00NzgwLUFBQzEtMTVDNzlDMTk4QjlB',
|
||||
value: [
|
||||
{
|
||||
'@odata.etag': '"58a279af-1f06-4392-a5ed-2b37fa1d6c1d,5"',
|
||||
id: '58a279af-1f06-4392-a5ed-2b37fa1d6c1d',
|
||||
displayName: 'List 2',
|
||||
},
|
||||
{
|
||||
'@odata.etag': '"23af565a-da89-48f0-ae5f-2d4a7244b446,0"',
|
||||
id: '23af565a-da89-48f0-ae5f-2d4a7244b446',
|
||||
displayName: 'List 1',
|
||||
},
|
||||
],
|
||||
};
|
||||
mockRequestWithAuthentication.mockReturnValue(mockResponse);
|
||||
loadOptionsFunctions.getNodeParameter.mockReturnValueOnce('site');
|
||||
|
||||
const listSearchResult = await node.methods.listSearch.getLists.call(
|
||||
loadOptionsFunctions,
|
||||
'List',
|
||||
);
|
||||
|
||||
expect(mockRequestWithAuthentication).toHaveBeenCalledTimes(1);
|
||||
expect(mockRequestWithAuthentication.mock.calls[0][1]).toMatchObject({
|
||||
qs: {
|
||||
$filter: "displayName eq 'List'",
|
||||
},
|
||||
});
|
||||
expect(listSearchResult).toEqual({
|
||||
results: [
|
||||
{
|
||||
name: 'List 1',
|
||||
value: '23af565a-da89-48f0-ae5f-2d4a7244b446',
|
||||
},
|
||||
{
|
||||
name: 'List 2',
|
||||
value: '58a279af-1f06-4392-a5ed-2b37fa1d6c1d',
|
||||
},
|
||||
],
|
||||
paginationToken:
|
||||
'https://mydomain.sharepoint.com/_api/v2.0/sites(%27mydomain.sharepoint.com,site1%27)/lists?%24skiptoken=aWQ9MjFFQkEzOUMtMkU3My00NzgwLUFBQzEtMTVDNzlDMTk4QjlB',
|
||||
});
|
||||
});
|
||||
|
||||
it('properly escapes filter parameter', async () => {
|
||||
const mockResponse = {
|
||||
'@odata.nextLink':
|
||||
'https://mydomain.sharepoint.com/_api/v2.0/sites(%27mydomain.sharepoint.com,site1%27)/lists?%24skiptoken=aWQ9MjFFQkEzOUMtMkU3My00NzgwLUFBQzEtMTVDNzlDMTk4QjlB',
|
||||
value: [],
|
||||
};
|
||||
mockRequestWithAuthentication.mockReturnValue(mockResponse);
|
||||
loadOptionsFunctions.getNodeParameter.mockReturnValueOnce('site');
|
||||
|
||||
await node.methods.listSearch.getLists.call(loadOptionsFunctions, "' or '1'='1");
|
||||
|
||||
expect(mockRequestWithAuthentication).toHaveBeenCalledTimes(1);
|
||||
expect(mockRequestWithAuthentication.mock.calls[0][1]).toMatchObject({
|
||||
qs: {
|
||||
$filter: "displayName eq ''' or ''1''=''1'",
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it('should list search lists with pagination', async () => {
|
||||
const mockResponse = {
|
||||
value: [
|
||||
{
|
||||
'@odata.etag': '"23af565a-da89-48f0-ae5f-2d4a7244b446,0"',
|
||||
id: '23af565a-da89-48f0-ae5f-2d4a7244b446',
|
||||
displayName: 'List 1',
|
||||
},
|
||||
],
|
||||
};
|
||||
mockRequestWithAuthentication.mockReturnValue(mockResponse);
|
||||
loadOptionsFunctions.getNodeParameter.mockReturnValueOnce('site');
|
||||
|
||||
const listSearchResult = await node.methods.listSearch.getLists.call(
|
||||
loadOptionsFunctions,
|
||||
undefined,
|
||||
'https://mydomain.sharepoint.com/_api/v2.0/sites(%27mydomain.sharepoint.com,site1%27)/lists?%24skiptoken=aWQ9MjFFQkEzOUMtMkU3My00NzgwLUFBQzEtMTVDNzlDMTk4QjlB',
|
||||
);
|
||||
|
||||
expect(mockRequestWithAuthentication).toHaveBeenCalledTimes(1);
|
||||
expect(mockRequestWithAuthentication.mock.calls[0][1]).toMatchObject({
|
||||
url: 'https://mydomain.sharepoint.com/_api/v2.0/sites(%27mydomain.sharepoint.com,site1%27)/lists?%24skiptoken=aWQ9MjFFQkEzOUMtMkU3My00NzgwLUFBQzEtMTVDNzlDMTk4QjlB',
|
||||
});
|
||||
expect(listSearchResult).toEqual({
|
||||
results: [
|
||||
{
|
||||
name: 'List 1',
|
||||
value: '23af565a-da89-48f0-ae5f-2d4a7244b446',
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it('should list search sites', async () => {
|
||||
const mockResponse = {
|
||||
'@odata.nextLink':
|
||||
'https://mydomain.sharepoint.com/_api/v2.0/sites(%27mydomain.sharepoint.com,site1%27)/sites?%24skiptoken=aWQ9MjFFQkEzOUMtMkU3My00NzgwLUFBQzEtMTVDNzlDMTk4QjlB',
|
||||
value: [
|
||||
{
|
||||
id: 'mydomain.sharepoint.com,cf38a104-c767-48c7-93d0-c093e3909c78,3abe66fd-ec23-469f-abc6-332e3a95bf75',
|
||||
title: 'Site 2',
|
||||
},
|
||||
{
|
||||
id: 'mydomain.sharepoint.com,3286a459-bc45-4aab-8200-b9ba7edcca96,3abe66fd-ec23-469f-abc6-332e3a95bf75',
|
||||
title: 'Site 1',
|
||||
},
|
||||
],
|
||||
};
|
||||
mockRequestWithAuthentication.mockReturnValue(mockResponse);
|
||||
|
||||
const listSearchResult = await node.methods.listSearch.getSites.call(
|
||||
loadOptionsFunctions,
|
||||
'Site',
|
||||
);
|
||||
|
||||
expect(mockRequestWithAuthentication).toHaveBeenCalledTimes(1);
|
||||
expect(mockRequestWithAuthentication.mock.calls[0][1]).toMatchObject({
|
||||
qs: {
|
||||
$search: 'Site',
|
||||
},
|
||||
});
|
||||
expect(listSearchResult).toEqual({
|
||||
results: [
|
||||
{
|
||||
name: 'Site 1',
|
||||
value:
|
||||
'mydomain.sharepoint.com,3286a459-bc45-4aab-8200-b9ba7edcca96,3abe66fd-ec23-469f-abc6-332e3a95bf75',
|
||||
},
|
||||
{
|
||||
name: 'Site 2',
|
||||
value:
|
||||
'mydomain.sharepoint.com,cf38a104-c767-48c7-93d0-c093e3909c78,3abe66fd-ec23-469f-abc6-332e3a95bf75',
|
||||
},
|
||||
],
|
||||
paginationToken:
|
||||
'https://mydomain.sharepoint.com/_api/v2.0/sites(%27mydomain.sharepoint.com,site1%27)/sites?%24skiptoken=aWQ9MjFFQkEzOUMtMkU3My00NzgwLUFBQzEtMTVDNzlDMTk4QjlB',
|
||||
});
|
||||
});
|
||||
|
||||
it('should list search sites and pagination', async () => {
|
||||
const mockResponse = {
|
||||
value: [
|
||||
{
|
||||
id: 'mydomain.sharepoint.com,3286a459-bc45-4aab-8200-b9ba7edcca96,3abe66fd-ec23-469f-abc6-332e3a95bf75',
|
||||
title: 'Site 1',
|
||||
},
|
||||
],
|
||||
};
|
||||
mockRequestWithAuthentication.mockReturnValue(mockResponse);
|
||||
|
||||
const listSearchResult = await node.methods.listSearch.getSites.call(
|
||||
loadOptionsFunctions,
|
||||
undefined,
|
||||
'https://mydomain.sharepoint.com/_api/v2.0/sites(%27mydomain.sharepoint.com,site1%27)/sites?%24skiptoken=aWQ9MjFFQkEzOUMtMkU3My00NzgwLUFBQzEtMTVDNzlDMTk4QjlB',
|
||||
);
|
||||
|
||||
expect(mockRequestWithAuthentication).toHaveBeenCalledTimes(1);
|
||||
expect(mockRequestWithAuthentication.mock.calls[0][1]).toMatchObject({
|
||||
url: 'https://mydomain.sharepoint.com/_api/v2.0/sites(%27mydomain.sharepoint.com,site1%27)/sites?%24skiptoken=aWQ9MjFFQkEzOUMtMkU3My00NzgwLUFBQzEtMTVDNzlDMTk4QjlB',
|
||||
});
|
||||
expect(listSearchResult).toEqual({
|
||||
results: [
|
||||
{
|
||||
name: 'Site 1',
|
||||
value:
|
||||
'mydomain.sharepoint.com,3286a459-bc45-4aab-8200-b9ba7edcca96,3abe66fd-ec23-469f-abc6-332e3a95bf75',
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,886 @@
|
||||
import type { MockProxy } from 'jest-mock-extended';
|
||||
import { mock } from 'jest-mock-extended';
|
||||
import type { ILoadOptionsFunctions } from 'n8n-workflow';
|
||||
|
||||
import { getMappingColumns } from '../../methods/resourceMapping';
|
||||
|
||||
describe('Microsoft SharePoint Node', () => {
|
||||
describe('Resource mapping', () => {
|
||||
let loadOptionsFunctions: MockProxy<ILoadOptionsFunctions>;
|
||||
|
||||
beforeEach(() => {
|
||||
loadOptionsFunctions = mock<ILoadOptionsFunctions>();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
jest.resetAllMocks();
|
||||
});
|
||||
|
||||
it('should map columns', async () => {
|
||||
loadOptionsFunctions.getCredentials.mockResolvedValue({});
|
||||
loadOptionsFunctions.getNodeParameter.mockReturnValueOnce('site');
|
||||
loadOptionsFunctions.getNodeParameter.mockReturnValueOnce('list');
|
||||
loadOptionsFunctions.getNodeParameter.mockReturnValueOnce('create');
|
||||
const mockResponse = {
|
||||
value: [
|
||||
{
|
||||
'@odata.etag': '"0"',
|
||||
id: '0x0100362657F7588C5C438072A77E0EF184F4000272C0D1046D984B8097B3C00D199EDE',
|
||||
description: 'Create a new list item.',
|
||||
eTag: '"0"',
|
||||
group: 'List Content Types',
|
||||
hidden: false,
|
||||
name: 'Item',
|
||||
parentId: '0x01',
|
||||
readOnly: false,
|
||||
sealed: false,
|
||||
columns: [
|
||||
{
|
||||
displayName: 'Title',
|
||||
'@odata.etag': '"1"',
|
||||
columnGroup: 'Custom Columns',
|
||||
customFormatter: '',
|
||||
description: 'Description Title',
|
||||
enforceUniqueValues: true,
|
||||
eTag: '"1"',
|
||||
hidden: false,
|
||||
id: 'fa564e0f-0c70-4ab9-b863-0177e6ddd247',
|
||||
indexed: true,
|
||||
isDeletable: false,
|
||||
isReorderable: true,
|
||||
isSealed: false,
|
||||
propagateChanges: false,
|
||||
name: 'Title',
|
||||
readOnly: false,
|
||||
required: true,
|
||||
type: 'text',
|
||||
default: '',
|
||||
text: {
|
||||
allowMultipleLines: false,
|
||||
appendChangesToExistingText: false,
|
||||
autoHyperLink: true,
|
||||
linesForEditing: 0,
|
||||
maxLength: 255,
|
||||
},
|
||||
validation: {
|
||||
defaultLanguage: 'en-US',
|
||||
descriptions: [
|
||||
{
|
||||
languageTag: 'en-US',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Othertitle',
|
||||
'@odata.etag': '"0"',
|
||||
columnGroup: 'Custom Columns',
|
||||
description: 'Descriptio Othertitle',
|
||||
enforceUniqueValues: false,
|
||||
eTag: '"0"',
|
||||
hidden: false,
|
||||
id: '82642ec8-ef9b-478f-acf9-31f7d45fbc31',
|
||||
indexed: false,
|
||||
isDeletable: false,
|
||||
isReorderable: false,
|
||||
isSealed: false,
|
||||
propagateChanges: false,
|
||||
name: 'LinkTitle',
|
||||
readOnly: true,
|
||||
type: 'unknownFutureValue',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Choice',
|
||||
'@odata.etag': '"2"',
|
||||
columnGroup: 'Custom Columns',
|
||||
customFormatter:
|
||||
'{"elmType":"div","style":{"flex-wrap":"wrap","display":"flex"},"children":[{"elmType":"div","style":{"box-sizing":"border-box","padding":"4px 8px 5px 8px","overflow":"hidden","text-overflow":"ellipsis","display":"flex","border-radius":"16px","height":"24px","align-items":"center","white-space":"nowrap","margin":"4px 4px 4px 4px"},"attributes":{"class":{"operator":":","operands":[{"operator":"==","operands":["[$choice]","Choice 1"]},"sp-css-backgroundColor-BgCornflowerBlue sp-css-color-CornflowerBlueFont",{"operator":":","operands":[{"operator":"==","operands":["[$choice]","Choice 2"]},"sp-css-backgroundColor-BgMintGreen sp-css-color-MintGreenFont",{"operator":":","operands":[{"operator":"==","operands":["[$choice]","Choice 3"]},"sp-css-backgroundColor-BgGold sp-css-color-GoldFont",{"operator":":","operands":[{"operator":"==","operands":["[$choice]",""]},"","sp-field-borderAllRegular sp-field-borderAllSolid sp-css-borderColor-neutralSecondary"]}]}]}]}},"children":[{"elmType":"span","style":{"overflow":"hidden","text-overflow":"ellipsis","padding":"0 3px"},"txtContent":"[$choice]","attributes":{"class":{"operator":":","operands":[{"operator":"==","operands":["[$choice]","Choice 1"]},"sp-css-color-CornflowerBlueFont",{"operator":":","operands":[{"operator":"==","operands":["[$choice]","Choice 2"]},"sp-css-color-MintGreenFont",{"operator":":","operands":[{"operator":"==","operands":["[$choice]","Choice 3"]},"sp-css-color-GoldFont",{"operator":":","operands":[{"operator":"==","operands":["[$choice]",""]},"",""]}]}]}]}}}]}],"templateId":"BgColorChoicePill"}',
|
||||
description: 'Description Choice',
|
||||
enforceUniqueValues: false,
|
||||
eTag: '"2"',
|
||||
hidden: false,
|
||||
id: '21d4577a-e5f2-461d-a9cf-f7956c502f4e',
|
||||
indexed: false,
|
||||
isDeletable: true,
|
||||
isReorderable: true,
|
||||
isSealed: false,
|
||||
propagateChanges: false,
|
||||
name: 'choice',
|
||||
readOnly: false,
|
||||
type: 'choice',
|
||||
default: '',
|
||||
choice: {
|
||||
allowTextEntry: false,
|
||||
choices: ['Choice 1', 'Choice 2', 'Choice 3'],
|
||||
displayAs: 'dropDownMenu',
|
||||
},
|
||||
validation: {
|
||||
defaultLanguage: 'en-US',
|
||||
descriptions: [
|
||||
{
|
||||
languageTag: 'en-US',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Datetime',
|
||||
'@odata.etag': '"0"',
|
||||
columnGroup: 'Custom Columns',
|
||||
description: 'Description Datetime',
|
||||
enforceUniqueValues: false,
|
||||
eTag: '"0"',
|
||||
hidden: false,
|
||||
id: '7e2cf00a-1df6-4c1c-8ea9-d92ef3c7760e',
|
||||
indexed: false,
|
||||
isDeletable: true,
|
||||
isReorderable: true,
|
||||
isSealed: false,
|
||||
propagateChanges: false,
|
||||
name: 'datetime',
|
||||
readOnly: false,
|
||||
type: 'dateTime',
|
||||
default: '',
|
||||
dateTime: {
|
||||
displayAs: 'standard',
|
||||
format: 'dateOnly',
|
||||
},
|
||||
validation: {
|
||||
defaultLanguage: 'en-US',
|
||||
descriptions: [
|
||||
{
|
||||
languageTag: 'en-US',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Person',
|
||||
'@odata.etag': '"0"',
|
||||
columnGroup: 'Custom Columns',
|
||||
description: 'Description Person',
|
||||
enforceUniqueValues: false,
|
||||
eTag: '"0"',
|
||||
hidden: false,
|
||||
id: '574f4483-ec83-41a0-b772-67b331695c56',
|
||||
indexed: false,
|
||||
isDeletable: true,
|
||||
isReorderable: true,
|
||||
isSealed: false,
|
||||
propagateChanges: false,
|
||||
name: 'person',
|
||||
readOnly: false,
|
||||
type: 'user',
|
||||
default: '',
|
||||
personOrGroup: {
|
||||
allowMultipleSelection: false,
|
||||
displayAs: 'nameWithPresence',
|
||||
format: 'peopleOnly',
|
||||
hasPrefix: false,
|
||||
noLookupFieldHeader: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Number',
|
||||
'@odata.etag': '"2"',
|
||||
columnGroup: 'Custom Columns',
|
||||
description: 'Description Number',
|
||||
enforceUniqueValues: false,
|
||||
eTag: '"2"',
|
||||
hidden: false,
|
||||
id: 'c69c2fc9-b6fd-4a08-8750-a293b7c888a3',
|
||||
indexed: false,
|
||||
isDeletable: true,
|
||||
isReorderable: true,
|
||||
isSealed: false,
|
||||
propagateChanges: false,
|
||||
name: 'number',
|
||||
readOnly: false,
|
||||
type: 'number',
|
||||
default: 0,
|
||||
number: {
|
||||
decimalPlaces: 'automatic',
|
||||
displayAs: 'number',
|
||||
maximum: 1.7976931348623157e308,
|
||||
minimum: -1.7976931348623157e308,
|
||||
},
|
||||
validation: {
|
||||
defaultLanguage: 'en-US',
|
||||
descriptions: [
|
||||
{
|
||||
languageTag: 'en-US',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Bool',
|
||||
'@odata.etag': '"0"',
|
||||
columnGroup: 'Custom Columns',
|
||||
description: 'Whether Description Bool',
|
||||
enforceUniqueValues: false,
|
||||
eTag: '"0"',
|
||||
hidden: false,
|
||||
id: '955880c3-8c95-4609-93ef-cdbd2deef1b2',
|
||||
indexed: false,
|
||||
isDeletable: true,
|
||||
isReorderable: true,
|
||||
isSealed: false,
|
||||
propagateChanges: false,
|
||||
name: 'bool',
|
||||
readOnly: false,
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
boolean: {},
|
||||
defaultValue: {
|
||||
value: '1',
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Hyperlink',
|
||||
'@odata.etag': '"2"',
|
||||
columnGroup: 'Custom Columns',
|
||||
description: 'Description Hyperlink',
|
||||
enforceUniqueValues: false,
|
||||
eTag: '"2"',
|
||||
hidden: false,
|
||||
id: 'a6352b41-95e7-4cbf-9184-aae4fe92d865',
|
||||
indexed: false,
|
||||
isDeletable: true,
|
||||
isReorderable: true,
|
||||
isSealed: false,
|
||||
propagateChanges: false,
|
||||
name: 'hyperlink',
|
||||
readOnly: false,
|
||||
type: 'url',
|
||||
default: '',
|
||||
hyperlinkOrPicture: {
|
||||
isPicture: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Currency',
|
||||
'@odata.etag': '"0"',
|
||||
columnGroup: 'Custom Columns',
|
||||
description: 'Description Currency',
|
||||
enforceUniqueValues: false,
|
||||
eTag: '"0"',
|
||||
hidden: false,
|
||||
id: '40d9b8f9-05e0-4105-bc35-0c969eeb0096',
|
||||
indexed: false,
|
||||
isDeletable: true,
|
||||
isReorderable: true,
|
||||
isSealed: false,
|
||||
propagateChanges: false,
|
||||
name: 'currency',
|
||||
readOnly: false,
|
||||
type: 'currency',
|
||||
default: '',
|
||||
currency: {
|
||||
decimalPlaces: 'automatic',
|
||||
displayAs: 'number',
|
||||
locale: 'en-US',
|
||||
maximum: 1.7976931348623157e308,
|
||||
minimum: -1.7976931348623157e308,
|
||||
},
|
||||
validation: {
|
||||
defaultLanguage: 'en-US',
|
||||
descriptions: [
|
||||
{
|
||||
languageTag: 'en-US',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Location',
|
||||
'@odata.etag': '"0"',
|
||||
columnGroup: 'Custom Columns',
|
||||
description: 'Description Location',
|
||||
enforceUniqueValues: false,
|
||||
eTag: '"0"',
|
||||
hidden: false,
|
||||
id: '5bfb0a2c-04ed-4a59-ae6e-de0d97c8352b',
|
||||
indexed: false,
|
||||
isDeletable: true,
|
||||
isReorderable: true,
|
||||
isSealed: false,
|
||||
propagateChanges: false,
|
||||
name: 'location',
|
||||
readOnly: false,
|
||||
type: 'location',
|
||||
default: '',
|
||||
location: {},
|
||||
},
|
||||
{
|
||||
displayName: 'location: Country/Region',
|
||||
'@odata.etag': '"0"',
|
||||
columnGroup: 'Custom Columns',
|
||||
description: 'Description Location: Country/Region',
|
||||
enforceUniqueValues: false,
|
||||
eTag: '"0"',
|
||||
hidden: false,
|
||||
id: 'db61a63e-558b-4e41-b895-2da2f40a7a23',
|
||||
indexed: false,
|
||||
isDeletable: true,
|
||||
isReorderable: false,
|
||||
isSealed: true,
|
||||
propagateChanges: false,
|
||||
name: 'CountryOrRegion',
|
||||
readOnly: true,
|
||||
type: 'text',
|
||||
default: '',
|
||||
text: {
|
||||
allowMultipleLines: false,
|
||||
appendChangesToExistingText: false,
|
||||
autoHyperLink: false,
|
||||
linesForEditing: 0,
|
||||
maxLength: 255,
|
||||
},
|
||||
validation: {
|
||||
defaultLanguage: 'en-US',
|
||||
descriptions: [
|
||||
{
|
||||
languageTag: 'en-US',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'location: State',
|
||||
'@odata.etag': '"0"',
|
||||
columnGroup: 'Custom Columns',
|
||||
description: 'Description Location: State',
|
||||
enforceUniqueValues: false,
|
||||
eTag: '"0"',
|
||||
hidden: false,
|
||||
id: 'c24ae779-ee80-4e8c-b291-c716f1fdce66',
|
||||
indexed: false,
|
||||
isDeletable: true,
|
||||
isReorderable: false,
|
||||
isSealed: true,
|
||||
propagateChanges: false,
|
||||
name: 'State',
|
||||
readOnly: true,
|
||||
type: 'text',
|
||||
default: '',
|
||||
text: {
|
||||
allowMultipleLines: false,
|
||||
appendChangesToExistingText: false,
|
||||
autoHyperLink: false,
|
||||
linesForEditing: 0,
|
||||
maxLength: 255,
|
||||
},
|
||||
validation: {
|
||||
defaultLanguage: 'en-US',
|
||||
descriptions: [
|
||||
{
|
||||
languageTag: 'en-US',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'location: City',
|
||||
'@odata.etag': '"0"',
|
||||
columnGroup: 'Custom Columns',
|
||||
description: 'Description Location: City',
|
||||
enforceUniqueValues: false,
|
||||
eTag: '"0"',
|
||||
hidden: false,
|
||||
id: '7fb3c8e7-8a8c-4488-a768-4db6922b53f4',
|
||||
indexed: false,
|
||||
isDeletable: true,
|
||||
isReorderable: false,
|
||||
isSealed: true,
|
||||
propagateChanges: false,
|
||||
name: 'City',
|
||||
readOnly: true,
|
||||
type: 'text',
|
||||
default: '',
|
||||
text: {
|
||||
allowMultipleLines: false,
|
||||
appendChangesToExistingText: false,
|
||||
autoHyperLink: false,
|
||||
linesForEditing: 0,
|
||||
maxLength: 255,
|
||||
},
|
||||
validation: {
|
||||
defaultLanguage: 'en-US',
|
||||
descriptions: [
|
||||
{
|
||||
languageTag: 'en-US',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'location: Postal Code',
|
||||
'@odata.etag': '"0"',
|
||||
columnGroup: 'Custom Columns',
|
||||
description: 'Description Location: Postal Code',
|
||||
enforceUniqueValues: false,
|
||||
eTag: '"0"',
|
||||
hidden: false,
|
||||
id: '1fa93efa-579f-48cb-b1e3-f2a8fdb615fe',
|
||||
indexed: false,
|
||||
isDeletable: true,
|
||||
isReorderable: false,
|
||||
isSealed: true,
|
||||
propagateChanges: false,
|
||||
name: 'PostalCode',
|
||||
readOnly: true,
|
||||
type: 'text',
|
||||
default: '',
|
||||
text: {
|
||||
allowMultipleLines: false,
|
||||
appendChangesToExistingText: false,
|
||||
autoHyperLink: false,
|
||||
linesForEditing: 0,
|
||||
maxLength: 255,
|
||||
},
|
||||
validation: {
|
||||
defaultLanguage: 'en-US',
|
||||
descriptions: [
|
||||
{
|
||||
languageTag: 'en-US',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'location: Street',
|
||||
'@odata.etag': '"0"',
|
||||
columnGroup: 'Custom Columns',
|
||||
description: 'Description Location: Street',
|
||||
enforceUniqueValues: false,
|
||||
eTag: '"0"',
|
||||
hidden: false,
|
||||
id: '1ce8048e-a619-40fb-86b2-c5963c0a7526',
|
||||
indexed: false,
|
||||
isDeletable: true,
|
||||
isReorderable: false,
|
||||
isSealed: true,
|
||||
propagateChanges: false,
|
||||
name: 'Street',
|
||||
readOnly: true,
|
||||
type: 'text',
|
||||
default: '',
|
||||
text: {
|
||||
allowMultipleLines: false,
|
||||
appendChangesToExistingText: false,
|
||||
autoHyperLink: false,
|
||||
linesForEditing: 0,
|
||||
maxLength: 255,
|
||||
},
|
||||
validation: {
|
||||
defaultLanguage: 'en-US',
|
||||
descriptions: [
|
||||
{
|
||||
languageTag: 'en-US',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'location: Coordinates',
|
||||
'@odata.etag': '"0"',
|
||||
columnGroup: 'Custom Columns',
|
||||
description: 'Description Location: Coordinates',
|
||||
enforceUniqueValues: false,
|
||||
eTag: '"0"',
|
||||
hidden: false,
|
||||
id: '079b0670-2a3d-4a71-abe5-c0023a66879d',
|
||||
indexed: false,
|
||||
isDeletable: true,
|
||||
isReorderable: false,
|
||||
isSealed: true,
|
||||
propagateChanges: false,
|
||||
name: 'GeoLoc',
|
||||
readOnly: true,
|
||||
type: 'geolocation',
|
||||
default: '',
|
||||
geolocation: {},
|
||||
},
|
||||
{
|
||||
displayName: 'location: Name',
|
||||
'@odata.etag': '"0"',
|
||||
columnGroup: 'Custom Columns',
|
||||
description: 'Description Location: Name',
|
||||
enforceUniqueValues: false,
|
||||
eTag: '"0"',
|
||||
hidden: false,
|
||||
id: '73a8bcce-484b-4fd6-84be-47ef648c9c45',
|
||||
indexed: false,
|
||||
isDeletable: true,
|
||||
isReorderable: false,
|
||||
isSealed: true,
|
||||
propagateChanges: false,
|
||||
name: 'DispName',
|
||||
readOnly: true,
|
||||
type: 'text',
|
||||
default: '',
|
||||
text: {
|
||||
allowMultipleLines: false,
|
||||
appendChangesToExistingText: false,
|
||||
autoHyperLink: false,
|
||||
linesForEditing: 0,
|
||||
maxLength: 255,
|
||||
},
|
||||
validation: {
|
||||
defaultLanguage: 'en-US',
|
||||
descriptions: [
|
||||
{
|
||||
languageTag: 'en-US',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Image',
|
||||
'@odata.etag': '"0"',
|
||||
columnGroup: 'Custom Columns',
|
||||
description: 'Description Location: Image',
|
||||
enforceUniqueValues: false,
|
||||
eTag: '"0"',
|
||||
hidden: false,
|
||||
id: '2a485bec-bab9-493b-9214-2be0b8566a25',
|
||||
indexed: false,
|
||||
isDeletable: true,
|
||||
isReorderable: true,
|
||||
isSealed: false,
|
||||
propagateChanges: false,
|
||||
name: 'image',
|
||||
readOnly: false,
|
||||
type: 'thumbnail',
|
||||
default: '',
|
||||
thumbnail: {},
|
||||
},
|
||||
{
|
||||
displayName: 'Metadata',
|
||||
'@odata.etag': '"2"',
|
||||
columnGroup: 'Custom Columns',
|
||||
customFormatter: '',
|
||||
description: 'Description Location: Metadata',
|
||||
enforceUniqueValues: false,
|
||||
eTag: '"2"',
|
||||
hidden: false,
|
||||
id: '2d8cb8ec-4a8f-43ae-87fa-e832b4631f0d',
|
||||
indexed: false,
|
||||
isDeletable: true,
|
||||
isReorderable: true,
|
||||
isSealed: false,
|
||||
propagateChanges: false,
|
||||
name: 'metadata',
|
||||
readOnly: false,
|
||||
staticName: 'metadata',
|
||||
type: 'term',
|
||||
default: '',
|
||||
defaultValue: {
|
||||
value: '',
|
||||
},
|
||||
term: {
|
||||
allowMultipleValues: false,
|
||||
showFullyQualifiedName: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Lookup',
|
||||
'@odata.etag': '"2"',
|
||||
columnGroup: 'Custom Columns',
|
||||
description: 'Description Lookup',
|
||||
enforceUniqueValues: false,
|
||||
eTag: '"2"',
|
||||
hidden: false,
|
||||
id: '44bdab3a-ac89-4b40-acfd-707510f93719',
|
||||
indexed: false,
|
||||
isDeletable: true,
|
||||
isReorderable: true,
|
||||
isSealed: false,
|
||||
propagateChanges: false,
|
||||
name: 'lookup',
|
||||
readOnly: false,
|
||||
type: 'lookup',
|
||||
default: '',
|
||||
lookup: {
|
||||
allowMultipleValues: false,
|
||||
allowUnlimitedLength: false,
|
||||
columnName: 'Title',
|
||||
displayFormUrl:
|
||||
'https://mydomain.sharepoint.com/sites/n8ntest10/_layouts/15/listform.aspx?PageType=4&ListId=58a279af-1f06-4392-a5ed-2b37fa1d6c1d',
|
||||
listId: '58a279af-1f06-4392-a5ed-2b37fa1d6c1d',
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Rating (0-5)',
|
||||
'@odata.etag': '"1"',
|
||||
columnGroup: 'Content Feedback',
|
||||
description: 'Average value of all the ratings that have been submitted',
|
||||
enforceUniqueValues: false,
|
||||
eTag: '"1"',
|
||||
hidden: false,
|
||||
id: '5a14d1ab-1513-48c7-97b3-657a5ba6c742',
|
||||
indexed: false,
|
||||
isDeletable: true,
|
||||
isReorderable: true,
|
||||
isSealed: false,
|
||||
propagateChanges: false,
|
||||
name: 'AverageRating',
|
||||
readOnly: false,
|
||||
type: 'unknownFutureValue',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Number of Ratings',
|
||||
'@odata.etag': '"0"',
|
||||
columnGroup: 'Content Feedback',
|
||||
description: 'Number of ratings submitted',
|
||||
enforceUniqueValues: false,
|
||||
eTag: '"0"',
|
||||
hidden: false,
|
||||
id: 'b1996002-9167-45e5-a4df-b2c41c6723c7',
|
||||
indexed: false,
|
||||
isDeletable: true,
|
||||
isReorderable: true,
|
||||
isSealed: false,
|
||||
propagateChanges: false,
|
||||
name: 'RatingCount',
|
||||
readOnly: false,
|
||||
type: 'unknownFutureValue',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Number of Likes',
|
||||
'@odata.etag': '"1"',
|
||||
columnGroup: 'Content Feedback',
|
||||
description: 'Description Number of Likes',
|
||||
enforceUniqueValues: false,
|
||||
eTag: '"1"',
|
||||
hidden: false,
|
||||
id: '6e4d832b-f610-41a8-b3e0-239608efda41',
|
||||
indexed: false,
|
||||
isDeletable: true,
|
||||
isReorderable: true,
|
||||
isSealed: false,
|
||||
propagateChanges: false,
|
||||
name: 'LikesCount',
|
||||
readOnly: false,
|
||||
type: 'unknownFutureValue',
|
||||
default: '',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
loadOptionsFunctions.helpers.httpRequestWithAuthentication = jest
|
||||
.fn()
|
||||
.mockReturnValue(mockResponse);
|
||||
|
||||
const fields = await getMappingColumns.call(loadOptionsFunctions);
|
||||
|
||||
expect(fields).toEqual({
|
||||
fields: [
|
||||
{
|
||||
id: 'Title',
|
||||
canBeUsedToMatch: true,
|
||||
defaultMatch: false,
|
||||
display: true,
|
||||
displayName: 'Title',
|
||||
readOnly: false,
|
||||
required: true,
|
||||
type: 'string',
|
||||
},
|
||||
{
|
||||
id: 'choice',
|
||||
canBeUsedToMatch: false,
|
||||
defaultMatch: false,
|
||||
display: true,
|
||||
displayName: 'Choice',
|
||||
readOnly: false,
|
||||
required: undefined,
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'Choice 1',
|
||||
value: 'Choice 1',
|
||||
},
|
||||
{
|
||||
name: 'Choice 2',
|
||||
value: 'Choice 2',
|
||||
},
|
||||
{
|
||||
name: 'Choice 3',
|
||||
value: 'Choice 3',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 'datetime',
|
||||
canBeUsedToMatch: false,
|
||||
defaultMatch: false,
|
||||
display: true,
|
||||
displayName: 'Datetime',
|
||||
readOnly: false,
|
||||
required: undefined,
|
||||
type: 'dateTime',
|
||||
},
|
||||
{
|
||||
id: 'person',
|
||||
canBeUsedToMatch: false,
|
||||
defaultMatch: false,
|
||||
display: true,
|
||||
displayName: 'Person',
|
||||
readOnly: false,
|
||||
required: undefined,
|
||||
type: 'string',
|
||||
},
|
||||
{
|
||||
id: 'number',
|
||||
canBeUsedToMatch: false,
|
||||
defaultMatch: false,
|
||||
display: true,
|
||||
displayName: 'Number',
|
||||
readOnly: false,
|
||||
required: undefined,
|
||||
type: 'number',
|
||||
},
|
||||
{
|
||||
id: 'bool',
|
||||
canBeUsedToMatch: false,
|
||||
defaultMatch: false,
|
||||
display: true,
|
||||
displayName: 'Bool',
|
||||
readOnly: false,
|
||||
required: undefined,
|
||||
type: 'boolean',
|
||||
},
|
||||
{
|
||||
id: 'hyperlink',
|
||||
canBeUsedToMatch: false,
|
||||
defaultMatch: false,
|
||||
display: true,
|
||||
displayName: 'Hyperlink',
|
||||
readOnly: true,
|
||||
required: undefined,
|
||||
type: undefined,
|
||||
},
|
||||
{
|
||||
id: 'currency',
|
||||
canBeUsedToMatch: false,
|
||||
defaultMatch: false,
|
||||
display: true,
|
||||
displayName: 'Currency',
|
||||
readOnly: false,
|
||||
required: undefined,
|
||||
type: 'number',
|
||||
},
|
||||
{
|
||||
id: 'location',
|
||||
canBeUsedToMatch: false,
|
||||
defaultMatch: false,
|
||||
display: true,
|
||||
displayName: 'Location',
|
||||
readOnly: true,
|
||||
required: undefined,
|
||||
type: undefined,
|
||||
},
|
||||
{
|
||||
id: 'image',
|
||||
canBeUsedToMatch: false,
|
||||
defaultMatch: false,
|
||||
display: true,
|
||||
displayName: 'Image',
|
||||
readOnly: false,
|
||||
required: undefined,
|
||||
type: 'object',
|
||||
},
|
||||
{
|
||||
id: 'metadata',
|
||||
canBeUsedToMatch: false,
|
||||
defaultMatch: false,
|
||||
display: true,
|
||||
displayName: 'Metadata',
|
||||
readOnly: true,
|
||||
required: undefined,
|
||||
type: undefined,
|
||||
},
|
||||
{
|
||||
id: 'lookup',
|
||||
canBeUsedToMatch: false,
|
||||
defaultMatch: false,
|
||||
display: true,
|
||||
displayName: 'Lookup',
|
||||
readOnly: false,
|
||||
required: undefined,
|
||||
type: 'string',
|
||||
},
|
||||
{
|
||||
id: 'AverageRating',
|
||||
canBeUsedToMatch: false,
|
||||
defaultMatch: false,
|
||||
display: true,
|
||||
displayName: 'Rating (0-5)',
|
||||
readOnly: false,
|
||||
required: undefined,
|
||||
type: 'number',
|
||||
},
|
||||
{
|
||||
id: 'RatingCount',
|
||||
canBeUsedToMatch: false,
|
||||
defaultMatch: false,
|
||||
display: true,
|
||||
displayName: 'Number of Ratings',
|
||||
readOnly: false,
|
||||
required: undefined,
|
||||
type: 'number',
|
||||
},
|
||||
{
|
||||
id: 'LikesCount',
|
||||
canBeUsedToMatch: false,
|
||||
defaultMatch: false,
|
||||
display: true,
|
||||
displayName: 'Number of Likes',
|
||||
readOnly: false,
|
||||
required: undefined,
|
||||
type: 'number',
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it('should map columns with id for update', async () => {
|
||||
loadOptionsFunctions.getCredentials.mockResolvedValue({});
|
||||
loadOptionsFunctions.getNodeParameter.mockReturnValueOnce('site');
|
||||
loadOptionsFunctions.getNodeParameter.mockReturnValueOnce('list');
|
||||
loadOptionsFunctions.getNodeParameter.mockReturnValueOnce('update');
|
||||
const mockResponse = {
|
||||
value: [
|
||||
{
|
||||
columns: [],
|
||||
},
|
||||
],
|
||||
};
|
||||
loadOptionsFunctions.helpers.httpRequestWithAuthentication = jest
|
||||
.fn()
|
||||
.mockReturnValue(mockResponse);
|
||||
|
||||
const fields = await getMappingColumns.call(loadOptionsFunctions);
|
||||
|
||||
expect(fields).toEqual({
|
||||
fields: [
|
||||
{
|
||||
id: 'id',
|
||||
canBeUsedToMatch: true,
|
||||
defaultMatch: false,
|
||||
display: true,
|
||||
displayName: 'ID',
|
||||
readOnly: true,
|
||||
required: true,
|
||||
type: 'string',
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user