Skip to content

Commit 7f55363

Browse files
committed
fixup: revert test changes, only polyfill saslprep when on production webpack build
1 parent ec7428e commit 7f55363

File tree

2 files changed

+109
-93
lines changed

2 files changed

+109
-93
lines changed

packages/compass-e2e-tests/tests/connection.test.ts

Lines changed: 100 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -329,8 +329,7 @@ describe('Connection string', function () {
329329
});
330330

331331
it('can connect to an Atlas replicaset without srv', async function () {
332-
if (!hasAtlasEnvironmentVariables() || TEST_COMPASS_WEB) {
333-
// Skip this on web because it doesn't support saslprep.
332+
if (!hasAtlasEnvironmentVariables()) {
334333
return this.skip();
335334
}
336335

@@ -341,18 +340,19 @@ describe('Connection string', function () {
341340

342341
const connectionString = await resolveMongodbSrv(withSRV);
343342
await browser.connectWithConnectionString(connectionString);
344-
const result = await browser.shellEval(
345-
connectionNameFromString(connectionString),
346-
'db.runCommand({ connectionStatus: 1 })',
347-
true
348-
);
349-
assertNotError(result);
350-
expect(result).to.have.property('ok', 1);
343+
if (!TEST_COMPASS_WEB) {
344+
const result = await browser.shellEval(
345+
connectionNameFromString(connectionString),
346+
'db.runCommand({ connectionStatus: 1 })',
347+
true
348+
);
349+
assertNotError(result);
350+
expect(result).to.have.property('ok', 1);
351+
}
351352
});
352353

353354
it('can connect to an Atlas cluster with a direct connection', async function () {
354-
if (!hasAtlasEnvironmentVariables() || TEST_COMPASS_WEB) {
355-
// Skip this on web because it doesn't support saslprep.
355+
if (!hasAtlasEnvironmentVariables()) {
356356
return this.skip();
357357
}
358358

@@ -371,18 +371,19 @@ describe('Connection string', function () {
371371
const connectionString = parsedString.toString();
372372
await browser.connectWithConnectionString(connectionString);
373373

374-
const result = await browser.shellEval(
375-
connectionNameFromString(connectionString),
376-
'db.runCommand({ connectionStatus: 1 })',
377-
true
378-
);
379-
assertNotError(result);
380-
expect(result).to.have.property('ok', 1);
374+
if (!TEST_COMPASS_WEB) {
375+
const result = await browser.shellEval(
376+
connectionNameFromString(connectionString),
377+
'db.runCommand({ connectionStatus: 1 })',
378+
true
379+
);
380+
assertNotError(result);
381+
expect(result).to.have.property('ok', 1);
382+
}
381383
});
382384

383385
it('can connect to Atlas Serverless', async function () {
384-
if (!hasAtlasEnvironmentVariables() || TEST_COMPASS_WEB) {
385-
// Skip this on web because it doesn't support saslprep.
386+
if (!hasAtlasEnvironmentVariables()) {
386387
return this.skip();
387388
}
388389

@@ -394,18 +395,19 @@ describe('Connection string', function () {
394395

395396
await browser.connectWithConnectionString(connectionString);
396397

397-
const result = await browser.shellEval(
398-
connectionName,
399-
'db.runCommand({ connectionStatus: 1 })',
400-
true
401-
);
402-
assertNotError(result);
403-
expect(result).to.have.property('ok', 1);
398+
if (!TEST_COMPASS_WEB) {
399+
const result = await browser.shellEval(
400+
connectionName,
401+
'db.runCommand({ connectionStatus: 1 })',
402+
true
403+
);
404+
assertNotError(result);
405+
expect(result).to.have.property('ok', 1);
406+
}
404407
});
405408

406409
it('can connect to Atlas Datalake', async function () {
407-
if (!hasAtlasEnvironmentVariables() || TEST_COMPASS_WEB) {
408-
// Skip this on web because it doesn't support saslprep.
410+
if (!hasAtlasEnvironmentVariables()) {
409411
return this.skip();
410412
}
411413

@@ -417,18 +419,19 @@ describe('Connection string', function () {
417419

418420
await browser.connectWithConnectionString(connectionString);
419421

420-
const result = await browser.shellEval(
421-
connectionName,
422-
'db.runCommand({ connectionStatus: 1 })',
423-
true
424-
);
425-
assertNotError(result);
426-
expect(result).to.have.property('ok', 1);
422+
if (!TEST_COMPASS_WEB) {
423+
const result = await browser.shellEval(
424+
connectionName,
425+
'db.runCommand({ connectionStatus: 1 })',
426+
true
427+
);
428+
assertNotError(result);
429+
expect(result).to.have.property('ok', 1);
430+
}
427431
});
428432

429433
it('can connect to Atlas Analytics Node', async function () {
430-
if (!hasAtlasEnvironmentVariables() || TEST_COMPASS_WEB) {
431-
// Skip this on web because it doesn't support saslprep.
434+
if (!hasAtlasEnvironmentVariables()) {
432435
return this.skip();
433436
}
434437

@@ -440,18 +443,19 @@ describe('Connection string', function () {
440443

441444
await browser.connectWithConnectionString(connectionString);
442445

443-
const result = await browser.shellEval(
444-
connectionName,
445-
'db.runCommand({ connectionStatus: 1 })',
446-
true
447-
);
448-
assertNotError(result);
449-
expect(result).to.have.property('ok', 1);
446+
if (!TEST_COMPASS_WEB) {
447+
const result = await browser.shellEval(
448+
connectionName,
449+
'db.runCommand({ connectionStatus: 1 })',
450+
true
451+
);
452+
assertNotError(result);
453+
expect(result).to.have.property('ok', 1);
454+
}
450455
});
451456

452457
it('can connect to Atlas Free Tier', async function () {
453-
if (!hasAtlasEnvironmentVariables() || TEST_COMPASS_WEB) {
454-
// Skip this on web because it doesn't support saslprep.
458+
if (!hasAtlasEnvironmentVariables()) {
455459
return this.skip();
456460
}
457461

@@ -462,18 +466,19 @@ describe('Connection string', function () {
462466
const connectionName = connectionNameFromString(connectionString);
463467

464468
await browser.connectWithConnectionString(connectionString);
465-
const result = await browser.shellEval(
466-
connectionName,
467-
'db.runCommand({ connectionStatus: 1 })',
468-
true
469-
);
470-
assertNotError(result);
471-
expect(result).to.have.property('ok', 1);
469+
if (!TEST_COMPASS_WEB) {
470+
const result = await browser.shellEval(
471+
connectionName,
472+
'db.runCommand({ connectionStatus: 1 })',
473+
true
474+
);
475+
assertNotError(result);
476+
expect(result).to.have.property('ok', 1);
477+
}
472478
});
473479

474480
it('can connect with readWriteAnyDatabase builtin role', async function () {
475-
if (!hasAtlasEnvironmentVariables() || TEST_COMPASS_WEB) {
476-
// Skip this on web because it doesn't support saslprep.
481+
if (!hasAtlasEnvironmentVariables()) {
477482
return this.skip();
478483
}
479484

@@ -483,13 +488,15 @@ describe('Connection string', function () {
483488

484489
await browser.connectWithConnectionString(connectionString);
485490

486-
const result = await browser.shellEval(
487-
connectionName,
488-
'db.runCommand({ connectionStatus: 1 })',
489-
true
490-
);
491-
assertNotError(result);
492-
expect(result).to.have.property('ok', 1);
491+
if (!TEST_COMPASS_WEB) {
492+
const result = await browser.shellEval(
493+
connectionName,
494+
'db.runCommand({ connectionStatus: 1 })',
495+
true
496+
);
497+
assertNotError(result);
498+
expect(result).to.have.property('ok', 1);
499+
}
493500

494501
await assertCanReadData(
495502
browser,
@@ -500,8 +507,7 @@ describe('Connection string', function () {
500507
});
501508

502509
it('can connect with readAnyDatabase builtin role', async function () {
503-
if (!hasAtlasEnvironmentVariables() || TEST_COMPASS_WEB) {
504-
// Skip this on web because it doesn't support saslprep.
510+
if (!hasAtlasEnvironmentVariables()) {
505511
return this.skip();
506512
}
507513

@@ -512,13 +518,15 @@ describe('Connection string', function () {
512518

513519
const connectionName = connectionNameFromString(connectionString);
514520

515-
const result = await browser.shellEval(
516-
connectionName,
517-
'db.runCommand({ connectionStatus: 1 })',
518-
true
519-
);
520-
assertNotError(result);
521-
expect(result).to.have.property('ok', 1);
521+
if (!TEST_COMPASS_WEB) {
522+
const result = await browser.shellEval(
523+
connectionName,
524+
'db.runCommand({ connectionStatus: 1 })',
525+
true
526+
);
527+
assertNotError(result);
528+
expect(result).to.have.property('ok', 1);
529+
}
522530

523531
await assertCanReadData(
524532
browser,
@@ -547,8 +555,7 @@ describe('Connection string', function () {
547555
});
548556

549557
it('can connect with custom role', async function () {
550-
if (!hasAtlasEnvironmentVariables() || TEST_COMPASS_WEB) {
551-
// Skip this on web because it doesn't support saslprep.
558+
if (!hasAtlasEnvironmentVariables()) {
552559
return this.skip();
553560
}
554561

@@ -559,13 +566,15 @@ describe('Connection string', function () {
559566

560567
const connectionName = connectionNameFromString(connectionString);
561568

562-
const result = await browser.shellEval(
563-
connectionName,
564-
'db.runCommand({ connectionStatus: 1 })',
565-
true
566-
);
567-
assertNotError(result);
568-
expect(result).to.have.property('ok', 1);
569+
if (!TEST_COMPASS_WEB) {
570+
const result = await browser.shellEval(
571+
connectionName,
572+
'db.runCommand({ connectionStatus: 1 })',
573+
true
574+
);
575+
assertNotError(result);
576+
expect(result).to.have.property('ok', 1);
577+
}
569578

570579
await assertCanReadData(browser, connectionName, 'test', 'users');
571580
await assertCannotCreateDb(
@@ -583,7 +592,7 @@ describe('Connection string', function () {
583592
});
584593

585594
it('can connect with read one collection specific permission', async function () {
586-
if (!hasAtlasEnvironmentVariables() || TEST_COMPASS_WEB) {
595+
if (!hasAtlasEnvironmentVariables()) {
587596
return this.skip();
588597
}
589598

@@ -594,13 +603,15 @@ describe('Connection string', function () {
594603

595604
const connectionName = connectionNameFromString(connectionString);
596605

597-
const result = await browser.shellEval(
598-
connectionName,
599-
'db.runCommand({ connectionStatus: 1 })',
600-
true
601-
);
602-
assertNotError(result);
603-
expect(result).to.have.property('ok', 1);
606+
if (!TEST_COMPASS_WEB) {
607+
const result = await browser.shellEval(
608+
connectionName,
609+
'db.runCommand({ connectionStatus: 1 })',
610+
true
611+
);
612+
assertNotError(result);
613+
expect(result).to.have.property('ok', 1);
614+
}
604615

605616
await assertCanReadData(browser, connectionName, 'test', 'users');
606617
await assertCannotInsertData(browser, connectionName, 'test', 'users');

packages/compass-web/webpack.config.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,15 @@ module.exports = (env, args) => {
4545
'@mongodb-js/devtools-proxy-support'
4646
),
4747

48-
// We don't need saslprep in the web, as we don't use scram auth.
49-
// We use a local polyfill for the driver to avoid having it in the bundle
50-
// as it is a decent size.
51-
'@mongodb-js/saslprep': localPolyfill('@mongodb-js/saslprep'),
48+
...(config.mode === 'production'
49+
? {
50+
// We don't need saslprep in the product web bundle, as we don't use scram auth there.
51+
// We use a local polyfill for the driver to avoid having it in the bundle
52+
// as it is a decent size. We do use scram auth in tests and local
53+
// development, so we want it there.
54+
'@mongodb-js/saslprep': localPolyfill('@mongodb-js/saslprep'),
55+
}
56+
: {}),
5257

5358
// Replace 'devtools-connect' with a package that just directly connects
5459
// using the driver (= web-compatible driver) logic, because devtools-connect

0 commit comments

Comments
 (0)