mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2026-08-05 03:18:35 +02:00
feat(core): Support executing single nodes not part of a graph as a partial execution (#13529)
This commit is contained in:
+21
@@ -33,6 +33,27 @@ describe('findSubgraph', () => {
|
||||
expect(subgraph).toEqual(graph);
|
||||
});
|
||||
|
||||
// ►►
|
||||
// ┌──────┐
|
||||
// │orphan│
|
||||
// └──────┘
|
||||
// ┌───────┐ ┌───────────┐
|
||||
// │trigger├────►│destination│
|
||||
// └───────┘ └───────────┘
|
||||
test('works with a single node', () => {
|
||||
const trigger = createNodeData({ name: 'trigger' });
|
||||
const destination = createNodeData({ name: 'destination' });
|
||||
const orphan = createNodeData({ name: 'orphan' });
|
||||
|
||||
const graph = new DirectedGraph()
|
||||
.addNodes(trigger, destination, orphan)
|
||||
.addConnections({ from: trigger, to: destination });
|
||||
|
||||
const subgraph = findSubgraph({ graph, destination: orphan, trigger: orphan });
|
||||
|
||||
expect(subgraph).toEqual(new DirectedGraph().addNode(orphan));
|
||||
});
|
||||
|
||||
// ►►
|
||||
// ┌───────┐ ┌───────────┐
|
||||
// │ ├────────►│ │
|
||||
|
||||
@@ -13,6 +13,12 @@ function findSubgraphRecursive(
|
||||
) {
|
||||
// If the current node is the chosen trigger keep this branch.
|
||||
if (current === trigger) {
|
||||
// If this graph consists of only one node there won't be any connections
|
||||
// and the loop below won't add anything.
|
||||
// We're adding the trigger here so that graphs with one node and no
|
||||
// connections are handled correctly.
|
||||
newGraph.addNode(trigger);
|
||||
|
||||
for (const connection of currentBranch) {
|
||||
newGraph.addNodes(connection.from, connection.to);
|
||||
newGraph.addConnection(connection);
|
||||
|
||||
Reference in New Issue
Block a user