@@ -2,27 +2,14 @@ import {
22 DEFAULT_CONNECTION_NAME_1 ,
33 DEFAULT_CONNECTION_NAME_2 ,
44 DEFAULT_CONNECTION_STRING_1 ,
5- TEST_MULTIPLE_CONNECTIONS ,
65 connectionNameFromString ,
76} from '../compass' ;
87import type { CompassBrowser } from '../compass-browser' ;
98import type { ConnectFormState } from '../connect-form-state' ;
109import * as Selectors from '../selectors' ;
1110import Debug from 'debug' ;
12- const debug = Debug ( 'compass-e2e-tests' ) ;
13-
14- export async function waitForConnectionScreen (
15- browser : CompassBrowser
16- ) : Promise < void > {
17- // there isn't a separate connection screen in multiple connections, just a modal you can access at any time
18- if ( TEST_MULTIPLE_CONNECTIONS ) {
19- return ;
20- }
2111
22- const selector = Selectors . ConnectSection ;
23- const connectScreenElement = await browser . $ ( selector ) ;
24- await connectScreenElement . waitForDisplayed ( ) ;
25- }
12+ const debug = Debug ( 'compass-e2e-tests' ) ;
2613
2714export async function getConnectFormConnectionString (
2815 browser : CompassBrowser ,
@@ -57,32 +44,29 @@ export async function connectWithConnectionString(
5744 // connection string. Most test files should just be using
5845 // browser.connectToDefaults()
5946
60- if ( TEST_MULTIPLE_CONNECTIONS ) {
61- // if the modal is still animating away when we're connecting again, things
62- // are going to get confused
63- await browser
64- . $ ( Selectors . ConnectionModal )
65- . waitForDisplayed ( { reverse : true } ) ;
66-
67- // if a connection with this name already exists, remove it otherwise we'll
68- // add a duplicate and things will get complicated fast
69- const connectionName = connectionNameFromString ( connectionString ) ;
70- if ( await browser . removeConnection ( connectionName ) ) {
71- debug ( 'Removing existing connection so we do not create a duplicate' , {
72- connectionName,
73- } ) ;
74- }
47+ // if the modal is still animating away when we're connecting again, things
48+ // are going to get confused
49+ await browser
50+ . $ ( Selectors . ConnectionModal )
51+ . waitForDisplayed ( { reverse : true } ) ;
7552
76- await browser . clickVisible ( Selectors . Multiple . SidebarNewConnectionButton ) ;
77- await browser . $ ( Selectors . ConnectionModal ) . waitForDisplayed ( ) ;
53+ // if a connection with this name already exists, remove it otherwise we'll
54+ // add a duplicate and things will get complicated fast
55+ const connectionName = connectionNameFromString ( connectionString ) ;
56+ if ( await browser . removeConnection ( connectionName ) ) {
57+ debug ( 'Removing existing connection so we do not create a duplicate' , {
58+ connectionName,
59+ } ) ;
7860 }
7961
62+ await browser . clickVisible ( Selectors . Multiple . SidebarNewConnectionButton ) ;
63+ await browser . $ ( Selectors . ConnectionModal ) . waitForDisplayed ( ) ;
64+
8065 await browser . setValueVisible (
8166 Selectors . ConnectionFormStringInput ,
8267 connectionString
8368 ) ;
8469
85- const connectionName = connectionNameFromString ( connectionString ) ;
8670 await browser . doConnect ( connectionName , options ) ;
8771}
8872
@@ -133,75 +117,50 @@ export async function waitForConnectionResult(
133117) : Promise < string | undefined > {
134118 const waitOptions = typeof timeout !== 'undefined' ? { timeout } : undefined ;
135119
136- if ( TEST_MULTIPLE_CONNECTIONS ) {
137- if ( await browser . $ ( Selectors . SidebarFilterInput ) . isDisplayed ( ) ) {
138- // Clear the filter to make sure every connection shows
139- await browser . clickVisible ( Selectors . SidebarFilterInput ) ;
140- await browser . setValueVisible ( Selectors . SidebarFilterInput , '' ) ;
141- }
120+ if ( await browser . $ ( Selectors . SidebarFilterInput ) . isDisplayed ( ) ) {
121+ // Clear the filter to make sure every connection shows
122+ await browser . clickVisible ( Selectors . SidebarFilterInput ) ;
123+ await browser . setValueVisible ( Selectors . SidebarFilterInput , '' ) ;
142124 }
143125
144126 if ( connectionStatus === 'either' ) {
145127 // For the very rare cases where we don't care whether it fails or succeeds.
146128 // Usually because the exact result is a race condition.
147- if ( TEST_MULTIPLE_CONNECTIONS ) {
148- const successSelector = Selectors . Multiple . connectionItemByName (
149- connectionName ,
150- {
151- connected : true ,
152- }
153- ) ;
154- const failureSelector = Selectors . ConnectionToastErrorText ;
155- await browser
156- . $ ( `${ successSelector } ,${ failureSelector } ` )
157- . waitForDisplayed ( waitOptions ) ;
158- } else {
159- // TODO(COMPASS-7600): this doesn't support compass-web yet, but also
160- // isn't encountered yet
161- await browser
162- . $ ( `${ Selectors . MyQueriesList } ,${ Selectors . ConnectionFormErrorMessage } ` )
163- . waitForDisplayed ( ) ;
164- }
129+ const successSelector = Selectors . Multiple . connectionItemByName (
130+ connectionName ,
131+ {
132+ connected : true ,
133+ }
134+ ) ;
135+ const failureSelector = Selectors . ConnectionToastErrorText ;
136+ await browser
137+ . $ ( `${ successSelector } ,${ failureSelector } ` )
138+ . waitForDisplayed ( waitOptions ) ;
165139 } else if ( connectionStatus === 'success' ) {
166140 // Wait for the first meaningful thing on the screen after being connected
167141 // and assume that's a good enough indicator that we are connected to the
168142 // server
169- if ( TEST_MULTIPLE_CONNECTIONS ) {
170- await browser
171- . $ (
172- Selectors . Multiple . connectionItemByName ( connectionName , {
173- connected : true ,
174- } )
175- )
176- . waitForDisplayed ( ) ;
177- } else {
178- // In the single connection world we land on the My Queries page
179- await browser . $ ( Selectors . MyQueriesList ) . waitForDisplayed ( ) ;
180- }
143+ await browser
144+ . $ (
145+ Selectors . Multiple . connectionItemByName ( connectionName , {
146+ connected : true ,
147+ } )
148+ )
149+ . waitForDisplayed ( ) ;
181150 } else if ( connectionStatus === 'failure' ) {
182- if ( TEST_MULTIPLE_CONNECTIONS ) {
183- await browser
184- . $ ( Selectors . ConnectionToastErrorText )
185- . waitForDisplayed ( waitOptions ) ;
186- return await browser . $ ( Selectors . LGToastTitle ) . getText ( ) ;
187- } else {
188- // TODO(COMPASS-7600): this doesn't support compass-web yet, but also
189- // isn't encountered yet
190- const element = await browser . $ ( Selectors . ConnectionFormErrorMessage ) ;
191- await element . waitForDisplayed ( waitOptions ) ;
192- return await element . getText ( ) ;
193- }
151+ await browser
152+ . $ ( Selectors . ConnectionToastErrorText )
153+ . waitForDisplayed ( waitOptions ) ;
154+ return await browser . $ ( Selectors . LGToastTitle ) . getText ( ) ;
194155 } else {
195156 const exhaustiveCheck : never = connectionStatus ;
196157 throw new Error ( `Unhandled connectionStatus case: ${ exhaustiveCheck } ` ) ;
197158 }
198159
199- if ( TEST_MULTIPLE_CONNECTIONS ) {
200- // make sure the placeholders for databases & collections that are loading are all gone
201- await browser
202- . $ ( Selectors . DatabaseCollectionPlaceholder )
203- . waitForDisplayed ( { reverse : true } ) ;
204- }
160+ // make sure the placeholders for databases & collections that are loading are all gone
161+ await browser
162+ . $ ( Selectors . DatabaseCollectionPlaceholder )
163+ . waitForDisplayed ( { reverse : true } ) ;
205164}
206165
207166export async function connectByName (
@@ -210,25 +169,13 @@ export async function connectByName(
210169 options : ConnectionResultOptions = { }
211170) {
212171 await browser . clickVisible ( Selectors . sidebarConnectionButton ( connectionName ) ) ;
213-
214- if ( ! TEST_MULTIPLE_CONNECTIONS ) {
215- // for single connections it only fills the connection form and we still
216- // have to click connect. For multiple connections clicking the connection
217- // connects
218- await browser . pause ( 1000 ) ;
219- await browser . clickVisible ( Selectors . ConnectButton ) ;
220- }
221-
222172 await browser . waitForConnectionResult ( connectionName , options ) ;
223173}
224174
225175export async function connectToDefaults ( browser : CompassBrowser ) {
226176 // See setupDefaultConnections() for the details behind the thinking here.
227177 await browser . connectByName ( DEFAULT_CONNECTION_NAME_1 ) ;
228-
229- if ( TEST_MULTIPLE_CONNECTIONS ) {
230- await browser . connectByName ( DEFAULT_CONNECTION_NAME_2 ) ;
231- }
178+ await browser . connectByName ( DEFAULT_CONNECTION_NAME_2 ) ;
232179
233180 // We assume that we connected successfully, so just close the success toasts
234181 // early to make sure they aren't in the way of tests. Tests that care about
0 commit comments