@@ -14,6 +14,7 @@ import {
14
14
skipForWeb ,
15
15
TEST_COMPASS_WEB ,
16
16
TEST_MULTIPLE_CONNECTIONS ,
17
+ connectionNameFromString ,
17
18
} from '../helpers/compass' ;
18
19
import type { Compass } from '../helpers/compass' ;
19
20
import type { ConnectFormState } from '../helpers/connect-form-state' ;
@@ -125,6 +126,8 @@ function generateIamSessionToken(): {
125
126
126
127
async function assertCanReadData (
127
128
browser : CompassBrowser ,
129
+ // TODO(COMPASS-8002): take into account connectionName
130
+ connectionName : string ,
128
131
dbName : string ,
129
132
collectionName : string
130
133
) : Promise < void > {
@@ -139,6 +142,8 @@ async function assertCanReadData(
139
142
140
143
async function assertCannotInsertData (
141
144
browser : CompassBrowser ,
145
+ // TODO(COMPASS-8002): take into account connectionName
146
+ connectionName : string ,
142
147
dbName : string ,
143
148
collectionName : string
144
149
) : Promise < void > {
@@ -178,12 +183,23 @@ async function assertCannotInsertData(
178
183
179
184
async function assertCannotCreateDb (
180
185
browser : CompassBrowser ,
186
+ connectionName : string ,
181
187
dbName : string ,
182
188
collectionName : string
183
189
) : Promise < void > {
190
+ const Sidebar = TEST_MULTIPLE_CONNECTIONS
191
+ ? Selectors . Multiple
192
+ : Selectors . Single ;
193
+
194
+ if ( TEST_MULTIPLE_CONNECTIONS ) {
195
+ // navigate to the databases tab so that the connection is
196
+ // active/highlighted and then the add button and three dot menu will
197
+ // display without needing to hover
198
+ await browser . navigateToConnectionTab ( connectionName , 'Databases' ) ;
199
+ }
200
+
184
201
// open the create database modal from the sidebar
185
- // TODO(COMPASS-8002): add support for multiple connections
186
- await browser . clickVisible ( Selectors . SidebarCreateDatabaseButton ) ;
202
+ await browser . clickVisible ( Sidebar . CreateDatabaseButton ) ;
187
203
188
204
const createModalElement = await browser . $ ( Selectors . CreateDatabaseModal ) ;
189
205
await createModalElement . waitForDisplayed ( ) ;
@@ -212,6 +228,8 @@ async function assertCannotCreateDb(
212
228
213
229
async function assertCannotCreateCollection (
214
230
browser : CompassBrowser ,
231
+ // TODO(COMPASS-8002): take into account connectionName
232
+ connectionName : string ,
215
233
dbName : string ,
216
234
collectionName : string
217
235
) : Promise < void > {
@@ -436,7 +454,16 @@ describe('Connection string', function () {
436
454
expect ( result ) . to . have . property ( 'ok' , 1 ) ;
437
455
}
438
456
439
- await assertCanReadData ( browser , 'compass_e2e' , 'companies_info' ) ;
457
+ const connectionName = connectionNameFromString (
458
+ process . env . E2E_TESTS_ATLAS_READWRITEANY_STRING ?? ''
459
+ ) ;
460
+
461
+ await assertCanReadData (
462
+ browser ,
463
+ connectionName ,
464
+ 'compass_e2e' ,
465
+ 'companies_info'
466
+ ) ;
440
467
} ) ;
441
468
442
469
it ( 'can connect with readAnyDatabase builtin role' , async function ( ) {
@@ -457,16 +484,31 @@ describe('Connection string', function () {
457
484
expect ( result ) . to . have . property ( 'ok' , 1 ) ;
458
485
}
459
486
460
- await assertCanReadData ( browser , 'compass_e2e' , 'companies_info' ) ;
461
- await assertCannotInsertData ( browser , 'compass_e2e' , 'companies_info' ) ;
462
- // TODO(COMPASS-8002: we need to click the active connection's add database
463
- // button and therefore might as well wait for the active&saved connections
464
- // to be unified
465
- if ( ! TEST_MULTIPLE_CONNECTIONS ) {
466
- await assertCannotCreateDb ( browser , 'new-db' , 'new-collection' ) ;
467
- }
487
+ const connectionName = connectionNameFromString (
488
+ process . env . E2E_TESTS_ATLAS_READANYDATABASE_STRING ?? ''
489
+ ) ;
490
+
491
+ await assertCanReadData (
492
+ browser ,
493
+ connectionName ,
494
+ 'compass_e2e' ,
495
+ 'companies_info'
496
+ ) ;
497
+ await assertCannotInsertData (
498
+ browser ,
499
+ connectionName ,
500
+ 'compass_e2e' ,
501
+ 'companies_info'
502
+ ) ;
503
+ await assertCannotCreateDb (
504
+ browser ,
505
+ connectionName ,
506
+ 'new-db' ,
507
+ 'new-collection'
508
+ ) ;
468
509
await assertCannotCreateCollection (
469
510
browser ,
511
+ connectionName ,
470
512
'compass_e2e' ,
471
513
'new-collection'
472
514
) ;
@@ -490,14 +532,23 @@ describe('Connection string', function () {
490
532
expect ( result ) . to . have . property ( 'ok' , 1 ) ;
491
533
}
492
534
493
- await assertCanReadData ( browser , 'test' , 'users' ) ;
494
- // TODO(COMPASS-8002: we need to click the active connection's add database
495
- // button and therefore might as well wait for the active&saved connections
496
- // to be unified
497
- if ( ! TEST_MULTIPLE_CONNECTIONS ) {
498
- await assertCannotCreateDb ( browser , 'new-db' , 'new-collection' ) ;
499
- }
500
- await assertCannotCreateCollection ( browser , 'test' , 'new-collection' ) ;
535
+ const connectionName = connectionNameFromString (
536
+ process . env . E2E_TESTS_ATLAS_CUSTOMROLE_STRING ?? ''
537
+ ) ;
538
+
539
+ await assertCanReadData ( browser , connectionName , 'test' , 'users' ) ;
540
+ await assertCannotCreateDb (
541
+ browser ,
542
+ connectionName ,
543
+ 'new-db' ,
544
+ 'new-collection'
545
+ ) ;
546
+ await assertCannotCreateCollection (
547
+ browser ,
548
+ connectionName ,
549
+ 'test' ,
550
+ 'new-collection'
551
+ ) ;
501
552
} ) ;
502
553
503
554
it ( 'can connect with read one collection specific permission' , async function ( ) {
@@ -518,15 +569,24 @@ describe('Connection string', function () {
518
569
expect ( result ) . to . have . property ( 'ok' , 1 ) ;
519
570
}
520
571
521
- await assertCanReadData ( browser , 'test' , 'users' ) ;
522
- await assertCannotInsertData ( browser , 'test' , 'users' ) ;
523
- // TODO(COMPASS-8002: we need to click the active connection's add database
524
- // button and therefore might as well wait for the active&saved connections
525
- // to be unified
526
- if ( ! TEST_MULTIPLE_CONNECTIONS ) {
527
- await assertCannotCreateDb ( browser , 'new-db' , 'new-collection' ) ;
528
- }
529
- await assertCannotCreateCollection ( browser , 'test' , 'new-collection' ) ;
572
+ const connectionName = connectionNameFromString (
573
+ process . env . E2E_TESTS_ATLAS_CUSTOMROLE_STRING ?? ''
574
+ ) ;
575
+
576
+ await assertCanReadData ( browser , connectionName , 'test' , 'users' ) ;
577
+ await assertCannotInsertData ( browser , connectionName , 'test' , 'users' ) ;
578
+ await assertCannotCreateDb (
579
+ browser ,
580
+ connectionName ,
581
+ 'new-db' ,
582
+ 'new-collection'
583
+ ) ;
584
+ await assertCannotCreateCollection (
585
+ browser ,
586
+ connectionName ,
587
+ 'test' ,
588
+ 'new-collection'
589
+ ) ;
530
590
} ) ;
531
591
} ) ;
532
592
@@ -555,9 +615,11 @@ describe('Connection form', function () {
555
615
} ) ;
556
616
557
617
it ( 'can connect using connection form' , async function ( ) {
618
+ const connectionName = this . test ?. fullTitle ( ) ;
619
+
558
620
await browser . connectWithConnectionForm ( {
559
621
hosts : [ '127.0.0.1:27091' ] ,
560
- connectionName : this . test ?. fullTitle ( ) ,
622
+ connectionName,
561
623
} ) ;
562
624
if ( ! TEST_MULTIPLE_CONNECTIONS ) {
563
625
const result = await browser . shellEval (
@@ -574,12 +636,14 @@ describe('Connection form', function () {
574
636
return this . skip ( ) ;
575
637
}
576
638
639
+ const connectionName = this . test ?. fullTitle ( ) ;
640
+
577
641
const atlasConnectionOptions : ConnectFormState = basicAtlasOptions (
578
642
process . env . E2E_TESTS_ATLAS_HOST ?? ''
579
643
) ;
580
644
await browser . connectWithConnectionForm ( {
581
645
...atlasConnectionOptions ,
582
- connectionName : this . test ?. fullTitle ( ) ,
646
+ connectionName,
583
647
} ) ;
584
648
if ( ! TEST_MULTIPLE_CONNECTIONS ) {
585
649
const result = await browser . shellEval (
@@ -596,6 +660,8 @@ describe('Connection form', function () {
596
660
return this . skip ( ) ;
597
661
}
598
662
663
+ const connectionName = this . test ?. fullTitle ( ) ;
664
+
599
665
let tempdir ;
600
666
try {
601
667
tempdir = await fs . mkdtemp ( path . join ( os . tmpdir ( ) , 'connect-tests-' ) ) ;
@@ -611,7 +677,7 @@ describe('Connection form', function () {
611
677
} ;
612
678
await browser . connectWithConnectionForm ( {
613
679
...atlasConnectionOptions ,
614
- connectionName : this . test ?. fullTitle ( ) ,
680
+ connectionName,
615
681
} ) ;
616
682
if ( ! TEST_MULTIPLE_CONNECTIONS ) {
617
683
const result = await browser . shellEval (
@@ -633,6 +699,8 @@ describe('Connection form', function () {
633
699
return this . skip ( ) ;
634
700
}
635
701
702
+ const connectionName = this . test ?. fullTitle ( ) ;
703
+
636
704
const atlasConnectionOptions : ConnectFormState = {
637
705
hosts : [ process . env . E2E_TESTS_FREE_TIER_HOST ?? '' ] ,
638
706
authMethod : 'MONGODB-AWS' ,
@@ -643,7 +711,7 @@ describe('Connection form', function () {
643
711
} ;
644
712
await browser . connectWithConnectionForm ( {
645
713
...atlasConnectionOptions ,
646
- connectionName : this . test ?. fullTitle ( ) ,
714
+ connectionName,
647
715
} ) ;
648
716
if ( ! TEST_MULTIPLE_CONNECTIONS ) {
649
717
const result = await browser . shellEval (
0 commit comments