@@ -379,6 +379,7 @@ describe('MongoshNodeRepl', function () {
379379 } ) ;
380380 const initialized = await mongoshRepl . initialize ( serviceProvider ) ;
381381 await mongoshRepl . startRepl ( initialized ) ;
382+ await mongoshRepl . setConfig ( 'disableSchemaSampling' , false ) ;
382383 } ) ;
383384
384385 it ( 'provides an editor action' , async function ( ) {
@@ -481,14 +482,34 @@ describe('MongoshNodeRepl', function () {
481482 await tick ( ) ;
482483 expect ( output , output ) . to . include ( 'db.coll.updateOne' ) ;
483484 } ) ;
484- // this will eventually be supported in the new autocomplete
485- it . skip ( 'autocompletes collection schema fields' , async function ( ) {
486- input . write ( 'db.coll.find({' ) ;
485+ it ( 'autocompletes collection schema fields' , async function ( ) {
486+ if ( ! process . env . USE_NEW_AUTOCOMPLETE ) {
487+ // auto-completing collection field names only supported by new autocomplete
488+ this . skip ( ) ;
489+ }
490+ input . write ( 'db.coll.find({fo' ) ;
487491 await tabtab ( ) ;
488492 await waitCompletion ( bus ) ;
489493 await tick ( ) ;
490494 expect ( output , output ) . to . include ( 'db.coll.find({foo' ) ;
491495 } ) ;
496+
497+ it ( 'does not autocomplete collection schema fields if disableSchemaSampling=true' , async function ( ) {
498+ if ( ! process . env . USE_NEW_AUTOCOMPLETE ) {
499+ // auto-completing collection field names only supported by new autocomplete
500+ this . skip ( ) ;
501+ }
502+ await mongoshRepl . setConfig ( 'disableSchemaSampling' , true ) ;
503+ try {
504+ input . write ( 'db.coll.find({fo' ) ;
505+ await tabtab ( ) ;
506+ await waitCompletion ( bus ) ;
507+ await tick ( ) ;
508+ expect ( output , output ) . to . not . include ( 'db.coll.find({foo' ) ;
509+ } finally {
510+ await mongoshRepl . setConfig ( 'disableSchemaSampling' , false ) ;
511+ }
512+ } ) ;
492513 it ( 'autocompletes shell-api methods (once)' , async function ( ) {
493514 input . write ( 'vers' ) ;
494515 await tabtab ( ) ;
0 commit comments