mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-19 19:11:13 +00:00
refactor: Migrate NodeConnectionType to const object type (no-changelog) (#14078)
Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { mock } from 'jest-mock-extended';
|
||||
|
||||
import { NodeConnectionType } from '@/Interfaces';
|
||||
import { NodeConnectionTypes } from '@/Interfaces';
|
||||
import type { IConnection } from '@/Interfaces';
|
||||
import type {
|
||||
IBinaryKeyData,
|
||||
@@ -64,7 +64,7 @@ describe('Workflow', () => {
|
||||
[
|
||||
{
|
||||
node: 'Set',
|
||||
type: NodeConnectionType.Main,
|
||||
type: NodeConnectionTypes.Main,
|
||||
index: 0,
|
||||
},
|
||||
],
|
||||
@@ -75,7 +75,7 @@ describe('Workflow', () => {
|
||||
[
|
||||
{
|
||||
node: 'Set1',
|
||||
type: NodeConnectionType.Main,
|
||||
type: NodeConnectionTypes.Main,
|
||||
index: 0,
|
||||
},
|
||||
],
|
||||
@@ -134,21 +134,21 @@ describe('Workflow', () => {
|
||||
[
|
||||
{
|
||||
node: 'Set1',
|
||||
type: NodeConnectionType.Main,
|
||||
type: NodeConnectionTypes.Main,
|
||||
index: 0,
|
||||
},
|
||||
],
|
||||
[
|
||||
{
|
||||
node: 'Set',
|
||||
type: NodeConnectionType.Main,
|
||||
type: NodeConnectionTypes.Main,
|
||||
index: 0,
|
||||
},
|
||||
],
|
||||
[
|
||||
{
|
||||
node: 'Set',
|
||||
type: NodeConnectionType.Main,
|
||||
type: NodeConnectionTypes.Main,
|
||||
index: 0,
|
||||
},
|
||||
],
|
||||
@@ -159,7 +159,7 @@ describe('Workflow', () => {
|
||||
[
|
||||
{
|
||||
node: 'Set2',
|
||||
type: NodeConnectionType.Main,
|
||||
type: NodeConnectionTypes.Main,
|
||||
index: 0,
|
||||
},
|
||||
],
|
||||
@@ -170,7 +170,7 @@ describe('Workflow', () => {
|
||||
[
|
||||
{
|
||||
node: 'Set2',
|
||||
type: NodeConnectionType.Main,
|
||||
type: NodeConnectionTypes.Main,
|
||||
index: 0,
|
||||
},
|
||||
],
|
||||
@@ -234,7 +234,7 @@ describe('Workflow', () => {
|
||||
[
|
||||
{
|
||||
node: 'Set',
|
||||
type: NodeConnectionType.Main,
|
||||
type: NodeConnectionTypes.Main,
|
||||
index: 0,
|
||||
},
|
||||
],
|
||||
@@ -242,7 +242,7 @@ describe('Workflow', () => {
|
||||
[
|
||||
{
|
||||
node: 'Switch',
|
||||
type: NodeConnectionType.Main,
|
||||
type: NodeConnectionTypes.Main,
|
||||
index: 0,
|
||||
},
|
||||
],
|
||||
@@ -253,7 +253,7 @@ describe('Workflow', () => {
|
||||
[
|
||||
{
|
||||
node: 'Set1',
|
||||
type: NodeConnectionType.Main,
|
||||
type: NodeConnectionTypes.Main,
|
||||
index: 0,
|
||||
},
|
||||
],
|
||||
@@ -264,12 +264,12 @@ describe('Workflow', () => {
|
||||
[
|
||||
{
|
||||
node: 'Set1',
|
||||
type: NodeConnectionType.Main,
|
||||
type: NodeConnectionTypes.Main,
|
||||
index: 0,
|
||||
},
|
||||
{
|
||||
node: 'Switch',
|
||||
type: NodeConnectionType.Main,
|
||||
type: NodeConnectionTypes.Main,
|
||||
index: 0,
|
||||
},
|
||||
],
|
||||
@@ -280,7 +280,7 @@ describe('Workflow', () => {
|
||||
[
|
||||
{
|
||||
node: 'Set1',
|
||||
type: NodeConnectionType.Main,
|
||||
type: NodeConnectionTypes.Main,
|
||||
index: 0,
|
||||
},
|
||||
],
|
||||
@@ -323,7 +323,7 @@ describe('Workflow', () => {
|
||||
[
|
||||
{
|
||||
node: 'AINode',
|
||||
type: NodeConnectionType.AiAgent,
|
||||
type: NodeConnectionTypes.AiAgent,
|
||||
index: 0,
|
||||
},
|
||||
],
|
||||
@@ -334,7 +334,7 @@ describe('Workflow', () => {
|
||||
[
|
||||
{
|
||||
node: 'Set1',
|
||||
type: NodeConnectionType.Main,
|
||||
type: NodeConnectionTypes.Main,
|
||||
index: 0,
|
||||
},
|
||||
],
|
||||
@@ -707,7 +707,7 @@ describe('Workflow', () => {
|
||||
[
|
||||
{
|
||||
node: 'Node2',
|
||||
type: NodeConnectionType.Main,
|
||||
type: NodeConnectionTypes.Main,
|
||||
index: 0,
|
||||
},
|
||||
],
|
||||
@@ -738,7 +738,7 @@ describe('Workflow', () => {
|
||||
[
|
||||
{
|
||||
node: 'Node2',
|
||||
type: NodeConnectionType.Main,
|
||||
type: NodeConnectionTypes.Main,
|
||||
index: 0,
|
||||
},
|
||||
],
|
||||
@@ -774,7 +774,7 @@ describe('Workflow', () => {
|
||||
[
|
||||
{
|
||||
node: 'Node2',
|
||||
type: NodeConnectionType.Main,
|
||||
type: NodeConnectionTypes.Main,
|
||||
index: 0,
|
||||
},
|
||||
],
|
||||
@@ -805,7 +805,7 @@ describe('Workflow', () => {
|
||||
[
|
||||
{
|
||||
node: 'Node2New',
|
||||
type: NodeConnectionType.Main,
|
||||
type: NodeConnectionTypes.Main,
|
||||
index: 0,
|
||||
},
|
||||
],
|
||||
@@ -862,7 +862,7 @@ describe('Workflow', () => {
|
||||
[
|
||||
{
|
||||
node: 'Node3',
|
||||
type: NodeConnectionType.Main,
|
||||
type: NodeConnectionTypes.Main,
|
||||
index: 0,
|
||||
},
|
||||
],
|
||||
@@ -873,12 +873,12 @@ describe('Workflow', () => {
|
||||
[
|
||||
{
|
||||
node: 'Node3',
|
||||
type: NodeConnectionType.Main,
|
||||
type: NodeConnectionTypes.Main,
|
||||
index: 0,
|
||||
},
|
||||
{
|
||||
node: 'Node5',
|
||||
type: NodeConnectionType.Main,
|
||||
type: NodeConnectionTypes.Main,
|
||||
index: 0,
|
||||
},
|
||||
],
|
||||
@@ -889,12 +889,12 @@ describe('Workflow', () => {
|
||||
[
|
||||
{
|
||||
node: 'Node4',
|
||||
type: NodeConnectionType.Main,
|
||||
type: NodeConnectionTypes.Main,
|
||||
index: 0,
|
||||
},
|
||||
{
|
||||
node: 'Node5',
|
||||
type: NodeConnectionType.Main,
|
||||
type: NodeConnectionTypes.Main,
|
||||
index: 0,
|
||||
},
|
||||
],
|
||||
@@ -946,7 +946,7 @@ describe('Workflow', () => {
|
||||
[
|
||||
{
|
||||
node: 'Node3New',
|
||||
type: NodeConnectionType.Main,
|
||||
type: NodeConnectionTypes.Main,
|
||||
index: 0,
|
||||
},
|
||||
],
|
||||
@@ -957,12 +957,12 @@ describe('Workflow', () => {
|
||||
[
|
||||
{
|
||||
node: 'Node3New',
|
||||
type: NodeConnectionType.Main,
|
||||
type: NodeConnectionTypes.Main,
|
||||
index: 0,
|
||||
},
|
||||
{
|
||||
node: 'Node5',
|
||||
type: NodeConnectionType.Main,
|
||||
type: NodeConnectionTypes.Main,
|
||||
index: 0,
|
||||
},
|
||||
],
|
||||
@@ -973,12 +973,12 @@ describe('Workflow', () => {
|
||||
[
|
||||
{
|
||||
node: 'Node4',
|
||||
type: NodeConnectionType.Main,
|
||||
type: NodeConnectionTypes.Main,
|
||||
index: 0,
|
||||
},
|
||||
{
|
||||
node: 'Node5',
|
||||
type: NodeConnectionType.Main,
|
||||
type: NodeConnectionTypes.Main,
|
||||
index: 0,
|
||||
},
|
||||
],
|
||||
@@ -1558,7 +1558,7 @@ describe('Workflow', () => {
|
||||
[
|
||||
{
|
||||
node: 'Node2',
|
||||
type: NodeConnectionType.Main,
|
||||
type: NodeConnectionTypes.Main,
|
||||
index: 0,
|
||||
},
|
||||
],
|
||||
@@ -1569,7 +1569,7 @@ describe('Workflow', () => {
|
||||
[
|
||||
{
|
||||
node: 'Node3',
|
||||
type: NodeConnectionType.Main,
|
||||
type: NodeConnectionTypes.Main,
|
||||
index: 0,
|
||||
},
|
||||
],
|
||||
@@ -1580,7 +1580,7 @@ describe('Workflow', () => {
|
||||
[
|
||||
{
|
||||
node: 'Node2',
|
||||
type: NodeConnectionType.Main,
|
||||
type: NodeConnectionTypes.Main,
|
||||
index: 0,
|
||||
},
|
||||
],
|
||||
@@ -1884,10 +1884,10 @@ describe('Workflow', () => {
|
||||
it('should return connections by destination node', () => {
|
||||
const connections: IConnections = {
|
||||
Node1: {
|
||||
[NodeConnectionType.Main]: [
|
||||
[NodeConnectionTypes.Main]: [
|
||||
[
|
||||
{ node: 'Node2', type: NodeConnectionType.Main, index: 0 },
|
||||
{ node: 'Node3', type: NodeConnectionType.Main, index: 1 },
|
||||
{ node: 'Node2', type: NodeConnectionTypes.Main, index: 0 },
|
||||
{ node: 'Node3', type: NodeConnectionTypes.Main, index: 1 },
|
||||
],
|
||||
],
|
||||
},
|
||||
@@ -1895,12 +1895,14 @@ describe('Workflow', () => {
|
||||
const result = Workflow.getConnectionsByDestination(connections);
|
||||
expect(result).toEqual({
|
||||
Node2: {
|
||||
[NodeConnectionType.Main]: [[{ node: 'Node1', type: NodeConnectionType.Main, index: 0 }]],
|
||||
[NodeConnectionTypes.Main]: [
|
||||
[{ node: 'Node1', type: NodeConnectionTypes.Main, index: 0 }],
|
||||
],
|
||||
},
|
||||
Node3: {
|
||||
[NodeConnectionType.Main]: [
|
||||
[NodeConnectionTypes.Main]: [
|
||||
[],
|
||||
[{ node: 'Node1', type: NodeConnectionType.Main, index: 0 }],
|
||||
[{ node: 'Node1', type: NodeConnectionTypes.Main, index: 0 }],
|
||||
],
|
||||
},
|
||||
});
|
||||
@@ -1909,9 +1911,11 @@ describe('Workflow', () => {
|
||||
it('should handle multiple connection types', () => {
|
||||
const connections: IConnections = {
|
||||
Node1: {
|
||||
[NodeConnectionType.Main]: [[{ node: 'Node2', type: NodeConnectionType.Main, index: 0 }]],
|
||||
[NodeConnectionType.AiAgent]: [
|
||||
[{ node: 'Node3', type: NodeConnectionType.AiAgent, index: 0 }],
|
||||
[NodeConnectionTypes.Main]: [
|
||||
[{ node: 'Node2', type: NodeConnectionTypes.Main, index: 0 }],
|
||||
],
|
||||
[NodeConnectionTypes.AiAgent]: [
|
||||
[{ node: 'Node3', type: NodeConnectionTypes.AiAgent, index: 0 }],
|
||||
],
|
||||
},
|
||||
};
|
||||
@@ -1919,11 +1923,13 @@ describe('Workflow', () => {
|
||||
const result = Workflow.getConnectionsByDestination(connections);
|
||||
expect(result).toEqual({
|
||||
Node2: {
|
||||
[NodeConnectionType.Main]: [[{ node: 'Node1', type: NodeConnectionType.Main, index: 0 }]],
|
||||
[NodeConnectionTypes.Main]: [
|
||||
[{ node: 'Node1', type: NodeConnectionTypes.Main, index: 0 }],
|
||||
],
|
||||
},
|
||||
Node3: {
|
||||
[NodeConnectionType.AiAgent]: [
|
||||
[{ node: 'Node1', type: NodeConnectionType.AiAgent, index: 0 }],
|
||||
[NodeConnectionTypes.AiAgent]: [
|
||||
[{ node: 'Node1', type: NodeConnectionTypes.AiAgent, index: 0 }],
|
||||
],
|
||||
},
|
||||
});
|
||||
@@ -1932,7 +1938,7 @@ describe('Workflow', () => {
|
||||
it('should handle nodes with no connections', () => {
|
||||
const connections: IConnections = {
|
||||
Node1: {
|
||||
[NodeConnectionType.Main]: [[]],
|
||||
[NodeConnectionTypes.Main]: [[]],
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1944,9 +1950,9 @@ describe('Workflow', () => {
|
||||
it('should handle nodes with null connections', () => {
|
||||
const connections: IConnections = {
|
||||
Node1: {
|
||||
[NodeConnectionType.Main]: [
|
||||
[NodeConnectionTypes.Main]: [
|
||||
null as unknown as IConnection[],
|
||||
[{ node: 'Node2', type: NodeConnectionType.Main, index: 0 }],
|
||||
[{ node: 'Node2', type: NodeConnectionTypes.Main, index: 0 }],
|
||||
],
|
||||
},
|
||||
};
|
||||
@@ -1954,7 +1960,9 @@ describe('Workflow', () => {
|
||||
const result = Workflow.getConnectionsByDestination(connections);
|
||||
expect(result).toEqual({
|
||||
Node2: {
|
||||
[NodeConnectionType.Main]: [[{ node: 'Node1', type: NodeConnectionType.Main, index: 1 }]],
|
||||
[NodeConnectionTypes.Main]: [
|
||||
[{ node: 'Node1', type: NodeConnectionTypes.Main, index: 1 }],
|
||||
],
|
||||
},
|
||||
});
|
||||
});
|
||||
@@ -1962,20 +1970,24 @@ describe('Workflow', () => {
|
||||
it('should handle nodes with multiple input connections', () => {
|
||||
const connections: IConnections = {
|
||||
Node1: {
|
||||
[NodeConnectionType.Main]: [[{ node: 'Node2', type: NodeConnectionType.Main, index: 0 }]],
|
||||
[NodeConnectionTypes.Main]: [
|
||||
[{ node: 'Node2', type: NodeConnectionTypes.Main, index: 0 }],
|
||||
],
|
||||
},
|
||||
Node3: {
|
||||
[NodeConnectionType.Main]: [[{ node: 'Node2', type: NodeConnectionType.Main, index: 0 }]],
|
||||
[NodeConnectionTypes.Main]: [
|
||||
[{ node: 'Node2', type: NodeConnectionTypes.Main, index: 0 }],
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
const result = Workflow.getConnectionsByDestination(connections);
|
||||
expect(result).toEqual({
|
||||
Node2: {
|
||||
[NodeConnectionType.Main]: [
|
||||
[NodeConnectionTypes.Main]: [
|
||||
[
|
||||
{ node: 'Node1', type: NodeConnectionType.Main, index: 0 },
|
||||
{ node: 'Node3', type: NodeConnectionType.Main, index: 0 },
|
||||
{ node: 'Node1', type: NodeConnectionTypes.Main, index: 0 },
|
||||
{ node: 'Node3', type: NodeConnectionTypes.Main, index: 0 },
|
||||
],
|
||||
],
|
||||
},
|
||||
@@ -2030,10 +2042,10 @@ describe('Workflow', () => {
|
||||
|
||||
const connections = {
|
||||
Node1: {
|
||||
main: [[{ node: 'TargetNode', type: NodeConnectionType.Main, index: 0 }]],
|
||||
main: [[{ node: 'TargetNode', type: NodeConnectionTypes.Main, index: 0 }]],
|
||||
},
|
||||
Node2: {
|
||||
main: [[{ node: 'TargetNode', type: NodeConnectionType.Main, index: 0 }]],
|
||||
main: [[{ node: 'TargetNode', type: NodeConnectionTypes.Main, index: 0 }]],
|
||||
},
|
||||
};
|
||||
|
||||
@@ -2056,10 +2068,10 @@ describe('Workflow', () => {
|
||||
|
||||
const connections = {
|
||||
Node1: {
|
||||
main: [[{ node: 'TargetNode', type: NodeConnectionType.Main, index: 0 }]],
|
||||
main: [[{ node: 'TargetNode', type: NodeConnectionTypes.Main, index: 0 }]],
|
||||
},
|
||||
Node2: {
|
||||
main: [[{ node: 'TargetNode', type: NodeConnectionType.Main, index: 0 }]],
|
||||
main: [[{ node: 'TargetNode', type: NodeConnectionTypes.Main, index: 0 }]],
|
||||
},
|
||||
};
|
||||
|
||||
@@ -2084,12 +2096,12 @@ describe('Workflow', () => {
|
||||
const connections = {
|
||||
Node3: {
|
||||
main: [
|
||||
[{ node: 'Node1', type: NodeConnectionType.Main, index: 0 }],
|
||||
[{ node: 'Node2', type: NodeConnectionType.Main, index: 0 }],
|
||||
[{ node: 'Node1', type: NodeConnectionTypes.Main, index: 0 }],
|
||||
[{ node: 'Node2', type: NodeConnectionTypes.Main, index: 0 }],
|
||||
],
|
||||
},
|
||||
TargetNode: {
|
||||
main: [[{ node: 'Node3', type: NodeConnectionType.Main, index: 0 }]],
|
||||
main: [[{ node: 'Node3', type: NodeConnectionTypes.Main, index: 0 }]],
|
||||
},
|
||||
};
|
||||
|
||||
@@ -2112,10 +2124,10 @@ describe('Workflow', () => {
|
||||
|
||||
const connections = {
|
||||
Node1: {
|
||||
main: [[{ node: 'TargetNode', type: NodeConnectionType.Main, index: 0 }]],
|
||||
main: [[{ node: 'TargetNode', type: NodeConnectionTypes.Main, index: 0 }]],
|
||||
},
|
||||
Node2: {
|
||||
main: [[], [{ node: 'TargetNode', type: NodeConnectionType.Main, index: 1 }]],
|
||||
main: [[], [{ node: 'TargetNode', type: NodeConnectionTypes.Main, index: 1 }]],
|
||||
},
|
||||
};
|
||||
|
||||
@@ -2141,13 +2153,13 @@ describe('Workflow', () => {
|
||||
|
||||
const connections = {
|
||||
Node1: {
|
||||
main: [[{ node: 'Node2', type: NodeConnectionType.Main, index: 0 }]],
|
||||
main: [[{ node: 'Node2', type: NodeConnectionTypes.Main, index: 0 }]],
|
||||
},
|
||||
Node2: {
|
||||
main: [[{ node: 'Node1', type: NodeConnectionType.Main, index: 0 }]],
|
||||
main: [[{ node: 'Node1', type: NodeConnectionTypes.Main, index: 0 }]],
|
||||
},
|
||||
TargetNode: {
|
||||
main: [[{ node: 'Node1', type: NodeConnectionType.Main, index: 0 }]],
|
||||
main: [[{ node: 'Node1', type: NodeConnectionTypes.Main, index: 0 }]],
|
||||
},
|
||||
};
|
||||
|
||||
@@ -2169,10 +2181,10 @@ describe('Workflow', () => {
|
||||
|
||||
const connections = {
|
||||
Node1: {
|
||||
main: [[{ node: 'NonExistentNode', type: NodeConnectionType.Main, index: 0 }]],
|
||||
main: [[{ node: 'NonExistentNode', type: NodeConnectionTypes.Main, index: 0 }]],
|
||||
},
|
||||
TargetNode: {
|
||||
main: [[{ node: 'NonExistentNode', type: NodeConnectionType.Main, index: 0 }]],
|
||||
main: [[{ node: 'NonExistentNode', type: NodeConnectionTypes.Main, index: 0 }]],
|
||||
},
|
||||
};
|
||||
|
||||
@@ -2195,10 +2207,10 @@ describe('Workflow', () => {
|
||||
|
||||
const connections = {
|
||||
Node1: {
|
||||
main: [[{ node: 'TargetNode', type: NodeConnectionType.Main, index: 0 }]],
|
||||
main: [[{ node: 'TargetNode', type: NodeConnectionTypes.Main, index: 0 }]],
|
||||
},
|
||||
NonExistentNode: {
|
||||
main: [[{ node: 'TargetNode', type: NodeConnectionType.Main, index: 0 }]],
|
||||
main: [[{ node: 'TargetNode', type: NodeConnectionTypes.Main, index: 0 }]],
|
||||
},
|
||||
};
|
||||
|
||||
@@ -2272,7 +2284,7 @@ describe('Workflow', () => {
|
||||
const result = SIMPLE_WORKFLOW.getNodeConnectionIndexes(
|
||||
'Set',
|
||||
'Start',
|
||||
NodeConnectionType.Main,
|
||||
NodeConnectionTypes.Main,
|
||||
0,
|
||||
);
|
||||
expect(result).toBeUndefined();
|
||||
|
||||
Reference in New Issue
Block a user