@@ -29,6 +29,8 @@ describe('e2e direct connection', () => {
29
29
} ) ;
30
30
31
31
context ( 'after rs.initiate()' , ( ) => {
32
+ let dbname : string ;
33
+
32
34
before ( async ( ) => {
33
35
const replSetConfig = {
34
36
_id : replSetId ,
@@ -50,6 +52,15 @@ describe('e2e direct connection', () => {
50
52
shell . assertContainsOutput ( `me: '${ await rs0 . hostport ( ) } '` ) ;
51
53
shell . assertContainsOutput ( `setName: '${ replSetId } '` ) ;
52
54
} ) ;
55
+ dbname = `test-${ Date . now ( ) } -${ ( Math . random ( ) * 100000 ) | 0 } ` ;
56
+ await shell . executeLine ( `use ${ dbname } ` ) ;
57
+ await shell . executeLine ( 'db.testcollection.insertOne({})' ) ;
58
+ shell . writeInputLine ( 'exit' ) ;
59
+ } ) ;
60
+ after ( async ( ) => {
61
+ const shell = TestShell . start ( { args : [ await rs0 . connectionString ( ) ] } ) ;
62
+ await shell . executeLine ( `db.getSiblingDB("${ dbname } ").dropDatabase()` ) ;
63
+ shell . writeInputLine ( 'exit' ) ;
53
64
} ) ;
54
65
55
66
context ( 'connecting to secondary members directly' , ( ) => {
@@ -103,6 +114,14 @@ describe('e2e direct connection', () => {
103
114
expect ( await shell . executeLine ( 'show collections' ) ) . to . include ( 'system.version' ) ;
104
115
expect ( await shell . executeLine ( 'show dbs' ) ) . to . include ( 'admin' ) ;
105
116
} ) ;
117
+ it ( 'autocompletes collection names' , async ( ) => {
118
+ const shell = TestShell . start ( { args : [ `${ await rs1 . connectionString ( ) } /${ dbname } ` ] , forceTerminal : true } ) ;
119
+ await shell . waitForPrompt ( ) ;
120
+ shell . writeInput ( 'db.testc\u0009\u0009' ) ;
121
+ await eventually ( ( ) => {
122
+ shell . assertContainsOutput ( 'db.testcollection' ) ;
123
+ } ) ;
124
+ } ) ;
106
125
} ) ;
107
126
108
127
context ( 'connecting to primary' , ( ) => {
@@ -139,6 +158,14 @@ describe('e2e direct connection', () => {
139
158
expect ( await shell . executeLine ( 'show collections' ) ) . to . include ( 'system.version' ) ;
140
159
expect ( await shell . executeLine ( 'show dbs' ) ) . to . include ( 'admin' ) ;
141
160
} ) ;
161
+ it ( 'autocompletes collection names' , async ( ) => {
162
+ const shell = TestShell . start ( { args : [ `${ await rs1 . connectionString ( ) } /${ dbname } ` ] , forceTerminal : true } ) ;
163
+ await shell . waitForPrompt ( ) ;
164
+ shell . writeInput ( 'db.testc\u0009\u0009' ) ;
165
+ await eventually ( ( ) => {
166
+ shell . assertContainsOutput ( 'db.testcollection' ) ;
167
+ } ) ;
168
+ } ) ;
142
169
} ) ;
143
170
} ) ;
144
171
} ) ;
0 commit comments