@@ -309,6 +309,7 @@ describe('CliRepl', function () {
309
309
'maxTimeMS' ,
310
310
'enableTelemetry' ,
311
311
'editor' ,
312
+ 'disableSchemaSampling' ,
312
313
'snippetIndexSourceURLs' ,
313
314
'snippetRegistryURL' ,
314
315
'snippetAutoload' ,
@@ -2478,10 +2479,6 @@ describe('CliRepl', function () {
2478
2479
// be listed
2479
2480
wantWatch = true ;
2480
2481
wantShardDistribution = true ;
2481
-
2482
- // TODO: we need MQL support in mongodb-ts-autocomplete in order for it
2483
- // to autocomplete collection field names
2484
- wantQueryOperators = false ;
2485
2482
}
2486
2483
}
2487
2484
@@ -2492,8 +2489,11 @@ describe('CliRepl', function () {
2492
2489
await tick ( ) ;
2493
2490
input . write ( '\u0009' ) ;
2494
2491
await waitCompletion ( cliRepl . bus ) ;
2492
+ await tick ( ) ;
2495
2493
} ;
2496
2494
2495
+ let docsLoadedPromise : Promise < void > ;
2496
+
2497
2497
beforeEach ( async function ( ) {
2498
2498
if ( testServer === null ) {
2499
2499
cliReplOptions . shellCliOptions = { nodb : true } ;
@@ -2508,9 +2508,16 @@ describe('CliRepl', function () {
2508
2508
if ( ! ( testServer as any ) ?. _opts . args ?. includes ( '--auth' ) ) {
2509
2509
// make sure there are some collections we can autocomplete on below
2510
2510
input . write ( 'db.coll.insertOne({})\n' ) ;
2511
- input . write ( 'db.movies.insertOne({})\n' ) ;
2511
+ await waitEval ( cliRepl . bus ) ;
2512
+ input . write ( 'db.movies.insertOne({ year: 1 })\n' ) ;
2512
2513
await waitEval ( cliRepl . bus ) ;
2513
2514
}
2515
+
2516
+ docsLoadedPromise = new Promise < void > ( ( resolve ) => {
2517
+ cliRepl . bus . once ( 'mongosh:load-sample-docs-complete' , ( ) => {
2518
+ resolve ( ) ;
2519
+ } ) ;
2520
+ } ) ;
2514
2521
} ) ;
2515
2522
2516
2523
afterEach ( async function ( ) {
@@ -2521,6 +2528,29 @@ describe('CliRepl', function () {
2521
2528
await cliRepl . mongoshRepl . close ( ) ;
2522
2529
} ) ;
2523
2530
2531
+ it ( `${
2532
+ wantQueryOperators ? 'completes' : 'does not complete'
2533
+ } query operators`, async function ( ) {
2534
+ input . write ( 'db.movies.find({year: {$g' ) ;
2535
+ await tabCompletion ( ) ;
2536
+
2537
+ if ( wantQueryOperators ) {
2538
+ if ( process . env . USE_NEW_AUTOCOMPLETE ) {
2539
+ // wait for the documents to finish loading to be sure that the next
2540
+ // tabCompletion() call will work
2541
+ await docsLoadedPromise ;
2542
+ }
2543
+ }
2544
+
2545
+ await tabCompletion ( ) ;
2546
+
2547
+ if ( wantQueryOperators ) {
2548
+ expect ( output ) . to . include ( 'db.movies.find({year: {$gte' ) ;
2549
+ } else {
2550
+ expect ( output ) . to . not . include ( 'db.movies.find({year: {$gte' ) ;
2551
+ }
2552
+ } ) ;
2553
+
2524
2554
it ( `${
2525
2555
wantWatch ? 'completes' : 'does not complete'
2526
2556
} the watch method`, async function ( ) {
@@ -2644,19 +2674,6 @@ describe('CliRepl', function () {
2644
2674
expect ( output ) . to . include ( 'use admin' ) ;
2645
2675
} ) ;
2646
2676
2647
- it ( `${
2648
- wantQueryOperators ? 'completes' : 'does not complete'
2649
- } query operators`, async function ( ) {
2650
- input . write ( 'db.movies.find({year: {$g' ) ;
2651
- await tabCompletion ( ) ;
2652
- await tabCompletion ( ) ;
2653
- if ( wantQueryOperators ) {
2654
- expect ( output ) . to . include ( 'db.movies.find({year: {$gte' ) ;
2655
- } else {
2656
- expect ( output ) . to . not . include ( 'db.movies.find({year: {$gte' ) ;
2657
- }
2658
- } ) ;
2659
-
2660
2677
it ( 'completes properties of shell API result types' , async function ( ) {
2661
2678
if ( ! hasCollectionNames ) return this . skip ( ) ;
2662
2679
0 commit comments