Skip to content

Local code intelligence for developers and AI agents. Connect code, docs and infrastructure in a persistent graph, with CBM Lens, MCP tools, agent integrations and change-aware test selection.

fix(ui): treat a nested test package as product code in Routes

Bernhard Jackiewicz9b26e19faa38
diff --git a/graph-ui/src/architecture/semantic-graph.test.ts b/graph-ui/src/architecture/semantic-graph.test.ts
index bca6c7f94..e0b998749 100644
--- a/graph-ui/src/architecture/semantic-graph.test.ts
+++ b/graph-ui/src/architecture/semantic-graph.test.ts
@@ -332,6 +332,14 @@ describe('route identities and service evidence', () => {
const filtered = buildSemanticGraph(graph, { view: 'routes', groupRoutes: true, filter: '/accounts', routeSnapshot });
expect(filtered.nodes.filter(item => item.kind === 'route').map(item => item.label)).toEqual(['/accounts/login/', '/accounts/logout/']);
});
+ it('keeps routes of a product test package and hides those of test roots', () => {
+ const at = (id: number, name: string, file_path: string): GraphNode => ({ ...route, id, name, qualified_name: `fixture.route.${id}`, file_path });
+ const graph: GraphData = { nodes: [at(500, '/client/', 'django/test/client.py'), at(501, '/fixture/', 'tests/urls.py'),
+ at(502, '/java/', 'src/test/java/RoutesTest.java'), at(503, '/root/', 'test/urls.js'), at(504, '/spec/', 'web/__tests__/routes.ts')], edges: [], total_nodes: 5 };
+ const model = buildSemanticGraph(graph, { view: 'routes', hideTestRoutes: true });
+ expect(model.nodes.map(item => item.label)).toEqual(['/client/']);
+ expect(model.hiddenRoutes).toBe(4);
+ });
it('hides routes whose evidence lies only in test code and keeps test callers of other routes', () => {
const testCaller = node(2, 'tests/admin_views/tests.py', 'test_login');
const handler = node(3, 'django/contrib/admin/actions.py', 'delete_selected');
diff --git a/graph-ui/src/architecture/semantic-graph.ts b/graph-ui/src/architecture/semantic-graph.ts
index fb9223b38..fe399a817 100644
--- a/graph-ui/src/architecture/semantic-graph.ts
+++ b/graph-ui/src/architecture/semantic-graph.ts
@@ -99,8 +99,12 @@ const compare = (a: string, b: string) => a < b ? -1 : a > b ? 1 : 0;
const identity = (node: GraphNode) => `${node.label}:${node.qualified_name || `#${node.id}`}@${node.file_path ?? ''}`;
const nodeOrder = (a: GraphNode, b: GraphNode) => compare(identity(a), identity(b));
const symbolId = (node: GraphNode) => `symbol:${identity(node)}`;
-/** Conventional test locations: a test directory, or a test_*, tests.*, *_test, *.test or *.spec file. */
-const TEST_SOURCE = /(^|\/)(tests?|__tests__|specs?)\/|(^|\/)(test_[^/]*|tests?\.[^/.]+|[^/]+[._-](test|spec)\.[^/.]+)$/i;
+/**
+ * Conventional test locations: a tests, __tests__ or spec directory, a test
+ * root (test/ or src/test/), or a test_*, tests.*, *_test, *.test or *.spec
+ * file. A nested test/ package such as django/test/ is product code.
+ */
+const TEST_SOURCE = /(^|\/)(tests|__tests__|specs?)\/|^(src\/)?test\/|(^|\/)(test_[^/]*|tests?\.[^/.]+|[^/]+[._-](test|spec)\.[^/.]+)$/i;
const sourceNode = (node: GraphNode) => Boolean(node.file_path && node.file_path !== '{}'
&& !['Project', 'Folder', 'Package', 'Branch', 'Route'].includes(node.label));
const symbolNode = (node: GraphNode): SemanticNode => ({ id: symbolId(node),