@@ -155,6 +155,82 @@ describe("DocumentStore - With Embeddings", () => {
155155      expect ( await  store . checkDocumentExists ( "templib" ,  "1.0.0" ) ) . toBe ( false ) ; 
156156    } ) ; 
157157
158+     it ( "should completely remove a version including pages and documents" ,  async  ( )  =>  { 
159+       const  docs : Document [ ]  =  [ 
160+         { 
161+           pageContent : "First document for removal test" , 
162+           metadata : { 
163+             title : "Doc 1" , 
164+             url : "https://example.com/doc1" , 
165+             path : [ "docs" ] , 
166+           } , 
167+         } , 
168+         { 
169+           pageContent : "Second document for removal test" , 
170+           metadata : { 
171+             title : "Doc 2" , 
172+             url : "https://example.com/doc2" , 
173+             path : [ "docs" ] , 
174+           } , 
175+         } , 
176+       ] ; 
177+ 
178+       // Add documents and verify they exist 
179+       await  store . addDocuments ( "removelib" ,  "1.0.0" ,  docs ) ; 
180+       expect ( await  store . checkDocumentExists ( "removelib" ,  "1.0.0" ) ) . toBe ( true ) ; 
181+ 
182+       // Remove the version 
183+       const  result  =  await  store . removeVersion ( "removelib" ,  "1.0.0" ,  true ) ; 
184+ 
185+       // Verify the results 
186+       expect ( result . documentsDeleted ) . toBe ( 2 ) ; 
187+       expect ( result . versionDeleted ) . toBe ( true ) ; 
188+       expect ( result . libraryDeleted ) . toBe ( true ) ; 
189+ 
190+       // Verify documents no longer exist 
191+       expect ( await  store . checkDocumentExists ( "removelib" ,  "1.0.0" ) ) . toBe ( false ) ; 
192+     } ) ; 
193+ 
194+     it ( "should remove version but keep library when other versions exist" ,  async  ( )  =>  { 
195+       const  v1Docs : Document [ ]  =  [ 
196+         { 
197+           pageContent : "Version 1 document" , 
198+           metadata : { 
199+             title : "V1 Doc" , 
200+             url : "https://example.com/v1" , 
201+             path : [ "v1" ] , 
202+           } , 
203+         } , 
204+       ] ; 
205+ 
206+       const  v2Docs : Document [ ]  =  [ 
207+         { 
208+           pageContent : "Version 2 document" , 
209+           metadata : { 
210+             title : "V2 Doc" , 
211+             url : "https://example.com/v2" , 
212+             path : [ "v2" ] , 
213+           } , 
214+         } , 
215+       ] ; 
216+ 
217+       // Add two versions 
218+       await  store . addDocuments ( "multilib" ,  "1.0.0" ,  v1Docs ) ; 
219+       await  store . addDocuments ( "multilib" ,  "2.0.0" ,  v2Docs ) ; 
220+ 
221+       // Remove only version 1.0.0 
222+       const  result  =  await  store . removeVersion ( "multilib" ,  "1.0.0" ,  true ) ; 
223+ 
224+       // Verify version 1 was deleted but library remains 
225+       expect ( result . documentsDeleted ) . toBe ( 1 ) ; 
226+       expect ( result . versionDeleted ) . toBe ( true ) ; 
227+       expect ( result . libraryDeleted ) . toBe ( false ) ; 
228+ 
229+       // Verify version 1 no longer exists but version 2 does 
230+       expect ( await  store . checkDocumentExists ( "multilib" ,  "1.0.0" ) ) . toBe ( false ) ; 
231+       expect ( await  store . checkDocumentExists ( "multilib" ,  "2.0.0" ) ) . toBe ( true ) ; 
232+     } ) ; 
233+ 
158234    it ( "should handle multiple versions of the same library" ,  async  ( )  =>  { 
159235      const  v1Docs : Document [ ]  =  [ 
160236        { 
0 commit comments