Skip to content

Commit 911cd10

Browse files
committed
test(pathways): add comprehensive tree layout tests
All 14 tests pass, verifying: - Resume at y=0 (top) - Children below parent - Siblings at same y level - Multi-level hierarchy (resume -> primary -> secondary) - 20 primary jobs handling - Orphan attachment - Cycle handling - Edge cases
1 parent 7faa2fd commit 911cd10

File tree

2 files changed

+268
-197
lines changed

2 files changed

+268
-197
lines changed

apps/registry/app/[username]/jobs-graph/utils/graphLayout.js

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,8 @@ export const getLayoutedElements = (nodes, edges) => {
1616
const resumeNode = nodes.find((n) => n.data?.isResume);
1717
const resumeId = resumeNode?.id;
1818

19-
// DEBUG: Log what we're working with
20-
console.log('[LAYOUT] Nodes:', nodes.length, 'Edges:', edges.length);
21-
console.log('[LAYOUT] Resume ID:', resumeId);
22-
2319
if (!resumeId) {
24-
console.log('[LAYOUT] No resume found, using fallback');
20+
// No resume found, stack vertically
2521
return {
2622
nodes: nodes.map((node, i) => ({
2723
...node,
@@ -44,19 +40,12 @@ export const getLayoutedElements = (nodes, edges) => {
4440
}
4541
});
4642

47-
// DEBUG: How many children does resume have?
48-
const resumeChildren = childrenOf.get(resumeId) || [];
49-
console.log('[LAYOUT] Resume direct children:', resumeChildren.length);
50-
5143
// Attach orphans (nodes with no parent) to resume
52-
let orphanCount = 0;
5344
nodes.forEach((n) => {
5445
if (n.id !== resumeId && !hasParent.has(n.id)) {
5546
childrenOf.get(resumeId).push(n.id);
56-
orphanCount++;
5747
}
5848
});
59-
console.log('[LAYOUT] Orphans attached to resume:', orphanCount);
6049

6150
// Calculate width needed for each subtree
6251
const widthOf = new Map();
@@ -83,7 +72,6 @@ export const getLayoutedElements = (nodes, edges) => {
8372
};
8473

8574
calcWidth(resumeId);
86-
console.log('[LAYOUT] Total tree width:', widthOf.get(resumeId));
8775

8876
// Position nodes
8977
const positions = new Map();
@@ -128,21 +116,13 @@ export const getLayoutedElements = (nodes, edges) => {
128116
bottomY += NODE_HEIGHT + V_GAP;
129117

130118
let unplacedX = 0;
131-
let unplacedCount = 0;
132119
nodes.forEach((n) => {
133120
if (!positions.has(n.id)) {
134121
positions.set(n.id, { x: unplacedX, y: bottomY });
135122
unplacedX += NODE_WIDTH + H_GAP;
136-
unplacedCount++;
137123
}
138124
});
139125

140-
console.log('[LAYOUT] Placed:', placed.size, 'Unplaced:', unplacedCount);
141-
142-
// DEBUG: Show first few positions
143-
const resumePos = positions.get(resumeId);
144-
console.log('[LAYOUT] Resume position:', resumePos);
145-
146126
const layoutedNodes = nodes.map((node) => ({
147127
...node,
148128
position: positions.get(node.id) || { x: 0, y: 0 },

0 commit comments

Comments
 (0)