feat(editor): Connect adjacent nodes when a node is deleted in canvas v2 (no-changelog) (#10125)

This commit is contained in:
Elias Meire
2024-07-22 12:41:43 +02:00
committed by GitHub
parent b1816db449
commit a036aa43dc
3 changed files with 115 additions and 1 deletions

View File

@@ -398,6 +398,70 @@ describe('useCanvasOperations', () => {
expect(removeNodeExecutionDataByIdSpy).toHaveBeenCalledWith(id);
expect(pushCommandToUndoSpy).not.toHaveBeenCalled();
});
it('should connect adjacent nodes when deleting a node surrounded by other nodes', () => {
nodeTypesStore.setNodeTypes([mockNodeTypeDescription({ name: 'node' })]);
const nodes = [
createTestNode({
id: 'input',
type: 'node',
position: [10, 20],
name: 'Input Node',
}),
createTestNode({
id: 'middle',
type: 'node',
position: [10, 20],
name: 'Middle Node',
}),
createTestNode({
id: 'output',
type: 'node',
position: [10, 20],
name: 'Output Node',
}),
];
workflowsStore.setNodes(nodes);
workflowsStore.setConnections({
'Input Node': {
main: [
[
{
node: 'Middle Node',
type: NodeConnectionType.Main,
index: 0,
},
],
],
},
'Middle Node': {
main: [
[
{
node: 'Output Node',
type: NodeConnectionType.Main,
index: 0,
},
],
],
},
});
canvasOperations.deleteNode('middle');
expect(workflowsStore.allConnections).toEqual({
'Input Node': {
main: [
[
{
node: 'Output Node',
type: NodeConnectionType.Main,
index: 0,
},
],
],
},
});
});
});
describe('revertDeleteNode', () => {