From 7f45134e7550e746ee0086167067bdcf4726f356 Mon Sep 17 00:00:00 2001 From: waleedcodes <110061477+waleedcodes@users.noreply.github.com> Date: Fri, 9 Oct 2026 21:24:34 +0500 Subject: [PATCH 1/3] test(graph): scaffold project graph test fixture and suite --- tests/projectGraph.test.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 tests/projectGraph.test.ts diff --git a/tests/projectGraph.test.ts b/tests/projectGraph.test.ts new file mode 100644 index 0000000..2b600a8 --- /dev/null +++ b/tests/projectGraph.test.ts @@ -0,0 +1,19 @@ +import * as fs from 'node:fs'; +import * as os from 'node:os'; +import * as path from 'node:path'; +import { afterEach, beforeEach, describe, expect, it } from 'vitest'; +import { ProjectGraph } from '../src/graph/projectGraph'; + +describe('ProjectGraph', () => { + let tempDir: string; + + beforeEach(() => { + tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'proofcode-graph-test-')); + }); + + afterEach(() => { + fs.rmSync(tempDir, { recursive: true, force: true }); + }); + + it('should map imports and compute reverse dependents', async () => { + // File A: userService.ts From b4d9b197c7478900efe87878f7036d67541f055b Mon Sep 17 00:00:00 2001 From: waleedcodes <110061477+waleedcodes@users.noreply.github.com> Date: Fri, 9 Oct 2026 21:24:34 +0500 Subject: [PATCH 2/3] test(graph): test dependency resolution and reverse mapping --- tests/projectGraph.test.ts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/projectGraph.test.ts b/tests/projectGraph.test.ts index 2b600a8..fd6b6f6 100644 --- a/tests/projectGraph.test.ts +++ b/tests/projectGraph.test.ts @@ -17,3 +17,26 @@ describe('ProjectGraph', () => { it('should map imports and compute reverse dependents', async () => { // File A: userService.ts + const userPath = path.join(tempDir, 'userService.ts'); + fs.writeFileSync( + userPath, + `export function getUser(id: string) { return { id }; }`, + 'utf8' + ); + + // File B: orderController.ts imports userService + const orderPath = path.join(tempDir, 'orderController.ts'); + fs.writeFileSync( + orderPath, + `import { getUser } from './userService'; +export function handleOrder(userId: string) { + const user = getUser(userId); + return user; +}`, + 'utf8' + ); + + const graph = new ProjectGraph(tempDir); + await graph.buildGraph([userPath, orderPath]); + + const dependents = graph.getDependents(userPath); From d693efa3dd6c3af7f7710d4922935da9073187b5 Mon Sep 17 00:00:00 2001 From: waleedcodes <110061477+waleedcodes@users.noreply.github.com> Date: Fri, 9 Oct 2026 21:24:34 +0500 Subject: [PATCH 3/3] test(graph): test impact calculation and untested caller flags --- tests/projectGraph.test.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/projectGraph.test.ts b/tests/projectGraph.test.ts index fd6b6f6..af5ffa8 100644 --- a/tests/projectGraph.test.ts +++ b/tests/projectGraph.test.ts @@ -40,3 +40,17 @@ export function handleOrder(userId: string) { await graph.buildGraph([userPath, orderPath]); const dependents = graph.getDependents(userPath); + expect(dependents.has(orderPath)).toBe(true); + + const changedLinesMap = new Map(); + changedLinesMap.set(userPath, [1]); + + const impact = graph.computeImpact(changedLinesMap); + expect(impact.changedFiles).toContain(userPath); + expect(impact.changedSymbols).toHaveLength(1); + expect(impact.changedSymbols[0].symbolName).toBe('getUser'); + expect(impact.changedSymbols[0].callers).toHaveLength(1); + expect(impact.changedSymbols[0].callers[0].callerName).toBe('handleOrder'); + expect(impact.untestedCallersCount).toBe(1); + }); +});