Skip to content

Commit 27e0721

Browse files
authored
chore(e2e): port most e2e tests to multiple connections COMPASS-7925 COMPASS-8001 (#5878)
1 parent 8dda731 commit 27e0721

File tree

56 files changed

+1373
-384
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+1373
-384
lines changed

.evergreen/buildvariants-and-tasks.in.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,14 @@ buildvariants:
246246
- name: e2e-coverage-<%= group.number %>
247247
<% } %>
248248

249+
- name: e2e-multiple-connections
250+
display_name: E2E Multiple Connections
251+
run_on: ubuntu2004-large
252+
tasks:
253+
<% for(const group of E2E_TEST_GROUPS) { %>
254+
- name: e2e-multiple-connections-<%= group.number %>
255+
<% } %>
256+
249257
- name: csfle-tests
250258
display_name: CSFLE Tests
251259
run_on: ubuntu2004-large
@@ -332,6 +340,20 @@ tasks:
332340
debug: 'compass-e2e-tests*,electron*,hadron*,mongo*'
333341
<% } %>
334342

343+
<% for(const group of E2E_TEST_GROUPS) { %>
344+
- name: e2e-multiple-connections-<%= group.number %>
345+
tags: ['required-for-publish', 'run-on-pr']
346+
commands:
347+
- func: prepare
348+
- func: install
349+
- func: bootstrap
350+
- func: test-multiple-connections
351+
vars:
352+
e2e_test_groups: <%= E2E_TEST_GROUPS.length %>
353+
e2e_test_group: <%= group.number %>
354+
debug: 'compass-e2e-tests*,electron*,hadron*,mongo*'
355+
<% } %>
356+
335357
- name: generate-vulnerability-report
336358
tags: ['required-for-publish', 'run-on-pr']
337359
commands:

.evergreen/buildvariants-and-tasks.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,13 @@ buildvariants:
220220
- name: e2e-coverage-1
221221
- name: e2e-coverage-2
222222
- name: e2e-coverage-3
223+
- name: e2e-multiple-connections
224+
display_name: E2E Multiple Connections
225+
run_on: ubuntu2004-large
226+
tasks:
227+
- name: e2e-multiple-connections-1
228+
- name: e2e-multiple-connections-2
229+
- name: e2e-multiple-connections-3
223230
- name: csfle-tests
224231
display_name: CSFLE Tests
225232
run_on: ubuntu2004-large
@@ -331,6 +338,45 @@ tasks:
331338
e2e_test_groups: 3
332339
e2e_test_group: 3
333340
debug: compass-e2e-tests*,electron*,hadron*,mongo*
341+
- name: e2e-multiple-connections-1
342+
tags:
343+
- required-for-publish
344+
- run-on-pr
345+
commands:
346+
- func: prepare
347+
- func: install
348+
- func: bootstrap
349+
- func: test-multiple-connections
350+
vars:
351+
e2e_test_groups: 3
352+
e2e_test_group: 1
353+
debug: compass-e2e-tests*,electron*,hadron*,mongo*
354+
- name: e2e-multiple-connections-2
355+
tags:
356+
- required-for-publish
357+
- run-on-pr
358+
commands:
359+
- func: prepare
360+
- func: install
361+
- func: bootstrap
362+
- func: test-multiple-connections
363+
vars:
364+
e2e_test_groups: 3
365+
e2e_test_group: 2
366+
debug: compass-e2e-tests*,electron*,hadron*,mongo*
367+
- name: e2e-multiple-connections-3
368+
tags:
369+
- required-for-publish
370+
- run-on-pr
371+
commands:
372+
- func: prepare
373+
- func: install
374+
- func: bootstrap
375+
- func: test-multiple-connections
376+
vars:
377+
e2e_test_groups: 3
378+
e2e_test_group: 3
379+
debug: compass-e2e-tests*,electron*,hadron*,mongo*
334380
- name: generate-vulnerability-report
335381
tags:
336382
- required-for-publish

