@@ -20,12 +20,6 @@ import {
2020 IndexType ,
2121} from "../couchbase_query.js" ;
2222
23- // Helper function to delay execution
24- const delay = ( ms : number ) =>
25- new Promise ( ( resolve ) => {
26- setTimeout ( resolve , ms ) ;
27- } ) ;
28-
2923describe . skip ( "CouchbaseQueryVectorStore" , ( ) => {
3024 // Configuration
3125 const config = {
@@ -85,8 +79,6 @@ describe.skip("CouchbaseQueryVectorStore", () => {
8579 throw err ;
8680 }
8781 }
88-
89- await delay ( 5000 ) ;
9082 } ) ;
9183
9284 beforeEach ( async ( ) => {
@@ -178,11 +170,6 @@ describe.skip("CouchbaseQueryVectorStore", () => {
178170 const batch = documents . slice ( i , i + batchSize ) ;
179171 const ids = await indexTestStore . addDocuments ( batch ) ;
180172 allIds . push ( ...ids ) ;
181-
182- // Small delay between batches to avoid overwhelming the system
183- if ( i + batchSize < documents . length ) {
184- await delay ( 100 ) ;
185- }
186173 }
187174 return allIds ;
188175 } ;
@@ -359,9 +346,6 @@ describe.skip("CouchbaseQueryVectorStore", () => {
359346
360347 // Add documents in batches for better performance
361348 bulkDocumentIds = await addDocumentsInBatches ( bulkDocuments , 100 ) ;
362-
363- // Wait a bit for documents to be indexed
364- await delay ( 10000 ) ;
365349 } ) ;
366350
367351 afterAll ( async ( ) => {
@@ -409,15 +393,22 @@ describe.skip("CouchbaseQueryVectorStore", () => {
409393 fields : [ "text" , "metadata" ] ,
410394 whereClause : "metadata.source = 'bulk_test'" ,
411395 indexScanNprobes : 10 ,
396+ indexTrainlist : 1024 ,
412397 } ;
413398
414399 // Test that createIndex doesn't throw an error
415400 await expect (
416401 indexTestStore . createIndex ( createBhiveIndexOptions )
417402 ) . resolves . not . toThrow ( ) ;
418403
419- // Wait a bit for index creation to process
420- await delay ( 2000 ) ;
404+ const indexes = await cluster
405+ . queryIndexes ( )
406+ . getAllIndexes ( config . indexTestBucketName ) ;
407+ expect (
408+ indexes . some (
409+ ( index ) => index . name === createBhiveIndexOptions . indexName
410+ )
411+ ) . toBe ( true ) ;
421412 } ) ;
422413
423414 test ( "should create COMPOSITE vector index" , async ( ) => {
@@ -430,15 +421,22 @@ describe.skip("CouchbaseQueryVectorStore", () => {
430421 fields : [ "text" , "metadata.category" ] ,
431422 whereClause : "metadata.source = 'bulk_test'" ,
432423 indexScanNprobes : 3 ,
424+ indexTrainlist : 1024 ,
433425 } ;
434426
435427 // Test that createIndex doesn't throw an error
436428 await expect (
437429 indexTestStore . createIndex ( createCompositeIndexOptions )
438430 ) . resolves . not . toThrow ( ) ;
439431
440- // Wait a bit for index creation to process
441- await delay ( 2000 ) ;
432+ const indexes = await cluster
433+ . queryIndexes ( )
434+ . getAllIndexes ( config . indexTestBucketName ) ;
435+ expect (
436+ indexes . some (
437+ ( index ) => index . name === createCompositeIndexOptions . indexName
438+ )
439+ ) . toBe ( true ) ;
442440 } ) ;
443441
444442 test ( "should create index with minimal options" , async ( ) => {
@@ -454,8 +452,12 @@ describe.skip("CouchbaseQueryVectorStore", () => {
454452 indexTestStore . createIndex ( minimalOptions )
455453 ) . resolves . not . toThrow ( ) ;
456454
457- // Wait a bit for index creation to process
458- await delay ( 2000 ) ;
455+ const indexes = await cluster
456+ . queryIndexes ( )
457+ . getAllIndexes ( config . indexTestBucketName ) ;
458+ expect (
459+ indexes . some ( ( index ) => index . name === minimalOptions . indexName )
460+ ) . toBe ( true ) ;
459461 } ) ;
460462
461463 test ( "should auto-detect vector dimension from embeddings" , async ( ) => {
@@ -471,8 +473,14 @@ describe.skip("CouchbaseQueryVectorStore", () => {
471473 indexTestStore . createIndex ( optionsWithoutDimension )
472474 ) . resolves . not . toThrow ( ) ;
473475
474- // Wait a bit for index creation to process
475- await delay ( 2000 ) ;
476+ const indexes = await cluster
477+ . queryIndexes ( )
478+ . getAllIndexes ( config . indexTestBucketName ) ;
479+ expect (
480+ indexes . some (
481+ ( index ) => index . name === optionsWithoutDimension . indexName
482+ )
483+ ) . toBe ( true ) ;
476484 } ) ;
477485
478486 test ( "should handle index creation errors gracefully" , async ( ) => {
@@ -486,6 +494,13 @@ describe.skip("CouchbaseQueryVectorStore", () => {
486494 await expect (
487495 indexTestStore . createIndex ( invalidOptions )
488496 ) . rejects . toThrow ( ) ;
497+
498+ const indexes = await cluster
499+ . queryIndexes ( )
500+ . getAllIndexes ( config . indexTestBucketName ) ;
501+ expect (
502+ indexes . some ( ( index ) => index . name === invalidOptions . indexName )
503+ ) . toBe ( false ) ;
489504 } ) ;
490505
491506 test ( "should create both BHIVE and COMPOSITE indexes sequentially" , async ( ) => {
@@ -509,13 +524,23 @@ describe.skip("CouchbaseQueryVectorStore", () => {
509524 await expect (
510525 indexTestStore . createIndex ( createBhiveIndexOptions )
511526 ) . resolves . not . toThrow ( ) ;
512- await delay ( 3000 ) ;
513527 await expect (
514528 indexTestStore . createIndex ( createCompositeIndexOptions )
515529 ) . resolves . not . toThrow ( ) ;
516530
517- // Wait a bit for index creation to process
518- await delay ( 2000 ) ;
531+ const indexes = await cluster
532+ . queryIndexes ( )
533+ . getAllIndexes ( config . indexTestBucketName ) ;
534+ expect (
535+ indexes . some (
536+ ( index ) => index . name === createBhiveIndexOptions . indexName
537+ )
538+ ) . toBe ( true ) ;
539+ expect (
540+ indexes . some (
541+ ( index ) => index . name === createCompositeIndexOptions . indexName
542+ )
543+ ) . toBe ( true ) ;
519544 } ) ;
520545
521546 test ( "should use default distance strategy when not specified" , async ( ) => {
@@ -531,8 +556,12 @@ describe.skip("CouchbaseQueryVectorStore", () => {
531556 indexTestStore . createIndex ( optionsWithoutDistance )
532557 ) . resolves . not . toThrow ( ) ;
533558
534- // Wait a bit for index creation to process
535- await delay ( 2000 ) ;
559+ const indexes = await cluster
560+ . queryIndexes ( )
561+ . getAllIndexes ( config . indexTestBucketName ) ;
562+ expect (
563+ indexes . some ( ( index ) => index . name === optionsWithoutDistance . indexName )
564+ ) . toBe ( true ) ;
536565 } ) ;
537566
538567 test ( "should handle different distance strategies" , async ( ) => {
@@ -541,6 +570,8 @@ describe.skip("CouchbaseQueryVectorStore", () => {
541570 DistanceStrategy . L2 ,
542571 DistanceStrategy . EUCLIDEAN ,
543572 DistanceStrategy . COSINE ,
573+ DistanceStrategy . L2_SQUARED ,
574+ DistanceStrategy . EUCLIDEAN_SQUARED ,
544575 ] ;
545576
546577 for ( let i = 0 ; i < distanceStrategies . length ; i += 1 ) {
@@ -555,8 +586,13 @@ describe.skip("CouchbaseQueryVectorStore", () => {
555586 await expect (
556587 indexTestStore . createIndex ( options )
557588 ) . resolves . not . toThrow ( ) ;
558- await delay ( 1000 ) ;
589+ const indexes = await cluster
590+ . queryIndexes ( )
591+ . getAllIndexes ( config . indexTestBucketName ) ;
592+ expect ( indexes . some ( ( index ) => index . name === options . indexName ) ) . toBe (
593+ true
594+ ) ;
559595 }
560- } ) ;
596+ } , 60000 ) ;
561597 } ) ;
562598} ) ;
0 commit comments