1- import { setup } from '../../../../../../setup.mjs' ;
1+ import { setup } from '../../../../../../setup.mjs' ;
22
33const appName = 'GraphServiceTest' ;
44
@@ -7,21 +7,22 @@ setup({
77 unitTestMode : true
88 } ,
99 appConfig : {
10- name : appName ,
11- isMounted : ( ) => true ,
10+ name : appName ,
11+ isMounted : ( ) => true ,
1212 vnodeInitialising : false
1313 }
1414} ) ;
1515
16- import { test , expect } from '@playwright/test' ;
17- import Neo from '../../../../../../../../src/Neo.mjs' ;
18- import * as core from '../../../../../../../../src/core/_export.mjs' ;
19- import GraphService from '../../../../../../../../ai/mcp/server/memory-core/services/GraphService.mjs' ;
20- import aiConfig from '../../../../../../../../ai/mcp/server/memory-core/config.mjs' ;
21- import fs from 'fs-extra' ;
22- import path from 'path' ;
23- import os from 'os' ;
24- import { getPaths } from '../../../../../../../../ai/graph/queries/Traversal.mjs' ;
16+ import { test , expect } from '@playwright/test' ;
17+ import Neo from '../../../../../../../../src/Neo.mjs' ;
18+ import * as core from '../../../../../../../../src/core/_export.mjs' ;
19+ import InstanceManager from '../../../../../../../../src/manager/Instance.mjs' ;
20+ import GraphService from '../../../../../../../../ai/mcp/server/memory-core/services/GraphService.mjs' ;
21+ import aiConfig from '../../../../../../../../ai/mcp/server/memory-core/config.mjs' ;
22+ import fs from 'fs-extra' ;
23+ import path from 'path' ;
24+ import os from 'os' ;
25+ import { getPaths } from '../../../../../../../../ai/graph/queries/Traversal.mjs' ;
2526
2627test . describe ( 'Neo.ai.mcp.server.memory-core.services.GraphService' , ( ) => {
2728 let service ;
@@ -42,14 +43,22 @@ test.describe('Neo.ai.mcp.server.memory-core.services.GraphService', () => {
4243 GraphService . db . nodes . clear ( ) ;
4344 GraphService . db . edges . clear ( ) ;
4445 GraphService . db . vicinityLoadedNodes . clear ( ) ;
46+
47+ if ( GraphService . db . storage ) {
48+ await GraphService . db . storage . clear ( ) ;
49+ }
4550 }
4651 } ) ;
4752
48- test . afterEach ( ( ) => {
53+ test . afterEach ( async ( ) => {
4954 if ( GraphService . db ) {
5055 GraphService . db . nodes . clear ( ) ;
5156 GraphService . db . edges . clear ( ) ;
5257 GraphService . db . vicinityLoadedNodes . clear ( ) ;
58+
59+ if ( GraphService . db . storage ) {
60+ await GraphService . db . storage . clear ( ) ;
61+ }
5362 }
5463 } ) ;
5564
@@ -177,12 +186,12 @@ test.describe('Neo.ai.mcp.server.memory-core.services.GraphService', () => {
177186
178187 let wasAutoSave = GraphService . db . autoSave ;
179188 GraphService . db . autoSave = false ;
180-
189+
181190 // Explicitly clear RAM cache WITHOUT cascading to SQLite
182191 GraphService . db . nodes . clear ( ) ;
183192 GraphService . db . edges . clear ( ) ;
184193 GraphService . db . vicinityLoadedNodes . clear ( ) ;
185-
194+
186195 GraphService . db . autoSave = wasAutoSave ;
187196
188197 // Traverse using getPaths. Depth parameter is set to 3 to hit all nodes.
@@ -194,10 +203,10 @@ test.describe('Neo.ai.mcp.server.memory-core.services.GraphService', () => {
194203 // Depth 2: Depth2
195204 // Depth 3: Depth3
196205 expect ( results . length ) . toBe ( 4 ) ;
197-
206+
198207 let pathIds = results . map ( n => n . id ) . sort ( ) ;
199208 expect ( pathIds ) . toEqual ( [ 'Depth1' , 'Depth2' , 'Depth3' , 'Root' ] ) ;
200-
209+
201210 // Verify that deeply resolved nodes were structurally hydrated into memory
202211 expect ( GraphService . db . nodes . has ( 'Depth3' ) ) . toBe ( true ) ;
203212 expect ( GraphService . getNode ( { id : 'Depth3' } ) . name ) . toBe ( 'Final Hop' ) ;
@@ -209,12 +218,12 @@ test.describe('Neo.ai.mcp.server.memory-core.services.GraphService', () => {
209218
210219 GraphService . upsertNode ( { id : 'N1' , name : 'First' } ) ;
211220 GraphService . getNode ( { id : 'N1' } ) ; // Register to LRU Matrix natively
212-
221+
213222 // Let timestamp differential tick natively avoiding micro-millisecond collisions gracefully
214223 await new Promise ( resolve => setTimeout ( resolve , 5 ) ) ;
215224 GraphService . upsertNode ( { id : 'N2' , name : 'Second' } ) ;
216225 GraphService . getNode ( { id : 'N2' } ) ;
217-
226+
218227 await new Promise ( resolve => setTimeout ( resolve , 5 ) ) ;
219228 GraphService . upsertNode ( { id : 'N3' , name : 'Third' } ) ;
220229 GraphService . getNode ( { id : 'N3' } ) ;
@@ -224,20 +233,20 @@ test.describe('Neo.ai.mcp.server.memory-core.services.GraphService', () => {
224233 expect ( GraphService . db . nodes . has ( 'N1' ) ) . toBe ( true ) ;
225234
226235 await new Promise ( resolve => setTimeout ( resolve , 5 ) ) ;
227-
236+
228237 // This 4th insert will push the length over 3 when accessed.
229238 GraphService . upsertNode ( { id : 'N4' , name : 'Fourth' } ) ;
230239 GraphService . getNode ( { id : 'N4' } ) ; // GC fires here natively!
231240
232241 // V8 footprint must hold 3 items cleanly locally natively. Output should be N2, N3, N4
233242 expect ( GraphService . db . nodes . getCount ( ) ) . toBe ( 3 ) ;
234-
243+
235244 expect ( GraphService . db . nodes . has ( 'N1' ) ) . toBe ( false ) ; // N1 dropped out of cache natively gracefully!
236245 expect ( GraphService . db . nodes . has ( 'N2' ) ) . toBe ( true ) ;
237246 expect ( GraphService . db . nodes . has ( 'N3' ) ) . toBe ( true ) ;
238247 expect ( GraphService . db . nodes . has ( 'N4' ) ) . toBe ( true ) ;
239-
240- // Restore maxGraphNodes constraint cleanly safely natively
248+
249+ // Restore maxGraphNodes constraint cleanly safely natively
241250 GraphService . db . maxGraphNodes = null ;
242251 } ) ;
243252
0 commit comments