mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
refactor: Overhaul nodes-testing setup - Part 1 (no-changelog) (#14303)
This commit is contained in:
committed by
GitHub
parent
f85b851851
commit
73e8d76e13
@@ -1,6 +1,6 @@
|
||||
import type { IHttpRequestMethods } from 'n8n-workflow';
|
||||
import nock from 'nock';
|
||||
|
||||
import { equalityTest, setup, workflowToTests } from '@test/nodes/Helpers';
|
||||
import { testWorkflows } from '@test/nodes/Helpers';
|
||||
|
||||
const API_RESPONSE = {
|
||||
object: 'list',
|
||||
@@ -411,24 +411,11 @@ const API_RESPONSE = {
|
||||
request_id: '33358f1b-fc4d-4387-8d95-43c7d03519a5',
|
||||
};
|
||||
|
||||
jest.mock('../../../../shared/GenericFunctions', () => {
|
||||
const originalModule = jest.requireActual('../../../../shared/GenericFunctions');
|
||||
return {
|
||||
...originalModule,
|
||||
notionApiRequest: jest.fn(async function (method: IHttpRequestMethods) {
|
||||
if (method === 'PATCH') {
|
||||
return API_RESPONSE;
|
||||
}
|
||||
}),
|
||||
};
|
||||
});
|
||||
|
||||
describe('Test NotionV2, block => append', () => {
|
||||
const workflows = ['nodes/Notion/test/node/v2/block/append.workflow.json'];
|
||||
const tests = workflowToTests(workflows);
|
||||
const nodeTypes = setup(tests);
|
||||
nock('https://api.notion.com')
|
||||
.patch('/v1/blocks/90e03468f8aa457695da02ccad963040/children')
|
||||
.reply(200, API_RESPONSE);
|
||||
|
||||
for (const testData of tests) {
|
||||
test(testData.description, async () => await equalityTest(testData, nodeTypes));
|
||||
}
|
||||
const workflows = ['nodes/Notion/test/node/v2/block/append.workflow.json'];
|
||||
testWorkflows(workflows);
|
||||
});
|
||||
|
||||
@@ -1,230 +1,220 @@
|
||||
import type { IHttpRequestMethods } from 'n8n-workflow';
|
||||
import nock from 'nock';
|
||||
|
||||
import { equalityTest, setup, workflowToTests } from '@test/nodes/Helpers';
|
||||
import { testWorkflows } from '@test/nodes/Helpers';
|
||||
|
||||
const API_RESPONSE = [
|
||||
{
|
||||
object: 'block',
|
||||
id: 'b14bdaaf-b7e9-48c9-a7fa-1b9e1e2092ae',
|
||||
parent: {
|
||||
type: 'block_id',
|
||||
block_id: '90e03468-f8aa-4576-95da-02ccad963040',
|
||||
},
|
||||
created_time: '2023-11-23T10:42:00.000Z',
|
||||
last_edited_time: '2024-12-13T03:35:00.000Z',
|
||||
created_by: {
|
||||
object: 'user',
|
||||
id: '88f72c1a-07ed-4bae-9fa0-231365d813d9',
|
||||
},
|
||||
last_edited_by: {
|
||||
object: 'user',
|
||||
id: '88f72c1a-07ed-4bae-9fa0-231365d813d9',
|
||||
},
|
||||
has_children: true,
|
||||
archived: false,
|
||||
in_trash: false,
|
||||
type: 'toggle',
|
||||
toggle: {
|
||||
color: 'default',
|
||||
text: [
|
||||
{
|
||||
type: 'text',
|
||||
text: {
|
||||
content: 'Drop down First',
|
||||
link: null,
|
||||
const API_RESPONSE = {
|
||||
results: [
|
||||
{
|
||||
object: 'block',
|
||||
id: 'b14bdaaf-b7e9-48c9-a7fa-1b9e1e2092ae',
|
||||
parent: {
|
||||
type: 'block_id',
|
||||
block_id: '90e03468-f8aa-4576-95da-02ccad963040',
|
||||
},
|
||||
created_time: '2023-11-23T10:42:00.000Z',
|
||||
last_edited_time: '2024-12-13T03:35:00.000Z',
|
||||
created_by: {
|
||||
object: 'user',
|
||||
id: '88f72c1a-07ed-4bae-9fa0-231365d813d9',
|
||||
},
|
||||
last_edited_by: {
|
||||
object: 'user',
|
||||
id: '88f72c1a-07ed-4bae-9fa0-231365d813d9',
|
||||
},
|
||||
has_children: true,
|
||||
archived: false,
|
||||
in_trash: false,
|
||||
type: 'toggle',
|
||||
toggle: {
|
||||
color: 'default',
|
||||
text: [
|
||||
{
|
||||
type: 'text',
|
||||
text: {
|
||||
content: 'Drop down First',
|
||||
link: null,
|
||||
},
|
||||
annotations: {
|
||||
bold: false,
|
||||
italic: false,
|
||||
strikethrough: false,
|
||||
underline: false,
|
||||
code: false,
|
||||
color: 'default',
|
||||
},
|
||||
plain_text: 'Drop down First',
|
||||
href: null,
|
||||
},
|
||||
annotations: {
|
||||
bold: false,
|
||||
italic: false,
|
||||
strikethrough: false,
|
||||
underline: false,
|
||||
code: false,
|
||||
color: 'default',
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
object: 'block',
|
||||
id: 'de572f5d-ff5c-4c13-a879-efc20fe47db0',
|
||||
parent: {
|
||||
type: 'block_id',
|
||||
block_id: '90e03468-f8aa-4576-95da-02ccad963040',
|
||||
},
|
||||
created_time: '2023-11-23T10:42:00.000Z',
|
||||
last_edited_time: '2024-03-11T12:39:00.000Z',
|
||||
created_by: {
|
||||
object: 'user',
|
||||
id: '88f72c1a-07ed-4bae-9fa0-231365d813d9',
|
||||
},
|
||||
last_edited_by: {
|
||||
object: 'user',
|
||||
id: 'f215e49c-4677-40c0-9adc-87440d341324',
|
||||
},
|
||||
has_children: true,
|
||||
archived: false,
|
||||
in_trash: false,
|
||||
type: 'bulleted_list_item',
|
||||
bulleted_list_item: {
|
||||
color: 'default',
|
||||
text: [
|
||||
{
|
||||
type: 'text',
|
||||
text: {
|
||||
content: 'Bullet Point Second',
|
||||
link: null,
|
||||
},
|
||||
annotations: {
|
||||
bold: false,
|
||||
italic: false,
|
||||
strikethrough: false,
|
||||
underline: false,
|
||||
code: false,
|
||||
color: 'default',
|
||||
},
|
||||
plain_text: 'Bullet Point Second',
|
||||
href: null,
|
||||
},
|
||||
plain_text: 'Drop down First',
|
||||
href: null,
|
||||
},
|
||||
],
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
object: 'block',
|
||||
id: 'de572f5d-ff5c-4c13-a879-efc20fe47db0',
|
||||
parent: {
|
||||
type: 'block_id',
|
||||
block_id: '90e03468-f8aa-4576-95da-02ccad963040',
|
||||
},
|
||||
created_time: '2023-11-23T10:42:00.000Z',
|
||||
last_edited_time: '2024-03-11T12:39:00.000Z',
|
||||
created_by: {
|
||||
object: 'user',
|
||||
id: '88f72c1a-07ed-4bae-9fa0-231365d813d9',
|
||||
},
|
||||
last_edited_by: {
|
||||
object: 'user',
|
||||
id: 'f215e49c-4677-40c0-9adc-87440d341324',
|
||||
},
|
||||
has_children: true,
|
||||
archived: false,
|
||||
in_trash: false,
|
||||
type: 'bulleted_list_item',
|
||||
bulleted_list_item: {
|
||||
color: 'default',
|
||||
text: [
|
||||
{
|
||||
type: 'text',
|
||||
text: {
|
||||
content: 'Bullet Point Second',
|
||||
link: null,
|
||||
{
|
||||
object: 'block',
|
||||
id: 'c98cf981-c967-47f5-9948-4aa1be9ce9d0',
|
||||
parent: {
|
||||
type: 'block_id',
|
||||
block_id: '90e03468-f8aa-4576-95da-02ccad963040',
|
||||
},
|
||||
created_time: '2023-11-24T04:41:00.000Z',
|
||||
last_edited_time: '2024-12-13T03:35:00.000Z',
|
||||
created_by: {
|
||||
object: 'user',
|
||||
id: '88f72c1a-07ed-4bae-9fa0-231365d813d9',
|
||||
},
|
||||
last_edited_by: {
|
||||
object: 'user',
|
||||
id: '88f72c1a-07ed-4bae-9fa0-231365d813d9',
|
||||
},
|
||||
has_children: false,
|
||||
archived: false,
|
||||
in_trash: false,
|
||||
type: 'heading_2',
|
||||
heading_2: {
|
||||
is_toggleable: false,
|
||||
color: 'default',
|
||||
text: [
|
||||
{
|
||||
type: 'text',
|
||||
text: {
|
||||
content: 'Hello World',
|
||||
link: null,
|
||||
},
|
||||
annotations: {
|
||||
bold: false,
|
||||
italic: false,
|
||||
strikethrough: false,
|
||||
underline: false,
|
||||
code: false,
|
||||
color: 'default',
|
||||
},
|
||||
plain_text: 'Hello World',
|
||||
href: null,
|
||||
},
|
||||
annotations: {
|
||||
bold: false,
|
||||
italic: false,
|
||||
strikethrough: false,
|
||||
underline: false,
|
||||
code: false,
|
||||
color: 'default',
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
object: 'block',
|
||||
id: '527a0555-a486-401e-93a8-19819615c132',
|
||||
parent: {
|
||||
type: 'block_id',
|
||||
block_id: '90e03468-f8aa-4576-95da-02ccad963040',
|
||||
},
|
||||
created_time: '2023-11-23T10:42:00.000Z',
|
||||
last_edited_time: '2023-11-23T10:43:00.000Z',
|
||||
created_by: {
|
||||
object: 'user',
|
||||
id: '88f72c1a-07ed-4bae-9fa0-231365d813d9',
|
||||
},
|
||||
last_edited_by: {
|
||||
object: 'user',
|
||||
id: '88f72c1a-07ed-4bae-9fa0-231365d813d9',
|
||||
},
|
||||
has_children: false,
|
||||
archived: false,
|
||||
in_trash: false,
|
||||
type: 'child_page',
|
||||
child_page: {
|
||||
title: 'Page Third',
|
||||
},
|
||||
},
|
||||
{
|
||||
object: 'block',
|
||||
id: '15bfb9cb-4cf0-81b1-a6f1-eac377c4d163',
|
||||
parent: {
|
||||
type: 'block_id',
|
||||
block_id: '90e03468-f8aa-4576-95da-02ccad963040',
|
||||
},
|
||||
created_time: '2024-12-13T03:40:00.000Z',
|
||||
last_edited_time: '2024-12-13T06:15:00.000Z',
|
||||
created_by: {
|
||||
object: 'user',
|
||||
id: 'f215e49c-4677-40c0-9adc-87440d341324',
|
||||
},
|
||||
last_edited_by: {
|
||||
object: 'user',
|
||||
id: '88f72c1a-07ed-4bae-9fa0-231365d813d9',
|
||||
},
|
||||
has_children: false,
|
||||
archived: false,
|
||||
in_trash: false,
|
||||
type: 'paragraph',
|
||||
paragraph: {
|
||||
color: 'default',
|
||||
text: [
|
||||
{
|
||||
type: 'text',
|
||||
text: {
|
||||
content: '',
|
||||
link: null,
|
||||
},
|
||||
annotations: {
|
||||
bold: false,
|
||||
italic: false,
|
||||
strikethrough: false,
|
||||
underline: false,
|
||||
code: false,
|
||||
color: 'default',
|
||||
},
|
||||
plain_text: '',
|
||||
href: null,
|
||||
},
|
||||
plain_text: 'Bullet Point Second',
|
||||
href: null,
|
||||
},
|
||||
],
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
object: 'block',
|
||||
id: 'c98cf981-c967-47f5-9948-4aa1be9ce9d0',
|
||||
parent: {
|
||||
type: 'block_id',
|
||||
block_id: '90e03468-f8aa-4576-95da-02ccad963040',
|
||||
},
|
||||
created_time: '2023-11-24T04:41:00.000Z',
|
||||
last_edited_time: '2024-12-13T03:35:00.000Z',
|
||||
created_by: {
|
||||
object: 'user',
|
||||
id: '88f72c1a-07ed-4bae-9fa0-231365d813d9',
|
||||
},
|
||||
last_edited_by: {
|
||||
object: 'user',
|
||||
id: '88f72c1a-07ed-4bae-9fa0-231365d813d9',
|
||||
},
|
||||
has_children: false,
|
||||
archived: false,
|
||||
in_trash: false,
|
||||
type: 'heading_2',
|
||||
heading_2: {
|
||||
is_toggleable: false,
|
||||
color: 'default',
|
||||
text: [
|
||||
{
|
||||
type: 'text',
|
||||
text: {
|
||||
content: 'Hello World',
|
||||
link: null,
|
||||
},
|
||||
annotations: {
|
||||
bold: false,
|
||||
italic: false,
|
||||
strikethrough: false,
|
||||
underline: false,
|
||||
code: false,
|
||||
color: 'default',
|
||||
},
|
||||
plain_text: 'Hello World',
|
||||
href: null,
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
object: 'block',
|
||||
id: '527a0555-a486-401e-93a8-19819615c132',
|
||||
parent: {
|
||||
type: 'block_id',
|
||||
block_id: '90e03468-f8aa-4576-95da-02ccad963040',
|
||||
},
|
||||
created_time: '2023-11-23T10:42:00.000Z',
|
||||
last_edited_time: '2023-11-23T10:43:00.000Z',
|
||||
created_by: {
|
||||
object: 'user',
|
||||
id: '88f72c1a-07ed-4bae-9fa0-231365d813d9',
|
||||
},
|
||||
last_edited_by: {
|
||||
object: 'user',
|
||||
id: '88f72c1a-07ed-4bae-9fa0-231365d813d9',
|
||||
},
|
||||
has_children: false,
|
||||
archived: false,
|
||||
in_trash: false,
|
||||
type: 'child_page',
|
||||
child_page: {
|
||||
title: 'Page Third',
|
||||
},
|
||||
},
|
||||
{
|
||||
object: 'block',
|
||||
id: '15bfb9cb-4cf0-81b1-a6f1-eac377c4d163',
|
||||
parent: {
|
||||
type: 'block_id',
|
||||
block_id: '90e03468-f8aa-4576-95da-02ccad963040',
|
||||
},
|
||||
created_time: '2024-12-13T03:40:00.000Z',
|
||||
last_edited_time: '2024-12-13T06:15:00.000Z',
|
||||
created_by: {
|
||||
object: 'user',
|
||||
id: 'f215e49c-4677-40c0-9adc-87440d341324',
|
||||
},
|
||||
last_edited_by: {
|
||||
object: 'user',
|
||||
id: '88f72c1a-07ed-4bae-9fa0-231365d813d9',
|
||||
},
|
||||
has_children: false,
|
||||
archived: false,
|
||||
in_trash: false,
|
||||
type: 'paragraph',
|
||||
paragraph: {
|
||||
color: 'default',
|
||||
text: [
|
||||
{
|
||||
type: 'text',
|
||||
text: {
|
||||
content: '',
|
||||
link: null,
|
||||
},
|
||||
annotations: {
|
||||
bold: false,
|
||||
italic: false,
|
||||
strikethrough: false,
|
||||
underline: false,
|
||||
code: false,
|
||||
color: 'default',
|
||||
},
|
||||
plain_text: '',
|
||||
href: null,
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
jest.mock('../../../../shared/GenericFunctions', () => {
|
||||
const originalModule = jest.requireActual('../../../../shared/GenericFunctions');
|
||||
return {
|
||||
...originalModule,
|
||||
notionApiRequestAllItems: jest.fn(async function (_: string, method: IHttpRequestMethods) {
|
||||
if (method === 'GET') {
|
||||
return API_RESPONSE;
|
||||
}
|
||||
}),
|
||||
};
|
||||
});
|
||||
],
|
||||
has_more: false,
|
||||
};
|
||||
|
||||
describe('Test NotionV2, block => getAll', () => {
|
||||
const workflows = ['nodes/Notion/test/node/v2/block/getAll.workflow.json'];
|
||||
const tests = workflowToTests(workflows);
|
||||
const nodeTypes = setup(tests);
|
||||
nock('https://api.notion.com')
|
||||
.get('/v1/blocks/90e03468f8aa457695da02ccad963040/children')
|
||||
.reply(200, API_RESPONSE);
|
||||
|
||||
for (const testData of tests) {
|
||||
test(testData.description, async () => await equalityTest(testData, nodeTypes));
|
||||
}
|
||||
const workflows = ['nodes/Notion/test/node/v2/block/getAll.workflow.json'];
|
||||
testWorkflows(workflows);
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { IHttpRequestMethods } from 'n8n-workflow';
|
||||
import nock from 'nock';
|
||||
|
||||
import { equalityTest, setup, workflowToTests } from '@test/nodes/Helpers';
|
||||
import { testWorkflows } from '@test/nodes/Helpers';
|
||||
|
||||
const API_RESPONSE = {
|
||||
object: 'database',
|
||||
@@ -65,24 +65,11 @@ const API_RESPONSE = {
|
||||
request_id: 'd22a9046-be0d-4ef5-b551-8691da552d47',
|
||||
};
|
||||
|
||||
jest.mock('../../../../shared/GenericFunctions', () => {
|
||||
const originalModule = jest.requireActual('../../../../shared/GenericFunctions');
|
||||
return {
|
||||
...originalModule,
|
||||
notionApiRequest: jest.fn(async function (method: IHttpRequestMethods) {
|
||||
if (method === 'GET') {
|
||||
return API_RESPONSE;
|
||||
}
|
||||
}),
|
||||
};
|
||||
});
|
||||
|
||||
describe('Test NotionV2, database => get', () => {
|
||||
const workflows = ['nodes/Notion/test/node/v2/database/get.workflow.json'];
|
||||
const tests = workflowToTests(workflows);
|
||||
const nodeTypes = setup(tests);
|
||||
nock('https://api.notion.com')
|
||||
.get('/v1/databases/138fb9cb-4cf0-804c-8663-d8ecdd5e692f')
|
||||
.reply(200, API_RESPONSE);
|
||||
|
||||
for (const testData of tests) {
|
||||
test(testData.description, async () => await equalityTest(testData, nodeTypes));
|
||||
}
|
||||
const workflows = ['nodes/Notion/test/node/v2/database/get.workflow.json'];
|
||||
testWorkflows(workflows);
|
||||
});
|
||||
|
||||
@@ -1,329 +1,319 @@
|
||||
import type { IHttpRequestMethods } from 'n8n-workflow';
|
||||
import nock from 'nock';
|
||||
|
||||
import { equalityTest, setup, workflowToTests } from '@test/nodes/Helpers';
|
||||
import { testWorkflows } from '@test/nodes/Helpers';
|
||||
|
||||
const API_RESPONSE = [
|
||||
{
|
||||
object: 'database',
|
||||
id: '138fb9cb-4cf0-804c-8663-d8ecdd5e692f',
|
||||
cover: null,
|
||||
icon: null,
|
||||
created_time: '2024-11-08T07:59:00.000Z',
|
||||
created_by: {
|
||||
object: 'user',
|
||||
id: '88f72c1a-07ed-4bae-9fa0-231365d813d9',
|
||||
const API_RESPONSE = {
|
||||
results: [
|
||||
{
|
||||
object: 'database',
|
||||
id: '138fb9cb-4cf0-804c-8663-d8ecdd5e692f',
|
||||
cover: null,
|
||||
icon: null,
|
||||
created_time: '2024-11-08T07:59:00.000Z',
|
||||
created_by: {
|
||||
object: 'user',
|
||||
id: '88f72c1a-07ed-4bae-9fa0-231365d813d9',
|
||||
},
|
||||
last_edited_by: {
|
||||
object: 'user',
|
||||
id: '88f72c1a-07ed-4bae-9fa0-231365d813d9',
|
||||
},
|
||||
last_edited_time: '2024-11-08T07:59:00.000Z',
|
||||
title: [
|
||||
{
|
||||
type: 'text',
|
||||
text: {
|
||||
content: 'TEST_DB',
|
||||
link: null,
|
||||
},
|
||||
annotations: {
|
||||
bold: false,
|
||||
italic: false,
|
||||
strikethrough: false,
|
||||
underline: false,
|
||||
code: false,
|
||||
color: 'default',
|
||||
},
|
||||
plain_text: 'TEST_DB',
|
||||
href: null,
|
||||
},
|
||||
],
|
||||
description: [],
|
||||
is_inline: false,
|
||||
properties: {
|
||||
Tags: {
|
||||
id: '%40~Tp',
|
||||
name: 'Tags',
|
||||
type: 'multi_select',
|
||||
multi_select: {
|
||||
options: [],
|
||||
},
|
||||
},
|
||||
Name: {
|
||||
id: 'title',
|
||||
name: 'Name',
|
||||
type: 'title',
|
||||
title: {},
|
||||
},
|
||||
},
|
||||
parent: {
|
||||
type: 'page_id',
|
||||
page_id: 'cc3d2b3c-f31a-4773-ab39-17a60c54567a',
|
||||
},
|
||||
url: 'https://www.notion.so/138fb9cb4cf0804c8663d8ecdd5e692f',
|
||||
public_url: null,
|
||||
archived: false,
|
||||
in_trash: false,
|
||||
},
|
||||
last_edited_by: {
|
||||
object: 'user',
|
||||
id: '88f72c1a-07ed-4bae-9fa0-231365d813d9',
|
||||
{
|
||||
object: 'database',
|
||||
id: 'f7216195-e0d4-46cd-a2d3-587a05baf472',
|
||||
cover: null,
|
||||
icon: null,
|
||||
created_time: '2022-03-07T11:25:00.000Z',
|
||||
created_by: {
|
||||
object: 'user',
|
||||
id: '88f72c1a-07ed-4bae-9fa0-231365d813d9',
|
||||
},
|
||||
last_edited_by: {
|
||||
object: 'user',
|
||||
id: '88f72c1a-07ed-4bae-9fa0-231365d813d9',
|
||||
},
|
||||
last_edited_time: '2024-11-08T07:54:00.000Z',
|
||||
title: [
|
||||
{
|
||||
type: 'text',
|
||||
text: {
|
||||
content: 'ListDatabase',
|
||||
link: null,
|
||||
},
|
||||
annotations: {
|
||||
bold: false,
|
||||
italic: false,
|
||||
strikethrough: false,
|
||||
underline: false,
|
||||
code: false,
|
||||
color: 'default',
|
||||
},
|
||||
plain_text: 'ListDatabase',
|
||||
href: null,
|
||||
},
|
||||
],
|
||||
description: [],
|
||||
is_inline: false,
|
||||
properties: {
|
||||
Email: {
|
||||
id: 'Fitu',
|
||||
name: 'Email',
|
||||
type: 'email',
|
||||
email: {},
|
||||
},
|
||||
'Last edited by': {
|
||||
id: 'XZ~H',
|
||||
name: 'Last edited by',
|
||||
type: 'last_edited_by',
|
||||
last_edited_by: {},
|
||||
},
|
||||
Tags: {
|
||||
id: 'a%7BRG',
|
||||
name: 'Tags',
|
||||
type: 'multi_select',
|
||||
multi_select: {
|
||||
options: [],
|
||||
},
|
||||
},
|
||||
Created: {
|
||||
id: 'eqq~',
|
||||
name: 'Created',
|
||||
type: 'created_time',
|
||||
created_time: {},
|
||||
},
|
||||
Status: {
|
||||
id: 'nZEQ',
|
||||
name: 'Status',
|
||||
type: 'status',
|
||||
status: {
|
||||
options: [
|
||||
{
|
||||
id: '70312bf9-84d5-40e6-b1eb-d71798ee556f',
|
||||
name: 'Not started',
|
||||
color: 'default',
|
||||
description: null,
|
||||
},
|
||||
{
|
||||
id: '02a6bb40-3f4b-47d6-818d-6a4129cc6091',
|
||||
name: 'In progress',
|
||||
color: 'gray',
|
||||
description: null,
|
||||
},
|
||||
{
|
||||
id: 'a3c13d01-63b2-4571-8a02-8c1801649af7',
|
||||
name: 'Done',
|
||||
color: 'green',
|
||||
description: null,
|
||||
},
|
||||
],
|
||||
groups: [
|
||||
{
|
||||
id: '82e2022c-001d-47ac-a8b8-243ef7fac352',
|
||||
name: 'To-do',
|
||||
color: 'gray',
|
||||
option_ids: ['70312bf9-84d5-40e6-b1eb-d71798ee556f'],
|
||||
},
|
||||
{
|
||||
id: '296000d7-287e-4121-9445-98fa8f7de298',
|
||||
name: 'In progress',
|
||||
color: 'blue',
|
||||
option_ids: ['02a6bb40-3f4b-47d6-818d-6a4129cc6091'],
|
||||
},
|
||||
{
|
||||
id: 'db7689ae-127d-4218-8b3c-306e59e02070',
|
||||
name: 'Complete',
|
||||
color: 'green',
|
||||
option_ids: ['a3c13d01-63b2-4571-8a02-8c1801649af7'],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
Name: {
|
||||
id: 'title',
|
||||
name: 'Name',
|
||||
type: 'title',
|
||||
title: {},
|
||||
},
|
||||
},
|
||||
parent: {
|
||||
type: 'page_id',
|
||||
page_id: 'cc3d2b3c-f31a-4773-ab39-17a60c54567a',
|
||||
},
|
||||
url: 'https://www.notion.so/f7216195e0d446cda2d3587a05baf472',
|
||||
public_url: 'https://pleasant-halloumi-63e.notion.site/f7216195e0d446cda2d3587a05baf472',
|
||||
archived: false,
|
||||
in_trash: false,
|
||||
},
|
||||
last_edited_time: '2024-11-08T07:59:00.000Z',
|
||||
title: [
|
||||
{
|
||||
type: 'text',
|
||||
text: {
|
||||
content: 'TEST_DB',
|
||||
link: null,
|
||||
},
|
||||
annotations: {
|
||||
bold: false,
|
||||
italic: false,
|
||||
strikethrough: false,
|
||||
underline: false,
|
||||
code: false,
|
||||
color: 'default',
|
||||
},
|
||||
plain_text: 'TEST_DB',
|
||||
href: null,
|
||||
{
|
||||
object: 'database',
|
||||
id: 'e9c354e3-e506-4c42-83e2-d9c81a083f05',
|
||||
cover: null,
|
||||
icon: null,
|
||||
created_time: '2022-03-07T11:05:00.000Z',
|
||||
created_by: {
|
||||
object: 'user',
|
||||
id: '88f72c1a-07ed-4bae-9fa0-231365d813d9',
|
||||
},
|
||||
],
|
||||
description: [],
|
||||
is_inline: false,
|
||||
properties: {
|
||||
Tags: {
|
||||
id: '%40~Tp',
|
||||
name: 'Tags',
|
||||
type: 'multi_select',
|
||||
multi_select: {
|
||||
options: [],
|
||||
last_edited_by: {
|
||||
object: 'user',
|
||||
id: '88f72c1a-07ed-4bae-9fa0-231365d813d9',
|
||||
},
|
||||
last_edited_time: '2023-09-29T08:00:00.000Z',
|
||||
title: [
|
||||
{
|
||||
type: 'text',
|
||||
text: {
|
||||
content: 'n8n-trigger',
|
||||
link: null,
|
||||
},
|
||||
annotations: {
|
||||
bold: false,
|
||||
italic: false,
|
||||
strikethrough: false,
|
||||
underline: false,
|
||||
code: false,
|
||||
color: 'default',
|
||||
},
|
||||
plain_text: 'n8n-trigger',
|
||||
href: null,
|
||||
},
|
||||
],
|
||||
description: [],
|
||||
is_inline: false,
|
||||
properties: {
|
||||
Total: {
|
||||
id: 'A%3DdW',
|
||||
name: 'Total',
|
||||
type: 'formula',
|
||||
formula: {
|
||||
expression:
|
||||
'((({{notion:block_property:n%7DI%5E:00000000-0000-0000-0000-000000000000:fe91914e-2dc5-4510-82f8-399dd9b2daf8}} + {{notion:block_property:MH~%3B:00000000-0000-0000-0000-000000000000:fe91914e-2dc5-4510-82f8-399dd9b2daf8}}) - {{notion:block_property:MwMd:00000000-0000-0000-0000-000000000000:fe91914e-2dc5-4510-82f8-399dd9b2daf8}}) + {{notion:block_property:fJea:00000000-0000-0000-0000-000000000000:fe91914e-2dc5-4510-82f8-399dd9b2daf8}}) - {{notion:block_property:rSrM:00000000-0000-0000-0000-000000000000:fe91914e-2dc5-4510-82f8-399dd9b2daf8}}',
|
||||
},
|
||||
},
|
||||
'Total Incomes': {
|
||||
id: 'MH~%3B',
|
||||
name: 'Total Incomes',
|
||||
type: 'number',
|
||||
number: {
|
||||
format: 'number',
|
||||
},
|
||||
},
|
||||
'Total Expenses': {
|
||||
id: 'MwMd',
|
||||
name: 'Total Expenses',
|
||||
type: 'number',
|
||||
number: {
|
||||
format: 'number',
|
||||
},
|
||||
},
|
||||
'Created time': {
|
||||
id: 'Z%3BGM',
|
||||
name: 'Created time',
|
||||
type: 'created_time',
|
||||
created_time: {},
|
||||
},
|
||||
'Last edited time': {
|
||||
id: '%60%5ElG',
|
||||
name: 'Last edited time',
|
||||
type: 'last_edited_time',
|
||||
last_edited_time: {},
|
||||
},
|
||||
'Total Transfer-In': {
|
||||
id: 'fJea',
|
||||
name: 'Total Transfer-In',
|
||||
type: 'number',
|
||||
number: {
|
||||
format: 'number',
|
||||
},
|
||||
},
|
||||
'Starting Balance': {
|
||||
id: 'n%7DI%5E',
|
||||
name: 'Starting Balance',
|
||||
type: 'number',
|
||||
number: {
|
||||
format: 'number',
|
||||
},
|
||||
},
|
||||
'Total Transfer-Out': {
|
||||
id: 'rSrM',
|
||||
name: 'Total Transfer-Out',
|
||||
type: 'number',
|
||||
number: {
|
||||
format: 'number',
|
||||
},
|
||||
},
|
||||
Name: {
|
||||
id: 'title',
|
||||
name: 'Name',
|
||||
type: 'title',
|
||||
title: {},
|
||||
},
|
||||
},
|
||||
Name: {
|
||||
id: 'title',
|
||||
name: 'Name',
|
||||
type: 'title',
|
||||
title: {},
|
||||
parent: {
|
||||
type: 'page_id',
|
||||
page_id: 'cc3d2b3c-f31a-4773-ab39-17a60c54567a',
|
||||
},
|
||||
url: 'https://www.notion.so/e9c354e3e5064c4283e2d9c81a083f05',
|
||||
public_url: null,
|
||||
archived: false,
|
||||
in_trash: false,
|
||||
},
|
||||
parent: {
|
||||
type: 'page_id',
|
||||
page_id: 'cc3d2b3c-f31a-4773-ab39-17a60c54567a',
|
||||
},
|
||||
url: 'https://www.notion.so/138fb9cb4cf0804c8663d8ecdd5e692f',
|
||||
public_url: null,
|
||||
archived: false,
|
||||
in_trash: false,
|
||||
},
|
||||
{
|
||||
object: 'database',
|
||||
id: 'f7216195-e0d4-46cd-a2d3-587a05baf472',
|
||||
cover: null,
|
||||
icon: null,
|
||||
created_time: '2022-03-07T11:25:00.000Z',
|
||||
created_by: {
|
||||
object: 'user',
|
||||
id: '88f72c1a-07ed-4bae-9fa0-231365d813d9',
|
||||
},
|
||||
last_edited_by: {
|
||||
object: 'user',
|
||||
id: '88f72c1a-07ed-4bae-9fa0-231365d813d9',
|
||||
},
|
||||
last_edited_time: '2024-11-08T07:54:00.000Z',
|
||||
title: [
|
||||
{
|
||||
type: 'text',
|
||||
text: {
|
||||
content: 'ListDatabase',
|
||||
link: null,
|
||||
},
|
||||
annotations: {
|
||||
bold: false,
|
||||
italic: false,
|
||||
strikethrough: false,
|
||||
underline: false,
|
||||
code: false,
|
||||
color: 'default',
|
||||
},
|
||||
plain_text: 'ListDatabase',
|
||||
href: null,
|
||||
},
|
||||
],
|
||||
description: [],
|
||||
is_inline: false,
|
||||
properties: {
|
||||
Email: {
|
||||
id: 'Fitu',
|
||||
name: 'Email',
|
||||
type: 'email',
|
||||
email: {},
|
||||
},
|
||||
'Last edited by': {
|
||||
id: 'XZ~H',
|
||||
name: 'Last edited by',
|
||||
type: 'last_edited_by',
|
||||
last_edited_by: {},
|
||||
},
|
||||
Tags: {
|
||||
id: 'a%7BRG',
|
||||
name: 'Tags',
|
||||
type: 'multi_select',
|
||||
multi_select: {
|
||||
options: [],
|
||||
},
|
||||
},
|
||||
Created: {
|
||||
id: 'eqq~',
|
||||
name: 'Created',
|
||||
type: 'created_time',
|
||||
created_time: {},
|
||||
},
|
||||
Status: {
|
||||
id: 'nZEQ',
|
||||
name: 'Status',
|
||||
type: 'status',
|
||||
status: {
|
||||
options: [
|
||||
{
|
||||
id: '70312bf9-84d5-40e6-b1eb-d71798ee556f',
|
||||
name: 'Not started',
|
||||
color: 'default',
|
||||
description: null,
|
||||
},
|
||||
{
|
||||
id: '02a6bb40-3f4b-47d6-818d-6a4129cc6091',
|
||||
name: 'In progress',
|
||||
color: 'gray',
|
||||
description: null,
|
||||
},
|
||||
{
|
||||
id: 'a3c13d01-63b2-4571-8a02-8c1801649af7',
|
||||
name: 'Done',
|
||||
color: 'green',
|
||||
description: null,
|
||||
},
|
||||
],
|
||||
groups: [
|
||||
{
|
||||
id: '82e2022c-001d-47ac-a8b8-243ef7fac352',
|
||||
name: 'To-do',
|
||||
color: 'gray',
|
||||
option_ids: ['70312bf9-84d5-40e6-b1eb-d71798ee556f'],
|
||||
},
|
||||
{
|
||||
id: '296000d7-287e-4121-9445-98fa8f7de298',
|
||||
name: 'In progress',
|
||||
color: 'blue',
|
||||
option_ids: ['02a6bb40-3f4b-47d6-818d-6a4129cc6091'],
|
||||
},
|
||||
{
|
||||
id: 'db7689ae-127d-4218-8b3c-306e59e02070',
|
||||
name: 'Complete',
|
||||
color: 'green',
|
||||
option_ids: ['a3c13d01-63b2-4571-8a02-8c1801649af7'],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
Name: {
|
||||
id: 'title',
|
||||
name: 'Name',
|
||||
type: 'title',
|
||||
title: {},
|
||||
},
|
||||
},
|
||||
parent: {
|
||||
type: 'page_id',
|
||||
page_id: 'cc3d2b3c-f31a-4773-ab39-17a60c54567a',
|
||||
},
|
||||
url: 'https://www.notion.so/f7216195e0d446cda2d3587a05baf472',
|
||||
public_url: 'https://pleasant-halloumi-63e.notion.site/f7216195e0d446cda2d3587a05baf472',
|
||||
archived: false,
|
||||
in_trash: false,
|
||||
},
|
||||
{
|
||||
object: 'database',
|
||||
id: 'e9c354e3-e506-4c42-83e2-d9c81a083f05',
|
||||
cover: null,
|
||||
icon: null,
|
||||
created_time: '2022-03-07T11:05:00.000Z',
|
||||
created_by: {
|
||||
object: 'user',
|
||||
id: '88f72c1a-07ed-4bae-9fa0-231365d813d9',
|
||||
},
|
||||
last_edited_by: {
|
||||
object: 'user',
|
||||
id: '88f72c1a-07ed-4bae-9fa0-231365d813d9',
|
||||
},
|
||||
last_edited_time: '2023-09-29T08:00:00.000Z',
|
||||
title: [
|
||||
{
|
||||
type: 'text',
|
||||
text: {
|
||||
content: 'n8n-trigger',
|
||||
link: null,
|
||||
},
|
||||
annotations: {
|
||||
bold: false,
|
||||
italic: false,
|
||||
strikethrough: false,
|
||||
underline: false,
|
||||
code: false,
|
||||
color: 'default',
|
||||
},
|
||||
plain_text: 'n8n-trigger',
|
||||
href: null,
|
||||
},
|
||||
],
|
||||
description: [],
|
||||
is_inline: false,
|
||||
properties: {
|
||||
Total: {
|
||||
id: 'A%3DdW',
|
||||
name: 'Total',
|
||||
type: 'formula',
|
||||
formula: {
|
||||
expression:
|
||||
'((({{notion:block_property:n%7DI%5E:00000000-0000-0000-0000-000000000000:fe91914e-2dc5-4510-82f8-399dd9b2daf8}} + {{notion:block_property:MH~%3B:00000000-0000-0000-0000-000000000000:fe91914e-2dc5-4510-82f8-399dd9b2daf8}}) - {{notion:block_property:MwMd:00000000-0000-0000-0000-000000000000:fe91914e-2dc5-4510-82f8-399dd9b2daf8}}) + {{notion:block_property:fJea:00000000-0000-0000-0000-000000000000:fe91914e-2dc5-4510-82f8-399dd9b2daf8}}) - {{notion:block_property:rSrM:00000000-0000-0000-0000-000000000000:fe91914e-2dc5-4510-82f8-399dd9b2daf8}}',
|
||||
},
|
||||
},
|
||||
'Total Incomes': {
|
||||
id: 'MH~%3B',
|
||||
name: 'Total Incomes',
|
||||
type: 'number',
|
||||
number: {
|
||||
format: 'number',
|
||||
},
|
||||
},
|
||||
'Total Expenses': {
|
||||
id: 'MwMd',
|
||||
name: 'Total Expenses',
|
||||
type: 'number',
|
||||
number: {
|
||||
format: 'number',
|
||||
},
|
||||
},
|
||||
'Created time': {
|
||||
id: 'Z%3BGM',
|
||||
name: 'Created time',
|
||||
type: 'created_time',
|
||||
created_time: {},
|
||||
},
|
||||
'Last edited time': {
|
||||
id: '%60%5ElG',
|
||||
name: 'Last edited time',
|
||||
type: 'last_edited_time',
|
||||
last_edited_time: {},
|
||||
},
|
||||
'Total Transfer-In': {
|
||||
id: 'fJea',
|
||||
name: 'Total Transfer-In',
|
||||
type: 'number',
|
||||
number: {
|
||||
format: 'number',
|
||||
},
|
||||
},
|
||||
'Starting Balance': {
|
||||
id: 'n%7DI%5E',
|
||||
name: 'Starting Balance',
|
||||
type: 'number',
|
||||
number: {
|
||||
format: 'number',
|
||||
},
|
||||
},
|
||||
'Total Transfer-Out': {
|
||||
id: 'rSrM',
|
||||
name: 'Total Transfer-Out',
|
||||
type: 'number',
|
||||
number: {
|
||||
format: 'number',
|
||||
},
|
||||
},
|
||||
Name: {
|
||||
id: 'title',
|
||||
name: 'Name',
|
||||
type: 'title',
|
||||
title: {},
|
||||
},
|
||||
},
|
||||
parent: {
|
||||
type: 'page_id',
|
||||
page_id: 'cc3d2b3c-f31a-4773-ab39-17a60c54567a',
|
||||
},
|
||||
url: 'https://www.notion.so/e9c354e3e5064c4283e2d9c81a083f05',
|
||||
public_url: null,
|
||||
archived: false,
|
||||
in_trash: false,
|
||||
},
|
||||
];
|
||||
|
||||
jest.mock('../../../../shared/GenericFunctions', () => {
|
||||
const originalModule = jest.requireActual('../../../../shared/GenericFunctions');
|
||||
return {
|
||||
...originalModule,
|
||||
notionApiRequestAllItems: jest.fn(async function (_: string, method: IHttpRequestMethods) {
|
||||
if (method === 'POST') {
|
||||
return API_RESPONSE;
|
||||
}
|
||||
}),
|
||||
};
|
||||
});
|
||||
],
|
||||
has_more: false,
|
||||
};
|
||||
|
||||
describe('Test NotionV2, database => getAll', () => {
|
||||
const workflows = ['nodes/Notion/test/node/v2/database/getAll.workflow.json'];
|
||||
const tests = workflowToTests(workflows);
|
||||
const nodeTypes = setup(tests);
|
||||
nock('https://api.notion.com')
|
||||
.post('/v1/search', { filter: { property: 'object', value: 'database' } })
|
||||
.reply(200, API_RESPONSE);
|
||||
|
||||
for (const testData of tests) {
|
||||
test(testData.description, async () => await equalityTest(testData, nodeTypes));
|
||||
}
|
||||
const workflows = ['nodes/Notion/test/node/v2/database/getAll.workflow.json'];
|
||||
testWorkflows(workflows);
|
||||
});
|
||||
|
||||
@@ -1,203 +1,197 @@
|
||||
import type { IHttpRequestMethods } from 'n8n-workflow';
|
||||
import nock from 'nock';
|
||||
|
||||
import { equalityTest, setup, workflowToTests } from '@test/nodes/Helpers';
|
||||
import { testWorkflows } from '@test/nodes/Helpers';
|
||||
|
||||
const API_RESPONSE = [
|
||||
{
|
||||
object: 'database',
|
||||
id: 'e9c354e3-e506-4c42-83e2-d9c81a083f05',
|
||||
cover: null,
|
||||
icon: null,
|
||||
created_time: '2022-03-07T11:05:00.000Z',
|
||||
created_by: {
|
||||
object: 'user',
|
||||
id: '88f72c1a-07ed-4bae-9fa0-231365d813d9',
|
||||
const API_RESPONSE = {
|
||||
results: [
|
||||
{
|
||||
object: 'database',
|
||||
id: 'e9c354e3-e506-4c42-83e2-d9c81a083f05',
|
||||
cover: null,
|
||||
icon: null,
|
||||
created_time: '2022-03-07T11:05:00.000Z',
|
||||
created_by: {
|
||||
object: 'user',
|
||||
id: '88f72c1a-07ed-4bae-9fa0-231365d813d9',
|
||||
},
|
||||
last_edited_by: {
|
||||
object: 'user',
|
||||
id: '88f72c1a-07ed-4bae-9fa0-231365d813d9',
|
||||
},
|
||||
last_edited_time: '2023-09-29T08:00:00.000Z',
|
||||
title: [
|
||||
{
|
||||
type: 'text',
|
||||
text: {
|
||||
content: 'n8n-trigger',
|
||||
link: null,
|
||||
},
|
||||
annotations: {
|
||||
bold: false,
|
||||
italic: false,
|
||||
strikethrough: false,
|
||||
underline: false,
|
||||
code: false,
|
||||
color: 'default',
|
||||
},
|
||||
plain_text: 'n8n-trigger',
|
||||
href: null,
|
||||
},
|
||||
],
|
||||
description: [],
|
||||
is_inline: false,
|
||||
properties: {
|
||||
Total: {
|
||||
id: 'A%3DdW',
|
||||
name: 'Total',
|
||||
type: 'formula',
|
||||
formula: {
|
||||
expression:
|
||||
'((({{notion:block_property:n%7DI%5E:00000000-0000-0000-0000-000000000000:fe91914e-2dc5-4510-82f8-399dd9b2daf8}} + {{notion:block_property:MH~%3B:00000000-0000-0000-0000-000000000000:fe91914e-2dc5-4510-82f8-399dd9b2daf8}}) - {{notion:block_property:MwMd:00000000-0000-0000-0000-000000000000:fe91914e-2dc5-4510-82f8-399dd9b2daf8}}) + {{notion:block_property:fJea:00000000-0000-0000-0000-000000000000:fe91914e-2dc5-4510-82f8-399dd9b2daf8}}) - {{notion:block_property:rSrM:00000000-0000-0000-0000-000000000000:fe91914e-2dc5-4510-82f8-399dd9b2daf8}}',
|
||||
},
|
||||
},
|
||||
'Total Incomes': {
|
||||
id: 'MH~%3B',
|
||||
name: 'Total Incomes',
|
||||
type: 'number',
|
||||
number: {
|
||||
format: 'number',
|
||||
},
|
||||
},
|
||||
'Total Expenses': {
|
||||
id: 'MwMd',
|
||||
name: 'Total Expenses',
|
||||
type: 'number',
|
||||
number: {
|
||||
format: 'number',
|
||||
},
|
||||
},
|
||||
'Created time': {
|
||||
id: 'Z%3BGM',
|
||||
name: 'Created time',
|
||||
type: 'created_time',
|
||||
created_time: {},
|
||||
},
|
||||
'Last edited time': {
|
||||
id: '%60%5ElG',
|
||||
name: 'Last edited time',
|
||||
type: 'last_edited_time',
|
||||
last_edited_time: {},
|
||||
},
|
||||
'Total Transfer-In': {
|
||||
id: 'fJea',
|
||||
name: 'Total Transfer-In',
|
||||
type: 'number',
|
||||
number: {
|
||||
format: 'number',
|
||||
},
|
||||
},
|
||||
'Starting Balance': {
|
||||
id: 'n%7DI%5E',
|
||||
name: 'Starting Balance',
|
||||
type: 'number',
|
||||
number: {
|
||||
format: 'number',
|
||||
},
|
||||
},
|
||||
'Total Transfer-Out': {
|
||||
id: 'rSrM',
|
||||
name: 'Total Transfer-Out',
|
||||
type: 'number',
|
||||
number: {
|
||||
format: 'number',
|
||||
},
|
||||
},
|
||||
Name: {
|
||||
id: 'title',
|
||||
name: 'Name',
|
||||
type: 'title',
|
||||
title: {},
|
||||
},
|
||||
},
|
||||
parent: {
|
||||
type: 'page_id',
|
||||
page_id: 'cc3d2b3c-f31a-4773-ab39-17a60c54567a',
|
||||
},
|
||||
url: 'https://www.notion.so/e9c354e3e5064c4283e2d9c81a083f05',
|
||||
public_url: null,
|
||||
archived: false,
|
||||
in_trash: false,
|
||||
},
|
||||
last_edited_by: {
|
||||
object: 'user',
|
||||
id: '88f72c1a-07ed-4bae-9fa0-231365d813d9',
|
||||
{
|
||||
object: 'database',
|
||||
id: '138fb9cb-4cf0-804c-8663-d8ecdd5e692f',
|
||||
cover: null,
|
||||
icon: null,
|
||||
created_time: '2024-11-08T07:59:00.000Z',
|
||||
created_by: {
|
||||
object: 'user',
|
||||
id: '88f72c1a-07ed-4bae-9fa0-231365d813d9',
|
||||
},
|
||||
last_edited_by: {
|
||||
object: 'user',
|
||||
id: '88f72c1a-07ed-4bae-9fa0-231365d813d9',
|
||||
},
|
||||
last_edited_time: '2024-11-08T07:59:00.000Z',
|
||||
title: [
|
||||
{
|
||||
type: 'text',
|
||||
text: {
|
||||
content: 'TEST_DB',
|
||||
link: null,
|
||||
},
|
||||
annotations: {
|
||||
bold: false,
|
||||
italic: false,
|
||||
strikethrough: false,
|
||||
underline: false,
|
||||
code: false,
|
||||
color: 'default',
|
||||
},
|
||||
plain_text: 'TEST_DB',
|
||||
href: null,
|
||||
},
|
||||
],
|
||||
description: [],
|
||||
is_inline: false,
|
||||
properties: {
|
||||
Tags: {
|
||||
id: '%40~Tp',
|
||||
name: 'Tags',
|
||||
type: 'multi_select',
|
||||
multi_select: {
|
||||
options: [],
|
||||
},
|
||||
},
|
||||
Name: {
|
||||
id: 'title',
|
||||
name: 'Name',
|
||||
type: 'title',
|
||||
title: {},
|
||||
},
|
||||
},
|
||||
parent: {
|
||||
type: 'page_id',
|
||||
page_id: 'cc3d2b3c-f31a-4773-ab39-17a60c54567a',
|
||||
},
|
||||
url: 'https://www.notion.so/138fb9cb4cf0804c8663d8ecdd5e692f',
|
||||
public_url: null,
|
||||
archived: false,
|
||||
in_trash: false,
|
||||
},
|
||||
last_edited_time: '2023-09-29T08:00:00.000Z',
|
||||
title: [
|
||||
{
|
||||
type: 'text',
|
||||
text: {
|
||||
content: 'n8n-trigger',
|
||||
link: null,
|
||||
},
|
||||
annotations: {
|
||||
bold: false,
|
||||
italic: false,
|
||||
strikethrough: false,
|
||||
underline: false,
|
||||
code: false,
|
||||
color: 'default',
|
||||
},
|
||||
plain_text: 'n8n-trigger',
|
||||
href: null,
|
||||
},
|
||||
],
|
||||
description: [],
|
||||
is_inline: false,
|
||||
properties: {
|
||||
Total: {
|
||||
id: 'A%3DdW',
|
||||
name: 'Total',
|
||||
type: 'formula',
|
||||
formula: {
|
||||
expression:
|
||||
'((({{notion:block_property:n%7DI%5E:00000000-0000-0000-0000-000000000000:fe91914e-2dc5-4510-82f8-399dd9b2daf8}} + {{notion:block_property:MH~%3B:00000000-0000-0000-0000-000000000000:fe91914e-2dc5-4510-82f8-399dd9b2daf8}}) - {{notion:block_property:MwMd:00000000-0000-0000-0000-000000000000:fe91914e-2dc5-4510-82f8-399dd9b2daf8}}) + {{notion:block_property:fJea:00000000-0000-0000-0000-000000000000:fe91914e-2dc5-4510-82f8-399dd9b2daf8}}) - {{notion:block_property:rSrM:00000000-0000-0000-0000-000000000000:fe91914e-2dc5-4510-82f8-399dd9b2daf8}}',
|
||||
},
|
||||
},
|
||||
'Total Incomes': {
|
||||
id: 'MH~%3B',
|
||||
name: 'Total Incomes',
|
||||
type: 'number',
|
||||
number: {
|
||||
format: 'number',
|
||||
},
|
||||
},
|
||||
'Total Expenses': {
|
||||
id: 'MwMd',
|
||||
name: 'Total Expenses',
|
||||
type: 'number',
|
||||
number: {
|
||||
format: 'number',
|
||||
},
|
||||
},
|
||||
'Created time': {
|
||||
id: 'Z%3BGM',
|
||||
name: 'Created time',
|
||||
type: 'created_time',
|
||||
created_time: {},
|
||||
},
|
||||
'Last edited time': {
|
||||
id: '%60%5ElG',
|
||||
name: 'Last edited time',
|
||||
type: 'last_edited_time',
|
||||
last_edited_time: {},
|
||||
},
|
||||
'Total Transfer-In': {
|
||||
id: 'fJea',
|
||||
name: 'Total Transfer-In',
|
||||
type: 'number',
|
||||
number: {
|
||||
format: 'number',
|
||||
},
|
||||
},
|
||||
'Starting Balance': {
|
||||
id: 'n%7DI%5E',
|
||||
name: 'Starting Balance',
|
||||
type: 'number',
|
||||
number: {
|
||||
format: 'number',
|
||||
},
|
||||
},
|
||||
'Total Transfer-Out': {
|
||||
id: 'rSrM',
|
||||
name: 'Total Transfer-Out',
|
||||
type: 'number',
|
||||
number: {
|
||||
format: 'number',
|
||||
},
|
||||
},
|
||||
Name: {
|
||||
id: 'title',
|
||||
name: 'Name',
|
||||
type: 'title',
|
||||
title: {},
|
||||
},
|
||||
},
|
||||
parent: {
|
||||
type: 'page_id',
|
||||
page_id: 'cc3d2b3c-f31a-4773-ab39-17a60c54567a',
|
||||
},
|
||||
url: 'https://www.notion.so/e9c354e3e5064c4283e2d9c81a083f05',
|
||||
public_url: null,
|
||||
archived: false,
|
||||
in_trash: false,
|
||||
},
|
||||
{
|
||||
object: 'database',
|
||||
id: '138fb9cb-4cf0-804c-8663-d8ecdd5e692f',
|
||||
cover: null,
|
||||
icon: null,
|
||||
created_time: '2024-11-08T07:59:00.000Z',
|
||||
created_by: {
|
||||
object: 'user',
|
||||
id: '88f72c1a-07ed-4bae-9fa0-231365d813d9',
|
||||
},
|
||||
last_edited_by: {
|
||||
object: 'user',
|
||||
id: '88f72c1a-07ed-4bae-9fa0-231365d813d9',
|
||||
},
|
||||
last_edited_time: '2024-11-08T07:59:00.000Z',
|
||||
title: [
|
||||
{
|
||||
type: 'text',
|
||||
text: {
|
||||
content: 'TEST_DB',
|
||||
link: null,
|
||||
},
|
||||
annotations: {
|
||||
bold: false,
|
||||
italic: false,
|
||||
strikethrough: false,
|
||||
underline: false,
|
||||
code: false,
|
||||
color: 'default',
|
||||
},
|
||||
plain_text: 'TEST_DB',
|
||||
href: null,
|
||||
},
|
||||
],
|
||||
description: [],
|
||||
is_inline: false,
|
||||
properties: {
|
||||
Tags: {
|
||||
id: '%40~Tp',
|
||||
name: 'Tags',
|
||||
type: 'multi_select',
|
||||
multi_select: {
|
||||
options: [],
|
||||
},
|
||||
},
|
||||
Name: {
|
||||
id: 'title',
|
||||
name: 'Name',
|
||||
type: 'title',
|
||||
title: {},
|
||||
},
|
||||
},
|
||||
parent: {
|
||||
type: 'page_id',
|
||||
page_id: 'cc3d2b3c-f31a-4773-ab39-17a60c54567a',
|
||||
},
|
||||
url: 'https://www.notion.so/138fb9cb4cf0804c8663d8ecdd5e692f',
|
||||
public_url: null,
|
||||
archived: false,
|
||||
in_trash: false,
|
||||
},
|
||||
];
|
||||
|
||||
jest.mock('../../../../shared/GenericFunctions', () => {
|
||||
const originalModule = jest.requireActual('../../../../shared/GenericFunctions');
|
||||
return {
|
||||
...originalModule,
|
||||
notionApiRequestAllItems: jest.fn(async function (_: string, method: IHttpRequestMethods) {
|
||||
if (method === 'POST') {
|
||||
return API_RESPONSE;
|
||||
}
|
||||
}),
|
||||
};
|
||||
});
|
||||
],
|
||||
has_more: false,
|
||||
};
|
||||
|
||||
describe('Test NotionV2, database => search', () => {
|
||||
const workflows = ['nodes/Notion/test/node/v2/database/search.workflow.json'];
|
||||
const tests = workflowToTests(workflows);
|
||||
const nodeTypes = setup(tests);
|
||||
nock('https://api.notion.com')
|
||||
.post('/v1/search', {
|
||||
filter: { property: 'object', value: 'database' },
|
||||
query: 't',
|
||||
sort: { direction: 'ascending', timestamp: 'last_edited_time' },
|
||||
})
|
||||
.reply(200, API_RESPONSE);
|
||||
|
||||
for (const testData of tests) {
|
||||
test(testData.description, async () => await equalityTest(testData, nodeTypes));
|
||||
}
|
||||
const workflows = ['nodes/Notion/test/node/v2/database/search.workflow.json'];
|
||||
testWorkflows(workflows);
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { IHttpRequestMethods } from 'n8n-workflow';
|
||||
import nock from 'nock';
|
||||
|
||||
import { equalityTest, setup, workflowToTests } from '@test/nodes/Helpers';
|
||||
import { testWorkflows } from '@test/nodes/Helpers';
|
||||
|
||||
const API_RESPONSE = {
|
||||
object: 'page',
|
||||
@@ -61,44 +61,46 @@ const API_RESPONSE = {
|
||||
request_id: '1416702d-daa8-4f8d-9be3-c55fe52486b5',
|
||||
};
|
||||
|
||||
jest.mock('../../../../shared/GenericFunctions', () => {
|
||||
const originalModule = jest.requireActual('../../../../shared/GenericFunctions');
|
||||
return {
|
||||
...originalModule,
|
||||
notionApiRequest: jest.fn(async function (method: IHttpRequestMethods) {
|
||||
if (method === 'GET') {
|
||||
return {
|
||||
properties: {
|
||||
Tags: {
|
||||
id: '%40~Tp',
|
||||
name: 'Tags',
|
||||
type: 'multi_select',
|
||||
multi_select: {
|
||||
options: [],
|
||||
},
|
||||
},
|
||||
Name: {
|
||||
id: 'title',
|
||||
name: 'Name',
|
||||
type: 'title',
|
||||
title: {},
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
if (method === 'POST') {
|
||||
return API_RESPONSE;
|
||||
}
|
||||
}),
|
||||
};
|
||||
});
|
||||
|
||||
describe('Test NotionV2, databasePage => create', () => {
|
||||
const workflows = ['nodes/Notion/test/node/v2/databasePage/create.workflow.json'];
|
||||
const tests = workflowToTests(workflows);
|
||||
const nodeTypes = setup(tests);
|
||||
nock('https://api.notion.com')
|
||||
.get('/v1/databases/138fb9cb-4cf0-804c-8663-d8ecdd5e692f')
|
||||
.reply(200, {
|
||||
properties: {
|
||||
Tags: {
|
||||
id: '%40~Tp',
|
||||
name: 'Tags',
|
||||
type: 'multi_select',
|
||||
multi_select: {
|
||||
options: [],
|
||||
},
|
||||
},
|
||||
Name: {
|
||||
id: 'title',
|
||||
name: 'Name',
|
||||
type: 'title',
|
||||
title: {},
|
||||
},
|
||||
},
|
||||
})
|
||||
.post('/v1/pages', {
|
||||
parent: { database_id: '138fb9cb-4cf0-804c-8663-d8ecdd5e692f' },
|
||||
properties: { Name: { title: [{ text: { content: 'new name 1' } }] } },
|
||||
children: [
|
||||
{
|
||||
object: 'block',
|
||||
type: 'paragraph',
|
||||
paragraph: { text: [{ text: { content: 'new text' } }] },
|
||||
},
|
||||
{
|
||||
object: 'block',
|
||||
type: 'toggle',
|
||||
toggle: { text: [{ text: { content: 'new toggle' } }] },
|
||||
},
|
||||
],
|
||||
icon: { emoji: '😗' },
|
||||
})
|
||||
.reply(200, API_RESPONSE);
|
||||
|
||||
for (const testData of tests) {
|
||||
test(testData.description, async () => await equalityTest(testData, nodeTypes));
|
||||
}
|
||||
const workflows = ['nodes/Notion/test/node/v2/databasePage/create.workflow.json'];
|
||||
testWorkflows(workflows);
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { IHttpRequestMethods } from 'n8n-workflow';
|
||||
import nock from 'nock';
|
||||
|
||||
import { equalityTest, setup, workflowToTests } from '@test/nodes/Helpers';
|
||||
import { testWorkflows } from '@test/nodes/Helpers';
|
||||
|
||||
const API_RESPONSE = {
|
||||
object: 'page',
|
||||
@@ -61,24 +61,11 @@ const API_RESPONSE = {
|
||||
request_id: 'c01d3a3e-d9c3-4e48-8d73-077a8503c3ba',
|
||||
};
|
||||
|
||||
jest.mock('../../../../shared/GenericFunctions', () => {
|
||||
const originalModule = jest.requireActual('../../../../shared/GenericFunctions');
|
||||
return {
|
||||
...originalModule,
|
||||
notionApiRequest: jest.fn(async function (method: IHttpRequestMethods) {
|
||||
if (method === 'GET') {
|
||||
return API_RESPONSE;
|
||||
}
|
||||
}),
|
||||
};
|
||||
});
|
||||
|
||||
describe('Test NotionV2, databasePage => get', () => {
|
||||
const workflows = ['nodes/Notion/test/node/v2/databasePage/get.workflow.json'];
|
||||
const tests = workflowToTests(workflows);
|
||||
const nodeTypes = setup(tests);
|
||||
nock('https://api.notion.com')
|
||||
.get('/v1/pages/15bfb9cb4cf081c7aab4c5855b8cb6c3')
|
||||
.reply(200, API_RESPONSE);
|
||||
|
||||
for (const testData of tests) {
|
||||
test(testData.description, async () => await equalityTest(testData, nodeTypes));
|
||||
}
|
||||
const workflows = ['nodes/Notion/test/node/v2/databasePage/get.workflow.json'];
|
||||
testWorkflows(workflows);
|
||||
});
|
||||
|
||||
@@ -1,85 +1,78 @@
|
||||
import type { IHttpRequestMethods } from 'n8n-workflow';
|
||||
import nock from 'nock';
|
||||
|
||||
import { equalityTest, setup, workflowToTests } from '@test/nodes/Helpers';
|
||||
import { testWorkflows } from '@test/nodes/Helpers';
|
||||
|
||||
const API_RESPONSE = [
|
||||
{
|
||||
object: 'page',
|
||||
id: '15bfb9cb-4cf0-81c7-aab4-c5855b8cb6c3',
|
||||
created_time: '2024-12-13T04:45:00.000Z',
|
||||
last_edited_time: '2024-12-13T04:45:00.000Z',
|
||||
created_by: {
|
||||
object: 'user',
|
||||
id: 'f215e49c-4677-40c0-9adc-87440d341324',
|
||||
},
|
||||
last_edited_by: {
|
||||
object: 'user',
|
||||
id: 'f215e49c-4677-40c0-9adc-87440d341324',
|
||||
},
|
||||
cover: null,
|
||||
icon: {
|
||||
type: 'emoji',
|
||||
emoji: '😗',
|
||||
},
|
||||
parent: {
|
||||
type: 'database_id',
|
||||
database_id: '138fb9cb-4cf0-804c-8663-d8ecdd5e692f',
|
||||
},
|
||||
archived: false,
|
||||
in_trash: false,
|
||||
properties: {
|
||||
Tags: {
|
||||
id: '%40~Tp',
|
||||
type: 'multi_select',
|
||||
multi_select: [],
|
||||
const API_RESPONSE = {
|
||||
results: [
|
||||
{
|
||||
object: 'page',
|
||||
id: '15bfb9cb-4cf0-81c7-aab4-c5855b8cb6c3',
|
||||
created_time: '2024-12-13T04:45:00.000Z',
|
||||
last_edited_time: '2024-12-13T04:45:00.000Z',
|
||||
created_by: {
|
||||
object: 'user',
|
||||
id: 'f215e49c-4677-40c0-9adc-87440d341324',
|
||||
},
|
||||
Name: {
|
||||
id: 'title',
|
||||
type: 'title',
|
||||
title: [
|
||||
{
|
||||
type: 'text',
|
||||
text: {
|
||||
content: 'new name 1',
|
||||
link: null,
|
||||
},
|
||||
annotations: {
|
||||
bold: false,
|
||||
italic: false,
|
||||
strikethrough: false,
|
||||
underline: false,
|
||||
code: false,
|
||||
color: 'default',
|
||||
},
|
||||
plain_text: 'new name 1',
|
||||
href: null,
|
||||
},
|
||||
],
|
||||
last_edited_by: {
|
||||
object: 'user',
|
||||
id: 'f215e49c-4677-40c0-9adc-87440d341324',
|
||||
},
|
||||
cover: null,
|
||||
icon: {
|
||||
type: 'emoji',
|
||||
emoji: '😗',
|
||||
},
|
||||
parent: {
|
||||
type: 'database_id',
|
||||
database_id: '138fb9cb-4cf0-804c-8663-d8ecdd5e692f',
|
||||
},
|
||||
archived: false,
|
||||
in_trash: false,
|
||||
properties: {
|
||||
Tags: {
|
||||
id: '%40~Tp',
|
||||
type: 'multi_select',
|
||||
multi_select: [],
|
||||
},
|
||||
Name: {
|
||||
id: 'title',
|
||||
type: 'title',
|
||||
title: [
|
||||
{
|
||||
type: 'text',
|
||||
text: {
|
||||
content: 'new name 1',
|
||||
link: null,
|
||||
},
|
||||
annotations: {
|
||||
bold: false,
|
||||
italic: false,
|
||||
strikethrough: false,
|
||||
underline: false,
|
||||
code: false,
|
||||
color: 'default',
|
||||
},
|
||||
plain_text: 'new name 1',
|
||||
href: null,
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
url: 'https://www.notion.so/new-name-1-15bfb9cb4cf081c7aab4c5855b8cb6c3',
|
||||
public_url: null,
|
||||
},
|
||||
url: 'https://www.notion.so/new-name-1-15bfb9cb4cf081c7aab4c5855b8cb6c3',
|
||||
public_url: null,
|
||||
},
|
||||
];
|
||||
|
||||
jest.mock('../../../../shared/GenericFunctions', () => {
|
||||
const originalModule = jest.requireActual('../../../../shared/GenericFunctions');
|
||||
return {
|
||||
...originalModule,
|
||||
notionApiRequestAllItems: jest.fn(async function (_: string, method: IHttpRequestMethods) {
|
||||
if (method === 'POST') {
|
||||
return API_RESPONSE;
|
||||
}
|
||||
}),
|
||||
};
|
||||
});
|
||||
],
|
||||
has_more: false,
|
||||
};
|
||||
|
||||
describe('Test NotionV2, databasePage => getAll', () => {
|
||||
const workflows = ['nodes/Notion/test/node/v2/databasePage/getAll.workflow.json'];
|
||||
const tests = workflowToTests(workflows);
|
||||
const nodeTypes = setup(tests);
|
||||
nock('https://api.notion.com')
|
||||
.post('/v1/databases/138fb9cb-4cf0-804c-8663-d8ecdd5e692f/query', {
|
||||
filter: { or: [{ property: 'Name', title: { contains: 'new' } }] },
|
||||
sorts: [{ direction: 'ascending', property: 'Name' }],
|
||||
})
|
||||
.reply(200, API_RESPONSE);
|
||||
|
||||
for (const testData of tests) {
|
||||
test(testData.description, async () => await equalityTest(testData, nodeTypes));
|
||||
}
|
||||
const workflows = ['nodes/Notion/test/node/v2/databasePage/getAll.workflow.json'];
|
||||
testWorkflows(workflows);
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { IHttpRequestMethods } from 'n8n-workflow';
|
||||
import nock from 'nock';
|
||||
|
||||
import { equalityTest, setup, workflowToTests } from '@test/nodes/Helpers';
|
||||
import { testWorkflows } from '@test/nodes/Helpers';
|
||||
|
||||
const API_RESPONSE = {
|
||||
object: 'page',
|
||||
@@ -61,24 +61,13 @@ const API_RESPONSE = {
|
||||
request_id: 'a4683091-f165-4f10-92b4-a629b8b1266e',
|
||||
};
|
||||
|
||||
jest.mock('../../../../shared/GenericFunctions', () => {
|
||||
const originalModule = jest.requireActual('../../../../shared/GenericFunctions');
|
||||
return {
|
||||
...originalModule,
|
||||
notionApiRequest: jest.fn(async function (method: IHttpRequestMethods) {
|
||||
if (method === 'PATCH') {
|
||||
return API_RESPONSE;
|
||||
}
|
||||
}),
|
||||
};
|
||||
});
|
||||
|
||||
describe('Test NotionV2, databasePage => update', () => {
|
||||
const workflows = ['nodes/Notion/test/node/v2/databasePage/update.workflow.json'];
|
||||
const tests = workflowToTests(workflows);
|
||||
const nodeTypes = setup(tests);
|
||||
nock('https://api.notion.com')
|
||||
.patch('/v1/pages/15bfb9cb4cf081c7aab4c5855b8cb6c3', {
|
||||
properties: { Name: { title: [{ text: { content: 'Updated Name' } }] } },
|
||||
})
|
||||
.reply(200, API_RESPONSE);
|
||||
|
||||
for (const testData of tests) {
|
||||
test(testData.description, async () => await equalityTest(testData, nodeTypes));
|
||||
}
|
||||
const workflows = ['nodes/Notion/test/node/v2/databasePage/update.workflow.json'];
|
||||
testWorkflows(workflows);
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { IHttpRequestMethods } from 'n8n-workflow';
|
||||
import nock from 'nock';
|
||||
|
||||
import { equalityTest, setup, workflowToTests } from '@test/nodes/Helpers';
|
||||
import { testWorkflows } from '@test/nodes/Helpers';
|
||||
|
||||
const API_RESPONSE = {
|
||||
object: 'page',
|
||||
@@ -61,24 +61,11 @@ const API_RESPONSE = {
|
||||
request_id: 'ce91abaa-261f-43c3-9237-57c0f28af682',
|
||||
};
|
||||
|
||||
jest.mock('../../../../shared/GenericFunctions', () => {
|
||||
const originalModule = jest.requireActual('../../../../shared/GenericFunctions');
|
||||
return {
|
||||
...originalModule,
|
||||
notionApiRequest: jest.fn(async function (method: IHttpRequestMethods) {
|
||||
if (method === 'PATCH') {
|
||||
return API_RESPONSE;
|
||||
}
|
||||
}),
|
||||
};
|
||||
});
|
||||
|
||||
describe('Test NotionV2, page => archive', () => {
|
||||
const workflows = ['nodes/Notion/test/node/v2/page/archive.workflow.json'];
|
||||
const tests = workflowToTests(workflows);
|
||||
const nodeTypes = setup(tests);
|
||||
nock('https://api.notion.com')
|
||||
.patch('/v1/pages/15bfb9cb4cf081c7aab4c5855b8cb6c3', { archived: true })
|
||||
.reply(200, API_RESPONSE);
|
||||
|
||||
for (const testData of tests) {
|
||||
test(testData.description, async () => await equalityTest(testData, nodeTypes));
|
||||
}
|
||||
const workflows = ['nodes/Notion/test/node/v2/page/archive.workflow.json'];
|
||||
testWorkflows(workflows);
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { IHttpRequestMethods } from 'n8n-workflow';
|
||||
import nock from 'nock';
|
||||
|
||||
import { equalityTest, setup, workflowToTests } from '@test/nodes/Helpers';
|
||||
import { testWorkflows } from '@test/nodes/Helpers';
|
||||
|
||||
const API_RESPONSE = {
|
||||
object: 'page',
|
||||
@@ -56,24 +56,27 @@ const API_RESPONSE = {
|
||||
request_id: 'df28ec00-4361-46af-a3b6-add18c8d1295',
|
||||
};
|
||||
|
||||
jest.mock('../../../../shared/GenericFunctions', () => {
|
||||
const originalModule = jest.requireActual('../../../../shared/GenericFunctions');
|
||||
return {
|
||||
...originalModule,
|
||||
notionApiRequest: jest.fn(async function (method: IHttpRequestMethods) {
|
||||
if (method === 'POST') {
|
||||
return API_RESPONSE;
|
||||
}
|
||||
}),
|
||||
};
|
||||
});
|
||||
|
||||
describe('Test NotionV2, page => create', () => {
|
||||
const workflows = ['nodes/Notion/test/node/v2/page/create.workflow.json'];
|
||||
const tests = workflowToTests(workflows);
|
||||
const nodeTypes = setup(tests);
|
||||
nock('https://api.notion.com')
|
||||
.post('/v1/pages', {
|
||||
parent: { page_id: '15bfb9cb4cf081c7aab4c5855b8cb6c3' },
|
||||
properties: { title: [{ text: { content: 'Child page' } }] },
|
||||
children: [
|
||||
{
|
||||
object: 'block',
|
||||
type: 'heading_1',
|
||||
heading_1: { text: [{ type: 'text', text: { content: 'Title' }, annotations: {} }] },
|
||||
},
|
||||
{
|
||||
object: 'block',
|
||||
type: 'paragraph',
|
||||
paragraph: { text: [{ text: { content: 'text' } }] },
|
||||
},
|
||||
],
|
||||
icon: { emoji: '😊' },
|
||||
})
|
||||
.reply(200, API_RESPONSE);
|
||||
|
||||
for (const testData of tests) {
|
||||
test(testData.description, async () => await equalityTest(testData, nodeTypes));
|
||||
}
|
||||
const workflows = ['nodes/Notion/test/node/v2/page/create.workflow.json'];
|
||||
testWorkflows(workflows);
|
||||
});
|
||||
|
||||
@@ -1,80 +1,74 @@
|
||||
import type { IHttpRequestMethods } from 'n8n-workflow';
|
||||
import nock from 'nock';
|
||||
|
||||
import { equalityTest, setup, workflowToTests } from '@test/nodes/Helpers';
|
||||
import { testWorkflows } from '@test/nodes/Helpers';
|
||||
|
||||
const API_RESPONSE = [
|
||||
{
|
||||
object: 'page',
|
||||
id: '15bfb9cb-4cf0-812b-b4bc-c85cd00727f8',
|
||||
created_time: '2024-12-13T06:01:00.000Z',
|
||||
last_edited_time: '2024-12-13T06:01:00.000Z',
|
||||
created_by: {
|
||||
object: 'user',
|
||||
id: 'f215e49c-4677-40c0-9adc-87440d341324',
|
||||
},
|
||||
last_edited_by: {
|
||||
object: 'user',
|
||||
id: 'f215e49c-4677-40c0-9adc-87440d341324',
|
||||
},
|
||||
cover: null,
|
||||
icon: {
|
||||
type: 'emoji',
|
||||
emoji: '😊',
|
||||
},
|
||||
parent: {
|
||||
type: 'page_id',
|
||||
page_id: '15bfb9cb-4cf0-81c7-aab4-c5855b8cb6c3',
|
||||
},
|
||||
archived: false,
|
||||
in_trash: false,
|
||||
properties: {
|
||||
title: {
|
||||
id: 'title',
|
||||
type: 'title',
|
||||
title: [
|
||||
{
|
||||
type: 'text',
|
||||
text: {
|
||||
content: 'Child page',
|
||||
link: null,
|
||||
},
|
||||
annotations: {
|
||||
bold: false,
|
||||
italic: false,
|
||||
strikethrough: false,
|
||||
underline: false,
|
||||
code: false,
|
||||
color: 'default',
|
||||
},
|
||||
plain_text: 'Child page',
|
||||
href: null,
|
||||
},
|
||||
],
|
||||
const API_RESPONSE = {
|
||||
results: [
|
||||
{
|
||||
object: 'page',
|
||||
id: '15bfb9cb-4cf0-812b-b4bc-c85cd00727f8',
|
||||
created_time: '2024-12-13T06:01:00.000Z',
|
||||
last_edited_time: '2024-12-13T06:01:00.000Z',
|
||||
created_by: {
|
||||
object: 'user',
|
||||
id: 'f215e49c-4677-40c0-9adc-87440d341324',
|
||||
},
|
||||
last_edited_by: {
|
||||
object: 'user',
|
||||
id: 'f215e49c-4677-40c0-9adc-87440d341324',
|
||||
},
|
||||
cover: null,
|
||||
icon: {
|
||||
type: 'emoji',
|
||||
emoji: '😊',
|
||||
},
|
||||
parent: {
|
||||
type: 'page_id',
|
||||
page_id: '15bfb9cb-4cf0-81c7-aab4-c5855b8cb6c3',
|
||||
},
|
||||
archived: false,
|
||||
in_trash: false,
|
||||
properties: {
|
||||
title: {
|
||||
id: 'title',
|
||||
type: 'title',
|
||||
title: [
|
||||
{
|
||||
type: 'text',
|
||||
text: {
|
||||
content: 'Child page',
|
||||
link: null,
|
||||
},
|
||||
annotations: {
|
||||
bold: false,
|
||||
italic: false,
|
||||
strikethrough: false,
|
||||
underline: false,
|
||||
code: false,
|
||||
color: 'default',
|
||||
},
|
||||
plain_text: 'Child page',
|
||||
href: null,
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
url: 'https://www.notion.so/Child-page-15bfb9cb4cf0812bb4bcc85cd00727f8',
|
||||
public_url: null,
|
||||
},
|
||||
url: 'https://www.notion.so/Child-page-15bfb9cb4cf0812bb4bcc85cd00727f8',
|
||||
public_url: null,
|
||||
},
|
||||
];
|
||||
|
||||
jest.mock('../../../../shared/GenericFunctions', () => {
|
||||
const originalModule = jest.requireActual('../../../../shared/GenericFunctions');
|
||||
return {
|
||||
...originalModule,
|
||||
notionApiRequestAllItems: jest.fn(async function (_: string, method: IHttpRequestMethods) {
|
||||
if (method === 'POST') {
|
||||
return API_RESPONSE;
|
||||
}
|
||||
}),
|
||||
};
|
||||
});
|
||||
],
|
||||
has_more: false,
|
||||
};
|
||||
|
||||
describe('Test NotionV2, page => search', () => {
|
||||
const workflows = ['nodes/Notion/test/node/v2/page/search.workflow.json'];
|
||||
const tests = workflowToTests(workflows);
|
||||
const nodeTypes = setup(tests);
|
||||
nock('https://api.notion.com')
|
||||
.post('/v1/search', {
|
||||
query: 'child',
|
||||
filter: { property: 'object', value: 'page' },
|
||||
sort: { direction: 'ascending', timestamp: 'last_edited_time' },
|
||||
})
|
||||
.reply(200, API_RESPONSE);
|
||||
|
||||
for (const testData of tests) {
|
||||
test(testData.description, async () => await equalityTest(testData, nodeTypes));
|
||||
}
|
||||
const workflows = ['nodes/Notion/test/node/v2/page/search.workflow.json'];
|
||||
testWorkflows(workflows);
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { IHttpRequestMethods } from 'n8n-workflow';
|
||||
import nock from 'nock';
|
||||
|
||||
import { equalityTest, setup, workflowToTests } from '@test/nodes/Helpers';
|
||||
import { testWorkflows } from '@test/nodes/Helpers';
|
||||
|
||||
const API_RESPONSE = {
|
||||
object: 'user',
|
||||
@@ -12,24 +12,11 @@ const API_RESPONSE = {
|
||||
request_id: 'ad2a00c0-fa6a-4a14-bf9a-68e1715b51a1',
|
||||
};
|
||||
|
||||
jest.mock('../../../../shared/GenericFunctions', () => {
|
||||
const originalModule = jest.requireActual('../../../../shared/GenericFunctions');
|
||||
return {
|
||||
...originalModule,
|
||||
notionApiRequest: jest.fn(async function (method: IHttpRequestMethods) {
|
||||
if (method === 'GET') {
|
||||
return API_RESPONSE;
|
||||
}
|
||||
}),
|
||||
};
|
||||
});
|
||||
|
||||
describe('Test NotionV2, user => get', () => {
|
||||
const workflows = ['nodes/Notion/test/node/v2/user/get.workflow.json'];
|
||||
const tests = workflowToTests(workflows);
|
||||
const nodeTypes = setup(tests);
|
||||
nock('https://api.notion.com')
|
||||
.get('/v1/users/34a945c6-de97-4efc-90d6-6d7cc14a6583')
|
||||
.reply(200, API_RESPONSE);
|
||||
|
||||
for (const testData of tests) {
|
||||
test(testData.description, async () => await equalityTest(testData, nodeTypes));
|
||||
}
|
||||
const workflows = ['nodes/Notion/test/node/v2/user/get.workflow.json'];
|
||||
testWorkflows(workflows);
|
||||
});
|
||||
|
||||
@@ -1,59 +1,47 @@
|
||||
import type { IHttpRequestMethods } from 'n8n-workflow';
|
||||
import nock from 'nock';
|
||||
|
||||
import { equalityTest, setup, workflowToTests } from '@test/nodes/Helpers';
|
||||
import { testWorkflows } from '@test/nodes/Helpers';
|
||||
|
||||
const API_RESPONSE = [
|
||||
{
|
||||
object: 'user',
|
||||
id: 'f215e49c-4677-40c0-9adc-87440d341324',
|
||||
name: 'n8n-test',
|
||||
avatar_url: null,
|
||||
type: 'bot',
|
||||
bot: {
|
||||
owner: {
|
||||
type: 'workspace',
|
||||
workspace: true,
|
||||
const API_RESPONSE = {
|
||||
results: [
|
||||
{
|
||||
object: 'user',
|
||||
id: 'f215e49c-4677-40c0-9adc-87440d341324',
|
||||
name: 'n8n-test',
|
||||
avatar_url: null,
|
||||
type: 'bot',
|
||||
bot: {
|
||||
owner: {
|
||||
type: 'workspace',
|
||||
workspace: true,
|
||||
},
|
||||
workspace_name: "Michael Kret's Notion",
|
||||
},
|
||||
workspace_name: "Michael Kret's Notion",
|
||||
},
|
||||
},
|
||||
{
|
||||
object: 'user',
|
||||
id: '34a945c6-de97-4efc-90d6-6d7cc14a6583',
|
||||
name: 'second',
|
||||
avatar_url: null,
|
||||
type: 'bot',
|
||||
bot: {},
|
||||
},
|
||||
{
|
||||
object: 'user',
|
||||
id: '2598a5de-49b3-4acd-adad-20f6b18c9fbe',
|
||||
name: 'DryMerge',
|
||||
avatar_url:
|
||||
'https://s3-us-west-2.amazonaws.com/public.notion-static.com/e67863a3-a867-4355-a602-c9830dbb1828/Primary_(recommended).jpg',
|
||||
type: 'bot',
|
||||
bot: {},
|
||||
},
|
||||
];
|
||||
|
||||
jest.mock('../../../../shared/GenericFunctions', () => {
|
||||
const originalModule = jest.requireActual('../../../../shared/GenericFunctions');
|
||||
return {
|
||||
...originalModule,
|
||||
notionApiRequestAllItems: jest.fn(async function (_: string, method: IHttpRequestMethods) {
|
||||
if (method === 'GET') {
|
||||
return API_RESPONSE;
|
||||
}
|
||||
}),
|
||||
};
|
||||
});
|
||||
{
|
||||
object: 'user',
|
||||
id: '34a945c6-de97-4efc-90d6-6d7cc14a6583',
|
||||
name: 'second',
|
||||
avatar_url: null,
|
||||
type: 'bot',
|
||||
bot: {},
|
||||
},
|
||||
{
|
||||
object: 'user',
|
||||
id: '2598a5de-49b3-4acd-adad-20f6b18c9fbe',
|
||||
name: 'DryMerge',
|
||||
avatar_url:
|
||||
'https://s3-us-west-2.amazonaws.com/public.notion-static.com/e67863a3-a867-4355-a602-c9830dbb1828/Primary_(recommended).jpg',
|
||||
type: 'bot',
|
||||
bot: {},
|
||||
},
|
||||
],
|
||||
has_more: false,
|
||||
};
|
||||
|
||||
describe('Test NotionV2, user => getAll', () => {
|
||||
const workflows = ['nodes/Notion/test/node/v2/user/getAll.workflow.json'];
|
||||
const tests = workflowToTests(workflows);
|
||||
const nodeTypes = setup(tests);
|
||||
nock('https://api.notion.com').get('/v1/users').reply(200, API_RESPONSE);
|
||||
|
||||
for (const testData of tests) {
|
||||
test(testData.description, async () => await equalityTest(testData, nodeTypes));
|
||||
}
|
||||
const workflows = ['nodes/Notion/test/node/v2/user/getAll.workflow.json'];
|
||||
testWorkflows(workflows);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user