mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-21 03:42:16 +00:00
refactor: Migrate NodeConnectionType to const object type (no-changelog) (#14078)
Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
This commit is contained in:
@@ -7,7 +7,7 @@ import type {
|
||||
INodeConnections,
|
||||
WorkflowExecuteMode,
|
||||
} from 'n8n-workflow';
|
||||
import { NodeConnectionType, NodeHelpers } from 'n8n-workflow';
|
||||
import { NodeConnectionTypes, NodeHelpers } from 'n8n-workflow';
|
||||
import { useCanvasOperations } from '@/composables/useCanvasOperations';
|
||||
import type { CanvasConnection, CanvasNode } from '@/types';
|
||||
import { CanvasConnectionMode } from '@/types';
|
||||
@@ -350,11 +350,11 @@ describe('useCanvasOperations', () => {
|
||||
workflowObject.getNode = vi.fn().mockReturnValue(node);
|
||||
|
||||
vi.spyOn(NodeHelpers, 'getNodeOutputs').mockReturnValueOnce([
|
||||
{ type: NodeConnectionType.AiTool },
|
||||
{ type: NodeConnectionTypes.AiTool },
|
||||
]);
|
||||
vi.spyOn(NodeHelpers, 'getConnectionTypes')
|
||||
.mockReturnValueOnce([NodeConnectionType.AiTool])
|
||||
.mockReturnValueOnce([NodeConnectionType.AiTool]);
|
||||
.mockReturnValueOnce([NodeConnectionTypes.AiTool])
|
||||
.mockReturnValueOnce([NodeConnectionTypes.AiTool]);
|
||||
|
||||
const { resolveNodePosition } = useCanvasOperations({ router });
|
||||
const position = resolveNodePosition({ ...node, position: undefined }, nodeTypeDescription);
|
||||
@@ -871,7 +871,7 @@ describe('useCanvasOperations', () => {
|
||||
[
|
||||
{
|
||||
node: nodes[1].name,
|
||||
type: NodeConnectionType.Main,
|
||||
type: NodeConnectionTypes.Main,
|
||||
index: 0,
|
||||
},
|
||||
],
|
||||
@@ -882,7 +882,7 @@ describe('useCanvasOperations', () => {
|
||||
[
|
||||
{
|
||||
node: nodes[2].name,
|
||||
type: NodeConnectionType.Main,
|
||||
type: NodeConnectionTypes.Main,
|
||||
index: 0,
|
||||
},
|
||||
],
|
||||
@@ -945,7 +945,7 @@ describe('useCanvasOperations', () => {
|
||||
[
|
||||
{
|
||||
node: nodes[1].name,
|
||||
type: NodeConnectionType.Main,
|
||||
type: NodeConnectionTypes.Main,
|
||||
index: 0,
|
||||
},
|
||||
],
|
||||
@@ -958,7 +958,7 @@ describe('useCanvasOperations', () => {
|
||||
[
|
||||
{
|
||||
node: nodes[2].name,
|
||||
type: NodeConnectionType.Main,
|
||||
type: NodeConnectionTypes.Main,
|
||||
index: 0,
|
||||
},
|
||||
],
|
||||
@@ -1172,8 +1172,8 @@ describe('useCanvasOperations', () => {
|
||||
const nodeTypeName = SET_NODE_TYPE;
|
||||
const nodeType = mockNodeTypeDescription({
|
||||
name: nodeTypeName,
|
||||
inputs: [NodeConnectionType.Main],
|
||||
outputs: [NodeConnectionType.Main],
|
||||
inputs: [NodeConnectionTypes.Main],
|
||||
outputs: [NodeConnectionTypes.Main],
|
||||
});
|
||||
const nodes = [
|
||||
mockNode({ id: 'a', name: 'Node A', type: nodeTypeName, position: [40, 40] }),
|
||||
@@ -1186,17 +1186,17 @@ describe('useCanvasOperations', () => {
|
||||
sourceHandle: createCanvasConnectionHandleString({
|
||||
mode: CanvasConnectionMode.Output,
|
||||
index: 0,
|
||||
type: NodeConnectionType.Main,
|
||||
type: NodeConnectionTypes.Main,
|
||||
}),
|
||||
target: nodes[1].id,
|
||||
targetHandle: createCanvasConnectionHandleString({
|
||||
mode: CanvasConnectionMode.Input,
|
||||
index: 0,
|
||||
type: NodeConnectionType.Main,
|
||||
type: NodeConnectionTypes.Main,
|
||||
}),
|
||||
data: {
|
||||
source: { type: NodeConnectionType.Main, index: 0 },
|
||||
target: { type: NodeConnectionType.Main, index: 0 },
|
||||
source: { type: NodeConnectionTypes.Main, index: 0 },
|
||||
target: { type: NodeConnectionTypes.Main, index: 0 },
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -1204,17 +1204,17 @@ describe('useCanvasOperations', () => {
|
||||
sourceHandle: createCanvasConnectionHandleString({
|
||||
mode: CanvasConnectionMode.Output,
|
||||
index: 0,
|
||||
type: NodeConnectionType.Main,
|
||||
type: NodeConnectionTypes.Main,
|
||||
}),
|
||||
target: nodes[2].id,
|
||||
targetHandle: createCanvasConnectionHandleString({
|
||||
mode: CanvasConnectionMode.Input,
|
||||
index: 0,
|
||||
type: NodeConnectionType.Main,
|
||||
type: NodeConnectionTypes.Main,
|
||||
}),
|
||||
data: {
|
||||
source: { type: NodeConnectionType.Main, index: 0 },
|
||||
target: { type: NodeConnectionType.Main, index: 0 },
|
||||
source: { type: NodeConnectionTypes.Main, index: 0 },
|
||||
target: { type: NodeConnectionTypes.Main, index: 0 },
|
||||
},
|
||||
},
|
||||
];
|
||||
@@ -1237,12 +1237,12 @@ describe('useCanvasOperations', () => {
|
||||
{
|
||||
index: 0,
|
||||
node: 'Node A',
|
||||
type: NodeConnectionType.Main,
|
||||
type: NodeConnectionTypes.Main,
|
||||
},
|
||||
{
|
||||
index: 0,
|
||||
node: 'Node B',
|
||||
type: NodeConnectionType.Main,
|
||||
type: NodeConnectionTypes.Main,
|
||||
},
|
||||
],
|
||||
});
|
||||
@@ -1307,8 +1307,8 @@ describe('useCanvasOperations', () => {
|
||||
|
||||
const nodeTypeDescription = mockNodeTypeDescription({
|
||||
name: SET_NODE_TYPE,
|
||||
inputs: [NodeConnectionType.Main],
|
||||
outputs: [NodeConnectionType.Main],
|
||||
inputs: [NodeConnectionTypes.Main],
|
||||
outputs: [NodeConnectionTypes.Main],
|
||||
});
|
||||
|
||||
const nodeA = createTestNode({
|
||||
@@ -1325,9 +1325,9 @@ describe('useCanvasOperations', () => {
|
||||
|
||||
const connection: Connection = {
|
||||
source: nodeA.id,
|
||||
sourceHandle: `outputs/${NodeConnectionType.Main}/0`,
|
||||
sourceHandle: `outputs/${NodeConnectionTypes.Main}/0`,
|
||||
target: nodeB.id,
|
||||
targetHandle: `inputs/${NodeConnectionType.Main}/0`,
|
||||
targetHandle: `inputs/${NodeConnectionTypes.Main}/0`,
|
||||
};
|
||||
|
||||
nodeTypesStore.nodeTypes = {
|
||||
@@ -1350,8 +1350,8 @@ describe('useCanvasOperations', () => {
|
||||
|
||||
expect(workflowsStore.addConnection).toHaveBeenCalledWith({
|
||||
connection: [
|
||||
{ index: 0, node: nodeA.name, type: NodeConnectionType.Main },
|
||||
{ index: 0, node: nodeB.name, type: NodeConnectionType.Main },
|
||||
{ index: 0, node: nodeA.name, type: NodeConnectionTypes.Main },
|
||||
{ index: 0, node: nodeB.name, type: NodeConnectionTypes.Main },
|
||||
],
|
||||
});
|
||||
expect(uiStore.stateIsDirty).toBe(true);
|
||||
@@ -1364,8 +1364,8 @@ describe('useCanvasOperations', () => {
|
||||
|
||||
const nodeTypeDescription = mockNodeTypeDescription({
|
||||
name: SET_NODE_TYPE,
|
||||
inputs: [NodeConnectionType.Main],
|
||||
outputs: [NodeConnectionType.Main],
|
||||
inputs: [NodeConnectionTypes.Main],
|
||||
outputs: [NodeConnectionTypes.Main],
|
||||
});
|
||||
|
||||
const nodeA = createTestNode({
|
||||
@@ -1382,9 +1382,9 @@ describe('useCanvasOperations', () => {
|
||||
|
||||
const connection: Connection = {
|
||||
source: nodeA.id,
|
||||
sourceHandle: `outputs/${NodeConnectionType.Main}/0`,
|
||||
sourceHandle: `outputs/${NodeConnectionTypes.Main}/0`,
|
||||
target: nodeB.id,
|
||||
targetHandle: `inputs/${NodeConnectionType.Main}/0`,
|
||||
targetHandle: `inputs/${NodeConnectionTypes.Main}/0`,
|
||||
};
|
||||
|
||||
nodeTypesStore.nodeTypes = {
|
||||
@@ -1413,8 +1413,8 @@ describe('useCanvasOperations', () => {
|
||||
it('deletes connection if both source and target nodes exist', () => {
|
||||
const workflowsStore = mockedStore(useWorkflowsStore);
|
||||
const connection: [IConnection, IConnection] = [
|
||||
{ node: 'sourceNode', type: NodeConnectionType.Main, index: 0 },
|
||||
{ node: 'targetNode', type: NodeConnectionType.Main, index: 0 },
|
||||
{ node: 'sourceNode', type: NodeConnectionTypes.Main, index: 0 },
|
||||
{ node: 'targetNode', type: NodeConnectionTypes.Main, index: 0 },
|
||||
];
|
||||
const testNode = createTestNode();
|
||||
|
||||
@@ -1443,7 +1443,7 @@ describe('useCanvasOperations', () => {
|
||||
});
|
||||
const sourceHandle: IConnection = {
|
||||
node: sourceNode.name,
|
||||
type: NodeConnectionType.Main,
|
||||
type: NodeConnectionTypes.Main,
|
||||
index: 0,
|
||||
};
|
||||
const targetNode = mockNode({
|
||||
@@ -1457,7 +1457,7 @@ describe('useCanvasOperations', () => {
|
||||
});
|
||||
const targetHandle: IConnection = {
|
||||
node: targetNode.name,
|
||||
type: NodeConnectionType.Main,
|
||||
type: NodeConnectionTypes.Main,
|
||||
index: 0,
|
||||
};
|
||||
|
||||
@@ -1491,7 +1491,7 @@ describe('useCanvasOperations', () => {
|
||||
});
|
||||
const sourceHandle: IConnection = {
|
||||
node: sourceNode.name,
|
||||
type: NodeConnectionType.Main,
|
||||
type: NodeConnectionTypes.Main,
|
||||
index: 0,
|
||||
};
|
||||
const targetNode = mockNode({
|
||||
@@ -1501,11 +1501,11 @@ describe('useCanvasOperations', () => {
|
||||
});
|
||||
const targetNodeTypeDescription = mockNodeTypeDescription({
|
||||
name: targetNode.type,
|
||||
inputs: [NodeConnectionType.Main],
|
||||
inputs: [NodeConnectionTypes.Main],
|
||||
});
|
||||
const targetHandle: IConnection = {
|
||||
node: targetNode.name,
|
||||
type: NodeConnectionType.Main,
|
||||
type: NodeConnectionTypes.Main,
|
||||
index: 0,
|
||||
};
|
||||
|
||||
@@ -1533,11 +1533,11 @@ describe('useCanvasOperations', () => {
|
||||
});
|
||||
const sourceNodeTypeDescription = mockNodeTypeDescription({
|
||||
name: sourceNode.type,
|
||||
outputs: [NodeConnectionType.Main],
|
||||
outputs: [NodeConnectionTypes.Main],
|
||||
});
|
||||
const sourceHandle: IConnection = {
|
||||
node: sourceNode.name,
|
||||
type: NodeConnectionType.AiTool,
|
||||
type: NodeConnectionTypes.AiTool,
|
||||
index: 0,
|
||||
};
|
||||
|
||||
@@ -1548,11 +1548,11 @@ describe('useCanvasOperations', () => {
|
||||
});
|
||||
const targetNodeTypeDescription = mockNodeTypeDescription({
|
||||
name: 'targetType',
|
||||
inputs: [NodeConnectionType.AiTool],
|
||||
inputs: [NodeConnectionTypes.AiTool],
|
||||
});
|
||||
const targetHandle: IConnection = {
|
||||
node: targetNode.name,
|
||||
type: NodeConnectionType.AiTool,
|
||||
type: NodeConnectionTypes.AiTool,
|
||||
index: 0,
|
||||
};
|
||||
|
||||
@@ -1584,11 +1584,11 @@ describe('useCanvasOperations', () => {
|
||||
});
|
||||
const sourceNodeTypeDescription = mockNodeTypeDescription({
|
||||
name: sourceNode.type,
|
||||
outputs: [NodeConnectionType.Main],
|
||||
outputs: [NodeConnectionTypes.Main],
|
||||
});
|
||||
const sourceHandle: IConnection = {
|
||||
node: sourceNode.name,
|
||||
type: NodeConnectionType.Main,
|
||||
type: NodeConnectionTypes.Main,
|
||||
index: 0,
|
||||
};
|
||||
|
||||
@@ -1599,11 +1599,11 @@ describe('useCanvasOperations', () => {
|
||||
});
|
||||
const targetNodeTypeDescription = mockNodeTypeDescription({
|
||||
name: 'targetType',
|
||||
inputs: [NodeConnectionType.AiTool],
|
||||
inputs: [NodeConnectionTypes.AiTool],
|
||||
});
|
||||
const targetHandle: IConnection = {
|
||||
node: targetNode.name,
|
||||
type: NodeConnectionType.AiTool,
|
||||
type: NodeConnectionTypes.AiTool,
|
||||
index: 0,
|
||||
};
|
||||
|
||||
@@ -1636,11 +1636,11 @@ describe('useCanvasOperations', () => {
|
||||
});
|
||||
const sourceNodeTypeDescription = mockNodeTypeDescription({
|
||||
name: sourceNode.type,
|
||||
outputs: [NodeConnectionType.Main],
|
||||
outputs: [NodeConnectionTypes.Main],
|
||||
});
|
||||
const sourceHandle: IConnection = {
|
||||
node: sourceNode.name,
|
||||
type: NodeConnectionType.Main,
|
||||
type: NodeConnectionTypes.Main,
|
||||
index: 0,
|
||||
};
|
||||
|
||||
@@ -1654,7 +1654,7 @@ describe('useCanvasOperations', () => {
|
||||
name: 'targetType',
|
||||
inputs: [
|
||||
{
|
||||
type: NodeConnectionType.Main,
|
||||
type: NodeConnectionTypes.Main,
|
||||
filter: {
|
||||
nodes: ['allowedType'],
|
||||
},
|
||||
@@ -1663,7 +1663,7 @@ describe('useCanvasOperations', () => {
|
||||
});
|
||||
const targetHandle: IConnection = {
|
||||
node: targetNode.name,
|
||||
type: NodeConnectionType.Main,
|
||||
type: NodeConnectionTypes.Main,
|
||||
index: 0,
|
||||
};
|
||||
|
||||
@@ -1696,11 +1696,11 @@ describe('useCanvasOperations', () => {
|
||||
});
|
||||
const sourceNodeTypeDescription = mockNodeTypeDescription({
|
||||
name: sourceNode.type,
|
||||
outputs: [NodeConnectionType.Main],
|
||||
outputs: [NodeConnectionTypes.Main],
|
||||
});
|
||||
const sourceHandle: IConnection = {
|
||||
node: sourceNode.name,
|
||||
type: NodeConnectionType.Main,
|
||||
type: NodeConnectionTypes.Main,
|
||||
index: 1,
|
||||
};
|
||||
|
||||
@@ -1714,7 +1714,7 @@ describe('useCanvasOperations', () => {
|
||||
name: targetNode.type,
|
||||
inputs: [
|
||||
{
|
||||
type: NodeConnectionType.Main,
|
||||
type: NodeConnectionTypes.Main,
|
||||
filter: {
|
||||
nodes: [sourceNode.type],
|
||||
},
|
||||
@@ -1723,7 +1723,7 @@ describe('useCanvasOperations', () => {
|
||||
});
|
||||
const targetHandle: IConnection = {
|
||||
node: targetNode.name,
|
||||
type: NodeConnectionType.Main,
|
||||
type: NodeConnectionTypes.Main,
|
||||
index: 0,
|
||||
};
|
||||
|
||||
@@ -1756,11 +1756,11 @@ describe('useCanvasOperations', () => {
|
||||
});
|
||||
const sourceNodeTypeDescription = mockNodeTypeDescription({
|
||||
name: sourceNode.type,
|
||||
outputs: [NodeConnectionType.Main],
|
||||
outputs: [NodeConnectionTypes.Main],
|
||||
});
|
||||
const sourceHandle: IConnection = {
|
||||
node: sourceNode.name,
|
||||
type: NodeConnectionType.Main,
|
||||
type: NodeConnectionTypes.Main,
|
||||
index: 0,
|
||||
};
|
||||
|
||||
@@ -1774,7 +1774,7 @@ describe('useCanvasOperations', () => {
|
||||
name: targetNode.type,
|
||||
inputs: [
|
||||
{
|
||||
type: NodeConnectionType.Main,
|
||||
type: NodeConnectionTypes.Main,
|
||||
filter: {
|
||||
nodes: [sourceNode.type],
|
||||
},
|
||||
@@ -1783,7 +1783,7 @@ describe('useCanvasOperations', () => {
|
||||
});
|
||||
const targetHandle: IConnection = {
|
||||
node: targetNode.name,
|
||||
type: NodeConnectionType.Main,
|
||||
type: NodeConnectionTypes.Main,
|
||||
index: 1,
|
||||
};
|
||||
|
||||
@@ -1817,11 +1817,11 @@ describe('useCanvasOperations', () => {
|
||||
});
|
||||
const sourceNodeTypeDescription = mockNodeTypeDescription({
|
||||
name: sourceNode.type,
|
||||
outputs: [NodeConnectionType.Main],
|
||||
outputs: [NodeConnectionTypes.Main],
|
||||
});
|
||||
const sourceHandle: IConnection = {
|
||||
node: sourceNode.name,
|
||||
type: NodeConnectionType.Main,
|
||||
type: NodeConnectionTypes.Main,
|
||||
index: 0,
|
||||
};
|
||||
|
||||
@@ -1835,7 +1835,7 @@ describe('useCanvasOperations', () => {
|
||||
name: targetNode.type,
|
||||
inputs: [
|
||||
{
|
||||
type: NodeConnectionType.Main,
|
||||
type: NodeConnectionTypes.Main,
|
||||
filter: {
|
||||
nodes: [sourceNode.type],
|
||||
},
|
||||
@@ -1844,7 +1844,7 @@ describe('useCanvasOperations', () => {
|
||||
});
|
||||
const targetHandle: IConnection = {
|
||||
node: targetNode.name,
|
||||
type: NodeConnectionType.Main,
|
||||
type: NodeConnectionTypes.Main,
|
||||
index: 0,
|
||||
};
|
||||
|
||||
@@ -1878,11 +1878,11 @@ describe('useCanvasOperations', () => {
|
||||
});
|
||||
const sourceNodeTypeDescription = mockNodeTypeDescription({
|
||||
name: sourceNode.type,
|
||||
outputs: [NodeConnectionType.Main],
|
||||
outputs: [NodeConnectionTypes.Main],
|
||||
});
|
||||
const sourceHandle: IConnection = {
|
||||
node: sourceNode.name,
|
||||
type: NodeConnectionType.Main,
|
||||
type: NodeConnectionTypes.Main,
|
||||
index: 0,
|
||||
};
|
||||
|
||||
@@ -1896,13 +1896,13 @@ describe('useCanvasOperations', () => {
|
||||
name: targetNode.type,
|
||||
inputs: [
|
||||
{
|
||||
type: NodeConnectionType.Main,
|
||||
type: NodeConnectionTypes.Main,
|
||||
},
|
||||
],
|
||||
});
|
||||
const targetHandle: IConnection = {
|
||||
node: targetNode.name,
|
||||
type: NodeConnectionType.Main,
|
||||
type: NodeConnectionTypes.Main,
|
||||
index: 0,
|
||||
};
|
||||
|
||||
@@ -1936,16 +1936,16 @@ describe('useCanvasOperations', () => {
|
||||
});
|
||||
const sourceNodeTypeDescription = mockNodeTypeDescription({
|
||||
name: sourceNode.type,
|
||||
outputs: [NodeConnectionType.Main],
|
||||
outputs: [NodeConnectionTypes.Main],
|
||||
});
|
||||
const sourceHandle: IConnection = {
|
||||
node: sourceNode.name,
|
||||
type: NodeConnectionType.Main,
|
||||
type: NodeConnectionTypes.Main,
|
||||
index: 0,
|
||||
};
|
||||
const targetHandle: IConnection = {
|
||||
node: sourceNode.name,
|
||||
type: NodeConnectionType.Main,
|
||||
type: NodeConnectionTypes.Main,
|
||||
index: 0,
|
||||
};
|
||||
|
||||
@@ -2012,9 +2012,9 @@ describe('useCanvasOperations', () => {
|
||||
|
||||
const connection: Connection = {
|
||||
source: nodeA.id,
|
||||
sourceHandle: `outputs/${NodeConnectionType.Main}/0`,
|
||||
sourceHandle: `outputs/${NodeConnectionTypes.Main}/0`,
|
||||
target: nodeB.id,
|
||||
targetHandle: `inputs/${NodeConnectionType.Main}/0`,
|
||||
targetHandle: `inputs/${NodeConnectionTypes.Main}/0`,
|
||||
};
|
||||
|
||||
workflowsStore.getNodeById.mockReturnValueOnce(nodeA).mockReturnValueOnce(nodeB);
|
||||
@@ -2024,8 +2024,8 @@ describe('useCanvasOperations', () => {
|
||||
|
||||
expect(workflowsStore.removeConnection).toHaveBeenCalledWith({
|
||||
connection: [
|
||||
{ index: 0, node: nodeA.name, type: NodeConnectionType.Main },
|
||||
{ index: 0, node: nodeB.name, type: NodeConnectionType.Main },
|
||||
{ index: 0, node: nodeA.name, type: NodeConnectionTypes.Main },
|
||||
{ index: 0, node: nodeB.name, type: NodeConnectionTypes.Main },
|
||||
],
|
||||
});
|
||||
});
|
||||
@@ -2036,8 +2036,8 @@ describe('useCanvasOperations', () => {
|
||||
const workflowsStore = mockedStore(useWorkflowsStore);
|
||||
|
||||
const connection: [IConnection, IConnection] = [
|
||||
{ node: 'sourceNode', type: NodeConnectionType.Main, index: 1 },
|
||||
{ node: 'targetNode', type: NodeConnectionType.Main, index: 2 },
|
||||
{ node: 'sourceNode', type: NodeConnectionTypes.Main, index: 1 },
|
||||
{ node: 'targetNode', type: NodeConnectionTypes.Main, index: 2 },
|
||||
];
|
||||
|
||||
const { revertDeleteConnection } = useCanvasOperations({ router });
|
||||
@@ -2088,7 +2088,7 @@ describe('useCanvasOperations', () => {
|
||||
});
|
||||
const targetNodeType = mockNodeTypeDescription({
|
||||
name: SET_NODE_TYPE,
|
||||
inputs: [NodeConnectionType.Main],
|
||||
inputs: [NodeConnectionTypes.Main],
|
||||
});
|
||||
|
||||
const sourceNodeId = 'source';
|
||||
@@ -2099,14 +2099,14 @@ describe('useCanvasOperations', () => {
|
||||
});
|
||||
const sourceNodeType = mockNodeTypeDescription({
|
||||
name: AGENT_NODE_TYPE,
|
||||
outputs: [NodeConnectionType.AiTool],
|
||||
outputs: [NodeConnectionTypes.AiTool],
|
||||
});
|
||||
|
||||
workflowsStore.workflow.nodes = [sourceNode, targetNode];
|
||||
workflowsStore.workflow.connections = {
|
||||
[sourceNode.name]: {
|
||||
[NodeConnectionType.AiTool]: [
|
||||
[{ node: targetNode.name, type: NodeConnectionType.Main, index: 0 }],
|
||||
[NodeConnectionTypes.AiTool]: [
|
||||
[{ node: targetNode.name, type: NodeConnectionTypes.Main, index: 0 }],
|
||||
],
|
||||
},
|
||||
};
|
||||
@@ -2132,8 +2132,8 @@ describe('useCanvasOperations', () => {
|
||||
|
||||
expect(workflowsStore.removeConnection).toHaveBeenCalledWith({
|
||||
connection: [
|
||||
{ node: sourceNode.name, type: NodeConnectionType.AiTool, index: 0 },
|
||||
{ node: targetNode.name, type: NodeConnectionType.Main, index: 0 },
|
||||
{ node: sourceNode.name, type: NodeConnectionTypes.AiTool, index: 0 },
|
||||
{ node: targetNode.name, type: NodeConnectionTypes.Main, index: 0 },
|
||||
],
|
||||
});
|
||||
});
|
||||
@@ -2152,7 +2152,7 @@ describe('useCanvasOperations', () => {
|
||||
});
|
||||
const targetNodeType = mockNodeTypeDescription({
|
||||
name: SET_NODE_TYPE,
|
||||
inputs: [NodeConnectionType.Main],
|
||||
inputs: [NodeConnectionTypes.Main],
|
||||
});
|
||||
|
||||
const sourceNodeId = 'source';
|
||||
@@ -2163,14 +2163,14 @@ describe('useCanvasOperations', () => {
|
||||
});
|
||||
const sourceNodeType = mockNodeTypeDescription({
|
||||
name: AGENT_NODE_TYPE,
|
||||
outputs: [NodeConnectionType.Main],
|
||||
outputs: [NodeConnectionTypes.Main],
|
||||
});
|
||||
|
||||
workflowsStore.workflow.nodes = [sourceNode, targetNode];
|
||||
workflowsStore.workflow.connections = {
|
||||
[sourceNode.name]: {
|
||||
[NodeConnectionType.Main]: [
|
||||
[{ node: targetNode.name, type: NodeConnectionType.Main, index: 0 }],
|
||||
[NodeConnectionTypes.Main]: [
|
||||
[{ node: targetNode.name, type: NodeConnectionTypes.Main, index: 0 }],
|
||||
],
|
||||
},
|
||||
};
|
||||
@@ -2237,7 +2237,7 @@ describe('useCanvasOperations', () => {
|
||||
});
|
||||
const targetNodeType = mockNodeTypeDescription({
|
||||
name: SET_NODE_TYPE,
|
||||
inputs: [NodeConnectionType.Main],
|
||||
inputs: [NodeConnectionTypes.Main],
|
||||
});
|
||||
|
||||
const sourceNodeId = 'source';
|
||||
@@ -2248,14 +2248,14 @@ describe('useCanvasOperations', () => {
|
||||
});
|
||||
const sourceNodeType = mockNodeTypeDescription({
|
||||
name: AGENT_NODE_TYPE,
|
||||
outputs: [NodeConnectionType.AiTool],
|
||||
outputs: [NodeConnectionTypes.AiTool],
|
||||
});
|
||||
|
||||
workflowsStore.workflow.nodes = [sourceNode, targetNode];
|
||||
workflowsStore.workflow.connections = {
|
||||
[sourceNode.name]: {
|
||||
[NodeConnectionType.AiTool]: [
|
||||
[{ node: targetNode.name, type: NodeConnectionType.Main, index: 0 }],
|
||||
[NodeConnectionTypes.AiTool]: [
|
||||
[{ node: targetNode.name, type: NodeConnectionTypes.Main, index: 0 }],
|
||||
],
|
||||
},
|
||||
};
|
||||
@@ -2281,8 +2281,8 @@ describe('useCanvasOperations', () => {
|
||||
|
||||
expect(workflowsStore.removeConnection).toHaveBeenCalledWith({
|
||||
connection: [
|
||||
{ node: sourceNode.name, type: NodeConnectionType.AiTool, index: 0 },
|
||||
{ node: targetNode.name, type: NodeConnectionType.Main, index: 0 },
|
||||
{ node: sourceNode.name, type: NodeConnectionTypes.AiTool, index: 0 },
|
||||
{ node: targetNode.name, type: NodeConnectionTypes.Main, index: 0 },
|
||||
],
|
||||
});
|
||||
});
|
||||
@@ -2301,7 +2301,7 @@ describe('useCanvasOperations', () => {
|
||||
});
|
||||
const targetNodeType = mockNodeTypeDescription({
|
||||
name: SET_NODE_TYPE,
|
||||
inputs: [NodeConnectionType.Main],
|
||||
inputs: [NodeConnectionTypes.Main],
|
||||
});
|
||||
|
||||
const sourceNodeId = 'source';
|
||||
@@ -2312,14 +2312,14 @@ describe('useCanvasOperations', () => {
|
||||
});
|
||||
const sourceNodeType = mockNodeTypeDescription({
|
||||
name: AGENT_NODE_TYPE,
|
||||
outputs: [NodeConnectionType.Main],
|
||||
outputs: [NodeConnectionTypes.Main],
|
||||
});
|
||||
|
||||
workflowsStore.workflow.nodes = [sourceNode, targetNode];
|
||||
workflowsStore.workflow.connections = {
|
||||
[sourceNode.name]: {
|
||||
[NodeConnectionType.AiTool]: [
|
||||
[{ node: targetNode.name, type: NodeConnectionType.Main, index: 0 }],
|
||||
[NodeConnectionTypes.AiTool]: [
|
||||
[{ node: targetNode.name, type: NodeConnectionTypes.Main, index: 0 }],
|
||||
],
|
||||
},
|
||||
};
|
||||
@@ -2355,13 +2355,13 @@ describe('useCanvasOperations', () => {
|
||||
|
||||
workflowsStore.workflow.connections = {
|
||||
[node1.name]: {
|
||||
[NodeConnectionType.Main]: [
|
||||
[{ node: node2.name, type: NodeConnectionType.Main, index: 0 }],
|
||||
[NodeConnectionTypes.Main]: [
|
||||
[{ node: node2.name, type: NodeConnectionTypes.Main, index: 0 }],
|
||||
],
|
||||
},
|
||||
node2: {
|
||||
[NodeConnectionType.Main]: [
|
||||
[{ node: node1.name, type: NodeConnectionType.Main, index: 0 }],
|
||||
[NodeConnectionTypes.Main]: [
|
||||
[{ node: node1.name, type: NodeConnectionTypes.Main, index: 0 }],
|
||||
],
|
||||
},
|
||||
};
|
||||
@@ -2373,15 +2373,15 @@ describe('useCanvasOperations', () => {
|
||||
|
||||
expect(workflowsStore.removeConnection).toHaveBeenCalledWith({
|
||||
connection: [
|
||||
{ node: node1.name, type: NodeConnectionType.Main, index: 0 },
|
||||
{ node: node2.name, type: NodeConnectionType.Main, index: 0 },
|
||||
{ node: node1.name, type: NodeConnectionTypes.Main, index: 0 },
|
||||
{ node: node2.name, type: NodeConnectionTypes.Main, index: 0 },
|
||||
],
|
||||
});
|
||||
|
||||
expect(workflowsStore.removeConnection).toHaveBeenCalledWith({
|
||||
connection: [
|
||||
{ node: node2.name, type: NodeConnectionType.Main, index: 0 },
|
||||
{ node: node1.name, type: NodeConnectionType.Main, index: 0 },
|
||||
{ node: node2.name, type: NodeConnectionTypes.Main, index: 0 },
|
||||
{ node: node1.name, type: NodeConnectionTypes.Main, index: 0 },
|
||||
],
|
||||
});
|
||||
|
||||
@@ -2573,12 +2573,12 @@ describe('useCanvasOperations', () => {
|
||||
describe('filterConnectionsByNodes', () => {
|
||||
it('should return filtered connections when all nodes are included', () => {
|
||||
const connections: INodeConnections = {
|
||||
[NodeConnectionType.Main]: [
|
||||
[NodeConnectionTypes.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 },
|
||||
],
|
||||
[{ node: 'node3', type: NodeConnectionType.Main, index: 0 }],
|
||||
[{ node: 'node3', type: NodeConnectionTypes.Main, index: 0 }],
|
||||
],
|
||||
};
|
||||
const includeNodeNames = new Set<string>(['node1', 'node2', 'node3']);
|
||||
@@ -2591,12 +2591,12 @@ describe('useCanvasOperations', () => {
|
||||
|
||||
it('should return empty connections when no nodes are included', () => {
|
||||
const connections: INodeConnections = {
|
||||
[NodeConnectionType.Main]: [
|
||||
[NodeConnectionTypes.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 },
|
||||
],
|
||||
[{ node: 'node3', type: NodeConnectionType.Main, index: 0 }],
|
||||
[{ node: 'node3', type: NodeConnectionTypes.Main, index: 0 }],
|
||||
],
|
||||
};
|
||||
const includeNodeNames = new Set<string>();
|
||||
@@ -2605,18 +2605,18 @@ describe('useCanvasOperations', () => {
|
||||
const result = filterConnectionsByNodes(connections, includeNodeNames);
|
||||
|
||||
expect(result).toEqual({
|
||||
[NodeConnectionType.Main]: [[], []],
|
||||
[NodeConnectionTypes.Main]: [[], []],
|
||||
});
|
||||
});
|
||||
|
||||
it('should return partially filtered connections when some nodes are included', () => {
|
||||
const connections: INodeConnections = {
|
||||
[NodeConnectionType.Main]: [
|
||||
[NodeConnectionTypes.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 },
|
||||
],
|
||||
[{ node: 'node3', type: NodeConnectionType.Main, index: 0 }],
|
||||
[{ node: 'node3', type: NodeConnectionTypes.Main, index: 0 }],
|
||||
],
|
||||
};
|
||||
const includeNodeNames = new Set<string>(['node1']);
|
||||
@@ -2625,8 +2625,8 @@ describe('useCanvasOperations', () => {
|
||||
const result = filterConnectionsByNodes(connections, includeNodeNames);
|
||||
|
||||
expect(result).toEqual({
|
||||
[NodeConnectionType.Main]: [
|
||||
[{ node: 'node1', type: NodeConnectionType.Main, index: 0 }],
|
||||
[NodeConnectionTypes.Main]: [
|
||||
[{ node: 'node1', type: NodeConnectionTypes.Main, index: 0 }],
|
||||
[],
|
||||
],
|
||||
});
|
||||
@@ -2644,12 +2644,12 @@ describe('useCanvasOperations', () => {
|
||||
|
||||
it('should handle connections with no valid nodes', () => {
|
||||
const connections: INodeConnections = {
|
||||
[NodeConnectionType.Main]: [
|
||||
[NodeConnectionTypes.Main]: [
|
||||
[
|
||||
{ node: 'node4', type: NodeConnectionType.Main, index: 0 },
|
||||
{ node: 'node5', type: NodeConnectionType.Main, index: 0 },
|
||||
{ node: 'node4', type: NodeConnectionTypes.Main, index: 0 },
|
||||
{ node: 'node5', type: NodeConnectionTypes.Main, index: 0 },
|
||||
],
|
||||
[{ node: 'node6', type: NodeConnectionType.Main, index: 0 }],
|
||||
[{ node: 'node6', type: NodeConnectionTypes.Main, index: 0 }],
|
||||
],
|
||||
};
|
||||
const includeNodeNames = new Set<string>(['node1', 'node2', 'node3']);
|
||||
@@ -2658,7 +2658,7 @@ describe('useCanvasOperations', () => {
|
||||
const result = filterConnectionsByNodes(connections, includeNodeNames);
|
||||
|
||||
expect(result).toEqual({
|
||||
[NodeConnectionType.Main]: [[], []],
|
||||
[NodeConnectionTypes.Main]: [[], []],
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -2737,8 +2737,8 @@ describe('useCanvasOperations', () => {
|
||||
|
||||
const nodeTypeDescription = mockNodeTypeDescription({
|
||||
name: nodeA.type,
|
||||
inputs: [NodeConnectionType.Main],
|
||||
outputs: [NodeConnectionType.Main],
|
||||
inputs: [NodeConnectionTypes.Main],
|
||||
outputs: [NodeConnectionTypes.Main],
|
||||
});
|
||||
|
||||
nodeTypesStore.getNodeType = vi.fn(() => nodeTypeDescription);
|
||||
@@ -2747,10 +2747,10 @@ describe('useCanvasOperations', () => {
|
||||
workflowsStore.workflow.nodes = [nodeA, nodeB, nodeC];
|
||||
workflowsStore.workflow.connections = {
|
||||
[nodeA.name]: {
|
||||
main: [[{ node: nodeB.name, type: NodeConnectionType.Main, index: 0 }]],
|
||||
main: [[{ node: nodeB.name, type: NodeConnectionTypes.Main, index: 0 }]],
|
||||
},
|
||||
[nodeB.name]: {
|
||||
main: [[{ node: nodeC.name, type: NodeConnectionType.Main, index: 0 }]],
|
||||
main: [[{ node: nodeC.name, type: NodeConnectionTypes.Main, index: 0 }]],
|
||||
},
|
||||
};
|
||||
|
||||
@@ -2774,10 +2774,10 @@ describe('useCanvasOperations', () => {
|
||||
})[name],
|
||||
);
|
||||
workflowsStore.outgoingConnectionsByNodeName.mockReturnValue({
|
||||
main: [[{ node: nodeC.name, type: NodeConnectionType.Main, index: 0 }]],
|
||||
main: [[{ node: nodeC.name, type: NodeConnectionTypes.Main, index: 0 }]],
|
||||
});
|
||||
workflowsStore.incomingConnectionsByNodeName.mockReturnValue({
|
||||
main: [[{ node: nodeA.name, type: NodeConnectionType.Main, index: 0 }]],
|
||||
main: [[{ node: nodeA.name, type: NodeConnectionTypes.Main, index: 0 }]],
|
||||
});
|
||||
|
||||
const { connectAdjacentNodes } = useCanvasOperations({ router });
|
||||
@@ -2786,8 +2786,8 @@ describe('useCanvasOperations', () => {
|
||||
// Check that A was connected directly to C
|
||||
expect(workflowsStore.addConnection).toHaveBeenCalledWith({
|
||||
connection: [
|
||||
{ node: nodeA.name, type: NodeConnectionType.Main, index: 0 },
|
||||
{ node: nodeC.name, type: NodeConnectionType.Main, index: 0 },
|
||||
{ node: nodeA.name, type: NodeConnectionTypes.Main, index: 0 },
|
||||
{ node: nodeC.name, type: NodeConnectionTypes.Main, index: 0 },
|
||||
],
|
||||
});
|
||||
|
||||
@@ -2807,8 +2807,8 @@ describe('useCanvasOperations', () => {
|
||||
|
||||
const nodeTypeDescription = mockNodeTypeDescription({
|
||||
name: nodeA.type,
|
||||
inputs: [NodeConnectionType.Main, NodeConnectionType.Main],
|
||||
outputs: [NodeConnectionType.Main, NodeConnectionType.Main],
|
||||
inputs: [NodeConnectionTypes.Main, NodeConnectionTypes.Main],
|
||||
outputs: [NodeConnectionTypes.Main, NodeConnectionTypes.Main],
|
||||
});
|
||||
|
||||
nodeTypesStore.getNodeType = vi.fn(() => nodeTypeDescription);
|
||||
@@ -2817,10 +2817,10 @@ describe('useCanvasOperations', () => {
|
||||
workflowsStore.workflow.nodes = [nodeA, nodeB, nodeC];
|
||||
workflowsStore.workflow.connections = {
|
||||
[nodeA.name]: {
|
||||
main: [[{ node: nodeB.name, type: NodeConnectionType.Main, index: 1 }]],
|
||||
main: [[{ node: nodeB.name, type: NodeConnectionTypes.Main, index: 1 }]],
|
||||
},
|
||||
[nodeB.name]: {
|
||||
main: [[{ node: nodeC.name, type: NodeConnectionType.Main, index: 0 }]],
|
||||
main: [[{ node: nodeC.name, type: NodeConnectionTypes.Main, index: 0 }]],
|
||||
},
|
||||
};
|
||||
|
||||
@@ -2844,10 +2844,10 @@ describe('useCanvasOperations', () => {
|
||||
})[name],
|
||||
);
|
||||
workflowsStore.outgoingConnectionsByNodeName.mockReturnValue({
|
||||
main: [[{ node: nodeC.name, type: NodeConnectionType.Main, index: 1 }]],
|
||||
main: [[{ node: nodeC.name, type: NodeConnectionTypes.Main, index: 1 }]],
|
||||
});
|
||||
workflowsStore.incomingConnectionsByNodeName.mockReturnValue({
|
||||
main: [[{ node: nodeA.name, type: NodeConnectionType.Main, index: 0 }]],
|
||||
main: [[{ node: nodeA.name, type: NodeConnectionTypes.Main, index: 0 }]],
|
||||
});
|
||||
|
||||
const { connectAdjacentNodes } = useCanvasOperations({ router });
|
||||
@@ -2856,8 +2856,8 @@ describe('useCanvasOperations', () => {
|
||||
// Check that A was connected directly to C
|
||||
expect(workflowsStore.addConnection).toHaveBeenCalledWith({
|
||||
connection: [
|
||||
{ node: nodeA.name, type: NodeConnectionType.Main, index: 0 },
|
||||
{ node: nodeC.name, type: NodeConnectionType.Main, index: 1 },
|
||||
{ node: nodeA.name, type: NodeConnectionTypes.Main, index: 0 },
|
||||
{ node: nodeC.name, type: NodeConnectionTypes.Main, index: 1 },
|
||||
],
|
||||
});
|
||||
|
||||
@@ -2875,7 +2875,7 @@ describe('useCanvasOperations', () => {
|
||||
workflowsStore.workflow.nodes = [nodeB, nodeC];
|
||||
workflowsStore.workflow.connections = {
|
||||
[nodeB.name]: {
|
||||
main: [[{ node: nodeC.name, type: NodeConnectionType.Main, index: 0 }]],
|
||||
main: [[{ node: nodeC.name, type: NodeConnectionTypes.Main, index: 0 }]],
|
||||
},
|
||||
};
|
||||
|
||||
@@ -2883,7 +2883,7 @@ describe('useCanvasOperations', () => {
|
||||
workflowsStore.getCurrentWorkflow.mockReturnValue(workflowObject);
|
||||
workflowsStore.getNodeById.mockReturnValue(nodeB);
|
||||
workflowsStore.outgoingConnectionsByNodeName.mockReturnValue({
|
||||
main: [[{ node: nodeC.name, type: NodeConnectionType.Main, index: 0 }]],
|
||||
main: [[{ node: nodeC.name, type: NodeConnectionTypes.Main, index: 0 }]],
|
||||
});
|
||||
workflowsStore.incomingConnectionsByNodeName.mockReturnValue({});
|
||||
|
||||
@@ -2903,7 +2903,7 @@ describe('useCanvasOperations', () => {
|
||||
workflowsStore.workflow.nodes = [nodeA, nodeB];
|
||||
workflowsStore.workflow.connections = {
|
||||
[nodeA.name]: {
|
||||
main: [[{ node: nodeB.name, type: NodeConnectionType.Main, index: 0 }]],
|
||||
main: [[{ node: nodeB.name, type: NodeConnectionTypes.Main, index: 0 }]],
|
||||
},
|
||||
};
|
||||
|
||||
@@ -2912,7 +2912,7 @@ describe('useCanvasOperations', () => {
|
||||
workflowsStore.getNodeById.mockReturnValue(nodeB);
|
||||
workflowsStore.outgoingConnectionsByNodeName.mockReturnValue({});
|
||||
workflowsStore.incomingConnectionsByNodeName.mockReturnValue({
|
||||
main: [[{ node: nodeA.name, type: NodeConnectionType.Main, index: 0 }]],
|
||||
main: [[{ node: nodeA.name, type: NodeConnectionTypes.Main, index: 0 }]],
|
||||
});
|
||||
|
||||
const { connectAdjacentNodes } = useCanvasOperations({ router });
|
||||
@@ -2978,7 +2978,7 @@ describe('useCanvasOperations', () => {
|
||||
nodes: [nodeA, nodeB],
|
||||
connections: {
|
||||
[nodeA.name]: {
|
||||
main: [[{ node: nodeB.name, type: NodeConnectionType.Main, index: 0 }]],
|
||||
main: [[{ node: nodeB.name, type: NodeConnectionTypes.Main, index: 0 }]],
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user