fix(core): Don't fail partial execution when an unrelated node is dirty (#13925)

This commit is contained in:
Danny Martini
2025-03-18 12:27:49 +01:00
committed by GitHub
parent d6d5a66f5d
commit 918cc51abc
4 changed files with 100 additions and 1 deletions
@@ -492,4 +492,35 @@ describe('DirectedGraph', () => {
expect(graph.hasNode(node.name + 'foo')).toBe(false);
});
});
describe('getNodesByNames', () => {
test('returns empty Set when no names are provided', () => {
// ARRANGE
const node1 = createNodeData({ name: 'Node1' });
const node2 = createNodeData({ name: 'Node2' });
const graph = new DirectedGraph().addNodes(node1, node2);
// ACT
const result = graph.getNodesByNames([]);
// ASSERT
expect(result.size).toBe(0);
expect(result).toEqual(new Set());
});
test('returns Set with only nodes that exist in the graph', () => {
// ARRANGE
const node1 = createNodeData({ name: 'Node1' });
const node2 = createNodeData({ name: 'Node2' });
const node3 = createNodeData({ name: 'Node3' });
const graph = new DirectedGraph().addNodes(node1, node2, node3);
// ACT
const result = graph.getNodesByNames(['Node1', 'Node3', 'Node4']);
// ASSERT
expect(result.size).toBe(2);
expect(result).toEqual(new Set([node1, node3]));
});
});
});
@@ -50,6 +50,25 @@ export class DirectedGraph {
return new Map(this.nodes.entries());
}
/**
* Returns a set of nodes whose names match the provided array of names.
*
* Only nodes that exist in the graph will be included in the result.
*/
getNodesByNames(names: string[]) {
const nodes: Set<INode> = new Set();
for (const name of names) {
const node = this.nodes.get(name);
if (node) {
nodes.add(node);
}
}
return nodes;
}
getConnections(filter: { to?: INode } = {}) {
const filteredCopy: GraphConnection[] = [];