.evergreen/functions.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,30 @@ functions:
581581
582582
tar czf coverage.tgz packages/compass-e2e-tests/coverage
583583
584+
test-multiple-connections:
585+
- command: shell.exec
586+
# Fail the task if it's idle for 10 mins
587+
timeout_secs: 600
588+
params:
589+
working_dir: src
590+
shell: bash
591+
env:
592+
<<: *compass-env
593+
DEBUG: ${debug|}
594+
MONGODB_VERSION: ${mongodb_version|}
595+
MONGODB_RUNNER_VERSION: ${mongodb_version|}
596+
E2E_TEST_GROUPS: ${e2e_test_groups}
597+
E2E_TEST_GROUP: ${e2e_test_group}
598+
script: |
599+
set -e
600+
# Load environment variables
601+
eval $(.evergreen/print-compass-env.sh)
602+
603+
echo "Running E2E tests for multiple connections"
604+
605+
npm run --unsafe-perm --workspace compass-e2e-tests test-ci -- -- --test-multiple-connections
606+
607+
584608
test-packaged-app:
585609
- command: shell.exec
586610
# Fail the task if it's idle for 10 mins

package-lock.json

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/compass-connections-navigation/src/navigation-item.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ export function NavigationItem({
110110
if (item.type === 'connection') {
111111
return {
112112
'data-connection-id': item.connectionInfo.id,
113-
'data-connection-name': item.connectionInfo.favorite?.name,
113+
'data-connection-name': item.name,
114114
};
115115
}
116116
if (item.type === 'database') {

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import * as Selectors from '../selectors';
33

44
async function navigateToCollection(
55
browser: CompassBrowser,
6+
// TODO(COMPASS-8002): take connectionName into account
67
dbName: string,
78
collectionName: string
89
): Promise<void> {
@@ -30,6 +31,7 @@ async function navigateToCollection(
3031

3132
export async function navigateToCollectionTab(
3233
browser: CompassBrowser,
34+
// TODO(COMPASS-8002): take connectionName into account
3335
dbName: string,
3436
collectionName: string,
3537
tabName:
@@ -45,6 +47,7 @@ export async function navigateToCollectionTab(
4547

4648
export async function navigateWithinCurrentCollectionTabs(
4749
browser: CompassBrowser,
50+
// TODO(COMPASS-8002): take connectionName into account
4851
tabName:
4952
| 'Documents'
5053
| 'Aggregations'
@@ -66,6 +69,7 @@ export async function navigateWithinCurrentCollectionTabs(
6669

6770
export async function waitUntilActiveCollectionTab(
6871
browser: CompassBrowser,
72+
// TODO(COMPASS-8002): take connectionName into account
6973
dbName: string,
7074
collectionName: string,
7175
tabName:
@@ -86,6 +90,7 @@ export async function waitUntilActiveCollectionTab(
8690

8791
export async function waitUntilActiveCollectionSubTab(
8892
browser: CompassBrowser,
93+
// TODO(COMPASS-8002): take connectionName into account
8994
tabName:
9095
| 'Documents'
9196
| 'Aggregations'
Lines changed: 61 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
import { DEFAULT_CONNECTION_STRING } from '../compass';
1+
import {
2+
DEFAULT_CONNECTION_STRING,
3+
TEST_MULTIPLE_CONNECTIONS,
4+
connectionNameFromString,
5+
} from '../compass';
26
import type { CompassBrowser } from '../compass-browser';
37
import * as Selectors from '../selectors';
48

@@ -8,14 +12,66 @@ export async function connectWithConnectionString(
812
connectionStatus: 'success' | 'failure' | 'either' = 'success',
913
timeout?: number
1014
): Promise<void> {
11-
const sidebar = await browser.$(Selectors.Sidebar);
12-
if (await sidebar.isDisplayed()) {
13-
await browser.disconnect();
15+
await browser.disconnect();
16+
17+
if (TEST_MULTIPLE_CONNECTIONS) {
18+
// if the modal is still animating away when we're connecting again, things
19+
// are going to get confused
20+
await browser
21+
.$(Selectors.ConnectionModal)
22+
.waitForDisplayed({ reverse: true });
23+
24+
// if a connection with this name already exists, remove it otherwise we'll
25+
// add a duplicate and things will get complicated fast
26+
const connectionName = connectionNameFromString(connectionString);
27+
28+
// make sure there's no filter because if the connection is not displayed then we can't remove it
29+
if (await browser.$(Selectors.SidebarFilterInput).isExisting()) {
30+
await browser.clickVisible(Selectors.SidebarFilterInput);
31+
await browser.setValueVisible(Selectors.SidebarFilterInput, '');
32+
33+
// wait for a connection to appear. It must because if there are no
34+
// connections the filter field wouldn't exist in the first place
35+
await browser.$(Selectors.SidebarTreeItems).waitForDisplayed();
36+
}
37+
38+
const selector = Selectors.sidebarConnection(connectionName);
39+
if (await browser.$(selector).isExisting()) {
40+
await browser.selectConnectionMenuItem(
41+
connectionName,
42+
Selectors.Multiple.RemoveConnectionItem
43+
);
44+
await browser.$(selector).waitForExist({ reverse: true });
45+
}
46+
47+
await browser.clickVisible(Selectors.Multiple.SidebarNewConnectionButton);
48+
await browser.$(Selectors.ConnectionModal).waitForDisplayed();
1449
}
1550

1651
await browser.setValueVisible(
17-
Selectors.ConnectionStringInput,
52+
Selectors.ConnectionFormStringInput,
1853
connectionString
1954
);
2055
await browser.doConnect(connectionStatus, timeout);
56+
57+
// Ideally this would be part of browser.doConnect() and
58+
// browser.waitForConnectionResult(), but that requires the context of
59+
// connectionName there. Which is easy enough for connectWithConnectionString,
60+
// but not so easy right now for connectWithConnectionForm.
61+
if (TEST_MULTIPLE_CONNECTIONS) {
62+
// There's a potential problem here: The list of connections is virtual, so
63+
// the new connection might not be rendered. By searching for it if possible
64+
// we can guarantee that it will be on screen. The search box won't exist
65+
// for the first connection, but that's OK because once connected it will be
66+
// the only connection so should be rendered.
67+
if (await browser.$(Selectors.SidebarFilterInput).isExisting()) {
68+
await browser.clickVisible(Selectors.SidebarFilterInput);
69+
await browser.setValueVisible(Selectors.SidebarFilterInput, '');
70+
}
71+
72+
// some connection should be expanded (ie. connected) by now
73+
await browser
74+
.$(`${Selectors.SidebarTreeItems} [aria-expanded=true]`)
75+
.waitForExist({ reverse: true });
76+
}
2177
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { TEST_MULTIPLE_CONNECTIONS } from '../compass';
2+
import type { CompassBrowser } from '../compass-browser';
3+
import * as Selectors from '../selectors';
4+
5+
export async function navigateToConnectionTab(
6+
browser: CompassBrowser,
7+
connectionName: string,
8+
tabName: 'Performance' | 'Databases'
9+
): Promise<void> {
10+
if (TEST_MULTIPLE_CONNECTIONS) {
11+
if (tabName === 'Databases') {
12+
await browser.clickVisible(Selectors.sidebarConnection(connectionName));
13+
} else {
14+
// TODO(COMPASS-8002): click the three dots menu then the relevant option. (View performance metrics)
15+
}
16+
17+
await waitUntilActiveConnectionTab(browser, connectionName, tabName);
18+
} else {
19+
const itemSelector = Selectors.sidebarInstanceNavigationItem(tabName);
20+
await browser.clickVisible(itemSelector);
21+
await waitUntilActiveConnectionTab(browser, connectionName, tabName);
22+
}
23+
}
24+
25+
export async function waitUntilActiveConnectionTab(
26+
browser: CompassBrowser,
27+
connectionName: string,
28+
tabName: 'Performance' | 'Databases'
29+
) {
30+
// TODO(COMPASS-8002): we should differentiate by connectionName somehow
31+
await browser
32+
.$(Selectors.instanceWorkspaceTab(tabName, true))
33+
.waitForDisplayed();
34+
}

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,20 @@ import * as Selectors from '../selectors';
33

44
export async function navigateToDatabaseCollectionsTab(
55
browser: CompassBrowser,
6+
connectionName: string,
67
dbName: string
78
): Promise<void> {
8-
await browser.navigateToInstanceTab('Databases');
9+
await browser.navigateToConnectionTab(connectionName, 'Databases');
910
await browser.clickVisible(Selectors.databaseCardClickable(dbName));
10-
await waitUntilActiveDatabaseTab(browser, dbName);
11+
await waitUntilActiveDatabaseTab(browser, connectionName, dbName);
1112
}
1213

1314
export async function waitUntilActiveDatabaseTab(
1415
browser: CompassBrowser,
16+
connectionName: string,
1517
dbName: string
1618
) {
19+
// TODO(COMPASS-8002): check that the connectionName matches too
1720
await browser
1821
.$(Selectors.databaseWorkspaceTab(dbName, true))
1922
.waitForDisplayed();

0 commit comments

Comments
 (0)