Skip to content

Commit 0eb682a

Browse files
committed
chore(cli-repl): fix flaky autocompletion test MONGOSH-1960
Our current autocomplete logic does not always wait for the collection or database name caches to be filled, in case it takes longer than 200ms to do so. By ensuring that the caches are filled before we run the test, we get consistent results.
1 parent b622534 commit 0eb682a

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

packages/cli-repl/src/cli-repl.spec.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2414,6 +2414,9 @@ describe('CliRepl', function () {
24142414

24152415
it('completes use <db>', async function () {
24162416
if (!hasDatabaseNames) return;
2417+
input.write('db.getMongo()._listDatabases()\n'); // populate database cache
2418+
await waitEval(cliRepl.bus);
2419+
24172420
input.write('use adm');
24182421
await tab();
24192422
await waitCompletion(cliRepl.bus);
@@ -2429,12 +2432,13 @@ describe('CliRepl', function () {
24292432

24302433
it('completes properties of shell API result types', async function () {
24312434
if (!hasCollectionNames) return;
2435+
24322436
input.write(
24332437
'res = db.autocompleteTestColl.deleteMany({ deletetestdummykey: 1 })\n'
24342438
);
24352439
await waitEval(cliRepl.bus);
24362440

2437-
// Consitency check: The result actually has a shell API type tag:
2441+
// Consistency check: The result actually has a shell API type tag:
24382442
output = '';
24392443
input.write('res[Symbol.for("@@mongosh.shellApiType")]\n');
24402444
await waitEval(cliRepl.bus);

0 commit comments

Comments
 (0)