From 3d74c3ee9ec7f0c812db6b2c39e3e23eb2a14b34 Mon Sep 17 00:00:00 2001 From: Shireen Missi <94372015+ShireenMissi@users.noreply.github.com> Date: Thu, 9 Oct 2025 17:14:28 +0100 Subject: [PATCH] fix(Github Node): Fix GitHub node no longer shows repo owner for Get Issues operation (#20580) --- .../nodes-base/nodes/Github/Github.node.ts | 22 +- ...ithub.organization.getRepositories.test.ts | 142 ++++ .../Github.repository.getIssues.test.ts | 374 +++++++++++ .../Github.user.getRepositories.test.ts | 142 ++++ .../Github.user.getUserIssues.test.ts | 609 ++++++++++++++++++ .../__tests__/getRepositories.workflow.json | 144 +++++ .../getRepositoriesLimit.workflow.json | 111 ++++ .../getRepositoryIssues.workflow.json | 255 ++++++++ .../getRepositoryIssuesFiltered.workflow.json | 170 +++++ .../getRepositoryIssuesLimit.workflow.json | 145 +++++ .../__tests__/getUserIssues.workflow.json | 353 ++++++++++ .../getUserIssuesFiltered.workflow.json | 211 ++++++ .../getUserIssuesLimit.workflow.json | 209 ++++++ .../getUserRepositories.workflow.json | 144 +++++ .../getUserRepositoriesLimit.workflow.json | 111 ++++ .../Github/__tests__/node/Github.node.test.ts | 6 +- 16 files changed, 3132 insertions(+), 16 deletions(-) create mode 100644 packages/nodes-base/nodes/Github/__tests__/Github.organization.getRepositories.test.ts create mode 100644 packages/nodes-base/nodes/Github/__tests__/Github.repository.getIssues.test.ts create mode 100644 packages/nodes-base/nodes/Github/__tests__/Github.user.getRepositories.test.ts create mode 100644 packages/nodes-base/nodes/Github/__tests__/Github.user.getUserIssues.test.ts create mode 100644 packages/nodes-base/nodes/Github/__tests__/getRepositories.workflow.json create mode 100644 packages/nodes-base/nodes/Github/__tests__/getRepositoriesLimit.workflow.json create mode 100644 packages/nodes-base/nodes/Github/__tests__/getRepositoryIssues.workflow.json create mode 100644 packages/nodes-base/nodes/Github/__tests__/getRepositoryIssuesFiltered.workflow.json create mode 100644 packages/nodes-base/nodes/Github/__tests__/getRepositoryIssuesLimit.workflow.json create mode 100644 packages/nodes-base/nodes/Github/__tests__/getUserIssues.workflow.json create mode 100644 packages/nodes-base/nodes/Github/__tests__/getUserIssuesFiltered.workflow.json create mode 100644 packages/nodes-base/nodes/Github/__tests__/getUserIssuesLimit.workflow.json create mode 100644 packages/nodes-base/nodes/Github/__tests__/getUserRepositories.workflow.json create mode 100644 packages/nodes-base/nodes/Github/__tests__/getUserRepositoriesLimit.workflow.json diff --git a/packages/nodes-base/nodes/Github/Github.node.ts b/packages/nodes-base/nodes/Github/Github.node.ts index 33ade1d4e4a..3c48224d690 100644 --- a/packages/nodes-base/nodes/Github/Github.node.ts +++ b/packages/nodes-base/nodes/Github/Github.node.ts @@ -336,7 +336,7 @@ export class Github implements INodeType { }, { name: 'Get Issues', - value: 'getIssues', + value: 'getUserIssues', description: 'Returns the issues assigned to the user', action: "Get a user's issues", }, @@ -564,8 +564,7 @@ export class Github implements INodeType { ], displayOptions: { hide: { - resource: ['user'], - operation: ['invite', 'getIssues'], + operation: ['invite', 'getUserIssues'], }, }, }, @@ -2120,8 +2119,7 @@ export class Github implements INodeType { type: 'boolean', displayOptions: { show: { - resource: ['user'], - operation: ['getIssues'], + operation: ['getUserIssues'], }, }, default: false, @@ -2133,8 +2131,7 @@ export class Github implements INodeType { type: 'number', displayOptions: { show: { - resource: ['user'], - operation: ['getIssues'], + operation: ['getUserIssues'], returnAll: [false], }, }, @@ -2154,8 +2151,7 @@ export class Github implements INodeType { }, displayOptions: { show: { - resource: ['user'], - operation: ['getIssues'], + operation: ['getUserIssues'], }, }, default: {}, @@ -2316,7 +2312,7 @@ export class Github implements INodeType { 'repository:listPopularPaths', 'repository:listReferrers', 'user:getRepositories', - 'user:getIssues', + 'user:getUserIssues', 'release:getAll', 'review:getAll', 'organization:getRepositories', @@ -2390,7 +2386,7 @@ export class Github implements INodeType { qs = {}; let owner = ''; - if (fullOperation !== 'user:invite' && fullOperation !== 'user:getIssues') { + if (fullOperation !== 'user:invite' && fullOperation !== 'user:getUserIssues') { // Request the parameters which almost all operations need owner = this.getNodeParameter('owner', i, '', { extractValue: true }) as string; } @@ -2398,7 +2394,7 @@ export class Github implements INodeType { let repository = ''; if ( fullOperation !== 'user:getRepositories' && - fullOperation !== 'user:getIssues' && + fullOperation !== 'user:getUserIssues' && fullOperation !== 'user:invite' && fullOperation !== 'organization:getRepositories' ) { @@ -2792,7 +2788,7 @@ export class Github implements INodeType { if (!returnAll) { qs.per_page = this.getNodeParameter('limit', 0); } - } else if (operation === 'getIssues') { + } else if (operation === 'getUserIssues') { // ---------------------------------- // getIssues // ---------------------------------- diff --git a/packages/nodes-base/nodes/Github/__tests__/Github.organization.getRepositories.test.ts b/packages/nodes-base/nodes/Github/__tests__/Github.organization.getRepositories.test.ts new file mode 100644 index 00000000000..fbaf776b565 --- /dev/null +++ b/packages/nodes-base/nodes/Github/__tests__/Github.organization.getRepositories.test.ts @@ -0,0 +1,142 @@ +import { NodeTestHarness } from '@nodes-testing/node-test-harness'; +import nock from 'nock'; + +describe('Github Node - Organization getRepositories', () => { + const credentials = { + githubApi: { + accessToken: 'test-token', + server: 'https://api.github.com', + user: 'testuser', + }, + }; + + describe('Basic getRepositories Operation', () => { + beforeAll(() => { + const mock = nock('https://api.github.com'); + + mock + .get('/orgs/testorg/repos') + .query(true) + .reply(200, [ + { + id: 1296269, + name: 'hello-world', + full_name: 'testorg/hello-world', + owner: { + login: 'testorg', + id: 1, + type: 'Organization', + }, + private: false, + html_url: 'https://github.com/testorg/hello-world', + description: 'My first repository on GitHub!', + fork: false, + created_at: '2011-01-26T19:01:12Z', + updated_at: '2011-01-26T19:14:43Z', + pushed_at: '2011-01-26T19:06:43Z', + clone_url: 'https://github.com/testorg/hello-world.git', + size: 108, + stargazers_count: 80, + watchers_count: 9, + language: 'C', + forks_count: 9, + archived: false, + disabled: false, + open_issues_count: 0, + license: { + key: 'mit', + name: 'MIT License', + }, + visibility: 'public', + default_branch: 'master', + }, + { + id: 1296270, + name: 'test-repo', + full_name: 'testorg/test-repo', + owner: { + login: 'testorg', + id: 1, + type: 'Organization', + }, + private: true, + html_url: 'https://github.com/testorg/test-repo', + description: 'Test repository', + fork: false, + created_at: '2011-01-27T19:01:12Z', + updated_at: '2011-01-27T19:14:43Z', + pushed_at: '2011-01-27T19:06:43Z', + clone_url: 'https://github.com/testorg/test-repo.git', + size: 256, + stargazers_count: 42, + watchers_count: 15, + language: 'JavaScript', + forks_count: 3, + archived: false, + disabled: false, + open_issues_count: 2, + license: { + key: 'apache-2.0', + name: 'Apache License 2.0', + }, + visibility: 'private', + default_branch: 'main', + }, + ]); + }); + + new NodeTestHarness().setupTests({ + credentials, + workflowFiles: ['getRepositories.workflow.json'], + }); + }); + + describe('Paginated getRepositories Operation', () => { + beforeAll(() => { + const mock = nock('https://api.github.com'); + + mock + .get('/orgs/testorg/repos') + .query({ per_page: 1 }) + .reply(200, [ + { + id: 1296269, + name: 'hello-world', + full_name: 'testorg/hello-world', + owner: { + login: 'testorg', + id: 1, + type: 'Organization', + }, + private: false, + html_url: 'https://github.com/testorg/hello-world', + description: 'My first repository on GitHub!', + fork: false, + created_at: '2011-01-26T19:01:12Z', + updated_at: '2011-01-26T19:14:43Z', + pushed_at: '2011-01-26T19:06:43Z', + clone_url: 'https://github.com/testorg/hello-world.git', + size: 108, + stargazers_count: 80, + watchers_count: 9, + language: 'C', + forks_count: 9, + archived: false, + disabled: false, + open_issues_count: 0, + license: { + key: 'mit', + name: 'MIT License', + }, + visibility: 'public', + default_branch: 'master', + }, + ]); + }); + + new NodeTestHarness().setupTests({ + credentials, + workflowFiles: ['getRepositoriesLimit.workflow.json'], + }); + }); +}); diff --git a/packages/nodes-base/nodes/Github/__tests__/Github.repository.getIssues.test.ts b/packages/nodes-base/nodes/Github/__tests__/Github.repository.getIssues.test.ts new file mode 100644 index 00000000000..c7dc517d3d6 --- /dev/null +++ b/packages/nodes-base/nodes/Github/__tests__/Github.repository.getIssues.test.ts @@ -0,0 +1,374 @@ +import { NodeTestHarness } from '@nodes-testing/node-test-harness'; +import nock from 'nock'; + +describe('Github Node - Repository getIssues', () => { + const credentials = { + githubApi: { + accessToken: 'test-token', + server: 'https://api.github.com', + user: 'testuser', + }, + }; + + describe('Basic getIssues Operation', () => { + beforeAll(() => { + const mock = nock('https://api.github.com'); + + mock + .get('/repos/testowner/testrepo/issues') + .query(true) + .reply(200, [ + { + url: 'https://api.github.com/repos/testowner/testrepo/issues/1', + repository_url: 'https://api.github.com/repos/testowner/testrepo', + labels_url: 'https://api.github.com/repos/testowner/testrepo/issues/1/labels{/name}', + comments_url: 'https://api.github.com/repos/testowner/testrepo/issues/1/comments', + events_url: 'https://api.github.com/repos/testowner/testrepo/issues/1/events', + html_url: 'https://github.com/testowner/testrepo/issues/1', + id: 1, + number: 1, + title: 'Found a bug', + user: { + login: 'testuser', + id: 1, + node_id: 'MDQ6VXNlcjE=', + avatar_url: 'https://github.com/images/error/testuser_happy.gif', + gravatar_id: '', + url: 'https://api.github.com/users/testuser', + html_url: 'https://github.com/testuser', + type: 'User', + site_admin: false, + }, + labels: [ + { + id: 208045946, + node_id: 'MDU6TGFiZWwyMDgwNDU5NDY=', + url: 'https://api.github.com/repos/testowner/testrepo/labels/bug', + name: 'bug', + description: "Something isn't working", + color: 'd73a49', + default: true, + }, + ], + state: 'open', + locked: false, + assignee: null, + assignees: [], + milestone: null, + comments: 0, + created_at: '2011-04-22T13:33:48Z', + updated_at: '2011-04-22T13:33:48Z', + closed_at: null, + author_association: 'COLLABORATOR', + active_lock_reason: null, + body: "I'm having a problem with this.", + reactions: { + url: 'https://api.github.com/repos/testowner/testrepo/issues/1/reactions', + total_count: 0, + '+1': 0, + '-1': 0, + laugh: 0, + hooray: 0, + confused: 0, + heart: 0, + rocket: 0, + eyes: 0, + }, + timeline_url: 'https://api.github.com/repos/testowner/testrepo/issues/1/timeline', + performed_via_github_app: null, + state_reason: null, + }, + { + url: 'https://api.github.com/repos/testowner/testrepo/issues/2', + repository_url: 'https://api.github.com/repos/testowner/testrepo', + labels_url: 'https://api.github.com/repos/testowner/testrepo/issues/2/labels{/name}', + comments_url: 'https://api.github.com/repos/testowner/testrepo/issues/2/comments', + events_url: 'https://api.github.com/repos/testowner/testrepo/issues/2/events', + html_url: 'https://github.com/testowner/testrepo/issues/2', + id: 2, + number: 2, + title: 'Feature request', + user: { + login: 'anotheruser', + id: 2, + node_id: 'MDQ6VXNlcjI=', + avatar_url: 'https://github.com/images/error/anotheruser_happy.gif', + gravatar_id: '', + url: 'https://api.github.com/users/anotheruser', + html_url: 'https://github.com/anotheruser', + type: 'User', + site_admin: false, + }, + labels: [ + { + id: 208045947, + node_id: 'MDU6TGFiZWwyMDgwNDU5NDc=', + url: 'https://api.github.com/repos/testowner/testrepo/labels/enhancement', + name: 'enhancement', + description: 'New feature or request', + color: 'a2eeef', + default: true, + }, + ], + state: 'open', + locked: false, + assignee: { + login: 'assigneduser', + id: 3, + node_id: 'MDQ6VXNlcjM=', + avatar_url: 'https://github.com/images/error/assigneduser_happy.gif', + gravatar_id: '', + url: 'https://api.github.com/users/assigneduser', + html_url: 'https://github.com/assigneduser', + type: 'User', + site_admin: false, + }, + assignees: [ + { + login: 'assigneduser', + id: 3, + node_id: 'MDQ6VXNlcjM=', + avatar_url: 'https://github.com/images/error/assigneduser_happy.gif', + gravatar_id: '', + url: 'https://api.github.com/users/assigneduser', + html_url: 'https://github.com/assigneduser', + type: 'User', + site_admin: false, + }, + ], + milestone: { + url: 'https://api.github.com/repos/testowner/testrepo/milestones/1', + html_url: 'https://github.com/testowner/testrepo/milestone/1', + labels_url: 'https://api.github.com/repos/testowner/testrepo/milestones/1/labels', + id: 1002604, + number: 1, + state: 'open', + title: 'v1.0', + description: 'Tracking milestone for version 1.0', + creator: { + login: 'testowner', + id: 4, + node_id: 'MDQ6VXNlcjQ=', + avatar_url: 'https://github.com/images/error/testowner_happy.gif', + gravatar_id: '', + url: 'https://api.github.com/users/testowner', + html_url: 'https://github.com/testowner', + type: 'User', + site_admin: false, + }, + open_issues: 4, + closed_issues: 8, + created_at: '2011-04-10T20:09:31Z', + updated_at: '2014-03-03T18:58:10Z', + closed_at: null, + due_on: '2018-09-22T23:39:01Z', + node_id: 'MDk6TWlsZXN0b25lMTAwMjYwNA==', + }, + comments: 3, + created_at: '2011-04-22T13:33:48Z', + updated_at: '2011-04-22T13:33:48Z', + closed_at: null, + author_association: 'COLLABORATOR', + active_lock_reason: null, + body: 'It would be great if we could add this feature.', + reactions: { + url: 'https://api.github.com/repos/testowner/testrepo/issues/2/reactions', + total_count: 5, + '+1': 3, + '-1': 1, + laugh: 0, + hooray: 0, + confused: 0, + heart: 1, + rocket: 0, + eyes: 0, + }, + timeline_url: 'https://api.github.com/repos/testowner/testrepo/issues/2/timeline', + performed_via_github_app: null, + state_reason: null, + }, + ]); + }); + + new NodeTestHarness().setupTests({ + credentials, + workflowFiles: ['getRepositoryIssues.workflow.json'], + }); + }); + + describe('Limited getIssues Operation', () => { + beforeAll(() => { + const mock = nock('https://api.github.com'); + + mock + .get('/repos/testowner/testrepo/issues') + .query({ per_page: 1 }) + .reply(200, [ + { + url: 'https://api.github.com/repos/testowner/testrepo/issues/1', + repository_url: 'https://api.github.com/repos/testowner/testrepo', + labels_url: 'https://api.github.com/repos/testowner/testrepo/issues/1/labels{/name}', + comments_url: 'https://api.github.com/repos/testowner/testrepo/issues/1/comments', + events_url: 'https://api.github.com/repos/testowner/testrepo/issues/1/events', + html_url: 'https://github.com/testowner/testrepo/issues/1', + id: 1, + number: 1, + title: 'Found a bug', + user: { + login: 'testuser', + id: 1, + node_id: 'MDQ6VXNlcjE=', + avatar_url: 'https://github.com/images/error/testuser_happy.gif', + gravatar_id: '', + url: 'https://api.github.com/users/testuser', + html_url: 'https://github.com/testuser', + type: 'User', + site_admin: false, + }, + labels: [ + { + id: 208045946, + node_id: 'MDU6TGFiZWwyMDgwNDU5NDY=', + url: 'https://api.github.com/repos/testowner/testrepo/labels/bug', + name: 'bug', + description: "Something isn't working", + color: 'd73a49', + default: true, + }, + ], + state: 'open', + locked: false, + assignee: null, + assignees: [], + milestone: null, + comments: 0, + created_at: '2011-04-22T13:33:48Z', + updated_at: '2011-04-22T13:33:48Z', + closed_at: null, + author_association: 'COLLABORATOR', + active_lock_reason: null, + body: "I'm having a problem with this.", + reactions: { + url: 'https://api.github.com/repos/testowner/testrepo/issues/1/reactions', + total_count: 0, + '+1': 0, + '-1': 0, + laugh: 0, + hooray: 0, + confused: 0, + heart: 0, + rocket: 0, + eyes: 0, + }, + timeline_url: 'https://api.github.com/repos/testowner/testrepo/issues/1/timeline', + performed_via_github_app: null, + state_reason: null, + }, + ]); + }); + + new NodeTestHarness().setupTests({ + credentials, + workflowFiles: ['getRepositoryIssuesLimit.workflow.json'], + }); + }); + + describe('Filtered getIssues Operation', () => { + beforeAll(() => { + const mock = nock('https://api.github.com'); + + mock + .get('/repos/testowner/testrepo/issues') + .query({ state: 'closed', labels: 'bug', assignee: 'testuser', per_page: 100, page: 1 }) + .reply(200, [ + { + url: 'https://api.github.com/repos/testowner/testrepo/issues/3', + repository_url: 'https://api.github.com/repos/testowner/testrepo', + labels_url: 'https://api.github.com/repos/testowner/testrepo/issues/3/labels{/name}', + comments_url: 'https://api.github.com/repos/testowner/testrepo/issues/3/comments', + events_url: 'https://api.github.com/repos/testowner/testrepo/issues/3/events', + html_url: 'https://github.com/testowner/testrepo/issues/3', + id: 3, + number: 3, + title: 'Fixed bug', + user: { + login: 'testuser', + id: 1, + node_id: 'MDQ6VXNlcjE=', + avatar_url: 'https://github.com/images/error/testuser_happy.gif', + gravatar_id: '', + url: 'https://api.github.com/users/testuser', + html_url: 'https://github.com/testuser', + type: 'User', + site_admin: false, + }, + labels: [ + { + id: 208045946, + node_id: 'MDU6TGFiZWwyMDgwNDU5NDY=', + url: 'https://api.github.com/repos/testowner/testrepo/labels/bug', + name: 'bug', + description: "Something isn't working", + color: 'd73a49', + default: true, + }, + ], + state: 'closed', + locked: false, + assignee: { + login: 'testuser', + id: 1, + node_id: 'MDQ6VXNlcjE=', + avatar_url: 'https://github.com/images/error/testuser_happy.gif', + gravatar_id: '', + url: 'https://api.github.com/users/testuser', + html_url: 'https://github.com/testuser', + type: 'User', + site_admin: false, + }, + assignees: [ + { + login: 'testuser', + id: 1, + node_id: 'MDQ6VXNlcjE=', + avatar_url: 'https://github.com/images/error/testuser_happy.gif', + gravatar_id: '', + url: 'https://api.github.com/users/testuser', + html_url: 'https://github.com/testuser', + type: 'User', + site_admin: false, + }, + ], + milestone: null, + comments: 2, + created_at: '2011-04-20T13:33:48Z', + updated_at: '2011-04-25T13:33:48Z', + closed_at: '2011-04-25T13:33:48Z', + author_association: 'COLLABORATOR', + active_lock_reason: null, + body: 'This bug has been fixed.', + reactions: { + url: 'https://api.github.com/repos/testowner/testrepo/issues/3/reactions', + total_count: 1, + '+1': 1, + '-1': 0, + laugh: 0, + hooray: 0, + confused: 0, + heart: 0, + rocket: 0, + eyes: 0, + }, + timeline_url: 'https://api.github.com/repos/testowner/testrepo/issues/3/timeline', + performed_via_github_app: null, + state_reason: 'completed', + }, + ]); + }); + + new NodeTestHarness().setupTests({ + credentials, + workflowFiles: ['getRepositoryIssuesFiltered.workflow.json'], + }); + }); +}); diff --git a/packages/nodes-base/nodes/Github/__tests__/Github.user.getRepositories.test.ts b/packages/nodes-base/nodes/Github/__tests__/Github.user.getRepositories.test.ts new file mode 100644 index 00000000000..43eef0e3b6b --- /dev/null +++ b/packages/nodes-base/nodes/Github/__tests__/Github.user.getRepositories.test.ts @@ -0,0 +1,142 @@ +import { NodeTestHarness } from '@nodes-testing/node-test-harness'; +import nock from 'nock'; + +describe('Github Node - User getRepositories', () => { + const credentials = { + githubApi: { + accessToken: 'test-token', + server: 'https://api.github.com', + user: 'testuser', + }, + }; + + describe('Basic User getRepositories Operation', () => { + beforeAll(() => { + const mock = nock('https://api.github.com'); + + mock + .get('/users/testuser/repos') + .query(true) + .reply(200, [ + { + id: 1296269, + name: 'hello-world', + full_name: 'testuser/hello-world', + owner: { + login: 'testuser', + id: 1, + type: 'User', + }, + private: false, + html_url: 'https://github.com/testuser/hello-world', + description: 'My first repository on GitHub!', + fork: false, + created_at: '2011-01-26T19:01:12Z', + updated_at: '2011-01-26T19:14:43Z', + pushed_at: '2011-01-26T19:06:43Z', + clone_url: 'https://github.com/testuser/hello-world.git', + size: 108, + stargazers_count: 80, + watchers_count: 9, + language: 'C', + forks_count: 9, + archived: false, + disabled: false, + open_issues_count: 0, + license: { + key: 'mit', + name: 'MIT License', + }, + visibility: 'public', + default_branch: 'master', + }, + { + id: 1296270, + name: 'my-app', + full_name: 'testuser/my-app', + owner: { + login: 'testuser', + id: 1, + type: 'User', + }, + private: false, + html_url: 'https://github.com/testuser/my-app', + description: 'My awesome application', + fork: false, + created_at: '2011-02-26T19:01:12Z', + updated_at: '2011-02-26T19:14:43Z', + pushed_at: '2011-02-26T19:06:43Z', + clone_url: 'https://github.com/testuser/my-app.git', + size: 512, + stargazers_count: 156, + watchers_count: 45, + language: 'JavaScript', + forks_count: 23, + archived: false, + disabled: false, + open_issues_count: 5, + license: { + key: 'apache-2.0', + name: 'Apache License 2.0', + }, + visibility: 'public', + default_branch: 'main', + }, + ]); + }); + + new NodeTestHarness().setupTests({ + credentials, + workflowFiles: ['getUserRepositories.workflow.json'], + }); + }); + + describe('Limited User getRepositories Operation', () => { + beforeAll(() => { + const mock = nock('https://api.github.com'); + + mock + .get('/users/testuser/repos') + .query({ per_page: 1 }) + .reply(200, [ + { + id: 1296269, + name: 'hello-world', + full_name: 'testuser/hello-world', + owner: { + login: 'testuser', + id: 1, + type: 'User', + }, + private: false, + html_url: 'https://github.com/testuser/hello-world', + description: 'My first repository on GitHub!', + fork: false, + created_at: '2011-01-26T19:01:12Z', + updated_at: '2011-01-26T19:14:43Z', + pushed_at: '2011-01-26T19:06:43Z', + clone_url: 'https://github.com/testuser/hello-world.git', + size: 108, + stargazers_count: 80, + watchers_count: 9, + language: 'C', + forks_count: 9, + archived: false, + disabled: false, + open_issues_count: 0, + license: { + key: 'mit', + name: 'MIT License', + }, + visibility: 'public', + default_branch: 'master', + }, + ]); + }); + + new NodeTestHarness().setupTests({ + credentials, + workflowFiles: ['getUserRepositoriesLimit.workflow.json'], + }); + }); +}); diff --git a/packages/nodes-base/nodes/Github/__tests__/Github.user.getUserIssues.test.ts b/packages/nodes-base/nodes/Github/__tests__/Github.user.getUserIssues.test.ts new file mode 100644 index 00000000000..6c8736a260f --- /dev/null +++ b/packages/nodes-base/nodes/Github/__tests__/Github.user.getUserIssues.test.ts @@ -0,0 +1,609 @@ +import { NodeTestHarness } from '@nodes-testing/node-test-harness'; +import nock from 'nock'; + +describe('Github Node - User getUserIssues', () => { + const credentials = { + githubApi: { + accessToken: 'test-token', + server: 'https://api.github.com', + user: 'testuser', + }, + }; + + describe('Basic getUserIssues Operation', () => { + beforeAll(() => { + const mock = nock('https://api.github.com'); + + mock + .get('/issues') + .query(true) + .reply(200, [ + { + url: 'https://api.github.com/repos/someowner/somerepo/issues/1', + repository_url: 'https://api.github.com/repos/someowner/somerepo', + labels_url: 'https://api.github.com/repos/someowner/somerepo/issues/1/labels{/name}', + comments_url: 'https://api.github.com/repos/someowner/somerepo/issues/1/comments', + events_url: 'https://api.github.com/repos/someowner/somerepo/issues/1/events', + html_url: 'https://github.com/someowner/somerepo/issues/1', + id: 1, + number: 1, + title: 'Issue assigned to me', + user: { + login: 'issueauthor', + id: 5, + node_id: 'MDQ6VXNlcjU=', + avatar_url: 'https://github.com/images/error/issueauthor_happy.gif', + gravatar_id: '', + url: 'https://api.github.com/users/issueauthor', + html_url: 'https://github.com/issueauthor', + type: 'User', + site_admin: false, + }, + labels: [ + { + id: 208045946, + node_id: 'MDU6TGFiZWwyMDgwNDU5NDY=', + url: 'https://api.github.com/repos/someowner/somerepo/labels/bug', + name: 'bug', + description: "Something isn't working", + color: 'd73a49', + default: true, + }, + ], + state: 'open', + locked: false, + assignee: { + login: 'testuser', + id: 1, + node_id: 'MDQ6VXNlcjE=', + avatar_url: 'https://github.com/images/error/testuser_happy.gif', + gravatar_id: '', + url: 'https://api.github.com/users/testuser', + html_url: 'https://github.com/testuser', + type: 'User', + site_admin: false, + }, + assignees: [ + { + login: 'testuser', + id: 1, + node_id: 'MDQ6VXNlcjE=', + avatar_url: 'https://github.com/images/error/testuser_happy.gif', + gravatar_id: '', + url: 'https://api.github.com/users/testuser', + html_url: 'https://github.com/testuser', + type: 'User', + site_admin: false, + }, + ], + milestone: null, + comments: 0, + created_at: '2011-04-22T13:33:48Z', + updated_at: '2011-04-22T13:33:48Z', + closed_at: null, + author_association: 'NONE', + active_lock_reason: null, + body: 'This is an issue assigned to me.', + reactions: { + url: 'https://api.github.com/repos/someowner/somerepo/issues/1/reactions', + total_count: 0, + '+1': 0, + '-1': 0, + laugh: 0, + hooray: 0, + confused: 0, + heart: 0, + rocket: 0, + eyes: 0, + }, + timeline_url: 'https://api.github.com/repos/someowner/somerepo/issues/1/timeline', + performed_via_github_app: null, + state_reason: null, + repository: { + id: 1296269, + node_id: 'MDEwOlJlcG9zaXRvcnkxMjk2MjY5', + name: 'somerepo', + full_name: 'someowner/somerepo', + owner: { + login: 'someowner', + id: 6, + node_id: 'MDQ6VXNlcjY=', + avatar_url: 'https://github.com/images/error/someowner_happy.gif', + gravatar_id: '', + url: 'https://api.github.com/users/someowner', + html_url: 'https://github.com/someowner', + type: 'User', + site_admin: false, + }, + private: false, + html_url: 'https://github.com/someowner/somerepo', + description: 'Repository with issues assigned to testuser', + fork: false, + url: 'https://api.github.com/repos/someowner/somerepo', + created_at: '2011-01-26T19:01:12Z', + updated_at: '2011-01-26T19:14:43Z', + pushed_at: '2011-01-26T19:06:43Z', + git_url: 'git://github.com/someowner/somerepo.git', + ssh_url: 'git@github.com:someowner/somerepo.git', + clone_url: 'https://github.com/someowner/somerepo.git', + size: 108, + stargazers_count: 80, + watchers_count: 9, + language: 'C', + has_issues: true, + has_projects: true, + has_wiki: true, + has_pages: false, + forks_count: 9, + mirror_url: null, + archived: false, + disabled: false, + open_issues_count: 0, + license: { + key: 'mit', + name: 'MIT License', + spdx_id: 'MIT', + url: 'https://api.github.com/licenses/mit', + node_id: 'MDc6TGljZW5zZW1pdA==', + }, + forks: 9, + open_issues: 0, + watchers: 9, + default_branch: 'master', + }, + }, + { + url: 'https://api.github.com/repos/anotherowner/anotherrepo/issues/5', + repository_url: 'https://api.github.com/repos/anotherowner/anotherrepo', + labels_url: + 'https://api.github.com/repos/anotherowner/anotherrepo/issues/5/labels{/name}', + comments_url: 'https://api.github.com/repos/anotherowner/anotherrepo/issues/5/comments', + events_url: 'https://api.github.com/repos/anotherowner/anotherrepo/issues/5/events', + html_url: 'https://github.com/anotherowner/anotherrepo/issues/5', + id: 5, + number: 5, + title: 'Enhancement request assigned to me', + user: { + login: 'requestor', + id: 7, + node_id: 'MDQ6VXNlcjc=', + avatar_url: 'https://github.com/images/error/requestor_happy.gif', + gravatar_id: '', + url: 'https://api.github.com/users/requestor', + html_url: 'https://github.com/requestor', + type: 'User', + site_admin: false, + }, + labels: [ + { + id: 208045947, + node_id: 'MDU6TGFiZWwyMDgwNDU5NDc=', + url: 'https://api.github.com/repos/anotherowner/anotherrepo/labels/enhancement', + name: 'enhancement', + description: 'New feature or request', + color: 'a2eeef', + default: true, + }, + { + id: 208045948, + node_id: 'MDU6TGFiZWwyMDgwNDU5NDg=', + url: 'https://api.github.com/repos/anotherowner/anotherrepo/labels/good-first-issue', + name: 'good first issue', + description: 'Good for newcomers', + color: '7057ff', + default: true, + }, + ], + state: 'open', + locked: false, + assignee: { + login: 'testuser', + id: 1, + node_id: 'MDQ6VXNlcjE=', + avatar_url: 'https://github.com/images/error/testuser_happy.gif', + gravatar_id: '', + url: 'https://api.github.com/users/testuser', + html_url: 'https://github.com/testuser', + type: 'User', + site_admin: false, + }, + assignees: [ + { + login: 'testuser', + id: 1, + node_id: 'MDQ6VXNlcjE=', + avatar_url: 'https://github.com/images/error/testuser_happy.gif', + gravatar_id: '', + url: 'https://api.github.com/users/testuser', + html_url: 'https://github.com/testuser', + type: 'User', + site_admin: false, + }, + ], + milestone: null, + comments: 1, + created_at: '2011-04-22T13:33:48Z', + updated_at: '2011-04-22T13:33:48Z', + closed_at: null, + author_association: 'CONTRIBUTOR', + active_lock_reason: null, + body: 'Please add this enhancement.', + reactions: { + url: 'https://api.github.com/repos/anotherowner/anotherrepo/issues/5/reactions', + total_count: 2, + '+1': 2, + '-1': 0, + laugh: 0, + hooray: 0, + confused: 0, + heart: 0, + rocket: 0, + eyes: 0, + }, + timeline_url: 'https://api.github.com/repos/anotherowner/anotherrepo/issues/5/timeline', + performed_via_github_app: null, + state_reason: null, + repository: { + id: 1296270, + node_id: 'MDEwOlJlcG9zaXRvcnkxMjk2Mjcw', + name: 'anotherrepo', + full_name: 'anotherowner/anotherrepo', + owner: { + login: 'anotherowner', + id: 8, + node_id: 'MDQ6VXNlcjg=', + avatar_url: 'https://github.com/images/error/anotherowner_happy.gif', + gravatar_id: '', + url: 'https://api.github.com/users/anotherowner', + html_url: 'https://github.com/anotherowner', + type: 'User', + site_admin: false, + }, + private: false, + html_url: 'https://github.com/anotherowner/anotherrepo', + description: 'Another repository with issues for testuser', + fork: false, + url: 'https://api.github.com/repos/anotherowner/anotherrepo', + created_at: '2011-01-26T19:01:12Z', + updated_at: '2011-01-26T19:14:43Z', + pushed_at: '2011-01-26T19:06:43Z', + git_url: 'git://github.com/anotherowner/anotherrepo.git', + ssh_url: 'git@github.com:anotherowner/anotherrepo.git', + clone_url: 'https://github.com/anotherowner/anotherrepo.git', + size: 256, + stargazers_count: 42, + watchers_count: 15, + language: 'JavaScript', + has_issues: true, + has_projects: true, + has_wiki: true, + has_pages: false, + forks_count: 3, + mirror_url: null, + archived: false, + disabled: false, + open_issues_count: 5, + license: { + key: 'apache-2.0', + name: 'Apache License 2.0', + spdx_id: 'Apache-2.0', + url: 'https://api.github.com/licenses/apache-2.0', + node_id: 'MDc6TGljZW5zZWFwYWNoZS0yLjA=', + }, + forks: 3, + open_issues: 5, + watchers: 15, + default_branch: 'main', + }, + }, + ]); + }); + + new NodeTestHarness().setupTests({ + credentials, + workflowFiles: ['getUserIssues.workflow.json'], + }); + }); + + describe('Limited getUserIssues Operation', () => { + beforeAll(() => { + const mock = nock('https://api.github.com'); + + mock + .get('/issues') + .query({ per_page: 1 }) + .reply(200, [ + { + url: 'https://api.github.com/repos/someowner/somerepo/issues/1', + repository_url: 'https://api.github.com/repos/someowner/somerepo', + labels_url: 'https://api.github.com/repos/someowner/somerepo/issues/1/labels{/name}', + comments_url: 'https://api.github.com/repos/someowner/somerepo/issues/1/comments', + events_url: 'https://api.github.com/repos/someowner/somerepo/issues/1/events', + html_url: 'https://github.com/someowner/somerepo/issues/1', + id: 1, + number: 1, + title: 'Issue assigned to me', + user: { + login: 'issueauthor', + id: 5, + node_id: 'MDQ6VXNlcjU=', + avatar_url: 'https://github.com/images/error/issueauthor_happy.gif', + gravatar_id: '', + url: 'https://api.github.com/users/issueauthor', + html_url: 'https://github.com/issueauthor', + type: 'User', + site_admin: false, + }, + labels: [ + { + id: 208045946, + node_id: 'MDU6TGFiZWwyMDgwNDU5NDY=', + url: 'https://api.github.com/repos/someowner/somerepo/labels/bug', + name: 'bug', + description: "Something isn't working", + color: 'd73a49', + default: true, + }, + ], + state: 'open', + locked: false, + assignee: { + login: 'testuser', + id: 1, + node_id: 'MDQ6VXNlcjE=', + avatar_url: 'https://github.com/images/error/testuser_happy.gif', + gravatar_id: '', + url: 'https://api.github.com/users/testuser', + html_url: 'https://github.com/testuser', + type: 'User', + site_admin: false, + }, + assignees: [ + { + login: 'testuser', + id: 1, + node_id: 'MDQ6VXNlcjE=', + avatar_url: 'https://github.com/images/error/testuser_happy.gif', + gravatar_id: '', + url: 'https://api.github.com/users/testuser', + html_url: 'https://github.com/testuser', + type: 'User', + site_admin: false, + }, + ], + milestone: null, + comments: 0, + created_at: '2011-04-22T13:33:48Z', + updated_at: '2011-04-22T13:33:48Z', + closed_at: null, + author_association: 'NONE', + active_lock_reason: null, + body: 'This is an issue assigned to me.', + reactions: { + url: 'https://api.github.com/repos/someowner/somerepo/issues/1/reactions', + total_count: 0, + '+1': 0, + '-1': 0, + laugh: 0, + hooray: 0, + confused: 0, + heart: 0, + rocket: 0, + eyes: 0, + }, + timeline_url: 'https://api.github.com/repos/someowner/somerepo/issues/1/timeline', + performed_via_github_app: null, + state_reason: null, + repository: { + id: 1296269, + node_id: 'MDEwOlJlcG9zaXRvcnkxMjk2MjY5', + name: 'somerepo', + full_name: 'someowner/somerepo', + owner: { + login: 'someowner', + id: 6, + node_id: 'MDQ6VXNlcjY=', + avatar_url: 'https://github.com/images/error/someowner_happy.gif', + gravatar_id: '', + url: 'https://api.github.com/users/someowner', + html_url: 'https://github.com/someowner', + type: 'User', + site_admin: false, + }, + private: false, + html_url: 'https://github.com/someowner/somerepo', + description: 'Repository with issues assigned to testuser', + fork: false, + url: 'https://api.github.com/repos/someowner/somerepo', + created_at: '2011-01-26T19:01:12Z', + updated_at: '2011-01-26T19:14:43Z', + pushed_at: '2011-01-26T19:06:43Z', + git_url: 'git://github.com/someowner/somerepo.git', + ssh_url: 'git@github.com:someowner/somerepo.git', + clone_url: 'https://github.com/someowner/somerepo.git', + size: 108, + stargazers_count: 80, + watchers_count: 9, + language: 'C', + has_issues: true, + has_projects: true, + has_wiki: true, + has_pages: false, + forks_count: 9, + mirror_url: null, + archived: false, + disabled: false, + open_issues_count: 0, + license: { + key: 'mit', + name: 'MIT License', + spdx_id: 'MIT', + url: 'https://api.github.com/licenses/mit', + node_id: 'MDc6TGljZW5zZW1pdA==', + }, + forks: 9, + open_issues: 0, + watchers: 9, + default_branch: 'master', + }, + }, + ]); + }); + + new NodeTestHarness().setupTests({ + credentials, + workflowFiles: ['getUserIssuesLimit.workflow.json'], + }); + }); + + describe('Filtered getUserIssues Operation', () => { + beforeAll(() => { + const mock = nock('https://api.github.com'); + + mock + .get('/issues') + .query({ state: 'closed', labels: 'enhancement', per_page: 100, page: 1 }) + .reply(200, [ + { + url: 'https://api.github.com/repos/testowner/closedrepo/issues/10', + repository_url: 'https://api.github.com/repos/testowner/closedrepo', + labels_url: 'https://api.github.com/repos/testowner/closedrepo/issues/10/labels{/name}', + comments_url: 'https://api.github.com/repos/testowner/closedrepo/issues/10/comments', + events_url: 'https://api.github.com/repos/testowner/closedrepo/issues/10/events', + html_url: 'https://github.com/testowner/closedrepo/issues/10', + id: 10, + number: 10, + title: 'Completed enhancement', + user: { + login: 'enhancementauthor', + id: 9, + node_id: 'MDQ6VXNlcjk=', + avatar_url: 'https://github.com/images/error/enhancementauthor_happy.gif', + gravatar_id: '', + url: 'https://api.github.com/users/enhancementauthor', + html_url: 'https://github.com/enhancementauthor', + type: 'User', + site_admin: false, + }, + labels: [ + { + id: 208045947, + node_id: 'MDU6TGFiZWwyMDgwNDU5NDc=', + url: 'https://api.github.com/repos/testowner/closedrepo/labels/enhancement', + name: 'enhancement', + description: 'New feature or request', + color: 'a2eeef', + default: true, + }, + ], + state: 'closed', + locked: false, + assignee: { + login: 'testuser', + id: 1, + node_id: 'MDQ6VXNlcjE=', + avatar_url: 'https://github.com/images/error/testuser_happy.gif', + gravatar_id: '', + url: 'https://api.github.com/users/testuser', + html_url: 'https://github.com/testuser', + type: 'User', + site_admin: false, + }, + assignees: [ + { + login: 'testuser', + id: 1, + node_id: 'MDQ6VXNlcjE=', + avatar_url: 'https://github.com/images/error/testuser_happy.gif', + gravatar_id: '', + url: 'https://api.github.com/users/testuser', + html_url: 'https://github.com/testuser', + type: 'User', + site_admin: false, + }, + ], + milestone: null, + comments: 5, + created_at: '2011-04-10T13:33:48Z', + updated_at: '2011-04-30T13:33:48Z', + closed_at: '2011-04-30T13:33:48Z', + author_association: 'CONTRIBUTOR', + active_lock_reason: null, + body: 'Enhancement has been completed successfully.', + reactions: { + url: 'https://api.github.com/repos/testowner/closedrepo/issues/10/reactions', + total_count: 3, + '+1': 2, + '-1': 0, + laugh: 0, + hooray: 1, + confused: 0, + heart: 0, + rocket: 0, + eyes: 0, + }, + timeline_url: 'https://api.github.com/repos/testowner/closedrepo/issues/10/timeline', + performed_via_github_app: null, + state_reason: 'completed', + repository: { + id: 1296271, + node_id: 'MDEwOlJlcG9zaXRvcnkxMjk2Mjcx', + name: 'closedrepo', + full_name: 'testowner/closedrepo', + owner: { + login: 'testowner', + id: 10, + node_id: 'MDQ6VXNlcjEw', + avatar_url: 'https://github.com/images/error/testowner_happy.gif', + gravatar_id: '', + url: 'https://api.github.com/users/testowner', + html_url: 'https://github.com/testowner', + type: 'User', + site_admin: false, + }, + private: false, + html_url: 'https://github.com/testowner/closedrepo', + description: 'Repository with closed enhancement issues', + fork: false, + url: 'https://api.github.com/repos/testowner/closedrepo', + created_at: '2011-01-26T19:01:12Z', + updated_at: '2011-01-26T19:14:43Z', + pushed_at: '2011-01-26T19:06:43Z', + git_url: 'git://github.com/testowner/closedrepo.git', + ssh_url: 'git@github.com:testowner/closedrepo.git', + clone_url: 'https://github.com/testowner/closedrepo.git', + size: 128, + stargazers_count: 25, + watchers_count: 5, + language: 'Python', + has_issues: true, + has_projects: true, + has_wiki: true, + has_pages: false, + forks_count: 2, + mirror_url: null, + archived: false, + disabled: false, + open_issues_count: 0, + license: { + key: 'mit', + name: 'MIT License', + spdx_id: 'MIT', + url: 'https://api.github.com/licenses/mit', + node_id: 'MDc6TGljZW5zZW1pdA==', + }, + forks: 2, + open_issues: 0, + watchers: 5, + default_branch: 'main', + }, + }, + ]); + }); + + new NodeTestHarness().setupTests({ + credentials, + workflowFiles: ['getUserIssuesFiltered.workflow.json'], + }); + }); +}); diff --git a/packages/nodes-base/nodes/Github/__tests__/getRepositories.workflow.json b/packages/nodes-base/nodes/Github/__tests__/getRepositories.workflow.json new file mode 100644 index 00000000000..256904638fd --- /dev/null +++ b/packages/nodes-base/nodes/Github/__tests__/getRepositories.workflow.json @@ -0,0 +1,144 @@ +{ + "name": "Github Organization getRepositories Test Workflow", + "nodes": [ + { + "parameters": {}, + "type": "n8n-nodes-base.manualTrigger", + "typeVersion": 1, + "position": [0, 0], + "id": "trigger-id", + "name": "When clicking 'Execute Workflow'" + }, + { + "parameters": { + "resource": "organization", + "operation": "getRepositories", + "owner": { + "__rl": true, + "value": "testorg", + "mode": "name" + }, + "returnAll": true + }, + "type": "n8n-nodes-base.github", + "typeVersion": 1, + "position": [200, 0], + "id": "github-node-id", + "name": "Get Organization Repositories", + "credentials": { + "githubApi": { + "id": "credential-id", + "name": "Test Credentials" + } + } + }, + { + "parameters": {}, + "type": "n8n-nodes-base.noOp", + "typeVersion": 1, + "position": [400, 0], + "id": "noop-id", + "name": "Repositories Response" + } + ], + "pinData": { + "Repositories Response": [ + { + "json": { + "id": 1296269, + "name": "hello-world", + "full_name": "testorg/hello-world", + "owner": { + "login": "testorg", + "id": 1, + "type": "Organization" + }, + "private": false, + "html_url": "https://github.com/testorg/hello-world", + "description": "My first repository on GitHub!", + "fork": false, + "created_at": "2011-01-26T19:01:12Z", + "updated_at": "2011-01-26T19:14:43Z", + "pushed_at": "2011-01-26T19:06:43Z", + "clone_url": "https://github.com/testorg/hello-world.git", + "size": 108, + "stargazers_count": 80, + "watchers_count": 9, + "language": "C", + "forks_count": 9, + "archived": false, + "disabled": false, + "open_issues_count": 0, + "license": { + "key": "mit", + "name": "MIT License" + }, + "visibility": "public", + "default_branch": "master" + } + }, + { + "json": { + "id": 1296270, + "name": "test-repo", + "full_name": "testorg/test-repo", + "owner": { + "login": "testorg", + "id": 1, + "type": "Organization" + }, + "private": true, + "html_url": "https://github.com/testorg/test-repo", + "description": "Test repository", + "fork": false, + "created_at": "2011-01-27T19:01:12Z", + "updated_at": "2011-01-27T19:14:43Z", + "pushed_at": "2011-01-27T19:06:43Z", + "clone_url": "https://github.com/testorg/test-repo.git", + "size": 256, + "stargazers_count": 42, + "watchers_count": 15, + "language": "JavaScript", + "forks_count": 3, + "archived": false, + "disabled": false, + "open_issues_count": 2, + "license": { + "key": "apache-2.0", + "name": "Apache License 2.0" + }, + "visibility": "private", + "default_branch": "main" + } + } + ] + }, + "connections": { + "When clicking 'Execute Workflow'": { + "main": [ + [ + { + "node": "Get Organization Repositories", + "type": "main", + "index": 0 + } + ] + ] + }, + "Get Organization Repositories": { + "main": [ + [ + { + "node": "Repositories Response", + "type": "main", + "index": 0 + } + ] + ] + } + }, + "active": false, + "settings": { + "executionOrder": "v1" + } +} diff --git a/packages/nodes-base/nodes/Github/__tests__/getRepositoriesLimit.workflow.json b/packages/nodes-base/nodes/Github/__tests__/getRepositoriesLimit.workflow.json new file mode 100644 index 00000000000..ece16ba0b4c --- /dev/null +++ b/packages/nodes-base/nodes/Github/__tests__/getRepositoriesLimit.workflow.json @@ -0,0 +1,111 @@ +{ + "name": "Github Organization getRepositories Limit Test Workflow", + "nodes": [ + { + "parameters": {}, + "type": "n8n-nodes-base.manualTrigger", + "typeVersion": 1, + "position": [0, 0], + "id": "trigger-id", + "name": "When clicking 'Execute Workflow'" + }, + { + "parameters": { + "resource": "organization", + "operation": "getRepositories", + "owner": { + "__rl": true, + "value": "testorg", + "mode": "name" + }, + "returnAll": false, + "limit": 1 + }, + "type": "n8n-nodes-base.github", + "typeVersion": 1, + "position": [200, 0], + "id": "github-node-id", + "name": "Get Organization Repositories Limited", + "credentials": { + "githubApi": { + "id": "credential-id", + "name": "Test Credentials" + } + } + }, + { + "parameters": {}, + "type": "n8n-nodes-base.noOp", + "typeVersion": 1, + "position": [400, 0], + "id": "noop-id", + "name": "Repositories Response" + } + ], + "pinData": { + "Repositories Response": [ + { + "json": { + "id": 1296269, + "name": "hello-world", + "full_name": "testorg/hello-world", + "owner": { + "login": "testorg", + "id": 1, + "type": "Organization" + }, + "private": false, + "html_url": "https://github.com/testorg/hello-world", + "description": "My first repository on GitHub!", + "fork": false, + "created_at": "2011-01-26T19:01:12Z", + "updated_at": "2011-01-26T19:14:43Z", + "pushed_at": "2011-01-26T19:06:43Z", + "clone_url": "https://github.com/testorg/hello-world.git", + "size": 108, + "stargazers_count": 80, + "watchers_count": 9, + "language": "C", + "forks_count": 9, + "archived": false, + "disabled": false, + "open_issues_count": 0, + "license": { + "key": "mit", + "name": "MIT License" + }, + "visibility": "public", + "default_branch": "master" + } + } + ] + }, + "connections": { + "When clicking 'Execute Workflow'": { + "main": [ + [ + { + "node": "Get Organization Repositories Limited", + "type": "main", + "index": 0 + } + ] + ] + }, + "Get Organization Repositories Limited": { + "main": [ + [ + { + "node": "Repositories Response", + "type": "main", + "index": 0 + } + ] + ] + } + }, + "active": false, + "settings": { + "executionOrder": "v1" + } +} diff --git a/packages/nodes-base/nodes/Github/__tests__/getRepositoryIssues.workflow.json b/packages/nodes-base/nodes/Github/__tests__/getRepositoryIssues.workflow.json new file mode 100644 index 00000000000..43972daf1ec --- /dev/null +++ b/packages/nodes-base/nodes/Github/__tests__/getRepositoryIssues.workflow.json @@ -0,0 +1,255 @@ +{ + "name": "Github Repository getIssues Test Workflow", + "nodes": [ + { + "parameters": {}, + "type": "n8n-nodes-base.manualTrigger", + "typeVersion": 1, + "position": [0, 0], + "id": "trigger-id", + "name": "When clicking 'Execute Workflow'" + }, + { + "parameters": { + "resource": "repository", + "operation": "getIssues", + "owner": { + "__rl": true, + "value": "testowner", + "mode": "name" + }, + "repository": { + "__rl": true, + "value": "testrepo", + "mode": "name" + }, + "returnAll": true, + "getRepositoryIssuesFilters": {} + }, + "type": "n8n-nodes-base.github", + "typeVersion": 1, + "position": [200, 0], + "id": "github-node-id", + "name": "Get Repository Issues", + "credentials": { + "githubApi": { + "id": "credential-id", + "name": "Test Credentials" + } + } + }, + { + "parameters": {}, + "type": "n8n-nodes-base.noOp", + "typeVersion": 1, + "position": [400, 0], + "id": "noop-id", + "name": "Issues Response" + } + ], + "pinData": { + "Issues Response": [ + { + "json": { + "url": "https://api.github.com/repos/testowner/testrepo/issues/1", + "repository_url": "https://api.github.com/repos/testowner/testrepo", + "labels_url": "https://api.github.com/repos/testowner/testrepo/issues/1/labels{/name}", + "comments_url": "https://api.github.com/repos/testowner/testrepo/issues/1/comments", + "events_url": "https://api.github.com/repos/testowner/testrepo/issues/1/events", + "html_url": "https://github.com/testowner/testrepo/issues/1", + "id": 1, + "number": 1, + "title": "Found a bug", + "user": { + "login": "testuser", + "id": 1, + "node_id": "MDQ6VXNlcjE=", + "avatar_url": "https://github.com/images/error/testuser_happy.gif", + "gravatar_id": "", + "url": "https://api.github.com/users/testuser", + "html_url": "https://github.com/testuser", + "type": "User", + "site_admin": false + }, + "labels": [ + { + "id": 208045946, + "node_id": "MDU6TGFiZWwyMDgwNDU5NDY=", + "url": "https://api.github.com/repos/testowner/testrepo/labels/bug", + "name": "bug", + "description": "Something isn't working", + "color": "d73a49", + "default": true + } + ], + "state": "open", + "locked": false, + "assignee": null, + "assignees": [], + "milestone": null, + "comments": 0, + "created_at": "2011-04-22T13:33:48Z", + "updated_at": "2011-04-22T13:33:48Z", + "closed_at": null, + "author_association": "COLLABORATOR", + "active_lock_reason": null, + "body": "I'm having a problem with this.", + "reactions": { + "url": "https://api.github.com/repos/testowner/testrepo/issues/1/reactions", + "total_count": 0, + "+1": 0, + "-1": 0, + "laugh": 0, + "hooray": 0, + "confused": 0, + "heart": 0, + "rocket": 0, + "eyes": 0 + }, + "timeline_url": "https://api.github.com/repos/testowner/testrepo/issues/1/timeline", + "performed_via_github_app": null, + "state_reason": null + } + }, + { + "json": { + "url": "https://api.github.com/repos/testowner/testrepo/issues/2", + "repository_url": "https://api.github.com/repos/testowner/testrepo", + "labels_url": "https://api.github.com/repos/testowner/testrepo/issues/2/labels{/name}", + "comments_url": "https://api.github.com/repos/testowner/testrepo/issues/2/comments", + "events_url": "https://api.github.com/repos/testowner/testrepo/issues/2/events", + "html_url": "https://github.com/testowner/testrepo/issues/2", + "id": 2, + "number": 2, + "title": "Feature request", + "user": { + "login": "anotheruser", + "id": 2, + "node_id": "MDQ6VXNlcjI=", + "avatar_url": "https://github.com/images/error/anotheruser_happy.gif", + "gravatar_id": "", + "url": "https://api.github.com/users/anotheruser", + "html_url": "https://github.com/anotheruser", + "type": "User", + "site_admin": false + }, + "labels": [ + { + "id": 208045947, + "node_id": "MDU6TGFiZWwyMDgwNDU5NDc=", + "url": "https://api.github.com/repos/testowner/testrepo/labels/enhancement", + "name": "enhancement", + "description": "New feature or request", + "color": "a2eeef", + "default": true + } + ], + "state": "open", + "locked": false, + "assignee": { + "login": "assigneduser", + "id": 3, + "node_id": "MDQ6VXNlcjM=", + "avatar_url": "https://github.com/images/error/assigneduser_happy.gif", + "gravatar_id": "", + "url": "https://api.github.com/users/assigneduser", + "html_url": "https://github.com/assigneduser", + "type": "User", + "site_admin": false + }, + "assignees": [ + { + "login": "assigneduser", + "id": 3, + "node_id": "MDQ6VXNlcjM=", + "avatar_url": "https://github.com/images/error/assigneduser_happy.gif", + "gravatar_id": "", + "url": "https://api.github.com/users/assigneduser", + "html_url": "https://github.com/assigneduser", + "type": "User", + "site_admin": false + } + ], + "milestone": { + "url": "https://api.github.com/repos/testowner/testrepo/milestones/1", + "html_url": "https://github.com/testowner/testrepo/milestone/1", + "labels_url": "https://api.github.com/repos/testowner/testrepo/milestones/1/labels", + "id": 1002604, + "number": 1, + "state": "open", + "title": "v1.0", + "description": "Tracking milestone for version 1.0", + "creator": { + "login": "testowner", + "id": 4, + "node_id": "MDQ6VXNlcjQ=", + "avatar_url": "https://github.com/images/error/testowner_happy.gif", + "gravatar_id": "", + "url": "https://api.github.com/users/testowner", + "html_url": "https://github.com/testowner", + "type": "User", + "site_admin": false + }, + "open_issues": 4, + "closed_issues": 8, + "created_at": "2011-04-10T20:09:31Z", + "updated_at": "2014-03-03T18:58:10Z", + "closed_at": null, + "due_on": "2018-09-22T23:39:01Z", + "node_id": "MDk6TWlsZXN0b25lMTAwMjYwNA==" + }, + "comments": 3, + "created_at": "2011-04-22T13:33:48Z", + "updated_at": "2011-04-22T13:33:48Z", + "closed_at": null, + "author_association": "COLLABORATOR", + "active_lock_reason": null, + "body": "It would be great if we could add this feature.", + "reactions": { + "url": "https://api.github.com/repos/testowner/testrepo/issues/2/reactions", + "total_count": 5, + "+1": 3, + "-1": 1, + "laugh": 0, + "hooray": 0, + "confused": 0, + "heart": 1, + "rocket": 0, + "eyes": 0 + }, + "timeline_url": "https://api.github.com/repos/testowner/testrepo/issues/2/timeline", + "performed_via_github_app": null, + "state_reason": null + } + } + ] + }, + "connections": { + "When clicking 'Execute Workflow'": { + "main": [ + [ + { + "node": "Get Repository Issues", + "type": "main", + "index": 0 + } + ] + ] + }, + "Get Repository Issues": { + "main": [ + [ + { + "node": "Issues Response", + "type": "main", + "index": 0 + } + ] + ] + } + }, + "active": false, + "settings": { + "executionOrder": "v1" + } +} diff --git a/packages/nodes-base/nodes/Github/__tests__/getRepositoryIssuesFiltered.workflow.json b/packages/nodes-base/nodes/Github/__tests__/getRepositoryIssuesFiltered.workflow.json new file mode 100644 index 00000000000..93c0ae9a6c5 --- /dev/null +++ b/packages/nodes-base/nodes/Github/__tests__/getRepositoryIssuesFiltered.workflow.json @@ -0,0 +1,170 @@ +{ + "name": "Github Repository getIssues Filtered Test Workflow", + "nodes": [ + { + "parameters": {}, + "type": "n8n-nodes-base.manualTrigger", + "typeVersion": 1, + "position": [0, 0], + "id": "trigger-id", + "name": "When clicking 'Execute Workflow'" + }, + { + "parameters": { + "resource": "repository", + "operation": "getIssues", + "owner": { + "__rl": true, + "value": "testowner", + "mode": "name" + }, + "repository": { + "__rl": true, + "value": "testrepo", + "mode": "name" + }, + "returnAll": true, + "getRepositoryIssuesFilters": { + "state": "closed", + "labels": "bug", + "assignee": "testuser" + } + }, + "type": "n8n-nodes-base.github", + "typeVersion": 1, + "position": [200, 0], + "id": "github-node-id", + "name": "Get Repository Issues Filtered", + "credentials": { + "githubApi": { + "id": "credential-id", + "name": "Test Credentials" + } + } + }, + { + "parameters": {}, + "type": "n8n-nodes-base.noOp", + "typeVersion": 1, + "position": [400, 0], + "id": "noop-id", + "name": "Issues Response" + } + ], + "pinData": { + "Issues Response": [ + { + "json": { + "url": "https://api.github.com/repos/testowner/testrepo/issues/3", + "repository_url": "https://api.github.com/repos/testowner/testrepo", + "labels_url": "https://api.github.com/repos/testowner/testrepo/issues/3/labels{/name}", + "comments_url": "https://api.github.com/repos/testowner/testrepo/issues/3/comments", + "events_url": "https://api.github.com/repos/testowner/testrepo/issues/3/events", + "html_url": "https://github.com/testowner/testrepo/issues/3", + "id": 3, + "number": 3, + "title": "Fixed bug", + "user": { + "login": "testuser", + "id": 1, + "node_id": "MDQ6VXNlcjE=", + "avatar_url": "https://github.com/images/error/testuser_happy.gif", + "gravatar_id": "", + "url": "https://api.github.com/users/testuser", + "html_url": "https://github.com/testuser", + "type": "User", + "site_admin": false + }, + "labels": [ + { + "id": 208045946, + "node_id": "MDU6TGFiZWwyMDgwNDU5NDY=", + "url": "https://api.github.com/repos/testowner/testrepo/labels/bug", + "name": "bug", + "description": "Something isn't working", + "color": "d73a49", + "default": true + } + ], + "state": "closed", + "locked": false, + "assignee": { + "login": "testuser", + "id": 1, + "node_id": "MDQ6VXNlcjE=", + "avatar_url": "https://github.com/images/error/testuser_happy.gif", + "gravatar_id": "", + "url": "https://api.github.com/users/testuser", + "html_url": "https://github.com/testuser", + "type": "User", + "site_admin": false + }, + "assignees": [ + { + "login": "testuser", + "id": 1, + "node_id": "MDQ6VXNlcjE=", + "avatar_url": "https://github.com/images/error/testuser_happy.gif", + "gravatar_id": "", + "url": "https://api.github.com/users/testuser", + "html_url": "https://github.com/testuser", + "type": "User", + "site_admin": false + } + ], + "milestone": null, + "comments": 2, + "created_at": "2011-04-20T13:33:48Z", + "updated_at": "2011-04-25T13:33:48Z", + "closed_at": "2011-04-25T13:33:48Z", + "author_association": "COLLABORATOR", + "active_lock_reason": null, + "body": "This bug has been fixed.", + "reactions": { + "url": "https://api.github.com/repos/testowner/testrepo/issues/3/reactions", + "total_count": 1, + "+1": 1, + "-1": 0, + "laugh": 0, + "hooray": 0, + "confused": 0, + "heart": 0, + "rocket": 0, + "eyes": 0 + }, + "timeline_url": "https://api.github.com/repos/testowner/testrepo/issues/3/timeline", + "performed_via_github_app": null, + "state_reason": "completed" + } + } + ] + }, + "connections": { + "When clicking 'Execute Workflow'": { + "main": [ + [ + { + "node": "Get Repository Issues Filtered", + "type": "main", + "index": 0 + } + ] + ] + }, + "Get Repository Issues Filtered": { + "main": [ + [ + { + "node": "Issues Response", + "type": "main", + "index": 0 + } + ] + ] + } + }, + "active": false, + "settings": { + "executionOrder": "v1" + } +} diff --git a/packages/nodes-base/nodes/Github/__tests__/getRepositoryIssuesLimit.workflow.json b/packages/nodes-base/nodes/Github/__tests__/getRepositoryIssuesLimit.workflow.json new file mode 100644 index 00000000000..4e451f2bd03 --- /dev/null +++ b/packages/nodes-base/nodes/Github/__tests__/getRepositoryIssuesLimit.workflow.json @@ -0,0 +1,145 @@ +{ + "name": "Github Repository getIssues Limit Test Workflow", + "nodes": [ + { + "parameters": {}, + "type": "n8n-nodes-base.manualTrigger", + "typeVersion": 1, + "position": [0, 0], + "id": "trigger-id", + "name": "When clicking 'Execute Workflow'" + }, + { + "parameters": { + "resource": "repository", + "operation": "getIssues", + "owner": { + "__rl": true, + "value": "testowner", + "mode": "name" + }, + "repository": { + "__rl": true, + "value": "testrepo", + "mode": "name" + }, + "returnAll": false, + "limit": 1, + "getRepositoryIssuesFilters": {} + }, + "type": "n8n-nodes-base.github", + "typeVersion": 1, + "position": [200, 0], + "id": "github-node-id", + "name": "Get Repository Issues Limited", + "credentials": { + "githubApi": { + "id": "credential-id", + "name": "Test Credentials" + } + } + }, + { + "parameters": {}, + "type": "n8n-nodes-base.noOp", + "typeVersion": 1, + "position": [400, 0], + "id": "noop-id", + "name": "Issues Response" + } + ], + "pinData": { + "Issues Response": [ + { + "json": { + "url": "https://api.github.com/repos/testowner/testrepo/issues/1", + "repository_url": "https://api.github.com/repos/testowner/testrepo", + "labels_url": "https://api.github.com/repos/testowner/testrepo/issues/1/labels{/name}", + "comments_url": "https://api.github.com/repos/testowner/testrepo/issues/1/comments", + "events_url": "https://api.github.com/repos/testowner/testrepo/issues/1/events", + "html_url": "https://github.com/testowner/testrepo/issues/1", + "id": 1, + "number": 1, + "title": "Found a bug", + "user": { + "login": "testuser", + "id": 1, + "node_id": "MDQ6VXNlcjE=", + "avatar_url": "https://github.com/images/error/testuser_happy.gif", + "gravatar_id": "", + "url": "https://api.github.com/users/testuser", + "html_url": "https://github.com/testuser", + "type": "User", + "site_admin": false + }, + "labels": [ + { + "id": 208045946, + "node_id": "MDU6TGFiZWwyMDgwNDU5NDY=", + "url": "https://api.github.com/repos/testowner/testrepo/labels/bug", + "name": "bug", + "description": "Something isn't working", + "color": "d73a49", + "default": true + } + ], + "state": "open", + "locked": false, + "assignee": null, + "assignees": [], + "milestone": null, + "comments": 0, + "created_at": "2011-04-22T13:33:48Z", + "updated_at": "2011-04-22T13:33:48Z", + "closed_at": null, + "author_association": "COLLABORATOR", + "active_lock_reason": null, + "body": "I'm having a problem with this.", + "reactions": { + "url": "https://api.github.com/repos/testowner/testrepo/issues/1/reactions", + "total_count": 0, + "+1": 0, + "-1": 0, + "laugh": 0, + "hooray": 0, + "confused": 0, + "heart": 0, + "rocket": 0, + "eyes": 0 + }, + "timeline_url": "https://api.github.com/repos/testowner/testrepo/issues/1/timeline", + "performed_via_github_app": null, + "state_reason": null + } + } + ] + }, + "connections": { + "When clicking 'Execute Workflow'": { + "main": [ + [ + { + "node": "Get Repository Issues Limited", + "type": "main", + "index": 0 + } + ] + ] + }, + "Get Repository Issues Limited": { + "main": [ + [ + { + "node": "Issues Response", + "type": "main", + "index": 0 + } + ] + ] + } + }, + "active": false, + "settings": { + "executionOrder": "v1" + } +} diff --git a/packages/nodes-base/nodes/Github/__tests__/getUserIssues.workflow.json b/packages/nodes-base/nodes/Github/__tests__/getUserIssues.workflow.json new file mode 100644 index 00000000000..23acfe4881b --- /dev/null +++ b/packages/nodes-base/nodes/Github/__tests__/getUserIssues.workflow.json @@ -0,0 +1,353 @@ +{ + "name": "Github User getUserIssues Test Workflow", + "nodes": [ + { + "parameters": {}, + "type": "n8n-nodes-base.manualTrigger", + "typeVersion": 1, + "position": [0, 0], + "id": "trigger-id", + "name": "When clicking 'Execute Workflow'" + }, + { + "parameters": { + "resource": "user", + "operation": "getUserIssues", + "returnAll": true, + "getUserIssuesFilters": {} + }, + "type": "n8n-nodes-base.github", + "typeVersion": 1, + "position": [200, 0], + "id": "github-node-id", + "name": "Get User Issues", + "credentials": { + "githubApi": { + "id": "credential-id", + "name": "Test Credentials" + } + } + }, + { + "parameters": {}, + "type": "n8n-nodes-base.noOp", + "typeVersion": 1, + "position": [400, 0], + "id": "noop-id", + "name": "Issues Response" + } + ], + "pinData": { + "Issues Response": [ + { + "json": { + "url": "https://api.github.com/repos/someowner/somerepo/issues/1", + "repository_url": "https://api.github.com/repos/someowner/somerepo", + "labels_url": "https://api.github.com/repos/someowner/somerepo/issues/1/labels{/name}", + "comments_url": "https://api.github.com/repos/someowner/somerepo/issues/1/comments", + "events_url": "https://api.github.com/repos/someowner/somerepo/issues/1/events", + "html_url": "https://github.com/someowner/somerepo/issues/1", + "id": 1, + "number": 1, + "title": "Issue assigned to me", + "user": { + "login": "issueauthor", + "id": 5, + "node_id": "MDQ6VXNlcjU=", + "avatar_url": "https://github.com/images/error/issueauthor_happy.gif", + "gravatar_id": "", + "url": "https://api.github.com/users/issueauthor", + "html_url": "https://github.com/issueauthor", + "type": "User", + "site_admin": false + }, + "labels": [ + { + "id": 208045946, + "node_id": "MDU6TGFiZWwyMDgwNDU5NDY=", + "url": "https://api.github.com/repos/someowner/somerepo/labels/bug", + "name": "bug", + "description": "Something isn't working", + "color": "d73a49", + "default": true + } + ], + "state": "open", + "locked": false, + "assignee": { + "login": "testuser", + "id": 1, + "node_id": "MDQ6VXNlcjE=", + "avatar_url": "https://github.com/images/error/testuser_happy.gif", + "gravatar_id": "", + "url": "https://api.github.com/users/testuser", + "html_url": "https://github.com/testuser", + "type": "User", + "site_admin": false + }, + "assignees": [ + { + "login": "testuser", + "id": 1, + "node_id": "MDQ6VXNlcjE=", + "avatar_url": "https://github.com/images/error/testuser_happy.gif", + "gravatar_id": "", + "url": "https://api.github.com/users/testuser", + "html_url": "https://github.com/testuser", + "type": "User", + "site_admin": false + } + ], + "milestone": null, + "comments": 0, + "created_at": "2011-04-22T13:33:48Z", + "updated_at": "2011-04-22T13:33:48Z", + "closed_at": null, + "author_association": "NONE", + "active_lock_reason": null, + "body": "This is an issue assigned to me.", + "reactions": { + "url": "https://api.github.com/repos/someowner/somerepo/issues/1/reactions", + "total_count": 0, + "+1": 0, + "-1": 0, + "laugh": 0, + "hooray": 0, + "confused": 0, + "heart": 0, + "rocket": 0, + "eyes": 0 + }, + "timeline_url": "https://api.github.com/repos/someowner/somerepo/issues/1/timeline", + "performed_via_github_app": null, + "state_reason": null, + "repository": { + "id": 1296269, + "node_id": "MDEwOlJlcG9zaXRvcnkxMjk2MjY5", + "name": "somerepo", + "full_name": "someowner/somerepo", + "owner": { + "login": "someowner", + "id": 6, + "node_id": "MDQ6VXNlcjY=", + "avatar_url": "https://github.com/images/error/someowner_happy.gif", + "gravatar_id": "", + "url": "https://api.github.com/users/someowner", + "html_url": "https://github.com/someowner", + "type": "User", + "site_admin": false + }, + "private": false, + "html_url": "https://github.com/someowner/somerepo", + "description": "Repository with issues assigned to testuser", + "fork": false, + "url": "https://api.github.com/repos/someowner/somerepo", + "created_at": "2011-01-26T19:01:12Z", + "updated_at": "2011-01-26T19:14:43Z", + "pushed_at": "2011-01-26T19:06:43Z", + "git_url": "git://github.com/someowner/somerepo.git", + "ssh_url": "git@github.com:someowner/somerepo.git", + "clone_url": "https://github.com/someowner/somerepo.git", + "size": 108, + "stargazers_count": 80, + "watchers_count": 9, + "language": "C", + "has_issues": true, + "has_projects": true, + "has_wiki": true, + "has_pages": false, + "forks_count": 9, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 0, + "license": { + "key": "mit", + "name": "MIT License", + "spdx_id": "MIT", + "url": "https://api.github.com/licenses/mit", + "node_id": "MDc6TGljZW5zZW1pdA==" + }, + "forks": 9, + "open_issues": 0, + "watchers": 9, + "default_branch": "master" + } + } + }, + { + "json": { + "url": "https://api.github.com/repos/anotherowner/anotherrepo/issues/5", + "repository_url": "https://api.github.com/repos/anotherowner/anotherrepo", + "labels_url": "https://api.github.com/repos/anotherowner/anotherrepo/issues/5/labels{/name}", + "comments_url": "https://api.github.com/repos/anotherowner/anotherrepo/issues/5/comments", + "events_url": "https://api.github.com/repos/anotherowner/anotherrepo/issues/5/events", + "html_url": "https://github.com/anotherowner/anotherrepo/issues/5", + "id": 5, + "number": 5, + "title": "Enhancement request assigned to me", + "user": { + "login": "requestor", + "id": 7, + "node_id": "MDQ6VXNlcjc=", + "avatar_url": "https://github.com/images/error/requestor_happy.gif", + "gravatar_id": "", + "url": "https://api.github.com/users/requestor", + "html_url": "https://github.com/requestor", + "type": "User", + "site_admin": false + }, + "labels": [ + { + "id": 208045947, + "node_id": "MDU6TGFiZWwyMDgwNDU5NDc=", + "url": "https://api.github.com/repos/anotherowner/anotherrepo/labels/enhancement", + "name": "enhancement", + "description": "New feature or request", + "color": "a2eeef", + "default": true + }, + { + "id": 208045948, + "node_id": "MDU6TGFiZWwyMDgwNDU5NDg=", + "url": "https://api.github.com/repos/anotherowner/anotherrepo/labels/good-first-issue", + "name": "good first issue", + "description": "Good for newcomers", + "color": "7057ff", + "default": true + } + ], + "state": "open", + "locked": false, + "assignee": { + "login": "testuser", + "id": 1, + "node_id": "MDQ6VXNlcjE=", + "avatar_url": "https://github.com/images/error/testuser_happy.gif", + "gravatar_id": "", + "url": "https://api.github.com/users/testuser", + "html_url": "https://github.com/testuser", + "type": "User", + "site_admin": false + }, + "assignees": [ + { + "login": "testuser", + "id": 1, + "node_id": "MDQ6VXNlcjE=", + "avatar_url": "https://github.com/images/error/testuser_happy.gif", + "gravatar_id": "", + "url": "https://api.github.com/users/testuser", + "html_url": "https://github.com/testuser", + "type": "User", + "site_admin": false + } + ], + "milestone": null, + "comments": 1, + "created_at": "2011-04-22T13:33:48Z", + "updated_at": "2011-04-22T13:33:48Z", + "closed_at": null, + "author_association": "CONTRIBUTOR", + "active_lock_reason": null, + "body": "Please add this enhancement.", + "reactions": { + "url": "https://api.github.com/repos/anotherowner/anotherrepo/issues/5/reactions", + "total_count": 2, + "+1": 2, + "-1": 0, + "laugh": 0, + "hooray": 0, + "confused": 0, + "heart": 0, + "rocket": 0, + "eyes": 0 + }, + "timeline_url": "https://api.github.com/repos/anotherowner/anotherrepo/issues/5/timeline", + "performed_via_github_app": null, + "state_reason": null, + "repository": { + "id": 1296270, + "node_id": "MDEwOlJlcG9zaXRvcnkxMjk2Mjcw", + "name": "anotherrepo", + "full_name": "anotherowner/anotherrepo", + "owner": { + "login": "anotherowner", + "id": 8, + "node_id": "MDQ6VXNlcjg=", + "avatar_url": "https://github.com/images/error/anotherowner_happy.gif", + "gravatar_id": "", + "url": "https://api.github.com/users/anotherowner", + "html_url": "https://github.com/anotherowner", + "type": "User", + "site_admin": false + }, + "private": false, + "html_url": "https://github.com/anotherowner/anotherrepo", + "description": "Another repository with issues for testuser", + "fork": false, + "url": "https://api.github.com/repos/anotherowner/anotherrepo", + "created_at": "2011-01-26T19:01:12Z", + "updated_at": "2011-01-26T19:14:43Z", + "pushed_at": "2011-01-26T19:06:43Z", + "git_url": "git://github.com/anotherowner/anotherrepo.git", + "ssh_url": "git@github.com:anotherowner/anotherrepo.git", + "clone_url": "https://github.com/anotherowner/anotherrepo.git", + "size": 256, + "stargazers_count": 42, + "watchers_count": 15, + "language": "JavaScript", + "has_issues": true, + "has_projects": true, + "has_wiki": true, + "has_pages": false, + "forks_count": 3, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 5, + "license": { + "key": "apache-2.0", + "name": "Apache License 2.0", + "spdx_id": "Apache-2.0", + "url": "https://api.github.com/licenses/apache-2.0", + "node_id": "MDc6TGljZW5zZWFwYWNoZS0yLjA=" + }, + "forks": 3, + "open_issues": 5, + "watchers": 15, + "default_branch": "main" + } + } + } + ] + }, + "connections": { + "When clicking 'Execute Workflow'": { + "main": [ + [ + { + "node": "Get User Issues", + "type": "main", + "index": 0 + } + ] + ] + }, + "Get User Issues": { + "main": [ + [ + { + "node": "Issues Response", + "type": "main", + "index": 0 + } + ] + ] + } + }, + "active": false, + "settings": { + "executionOrder": "v1" + } +} diff --git a/packages/nodes-base/nodes/Github/__tests__/getUserIssuesFiltered.workflow.json b/packages/nodes-base/nodes/Github/__tests__/getUserIssuesFiltered.workflow.json new file mode 100644 index 00000000000..9c2d93afe69 --- /dev/null +++ b/packages/nodes-base/nodes/Github/__tests__/getUserIssuesFiltered.workflow.json @@ -0,0 +1,211 @@ +{ + "name": "Github User getUserIssues Filtered Test Workflow", + "nodes": [ + { + "parameters": {}, + "type": "n8n-nodes-base.manualTrigger", + "typeVersion": 1, + "position": [0, 0], + "id": "trigger-id", + "name": "When clicking 'Execute Workflow'" + }, + { + "parameters": { + "resource": "user", + "operation": "getUserIssues", + "returnAll": true, + "getUserIssuesFilters": { + "state": "closed", + "labels": "enhancement" + } + }, + "type": "n8n-nodes-base.github", + "typeVersion": 1, + "position": [200, 0], + "id": "github-node-id", + "name": "Get User Issues Filtered", + "credentials": { + "githubApi": { + "id": "credential-id", + "name": "Test Credentials" + } + } + }, + { + "parameters": {}, + "type": "n8n-nodes-base.noOp", + "typeVersion": 1, + "position": [400, 0], + "id": "noop-id", + "name": "Issues Response" + } + ], + "pinData": { + "Issues Response": [ + { + "json": { + "url": "https://api.github.com/repos/testowner/closedrepo/issues/10", + "repository_url": "https://api.github.com/repos/testowner/closedrepo", + "labels_url": "https://api.github.com/repos/testowner/closedrepo/issues/10/labels{/name}", + "comments_url": "https://api.github.com/repos/testowner/closedrepo/issues/10/comments", + "events_url": "https://api.github.com/repos/testowner/closedrepo/issues/10/events", + "html_url": "https://github.com/testowner/closedrepo/issues/10", + "id": 10, + "number": 10, + "title": "Completed enhancement", + "user": { + "login": "enhancementauthor", + "id": 9, + "node_id": "MDQ6VXNlcjk=", + "avatar_url": "https://github.com/images/error/enhancementauthor_happy.gif", + "gravatar_id": "", + "url": "https://api.github.com/users/enhancementauthor", + "html_url": "https://github.com/enhancementauthor", + "type": "User", + "site_admin": false + }, + "labels": [ + { + "id": 208045947, + "node_id": "MDU6TGFiZWwyMDgwNDU5NDc=", + "url": "https://api.github.com/repos/testowner/closedrepo/labels/enhancement", + "name": "enhancement", + "description": "New feature or request", + "color": "a2eeef", + "default": true + } + ], + "state": "closed", + "locked": false, + "assignee": { + "login": "testuser", + "id": 1, + "node_id": "MDQ6VXNlcjE=", + "avatar_url": "https://github.com/images/error/testuser_happy.gif", + "gravatar_id": "", + "url": "https://api.github.com/users/testuser", + "html_url": "https://github.com/testuser", + "type": "User", + "site_admin": false + }, + "assignees": [ + { + "login": "testuser", + "id": 1, + "node_id": "MDQ6VXNlcjE=", + "avatar_url": "https://github.com/images/error/testuser_happy.gif", + "gravatar_id": "", + "url": "https://api.github.com/users/testuser", + "html_url": "https://github.com/testuser", + "type": "User", + "site_admin": false + } + ], + "milestone": null, + "comments": 5, + "created_at": "2011-04-10T13:33:48Z", + "updated_at": "2011-04-30T13:33:48Z", + "closed_at": "2011-04-30T13:33:48Z", + "author_association": "CONTRIBUTOR", + "active_lock_reason": null, + "body": "Enhancement has been completed successfully.", + "reactions": { + "url": "https://api.github.com/repos/testowner/closedrepo/issues/10/reactions", + "total_count": 3, + "+1": 2, + "-1": 0, + "laugh": 0, + "hooray": 1, + "confused": 0, + "heart": 0, + "rocket": 0, + "eyes": 0 + }, + "timeline_url": "https://api.github.com/repos/testowner/closedrepo/issues/10/timeline", + "performed_via_github_app": null, + "state_reason": "completed", + "repository": { + "id": 1296271, + "node_id": "MDEwOlJlcG9zaXRvcnkxMjk2Mjcx", + "name": "closedrepo", + "full_name": "testowner/closedrepo", + "owner": { + "login": "testowner", + "id": 10, + "node_id": "MDQ6VXNlcjEw", + "avatar_url": "https://github.com/images/error/testowner_happy.gif", + "gravatar_id": "", + "url": "https://api.github.com/users/testowner", + "html_url": "https://github.com/testowner", + "type": "User", + "site_admin": false + }, + "private": false, + "html_url": "https://github.com/testowner/closedrepo", + "description": "Repository with closed enhancement issues", + "fork": false, + "url": "https://api.github.com/repos/testowner/closedrepo", + "created_at": "2011-01-26T19:01:12Z", + "updated_at": "2011-01-26T19:14:43Z", + "pushed_at": "2011-01-26T19:06:43Z", + "git_url": "git://github.com/testowner/closedrepo.git", + "ssh_url": "git@github.com:testowner/closedrepo.git", + "clone_url": "https://github.com/testowner/closedrepo.git", + "size": 128, + "stargazers_count": 25, + "watchers_count": 5, + "language": "Python", + "has_issues": true, + "has_projects": true, + "has_wiki": true, + "has_pages": false, + "forks_count": 2, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 0, + "license": { + "key": "mit", + "name": "MIT License", + "spdx_id": "MIT", + "url": "https://api.github.com/licenses/mit", + "node_id": "MDc6TGljZW5zZW1pdA==" + }, + "forks": 2, + "open_issues": 0, + "watchers": 5, + "default_branch": "main" + } + } + } + ] + }, + "connections": { + "When clicking 'Execute Workflow'": { + "main": [ + [ + { + "node": "Get User Issues Filtered", + "type": "main", + "index": 0 + } + ] + ] + }, + "Get User Issues Filtered": { + "main": [ + [ + { + "node": "Issues Response", + "type": "main", + "index": 0 + } + ] + ] + } + }, + "active": false, + "settings": { + "executionOrder": "v1" + } +} diff --git a/packages/nodes-base/nodes/Github/__tests__/getUserIssuesLimit.workflow.json b/packages/nodes-base/nodes/Github/__tests__/getUserIssuesLimit.workflow.json new file mode 100644 index 00000000000..f77dabee121 --- /dev/null +++ b/packages/nodes-base/nodes/Github/__tests__/getUserIssuesLimit.workflow.json @@ -0,0 +1,209 @@ +{ + "name": "Github User getUserIssues Limit Test Workflow", + "nodes": [ + { + "parameters": {}, + "type": "n8n-nodes-base.manualTrigger", + "typeVersion": 1, + "position": [0, 0], + "id": "trigger-id", + "name": "When clicking 'Execute Workflow'" + }, + { + "parameters": { + "resource": "user", + "operation": "getUserIssues", + "returnAll": false, + "limit": 1, + "getUserIssuesFilters": {} + }, + "type": "n8n-nodes-base.github", + "typeVersion": 1, + "position": [200, 0], + "id": "github-node-id", + "name": "Get User Issues Limited", + "credentials": { + "githubApi": { + "id": "credential-id", + "name": "Test Credentials" + } + } + }, + { + "parameters": {}, + "type": "n8n-nodes-base.noOp", + "typeVersion": 1, + "position": [400, 0], + "id": "noop-id", + "name": "Issues Response" + } + ], + "pinData": { + "Issues Response": [ + { + "json": { + "url": "https://api.github.com/repos/someowner/somerepo/issues/1", + "repository_url": "https://api.github.com/repos/someowner/somerepo", + "labels_url": "https://api.github.com/repos/someowner/somerepo/issues/1/labels{/name}", + "comments_url": "https://api.github.com/repos/someowner/somerepo/issues/1/comments", + "events_url": "https://api.github.com/repos/someowner/somerepo/issues/1/events", + "html_url": "https://github.com/someowner/somerepo/issues/1", + "id": 1, + "number": 1, + "title": "Issue assigned to me", + "user": { + "login": "issueauthor", + "id": 5, + "node_id": "MDQ6VXNlcjU=", + "avatar_url": "https://github.com/images/error/issueauthor_happy.gif", + "gravatar_id": "", + "url": "https://api.github.com/users/issueauthor", + "html_url": "https://github.com/issueauthor", + "type": "User", + "site_admin": false + }, + "labels": [ + { + "id": 208045946, + "node_id": "MDU6TGFiZWwyMDgwNDU5NDY=", + "url": "https://api.github.com/repos/someowner/somerepo/labels/bug", + "name": "bug", + "description": "Something isn't working", + "color": "d73a49", + "default": true + } + ], + "state": "open", + "locked": false, + "assignee": { + "login": "testuser", + "id": 1, + "node_id": "MDQ6VXNlcjE=", + "avatar_url": "https://github.com/images/error/testuser_happy.gif", + "gravatar_id": "", + "url": "https://api.github.com/users/testuser", + "html_url": "https://github.com/testuser", + "type": "User", + "site_admin": false + }, + "assignees": [ + { + "login": "testuser", + "id": 1, + "node_id": "MDQ6VXNlcjE=", + "avatar_url": "https://github.com/images/error/testuser_happy.gif", + "gravatar_id": "", + "url": "https://api.github.com/users/testuser", + "html_url": "https://github.com/testuser", + "type": "User", + "site_admin": false + } + ], + "milestone": null, + "comments": 0, + "created_at": "2011-04-22T13:33:48Z", + "updated_at": "2011-04-22T13:33:48Z", + "closed_at": null, + "author_association": "NONE", + "active_lock_reason": null, + "body": "This is an issue assigned to me.", + "reactions": { + "url": "https://api.github.com/repos/someowner/somerepo/issues/1/reactions", + "total_count": 0, + "+1": 0, + "-1": 0, + "laugh": 0, + "hooray": 0, + "confused": 0, + "heart": 0, + "rocket": 0, + "eyes": 0 + }, + "timeline_url": "https://api.github.com/repos/someowner/somerepo/issues/1/timeline", + "performed_via_github_app": null, + "state_reason": null, + "repository": { + "id": 1296269, + "node_id": "MDEwOlJlcG9zaXRvcnkxMjk2MjY5", + "name": "somerepo", + "full_name": "someowner/somerepo", + "owner": { + "login": "someowner", + "id": 6, + "node_id": "MDQ6VXNlcjY=", + "avatar_url": "https://github.com/images/error/someowner_happy.gif", + "gravatar_id": "", + "url": "https://api.github.com/users/someowner", + "html_url": "https://github.com/someowner", + "type": "User", + "site_admin": false + }, + "private": false, + "html_url": "https://github.com/someowner/somerepo", + "description": "Repository with issues assigned to testuser", + "fork": false, + "url": "https://api.github.com/repos/someowner/somerepo", + "created_at": "2011-01-26T19:01:12Z", + "updated_at": "2011-01-26T19:14:43Z", + "pushed_at": "2011-01-26T19:06:43Z", + "git_url": "git://github.com/someowner/somerepo.git", + "ssh_url": "git@github.com:someowner/somerepo.git", + "clone_url": "https://github.com/someowner/somerepo.git", + "size": 108, + "stargazers_count": 80, + "watchers_count": 9, + "language": "C", + "has_issues": true, + "has_projects": true, + "has_wiki": true, + "has_pages": false, + "forks_count": 9, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 0, + "license": { + "key": "mit", + "name": "MIT License", + "spdx_id": "MIT", + "url": "https://api.github.com/licenses/mit", + "node_id": "MDc6TGljZW5zZW1pdA==" + }, + "forks": 9, + "open_issues": 0, + "watchers": 9, + "default_branch": "master" + } + } + } + ] + }, + "connections": { + "When clicking 'Execute Workflow'": { + "main": [ + [ + { + "node": "Get User Issues Limited", + "type": "main", + "index": 0 + } + ] + ] + }, + "Get User Issues Limited": { + "main": [ + [ + { + "node": "Issues Response", + "type": "main", + "index": 0 + } + ] + ] + } + }, + "active": false, + "settings": { + "executionOrder": "v1" + } +} diff --git a/packages/nodes-base/nodes/Github/__tests__/getUserRepositories.workflow.json b/packages/nodes-base/nodes/Github/__tests__/getUserRepositories.workflow.json new file mode 100644 index 00000000000..aa76326ff78 --- /dev/null +++ b/packages/nodes-base/nodes/Github/__tests__/getUserRepositories.workflow.json @@ -0,0 +1,144 @@ +{ + "name": "Github User getRepositories Test Workflow", + "nodes": [ + { + "parameters": {}, + "type": "n8n-nodes-base.manualTrigger", + "typeVersion": 1, + "position": [0, 0], + "id": "trigger-id", + "name": "When clicking 'Execute Workflow'" + }, + { + "parameters": { + "resource": "user", + "operation": "getRepositories", + "owner": { + "__rl": true, + "value": "testuser", + "mode": "name" + }, + "returnAll": true + }, + "type": "n8n-nodes-base.github", + "typeVersion": 1, + "position": [200, 0], + "id": "github-node-id", + "name": "Get User Repositories", + "credentials": { + "githubApi": { + "id": "credential-id", + "name": "Test Credentials" + } + } + }, + { + "parameters": {}, + "type": "n8n-nodes-base.noOp", + "typeVersion": 1, + "position": [400, 0], + "id": "noop-id", + "name": "Repositories Response" + } + ], + "pinData": { + "Repositories Response": [ + { + "json": { + "id": 1296269, + "name": "hello-world", + "full_name": "testuser/hello-world", + "owner": { + "login": "testuser", + "id": 1, + "type": "User" + }, + "private": false, + "html_url": "https://github.com/testuser/hello-world", + "description": "My first repository on GitHub!", + "fork": false, + "created_at": "2011-01-26T19:01:12Z", + "updated_at": "2011-01-26T19:14:43Z", + "pushed_at": "2011-01-26T19:06:43Z", + "clone_url": "https://github.com/testuser/hello-world.git", + "size": 108, + "stargazers_count": 80, + "watchers_count": 9, + "language": "C", + "forks_count": 9, + "archived": false, + "disabled": false, + "open_issues_count": 0, + "license": { + "key": "mit", + "name": "MIT License" + }, + "visibility": "public", + "default_branch": "master" + } + }, + { + "json": { + "id": 1296270, + "name": "my-app", + "full_name": "testuser/my-app", + "owner": { + "login": "testuser", + "id": 1, + "type": "User" + }, + "private": false, + "html_url": "https://github.com/testuser/my-app", + "description": "My awesome application", + "fork": false, + "created_at": "2011-02-26T19:01:12Z", + "updated_at": "2011-02-26T19:14:43Z", + "pushed_at": "2011-02-26T19:06:43Z", + "clone_url": "https://github.com/testuser/my-app.git", + "size": 512, + "stargazers_count": 156, + "watchers_count": 45, + "language": "JavaScript", + "forks_count": 23, + "archived": false, + "disabled": false, + "open_issues_count": 5, + "license": { + "key": "apache-2.0", + "name": "Apache License 2.0" + }, + "visibility": "public", + "default_branch": "main" + } + } + ] + }, + "connections": { + "When clicking 'Execute Workflow'": { + "main": [ + [ + { + "node": "Get User Repositories", + "type": "main", + "index": 0 + } + ] + ] + }, + "Get User Repositories": { + "main": [ + [ + { + "node": "Repositories Response", + "type": "main", + "index": 0 + } + ] + ] + } + }, + "active": false, + "settings": { + "executionOrder": "v1" + } +} diff --git a/packages/nodes-base/nodes/Github/__tests__/getUserRepositoriesLimit.workflow.json b/packages/nodes-base/nodes/Github/__tests__/getUserRepositoriesLimit.workflow.json new file mode 100644 index 00000000000..34f6ba23198 --- /dev/null +++ b/packages/nodes-base/nodes/Github/__tests__/getUserRepositoriesLimit.workflow.json @@ -0,0 +1,111 @@ +{ + "name": "Github User getRepositories Limit Test Workflow", + "nodes": [ + { + "parameters": {}, + "type": "n8n-nodes-base.manualTrigger", + "typeVersion": 1, + "position": [0, 0], + "id": "trigger-id", + "name": "When clicking 'Execute Workflow'" + }, + { + "parameters": { + "resource": "user", + "operation": "getRepositories", + "owner": { + "__rl": true, + "value": "testuser", + "mode": "name" + }, + "returnAll": false, + "limit": 1 + }, + "type": "n8n-nodes-base.github", + "typeVersion": 1, + "position": [200, 0], + "id": "github-node-id", + "name": "Get User Repositories Limited", + "credentials": { + "githubApi": { + "id": "credential-id", + "name": "Test Credentials" + } + } + }, + { + "parameters": {}, + "type": "n8n-nodes-base.noOp", + "typeVersion": 1, + "position": [400, 0], + "id": "noop-id", + "name": "Repositories Response" + } + ], + "pinData": { + "Repositories Response": [ + { + "json": { + "id": 1296269, + "name": "hello-world", + "full_name": "testuser/hello-world", + "owner": { + "login": "testuser", + "id": 1, + "type": "User" + }, + "private": false, + "html_url": "https://github.com/testuser/hello-world", + "description": "My first repository on GitHub!", + "fork": false, + "created_at": "2011-01-26T19:01:12Z", + "updated_at": "2011-01-26T19:14:43Z", + "pushed_at": "2011-01-26T19:06:43Z", + "clone_url": "https://github.com/testuser/hello-world.git", + "size": 108, + "stargazers_count": 80, + "watchers_count": 9, + "language": "C", + "forks_count": 9, + "archived": false, + "disabled": false, + "open_issues_count": 0, + "license": { + "key": "mit", + "name": "MIT License" + }, + "visibility": "public", + "default_branch": "master" + } + } + ] + }, + "connections": { + "When clicking 'Execute Workflow'": { + "main": [ + [ + { + "node": "Get User Repositories Limited", + "type": "main", + "index": 0 + } + ] + ] + }, + "Get User Repositories Limited": { + "main": [ + [ + { + "node": "Repositories Response", + "type": "main", + "index": 0 + } + ] + ] + } + }, + "active": false, + "settings": { + "executionOrder": "v1" + } +} diff --git a/packages/nodes-base/nodes/Github/__tests__/node/Github.node.test.ts b/packages/nodes-base/nodes/Github/__tests__/node/Github.node.test.ts index 571ab35eb13..ae0710956ed 100644 --- a/packages/nodes-base/nodes/Github/__tests__/node/Github.node.test.ts +++ b/packages/nodes-base/nodes/Github/__tests__/node/Github.node.test.ts @@ -622,7 +622,7 @@ describe('Test Github Node', () => { it('should fetch open issues by default (user:getIssues)', async () => { mockExecutionContext.getNodeParameter.mockImplementation((parameterName: string) => { if (parameterName === 'resource') return 'user'; - if (parameterName === 'operation') return 'getIssues'; + if (parameterName === 'operation') return 'getUserIssues'; if (parameterName === 'getUserIssuesFilters') return {}; if (parameterName === 'returnAll') return true; if (parameterName === 'authentication') return 'accessToken'; @@ -650,7 +650,7 @@ describe('Test Github Node', () => { it('should fetch closed issues when state filter is set to closed (user:getIssues)', async () => { mockExecutionContext.getNodeParameter.mockImplementation((parameterName: string) => { if (parameterName === 'resource') return 'user'; - if (parameterName === 'operation') return 'getIssues'; + if (parameterName === 'operation') return 'getUserIssues'; if (parameterName === 'getUserIssuesFilters') return { state: 'closed' }; if (parameterName === 'returnAll') return true; if (parameterName === 'authentication') return 'accessToken'; @@ -676,7 +676,7 @@ describe('Test Github Node', () => { it('should fetch issues with a specific label (user:getIssues)', async () => { mockExecutionContext.getNodeParameter.mockImplementation((parameterName: string) => { if (parameterName === 'resource') return 'user'; - if (parameterName === 'operation') return 'getIssues'; + if (parameterName === 'operation') return 'getUserIssues'; if (parameterName === 'getUserIssuesFilters') return { labels: 'bug' }; if (parameterName === 'returnAll') return true; if (parameterName === 'authentication') return 'accessToken';