@@ -309,6 +309,7 @@ describe('CliRepl', function () {
309309 'maxTimeMS' ,
310310 'enableTelemetry' ,
311311 'editor' ,
312+ 'disableSchemaSampling' ,
312313 'snippetIndexSourceURLs' ,
313314 'snippetRegistryURL' ,
314315 'snippetAutoload' ,
@@ -2478,10 +2479,6 @@ describe('CliRepl', function () {
24782479 // be listed
24792480 wantWatch = true ;
24802481 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 ;
24852482 }
24862483 }
24872484
@@ -2492,8 +2489,11 @@ describe('CliRepl', function () {
24922489 await tick ( ) ;
24932490 input . write ( '\u0009' ) ;
24942491 await waitCompletion ( cliRepl . bus ) ;
2492+ await tick ( ) ;
24952493 } ;
24962494
2495+ let docsLoadedPromise : Promise < void > ;
2496+
24972497 beforeEach ( async function ( ) {
24982498 if ( testServer === null ) {
24992499 cliReplOptions . shellCliOptions = { nodb : true } ;
@@ -2508,9 +2508,16 @@ describe('CliRepl', function () {
25082508 if ( ! ( testServer as any ) ?. _opts . args ?. includes ( '--auth' ) ) {
25092509 // make sure there are some collections we can autocomplete on below
25102510 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' ) ;
25122513 await waitEval ( cliRepl . bus ) ;
25132514 }
2515+
2516+ docsLoadedPromise = new Promise < void > ( ( resolve ) => {
2517+ cliRepl . bus . once ( 'mongosh:load-sample-docs-complete' , ( ) => {
2518+ resolve ( ) ;
2519+ } ) ;
2520+ } ) ;
25142521 } ) ;
25152522
25162523 afterEach ( async function ( ) {
@@ -2521,6 +2528,29 @@ describe('CliRepl', function () {
25212528 await cliRepl . mongoshRepl . close ( ) ;
25222529 } ) ;
25232530
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+
25242554 it ( `${
25252555 wantWatch ? 'completes' : 'does not complete'
25262556 } the watch method`, async function ( ) {
@@ -2644,19 +2674,6 @@ describe('CliRepl', function () {
26442674 expect ( output ) . to . include ( 'use admin' ) ;
26452675 } ) ;
26462676
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-
26602677 it ( 'completes properties of shell API result types' , async function ( ) {
26612678 if ( ! hasCollectionNames ) return this . skip ( ) ;
26622679
0 commit comments