Skip to content

Commit e58f6e2

Browse files
committed
chore(e2e): remove TEST_MULTIPLE_CONNECTIONS flag from e2e tests
1 parent ce0d66f commit e58f6e2

30 files changed

+417
-1073
lines changed
Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,11 @@
1-
import { TEST_MULTIPLE_CONNECTIONS } from '../compass';
21
import type { CompassBrowser } from '../compass-browser';
3-
import retryWithBackoff from '../retry-with-backoff';
4-
import * as Selectors from '../selectors';
52

63
export async function closeShell(
74
browser: CompassBrowser,
85
connectionName: string
96
): Promise<void> {
10-
if (TEST_MULTIPLE_CONNECTIONS) {
11-
await browser.closeWorkspaceTab({
12-
connectionName,
13-
type: 'Shell',
14-
});
15-
} else {
16-
await retryWithBackoff(async function () {
17-
const shellContentElement = await browser.$(Selectors.ShellContent);
18-
if (await shellContentElement.isDisplayed()) {
19-
await browser.clickVisible(Selectors.ShellExpandButton);
20-
}
21-
});
22-
}
7+
await browser.closeWorkspaceTab({
8+
connectionName,
9+
type: 'Shell',
10+
});
2311
}

packages/compass-e2e-tests/helpers/commands/collection-workspaces.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { TEST_MULTIPLE_CONNECTIONS } from '../compass';
21
import type { CompassBrowser } from '../compass-browser';
32
import * as Selectors from '../selectors';
43
import type { WorkspaceTabSelectorOptions } from '../selectors';
@@ -119,16 +118,13 @@ async function waitUntilActiveCollectionTab(
119118
) {
120119
const options: WorkspaceTabSelectorOptions = {
121120
type: 'Collection',
121+
connectionName,
122122
namespace: `${dbName}.${collectionName}`,
123123
active: true,
124124
};
125-
// Only add the connectionName for multiple connections because for some
126-
// reason this sometimes flakes in single connections even though the tab is
127-
// definitely there in the screenshot.
128-
if (TEST_MULTIPLE_CONNECTIONS) {
129-
options.connectionName = connectionName;
130-
}
125+
131126
await browser.$(Selectors.workspaceTab(options)).waitForDisplayed();
127+
132128
if (tabName) {
133129
await waitUntilActiveCollectionSubTab(browser, tabName);
134130
}

packages/compass-e2e-tests/helpers/commands/connect-form.ts

Lines changed: 27 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,24 @@ import { expect } from 'chai';
33
import type { CompassBrowser } from '../compass-browser';
44
import * as Selectors from '../selectors';
55
import type { ConnectFormState } from '../connect-form-state';
6-
import { TEST_MULTIPLE_CONNECTIONS } from '../compass';
76
import Debug from 'debug';
87
import { DEFAULT_CONNECTIONS } from '../test-runner-context';
98
import { getConnectionTitle } from '@mongodb-js/connection-info';
109
const debug = Debug('compass-e2e-tests');
1110

1211
export async function resetConnectForm(browser: CompassBrowser): Promise<void> {
13-
const Sidebar = TEST_MULTIPLE_CONNECTIONS
14-
? Selectors.Multiple
15-
: Selectors.Single;
12+
const Sidebar = Selectors.Multiple;
1613

17-
if (TEST_MULTIPLE_CONNECTIONS) {
18-
if (await browser.$(Selectors.ConnectionModal).isDisplayed()) {
19-
await browser.clickVisible(Selectors.ConnectionModalCloseButton);
20-
await browser
21-
.$(Selectors.ConnectionModal)
22-
.waitForDisplayed({ reverse: true });
23-
}
14+
if (await browser.$(Selectors.ConnectionModal).isDisplayed()) {
15+
await browser.clickVisible(Selectors.ConnectionModalCloseButton);
16+
await browser
17+
.$(Selectors.ConnectionModal)
18+
.waitForDisplayed({ reverse: true });
2419
}
2520

2621
await browser.clickVisible(Sidebar.SidebarNewConnectionButton);
2722

28-
const connectionTitleSelector = TEST_MULTIPLE_CONNECTIONS
29-
? Selectors.ConnectionModalTitle
30-
: Selectors.ConnectionTitle;
23+
const connectionTitleSelector = Selectors.ConnectionModalTitle;
3124

3225
const connectionTitle = await browser.$(connectionTitleSelector);
3326
await connectionTitle.waitUntil(async () => {
@@ -57,29 +50,20 @@ export async function getConnectFormState(
5750
// General
5851
const initialTab = await browser.navigateToConnectTab('General');
5952

60-
const defaultPromises: Record<string, Promise<any>> = {
53+
const defaultState = await promiseMap({
6154
scheme: getCheckedRadioValue(browser, Selectors.ConnectionFormSchemeRadios),
6255
hosts: getMultipleValues(browser, Selectors.ConnectionFormHostInputs),
6356
directConnection: getCheckboxValue(
6457
browser,
6558
Selectors.ConnectionFormDirectConnectionCheckbox
6659
),
67-
};
68-
if (TEST_MULTIPLE_CONNECTIONS) {
69-
defaultPromises.connectionName = getValue(
70-
browser,
71-
Selectors.ConnectionFormConnectionName
72-
);
73-
defaultPromises.connectionColor = getValue(
74-
browser,
75-
Selectors.ConnectionFormConnectionColor
76-
);
77-
defaultPromises.connectionFavorite = getCheckboxValue(
60+
connectionName: getValue(browser, Selectors.ConnectionFormConnectionName),
61+
connectionColor: getValue(browser, Selectors.ConnectionFormConnectionColor),
62+
connectionFavorite: getCheckboxValue(
7863
browser,
7964
Selectors.ConnectionFormFavoriteCheckbox
80-
);
81-
}
82-
const defaultState = await promiseMap(defaultPromises);
65+
),
66+
});
8367

8468
// Authentication
8569
await browser.navigateToConnectTab('Authentication');
@@ -506,25 +490,22 @@ export async function setConnectFormState(
506490
await browser.clickParent(Selectors.ConnectionFormDirectConnectionCheckbox);
507491
}
508492

509-
if (TEST_MULTIPLE_CONNECTIONS) {
510-
// Name, Color, Favorite
511-
if (state.connectionName) {
512-
await browser.setValueVisible(
513-
Selectors.ConnectionFormConnectionName,
514-
state.connectionName
515-
);
516-
}
493+
if (state.connectionName) {
494+
await browser.setValueVisible(
495+
Selectors.ConnectionFormConnectionName,
496+
state.connectionName
497+
);
498+
}
517499

518-
if (state.connectionColor) {
519-
await browser.selectOption(
520-
Selectors.ConnectionFormConnectionColor,
521-
colorValueToName(state.connectionColor)
522-
);
523-
}
500+
if (state.connectionColor) {
501+
await browser.selectOption(
502+
Selectors.ConnectionFormConnectionColor,
503+
colorValueToName(state.connectionColor)
504+
);
505+
}
524506

525-
if (state.connectionFavorite) {
526-
await browser.clickParent(Selectors.ConnectionFormFavoriteCheckbox);
527-
}
507+
if (state.connectionFavorite) {
508+
await browser.clickParent(Selectors.ConnectionFormFavoriteCheckbox);
528509
}
529510

530511
// Authentication

packages/compass-e2e-tests/helpers/commands/connect.ts

Lines changed: 46 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -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';
87
import type { CompassBrowser } from '../compass-browser';
98
import type { ConnectFormState } from '../connect-form-state';
109
import * as Selectors from '../selectors';
1110
import 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

2714
export 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

207166
export 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

225175
export 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

Comments
 (0)