From e58f6e2becd0be8f17c9dc63544edac951f7660c Mon Sep 17 00:00:00 2001 From: Sergey Petushkov Date: Wed, 23 Oct 2024 14:23:41 +0200 Subject: [PATCH] chore(e2e): remove TEST_MULTIPLE_CONNECTIONS flag from e2e tests --- .../helpers/commands/close-shell.ts | 20 +- .../helpers/commands/collection-workspaces.ts | 10 +- .../helpers/commands/connect-form.ts | 73 +++--- .../helpers/commands/connect.ts | 145 ++++-------- .../helpers/commands/connection-workspaces.ts | 36 ++- .../helpers/commands/database-workspaces.ts | 9 +- .../helpers/commands/disconnect.ts | 35 --- .../helpers/commands/open-shell.ts | 50 ++--- .../helpers/commands/remove-connections.ts | 11 - .../save-connection-string-as-favorite.ts | 18 +- .../helpers/commands/save-favorite.ts | 43 ++-- .../commands/select-connections-menu-item.ts | 22 +- .../helpers/commands/sidebar-connection.ts | 60 +---- packages/compass-e2e-tests/helpers/compass.ts | 7 - .../compass-e2e-tests/helpers/insert-data.ts | 12 +- .../compass-e2e-tests/helpers/selectors.ts | 8 +- .../tests/auto-connect.test.ts | 85 ++----- .../tests/connection-form.test.ts | 207 ++++-------------- .../tests/connection.test.ts | 72 +++--- .../tests/force-connection-options.test.ts | 13 +- .../tests/import-export-connections.test.ts | 76 ++----- .../tests/in-use-encryption.test.ts | 112 +++------- .../tests/instance-sidebar.test.ts | 66 ++---- .../compass-e2e-tests/tests/logging.test.ts | 7 +- .../tests/my-queries-tab.test.ts | 98 +++------ packages/compass-e2e-tests/tests/oidc.test.ts | 61 +++--- .../tests/protect-connection-strings.test.ts | 22 +- .../compass-e2e-tests/tests/read-only.test.ts | 72 +++--- .../compass-e2e-tests/tests/shell.test.ts | 35 +-- packages/compass-e2e-tests/tests/tabs.test.ts | 5 - 30 files changed, 417 insertions(+), 1073 deletions(-) diff --git a/packages/compass-e2e-tests/helpers/commands/close-shell.ts b/packages/compass-e2e-tests/helpers/commands/close-shell.ts index 96e66d4df0a..2492ec30af2 100644 --- a/packages/compass-e2e-tests/helpers/commands/close-shell.ts +++ b/packages/compass-e2e-tests/helpers/commands/close-shell.ts @@ -1,23 +1,11 @@ -import { TEST_MULTIPLE_CONNECTIONS } from '../compass'; import type { CompassBrowser } from '../compass-browser'; -import retryWithBackoff from '../retry-with-backoff'; -import * as Selectors from '../selectors'; export async function closeShell( browser: CompassBrowser, connectionName: string ): Promise { - if (TEST_MULTIPLE_CONNECTIONS) { - await browser.closeWorkspaceTab({ - connectionName, - type: 'Shell', - }); - } else { - await retryWithBackoff(async function () { - const shellContentElement = await browser.$(Selectors.ShellContent); - if (await shellContentElement.isDisplayed()) { - await browser.clickVisible(Selectors.ShellExpandButton); - } - }); - } + await browser.closeWorkspaceTab({ + connectionName, + type: 'Shell', + }); } diff --git a/packages/compass-e2e-tests/helpers/commands/collection-workspaces.ts b/packages/compass-e2e-tests/helpers/commands/collection-workspaces.ts index 36d91b3ec64..8ca6d89c0c3 100644 --- a/packages/compass-e2e-tests/helpers/commands/collection-workspaces.ts +++ b/packages/compass-e2e-tests/helpers/commands/collection-workspaces.ts @@ -1,4 +1,3 @@ -import { TEST_MULTIPLE_CONNECTIONS } from '../compass'; import type { CompassBrowser } from '../compass-browser'; import * as Selectors from '../selectors'; import type { WorkspaceTabSelectorOptions } from '../selectors'; @@ -119,16 +118,13 @@ async function waitUntilActiveCollectionTab( ) { const options: WorkspaceTabSelectorOptions = { type: 'Collection', + connectionName, namespace: `${dbName}.${collectionName}`, active: true, }; - // Only add the connectionName for multiple connections because for some - // reason this sometimes flakes in single connections even though the tab is - // definitely there in the screenshot. - if (TEST_MULTIPLE_CONNECTIONS) { - options.connectionName = connectionName; - } + await browser.$(Selectors.workspaceTab(options)).waitForDisplayed(); + if (tabName) { await waitUntilActiveCollectionSubTab(browser, tabName); } diff --git a/packages/compass-e2e-tests/helpers/commands/connect-form.ts b/packages/compass-e2e-tests/helpers/commands/connect-form.ts index 90af05ad2b2..f47505af19e 100644 --- a/packages/compass-e2e-tests/helpers/commands/connect-form.ts +++ b/packages/compass-e2e-tests/helpers/commands/connect-form.ts @@ -3,31 +3,24 @@ import { expect } from 'chai'; import type { CompassBrowser } from '../compass-browser'; import * as Selectors from '../selectors'; import type { ConnectFormState } from '../connect-form-state'; -import { TEST_MULTIPLE_CONNECTIONS } from '../compass'; import Debug from 'debug'; import { DEFAULT_CONNECTIONS } from '../test-runner-context'; import { getConnectionTitle } from '@mongodb-js/connection-info'; const debug = Debug('compass-e2e-tests'); export async function resetConnectForm(browser: CompassBrowser): Promise { - const Sidebar = TEST_MULTIPLE_CONNECTIONS - ? Selectors.Multiple - : Selectors.Single; + const Sidebar = Selectors.Multiple; - if (TEST_MULTIPLE_CONNECTIONS) { - if (await browser.$(Selectors.ConnectionModal).isDisplayed()) { - await browser.clickVisible(Selectors.ConnectionModalCloseButton); - await browser - .$(Selectors.ConnectionModal) - .waitForDisplayed({ reverse: true }); - } + if (await browser.$(Selectors.ConnectionModal).isDisplayed()) { + await browser.clickVisible(Selectors.ConnectionModalCloseButton); + await browser + .$(Selectors.ConnectionModal) + .waitForDisplayed({ reverse: true }); } await browser.clickVisible(Sidebar.SidebarNewConnectionButton); - const connectionTitleSelector = TEST_MULTIPLE_CONNECTIONS - ? Selectors.ConnectionModalTitle - : Selectors.ConnectionTitle; + const connectionTitleSelector = Selectors.ConnectionModalTitle; const connectionTitle = await browser.$(connectionTitleSelector); await connectionTitle.waitUntil(async () => { @@ -57,29 +50,20 @@ export async function getConnectFormState( // General const initialTab = await browser.navigateToConnectTab('General'); - const defaultPromises: Record> = { + const defaultState = await promiseMap({ scheme: getCheckedRadioValue(browser, Selectors.ConnectionFormSchemeRadios), hosts: getMultipleValues(browser, Selectors.ConnectionFormHostInputs), directConnection: getCheckboxValue( browser, Selectors.ConnectionFormDirectConnectionCheckbox ), - }; - if (TEST_MULTIPLE_CONNECTIONS) { - defaultPromises.connectionName = getValue( - browser, - Selectors.ConnectionFormConnectionName - ); - defaultPromises.connectionColor = getValue( - browser, - Selectors.ConnectionFormConnectionColor - ); - defaultPromises.connectionFavorite = getCheckboxValue( + connectionName: getValue(browser, Selectors.ConnectionFormConnectionName), + connectionColor: getValue(browser, Selectors.ConnectionFormConnectionColor), + connectionFavorite: getCheckboxValue( browser, Selectors.ConnectionFormFavoriteCheckbox - ); - } - const defaultState = await promiseMap(defaultPromises); + ), + }); // Authentication await browser.navigateToConnectTab('Authentication'); @@ -506,25 +490,22 @@ export async function setConnectFormState( await browser.clickParent(Selectors.ConnectionFormDirectConnectionCheckbox); } - if (TEST_MULTIPLE_CONNECTIONS) { - // Name, Color, Favorite - if (state.connectionName) { - await browser.setValueVisible( - Selectors.ConnectionFormConnectionName, - state.connectionName - ); - } + if (state.connectionName) { + await browser.setValueVisible( + Selectors.ConnectionFormConnectionName, + state.connectionName + ); + } - if (state.connectionColor) { - await browser.selectOption( - Selectors.ConnectionFormConnectionColor, - colorValueToName(state.connectionColor) - ); - } + if (state.connectionColor) { + await browser.selectOption( + Selectors.ConnectionFormConnectionColor, + colorValueToName(state.connectionColor) + ); + } - if (state.connectionFavorite) { - await browser.clickParent(Selectors.ConnectionFormFavoriteCheckbox); - } + if (state.connectionFavorite) { + await browser.clickParent(Selectors.ConnectionFormFavoriteCheckbox); } // Authentication diff --git a/packages/compass-e2e-tests/helpers/commands/connect.ts b/packages/compass-e2e-tests/helpers/commands/connect.ts index 379524d622d..381ada2cf36 100644 --- a/packages/compass-e2e-tests/helpers/commands/connect.ts +++ b/packages/compass-e2e-tests/helpers/commands/connect.ts @@ -2,27 +2,14 @@ import { DEFAULT_CONNECTION_NAME_1, DEFAULT_CONNECTION_NAME_2, DEFAULT_CONNECTION_STRING_1, - TEST_MULTIPLE_CONNECTIONS, connectionNameFromString, } from '../compass'; import type { CompassBrowser } from '../compass-browser'; import type { ConnectFormState } from '../connect-form-state'; import * as Selectors from '../selectors'; import Debug from 'debug'; -const debug = Debug('compass-e2e-tests'); - -export async function waitForConnectionScreen( - browser: CompassBrowser -): Promise { - // there isn't a separate connection screen in multiple connections, just a modal you can access at any time - if (TEST_MULTIPLE_CONNECTIONS) { - return; - } - const selector = Selectors.ConnectSection; - const connectScreenElement = await browser.$(selector); - await connectScreenElement.waitForDisplayed(); -} +const debug = Debug('compass-e2e-tests'); export async function getConnectFormConnectionString( browser: CompassBrowser, @@ -57,32 +44,29 @@ export async function connectWithConnectionString( // connection string. Most test files should just be using // browser.connectToDefaults() - if (TEST_MULTIPLE_CONNECTIONS) { - // if the modal is still animating away when we're connecting again, things - // are going to get confused - await browser - .$(Selectors.ConnectionModal) - .waitForDisplayed({ reverse: true }); - - // if a connection with this name already exists, remove it otherwise we'll - // add a duplicate and things will get complicated fast - const connectionName = connectionNameFromString(connectionString); - if (await browser.removeConnection(connectionName)) { - debug('Removing existing connection so we do not create a duplicate', { - connectionName, - }); - } + // if the modal is still animating away when we're connecting again, things + // are going to get confused + await browser + .$(Selectors.ConnectionModal) + .waitForDisplayed({ reverse: true }); - await browser.clickVisible(Selectors.Multiple.SidebarNewConnectionButton); - await browser.$(Selectors.ConnectionModal).waitForDisplayed(); + // if a connection with this name already exists, remove it otherwise we'll + // add a duplicate and things will get complicated fast + const connectionName = connectionNameFromString(connectionString); + if (await browser.removeConnection(connectionName)) { + debug('Removing existing connection so we do not create a duplicate', { + connectionName, + }); } + await browser.clickVisible(Selectors.Multiple.SidebarNewConnectionButton); + await browser.$(Selectors.ConnectionModal).waitForDisplayed(); + await browser.setValueVisible( Selectors.ConnectionFormStringInput, connectionString ); - const connectionName = connectionNameFromString(connectionString); await browser.doConnect(connectionName, options); } @@ -133,75 +117,50 @@ export async function waitForConnectionResult( ): Promise { const waitOptions = typeof timeout !== 'undefined' ? { timeout } : undefined; - if (TEST_MULTIPLE_CONNECTIONS) { - if (await browser.$(Selectors.SidebarFilterInput).isDisplayed()) { - // Clear the filter to make sure every connection shows - await browser.clickVisible(Selectors.SidebarFilterInput); - await browser.setValueVisible(Selectors.SidebarFilterInput, ''); - } + if (await browser.$(Selectors.SidebarFilterInput).isDisplayed()) { + // Clear the filter to make sure every connection shows + await browser.clickVisible(Selectors.SidebarFilterInput); + await browser.setValueVisible(Selectors.SidebarFilterInput, ''); } if (connectionStatus === 'either') { // For the very rare cases where we don't care whether it fails or succeeds. // Usually because the exact result is a race condition. - if (TEST_MULTIPLE_CONNECTIONS) { - const successSelector = Selectors.Multiple.connectionItemByName( - connectionName, - { - connected: true, - } - ); - const failureSelector = Selectors.ConnectionToastErrorText; - await browser - .$(`${successSelector},${failureSelector}`) - .waitForDisplayed(waitOptions); - } else { - // TODO(COMPASS-7600): this doesn't support compass-web yet, but also - // isn't encountered yet - await browser - .$(`${Selectors.MyQueriesList},${Selectors.ConnectionFormErrorMessage}`) - .waitForDisplayed(); - } + const successSelector = Selectors.Multiple.connectionItemByName( + connectionName, + { + connected: true, + } + ); + const failureSelector = Selectors.ConnectionToastErrorText; + await browser + .$(`${successSelector},${failureSelector}`) + .waitForDisplayed(waitOptions); } else if (connectionStatus === 'success') { // Wait for the first meaningful thing on the screen after being connected // and assume that's a good enough indicator that we are connected to the // server - if (TEST_MULTIPLE_CONNECTIONS) { - await browser - .$( - Selectors.Multiple.connectionItemByName(connectionName, { - connected: true, - }) - ) - .waitForDisplayed(); - } else { - // In the single connection world we land on the My Queries page - await browser.$(Selectors.MyQueriesList).waitForDisplayed(); - } + await browser + .$( + Selectors.Multiple.connectionItemByName(connectionName, { + connected: true, + }) + ) + .waitForDisplayed(); } else if (connectionStatus === 'failure') { - if (TEST_MULTIPLE_CONNECTIONS) { - await browser - .$(Selectors.ConnectionToastErrorText) - .waitForDisplayed(waitOptions); - return await browser.$(Selectors.LGToastTitle).getText(); - } else { - // TODO(COMPASS-7600): this doesn't support compass-web yet, but also - // isn't encountered yet - const element = await browser.$(Selectors.ConnectionFormErrorMessage); - await element.waitForDisplayed(waitOptions); - return await element.getText(); - } + await browser + .$(Selectors.ConnectionToastErrorText) + .waitForDisplayed(waitOptions); + return await browser.$(Selectors.LGToastTitle).getText(); } else { const exhaustiveCheck: never = connectionStatus; throw new Error(`Unhandled connectionStatus case: ${exhaustiveCheck}`); } - if (TEST_MULTIPLE_CONNECTIONS) { - // make sure the placeholders for databases & collections that are loading are all gone - await browser - .$(Selectors.DatabaseCollectionPlaceholder) - .waitForDisplayed({ reverse: true }); - } + // make sure the placeholders for databases & collections that are loading are all gone + await browser + .$(Selectors.DatabaseCollectionPlaceholder) + .waitForDisplayed({ reverse: true }); } export async function connectByName( @@ -210,25 +169,13 @@ export async function connectByName( options: ConnectionResultOptions = {} ) { await browser.clickVisible(Selectors.sidebarConnectionButton(connectionName)); - - if (!TEST_MULTIPLE_CONNECTIONS) { - // for single connections it only fills the connection form and we still - // have to click connect. For multiple connections clicking the connection - // connects - await browser.pause(1000); - await browser.clickVisible(Selectors.ConnectButton); - } - await browser.waitForConnectionResult(connectionName, options); } export async function connectToDefaults(browser: CompassBrowser) { // See setupDefaultConnections() for the details behind the thinking here. await browser.connectByName(DEFAULT_CONNECTION_NAME_1); - - if (TEST_MULTIPLE_CONNECTIONS) { - await browser.connectByName(DEFAULT_CONNECTION_NAME_2); - } + await browser.connectByName(DEFAULT_CONNECTION_NAME_2); // We assume that we connected successfully, so just close the success toasts // early to make sure they aren't in the way of tests. Tests that care about diff --git a/packages/compass-e2e-tests/helpers/commands/connection-workspaces.ts b/packages/compass-e2e-tests/helpers/commands/connection-workspaces.ts index 29d5a7b0250..4b11cbce633 100644 --- a/packages/compass-e2e-tests/helpers/commands/connection-workspaces.ts +++ b/packages/compass-e2e-tests/helpers/commands/connection-workspaces.ts @@ -1,4 +1,3 @@ -import { TEST_MULTIPLE_CONNECTIONS } from '../compass'; import type { CompassBrowser } from '../compass-browser'; import * as Selectors from '../selectors'; import type { WorkspaceTabSelectorOptions } from '../selectors'; @@ -8,22 +7,16 @@ export async function navigateToConnectionTab( connectionName: string, tabType: 'Performance' | 'Databases' ): Promise { - if (TEST_MULTIPLE_CONNECTIONS) { - if (tabType === 'Databases') { - await browser.clickVisible(Selectors.sidebarConnection(connectionName)); - } else { - await browser.selectConnectionMenuItem( - connectionName, - Selectors.Multiple.ViewPerformanceItem - ); - } - - await waitUntilActiveConnectionTab(browser, connectionName, tabType); + if (tabType === 'Databases') { + await browser.clickVisible(Selectors.sidebarConnection(connectionName)); } else { - const itemSelector = Selectors.sidebarInstanceNavigationItem(tabType); - await browser.clickVisible(itemSelector); - await waitUntilActiveConnectionTab(browser, connectionName, tabType); + await browser.selectConnectionMenuItem( + connectionName, + Selectors.Multiple.ViewPerformanceItem + ); } + + await waitUntilActiveConnectionTab(browser, connectionName, tabType); } export async function waitUntilActiveConnectionTab( @@ -31,13 +24,10 @@ export async function waitUntilActiveConnectionTab( connectionName: string, tabType: 'Performance' | 'Databases' ) { - const options: WorkspaceTabSelectorOptions = { type: tabType, active: true }; - - // Only add the connectionName for multiple connections because for some - // reason this sometimes flakes in single connections even though the tab is - // definitely there in the screenshot. - if (TEST_MULTIPLE_CONNECTIONS) { - options.connectionName = connectionName; - } + const options: WorkspaceTabSelectorOptions = { + type: tabType, + connectionName, + active: true, + }; await browser.$(Selectors.workspaceTab(options)).waitForDisplayed(); } diff --git a/packages/compass-e2e-tests/helpers/commands/database-workspaces.ts b/packages/compass-e2e-tests/helpers/commands/database-workspaces.ts index e4dd8038269..c84321c1916 100644 --- a/packages/compass-e2e-tests/helpers/commands/database-workspaces.ts +++ b/packages/compass-e2e-tests/helpers/commands/database-workspaces.ts @@ -1,4 +1,3 @@ -import { TEST_MULTIPLE_CONNECTIONS } from '../compass'; import type { CompassBrowser } from '../compass-browser'; import * as Selectors from '../selectors'; import type { WorkspaceTabSelectorOptions } from '../selectors'; @@ -19,16 +18,10 @@ export async function waitUntilActiveDatabaseTab( dbName: string ) { const options: WorkspaceTabSelectorOptions = { + connectionName, namespace: dbName, active: true, }; - // Only add the connectionName for multiple connections because for some - // reason this sometimes flakes in single connections even though the tab is - // definitely there in the screenshot. - if (TEST_MULTIPLE_CONNECTIONS) { - options.connectionName = connectionName; - } - await browser.$(Selectors.workspaceTab(options)).waitForDisplayed(); } diff --git a/packages/compass-e2e-tests/helpers/commands/disconnect.ts b/packages/compass-e2e-tests/helpers/commands/disconnect.ts index c4f38f6e3bc..d0c9c8a3e38 100644 --- a/packages/compass-e2e-tests/helpers/commands/disconnect.ts +++ b/packages/compass-e2e-tests/helpers/commands/disconnect.ts @@ -1,37 +1,6 @@ -import { TEST_MULTIPLE_CONNECTIONS } from '../compass'; import type { CompassBrowser } from '../compass-browser'; -import delay from '../delay'; import * as Selectors from '../selectors'; -async function disconnectAllSingle(browser: CompassBrowser) { - const cancelConnectionButtonElement = await browser.$( - Selectors.CancelConnectionButton - ); - // If we are still connecting, let's try cancelling the connection first - if (await cancelConnectionButtonElement.isDisplayed()) { - try { - await browser.closeConnectModal(); - } catch (e) { - // If that failed, the button was probably gone before we managed to - // click it. Let's go through the whole disconnecting flow now - } - } - - await delay(100); - - await browser.execute(() => { - // eslint-disable-next-line @typescript-eslint/no-var-requires - require('electron').ipcRenderer.emit('app:disconnect'); - }); - - // for single connections we expect the connect screen to re-appear - await browser.$(Selectors.ConnectSection).waitForDisplayed(); - - // clear the form - await browser.clickVisible(Selectors.Single.SidebarNewConnectionButton); - await delay(100); -} - async function resetForDisconnect( browser: CompassBrowser, { @@ -69,10 +38,6 @@ export async function disconnectAll( // probably in conjunction with browser.connectToDefaults() so that each test // will start off with multiple connections already connected. - if (!TEST_MULTIPLE_CONNECTIONS) { - return await disconnectAllSingle(browser); - } - // The previous test could have ended with modals and/or toasts left open and // a search filter in the sidebar. Reset those so we can get to a known state. await resetForDisconnect(browser, { closeToasts }); diff --git a/packages/compass-e2e-tests/helpers/commands/open-shell.ts b/packages/compass-e2e-tests/helpers/commands/open-shell.ts index 8c3725259f4..918420416e1 100644 --- a/packages/compass-e2e-tests/helpers/commands/open-shell.ts +++ b/packages/compass-e2e-tests/helpers/commands/open-shell.ts @@ -1,43 +1,27 @@ -import { TEST_MULTIPLE_CONNECTIONS } from '../compass'; import type { CompassBrowser } from '../compass-browser'; -import retryWithBackoff from '../retry-with-backoff'; import * as Selectors from '../selectors'; export async function openShell( browser: CompassBrowser, connectionName: string ): Promise { - if (TEST_MULTIPLE_CONNECTIONS) { - await browser.selectConnectionMenuItem( - connectionName, - Selectors.Multiple.OpenShellItem, - false // the item is not contained in the three-dot menu - ); - - // try and make sure the shell tab is active and ready - await browser.waitUntil(async () => { - const currentActiveTab = await browser.$( - Selectors.workspaceTab({ active: true }) - ); - const activeType = await currentActiveTab.getAttribute('data-type'); - const activeConnectionName = await currentActiveTab.getAttribute( - 'data-connection-name' - ); - return activeType === 'Shell' && activeConnectionName === connectionName; - }); + await browser.selectConnectionMenuItem( + connectionName, + Selectors.Multiple.OpenShellItem, + false // the item is not contained in the three-dot menu + ); - await browser.clickVisible(Selectors.ShellInputEditor); - } else { - // Expand the shell - await retryWithBackoff(async function () { - const shellContentElement = await browser.$(Selectors.ShellContent); - if (!(await shellContentElement.isDisplayed())) { - // The toasts may be covering the shell, so we need to close them. - await browser.hideAllVisibleToasts(); - await browser.clickVisible(Selectors.ShellExpandButton); - } + // try and make sure the shell tab is active and ready + await browser.waitUntil(async () => { + const currentActiveTab = await browser.$( + Selectors.workspaceTab({ active: true }) + ); + const activeType = await currentActiveTab.getAttribute('data-type'); + const activeConnectionName = await currentActiveTab.getAttribute( + 'data-connection-name' + ); + return activeType === 'Shell' && activeConnectionName === connectionName; + }); - await browser.clickVisible(Selectors.ShellInputEditor); - }); - } + await browser.clickVisible(Selectors.ShellInputEditor); } diff --git a/packages/compass-e2e-tests/helpers/commands/remove-connections.ts b/packages/compass-e2e-tests/helpers/commands/remove-connections.ts index 74e654e9c2d..3c63b92d9be 100644 --- a/packages/compass-e2e-tests/helpers/commands/remove-connections.ts +++ b/packages/compass-e2e-tests/helpers/commands/remove-connections.ts @@ -1,4 +1,3 @@ -import { TEST_MULTIPLE_CONNECTIONS } from '../compass'; import type { CompassBrowser } from '../compass-browser'; import * as Selectors from '../selectors'; @@ -23,11 +22,6 @@ export async function removeAllConnections( // files that might create a lot of connections that will start running into // virtual scrolling issues - if (!TEST_MULTIPLE_CONNECTIONS) { - // not implemented for single connections / compass web - return; - } - // The previous test could have ended with modals and/or toasts left open and // a search filter in the sidebar. Reset those so we can get to a known state. await resetForRemove(browser); @@ -49,11 +43,6 @@ export async function removeConnectionByName( browser: CompassBrowser, connectionName: string ) { - if (!TEST_MULTIPLE_CONNECTIONS) { - // not implemented for single connections / compass web - return; - } - await resetForRemove(browser); await browser.selectConnectionMenuItem( diff --git a/packages/compass-e2e-tests/helpers/commands/save-connection-string-as-favorite.ts b/packages/compass-e2e-tests/helpers/commands/save-connection-string-as-favorite.ts index 57e48320003..be2f93a1acb 100644 --- a/packages/compass-e2e-tests/helpers/commands/save-connection-string-as-favorite.ts +++ b/packages/compass-e2e-tests/helpers/commands/save-connection-string-as-favorite.ts @@ -1,25 +1,17 @@ import { UUID } from 'bson'; import type { CompassBrowser } from '../compass-browser'; import * as Selectors from '../selectors'; -import { TEST_MULTIPLE_CONNECTIONS } from '../compass'; -// TODO(COMPASS-8023): Just remove this command and use setConnectionFormState() -// once we remove the single connection code +// TODO(COMPASS-8023): Provide a counterpart `browser.saveConnection` method to +// be able to edit existing connection export async function saveConnectionStringAsFavorite( browser: CompassBrowser, connectionString: string, favoriteName?: string, - color: `color${number}` | string = 'color1' + color = 'Green' ): Promise { - if (TEST_MULTIPLE_CONNECTIONS) { - // open the connection modal so we can fill in the connection string - await browser.clickVisible(Selectors.Multiple.SidebarNewConnectionButton); - } - - if (TEST_MULTIPLE_CONNECTIONS && color === 'color1') { - color = 'Green'; - } - + // open the connection modal so we can fill in the connection string + await browser.clickVisible(Selectors.Multiple.SidebarNewConnectionButton); favoriteName ??= new UUID().toHexString(); await browser.setValueVisible( Selectors.ConnectionFormStringInput, diff --git a/packages/compass-e2e-tests/helpers/commands/save-favorite.ts b/packages/compass-e2e-tests/helpers/commands/save-favorite.ts index 0921a0a7b8b..3635aaafd87 100644 --- a/packages/compass-e2e-tests/helpers/commands/save-favorite.ts +++ b/packages/compass-e2e-tests/helpers/commands/save-favorite.ts @@ -1,39 +1,22 @@ -import { TEST_MULTIPLE_CONNECTIONS } from '../compass'; import type { CompassBrowser } from '../compass-browser'; import * as Selectors from '../selectors'; -import { expect } from 'chai'; -// TODO(COMPASS-8023): Just remove this command and use -// setConnectionFormState() once we remove the single connection code +// TODO(COMPASS-8023): Provide a counterpart `browser.saveConnection` method to +// be able to edit existing connection export async function saveFavorite( browser: CompassBrowser, favoriteName: string, - color: `color${number}` | string + color: string ): Promise { - if (TEST_MULTIPLE_CONNECTIONS) { - // this assumes that the checkbox is unchecked - await browser.clickParent(Selectors.ConnectionFormFavoriteCheckbox); - await browser.setValueVisible( - Selectors.ConnectionFormConnectionName, - favoriteName - ); - await browser.selectOption(Selectors.ConnectionFormConnectionColor, color); - - await browser.clickVisible(Selectors.ConnectionModalSaveButton); - await browser.$(Selectors.ConnectionModal).waitForExist({ reverse: true }); - return; - } - - await browser.clickVisible(Selectors.ConnectionEditFavouriteButton); - await browser.$(Selectors.FavoriteModal).waitForDisplayed(); - await browser.setValueVisible(Selectors.FavoriteNameInput, favoriteName); - await browser.clickVisible( - `${Selectors.FavoriteColorSelector} [data-testid="color-pick-${color}"]` + // this assumes that the checkbox is unchecked + await browser.clickParent(Selectors.ConnectionFormFavoriteCheckbox); + await browser.setValueVisible( + Selectors.ConnectionFormConnectionName, + favoriteName ); - await browser.$(Selectors.FavoriteSaveButton).waitForEnabled(); - expect(await browser.$(Selectors.FavoriteSaveButton).getText()).to.equal( - 'Save' - ); - await browser.clickVisible(Selectors.FavoriteSaveButton); - await browser.$(Selectors.FavoriteModal).waitForExist({ reverse: true }); + await browser.selectOption(Selectors.ConnectionFormConnectionColor, color); + + await browser.clickVisible(Selectors.ConnectionModalSaveButton); + await browser.$(Selectors.ConnectionModal).waitForExist({ reverse: true }); + return; } diff --git a/packages/compass-e2e-tests/helpers/commands/select-connections-menu-item.ts b/packages/compass-e2e-tests/helpers/commands/select-connections-menu-item.ts index e9fbacc2a12..9fe30669298 100644 --- a/packages/compass-e2e-tests/helpers/commands/select-connections-menu-item.ts +++ b/packages/compass-e2e-tests/helpers/commands/select-connections-menu-item.ts @@ -1,4 +1,3 @@ -import { TEST_MULTIPLE_CONNECTIONS } from '../compass'; import type { CompassBrowser } from '../compass-browser'; import * as Selectors from '../selectors'; @@ -6,26 +5,7 @@ export async function selectConnectionsMenuItem( browser: CompassBrowser, itemSelector: string ) { - const Sidebar = TEST_MULTIPLE_CONNECTIONS - ? Selectors.Multiple - : Selectors.Single; - - if (!TEST_MULTIPLE_CONNECTIONS) { - // In the single connection world the button only appears on hover - - const selector = Selectors.Single.FavoriteConnectionsHeader; - await browser.$(selector).waitForDisplayed(); - - // workaround for weirdness in the ItemActionControls menu opener icon - await browser.clickVisible(Selectors.Single.ConnectionsTitle); - - // Hover over an arbitrary other element to ensure that the second hover will - // actually be a fresh one. This otherwise breaks if this function is called - // twice in a row. - await browser.hover(`*:not(${selector}, ${selector} *)`); - await browser.hover(selector); - } - + const Sidebar = Selectors.Multiple; await browser.clickVisible(Sidebar.ConnectionsMenuButton); await browser.$(Sidebar.ConnectionsMenu).waitForDisplayed(); await browser.clickVisible(itemSelector); diff --git a/packages/compass-e2e-tests/helpers/commands/sidebar-connection.ts b/packages/compass-e2e-tests/helpers/commands/sidebar-connection.ts index 3f5808d9dbb..47e32c29028 100644 --- a/packages/compass-e2e-tests/helpers/commands/sidebar-connection.ts +++ b/packages/compass-e2e-tests/helpers/commands/sidebar-connection.ts @@ -1,4 +1,3 @@ -import { TEST_MULTIPLE_CONNECTIONS } from '../compass'; import type { CompassBrowser } from '../compass-browser'; import * as Selectors from '../selectors'; @@ -6,12 +5,6 @@ export async function getConnectionIdByName( browser: CompassBrowser, connectionName: string ): Promise { - if (!TEST_MULTIPLE_CONNECTIONS) { - // the connection id isn't somewhere we can consistently access it in the - // single connection world - return undefined; - } - const connections = await browser.$$( Selectors.sidebarConnection(connectionName) ); @@ -31,26 +24,13 @@ export async function selectConnection( browser: CompassBrowser, connectionName: string ): Promise { - if (TEST_MULTIPLE_CONNECTIONS) { - await browser.selectConnectionMenuItem( - connectionName, - Selectors.Multiple.EditConnectionItem - ); - } else { - await browser.pause(1000); - - await browser.clickVisible( - Selectors.sidebarConnectionButton(connectionName), - { - screenshot: `selecting-connection-${connectionName}.png`, - } - ); - } + await browser.selectConnectionMenuItem( + connectionName, + Selectors.Multiple.EditConnectionItem + ); await browser.waitUntil(async () => { - const connectionTitleSelector = TEST_MULTIPLE_CONNECTIONS - ? Selectors.ConnectionModalTitle - : Selectors.ConnectionTitle; + const connectionTitleSelector = Selectors.ConnectionModalTitle; const text = await browser.$(connectionTitleSelector).getText(); return text === connectionName; @@ -63,9 +43,7 @@ export async function selectConnectionMenuItem( itemSelector: string, openMenu = true ) { - const Sidebar = TEST_MULTIPLE_CONNECTIONS - ? Selectors.Multiple - : Selectors.Single; + const Sidebar = Selectors.Multiple; const selector = Selectors.sidebarConnection(connectionName); @@ -104,36 +82,10 @@ export async function selectConnectionMenuItem( await browser.clickVisible(itemSelector); } -// TODO(COMPASS-8023): Just remove this once the single connection code is removed -async function removeConnectionSingle( - browser: CompassBrowser, - connectionName: string -): Promise { - const selector = Selectors.sidebarConnection(connectionName); - - if (await browser.$(selector).isExisting()) { - await browser.selectConnection(connectionName); - - await browser.selectConnectionMenuItem( - connectionName, - Selectors.Single.RemoveConnectionItem - ); - - await browser.$(selector).waitForDisplayed({ reverse: true }); - return true; - } - - return false; -} - export async function removeConnection( browser: CompassBrowser, connectionName: string ): Promise { - if (!TEST_MULTIPLE_CONNECTIONS) { - return await removeConnectionSingle(browser, connectionName); - } - // make sure there's no filter because if the connection is not displayed then we can't remove it if (await browser.$(Selectors.SidebarFilterInput).isExisting()) { await browser.clickVisible(Selectors.SidebarFilterInput); diff --git a/packages/compass-e2e-tests/helpers/compass.ts b/packages/compass-e2e-tests/helpers/compass.ts index 6bdb804e20b..71800865a86 100644 --- a/packages/compass-e2e-tests/helpers/compass.ts +++ b/packages/compass-e2e-tests/helpers/compass.ts @@ -58,8 +58,6 @@ const packageCompassAsync = promisify(packageCompass); // should we test compass-web (true) or compass electron (false)? export const TEST_COMPASS_WEB = _TEST_COMPASS_WEB; -// multiple connections is now the default -export const TEST_MULTIPLE_CONNECTIONS = true; /* A helper so we can easily find all the tests we're skipping in compass-web. @@ -411,7 +409,6 @@ export class Compass { interface StartCompassOptions { firstRun?: boolean; - noWaitForConnectionScreen?: boolean; extraSpawnArgs?: string[]; wrapBinary?: (binary: string) => Promise | string; } @@ -1057,10 +1054,6 @@ export async function init( await browser.closeWelcomeModal(); } - if (!opts.noWaitForConnectionScreen) { - await browser.waitForConnectionScreen(); - } - return compass; } diff --git a/packages/compass-e2e-tests/helpers/insert-data.ts b/packages/compass-e2e-tests/helpers/insert-data.ts index 2a18bdb218b..144e9b746dd 100644 --- a/packages/compass-e2e-tests/helpers/insert-data.ts +++ b/packages/compass-e2e-tests/helpers/insert-data.ts @@ -1,11 +1,6 @@ import { MongoClient } from 'mongodb'; import type { Db, MongoServerError } from 'mongodb'; - -import { - DEFAULT_CONNECTION_STRING_1, - DEFAULT_CONNECTION_STRING_2, - TEST_MULTIPLE_CONNECTIONS, -} from './compass'; +import { DEFAULT_CONNECTION_STRINGS } from './test-runner-context'; // This is a list of all the known database names that get created by tests so // that we can know what to drop when we clean up before every test. If a new @@ -53,10 +48,7 @@ export const beforeAll = async () => { // hopefully fail a test. // This should also mean that the database or collection name that we try and // use is always ambiguous, so we're forced to deal with it early in tests. - const connectionStrings = [DEFAULT_CONNECTION_STRING_1]; - if (TEST_MULTIPLE_CONNECTIONS) { - connectionStrings.push(DEFAULT_CONNECTION_STRING_2); - } + const connectionStrings = DEFAULT_CONNECTION_STRINGS; clients = connectionStrings.map( (connectionString) => new MongoClient(connectionString) ); diff --git a/packages/compass-e2e-tests/helpers/selectors.ts b/packages/compass-e2e-tests/helpers/selectors.ts index 5760e945347..0d4532ea4c1 100644 --- a/packages/compass-e2e-tests/helpers/selectors.ts +++ b/packages/compass-e2e-tests/helpers/selectors.ts @@ -1,5 +1,3 @@ -import { TEST_MULTIPLE_CONNECTIONS } from './compass'; - export type WorkspaceTabSelectorOptions = { id?: string; connectionName?: string; @@ -400,11 +398,7 @@ export const sidebarCollection = ( }; export const sidebarConnection = (connectionName: string): string => { - if (TEST_MULTIPLE_CONNECTIONS) { - return `${Sidebar} [data-connection-name="${connectionName}"]`; - } - - return sidebarFavorite(connectionName); + return `${Sidebar} [data-connection-name="${connectionName}"]`; }; export const sidebarConnectionButton = (connectionName: string): string => { diff --git a/packages/compass-e2e-tests/tests/auto-connect.test.ts b/packages/compass-e2e-tests/tests/auto-connect.test.ts index cb67cff9474..2f25ee90984 100644 --- a/packages/compass-e2e-tests/tests/auto-connect.test.ts +++ b/packages/compass-e2e-tests/tests/auto-connect.test.ts @@ -5,7 +5,6 @@ import { cleanup, positionalArgs, skipForWeb, - TEST_MULTIPLE_CONNECTIONS, screenshotPathName, connectionNameFromString, } from '../helpers/compass'; @@ -89,12 +88,6 @@ describe('Automatically connecting from the command line', function () { await compass.browser.waitForConnectionResult(connectionName, { connectionStatus: 'success', }); - if (!TEST_MULTIPLE_CONNECTIONS) { - const sidebarTitle = await compass.browser - .$(Selectors.SidebarTitle) - .getText(); - expect(sidebarTitle).to.eq(connectionName); - } const result = await compass.browser.shellEval( connectionName, 'db.runCommand({ connectionStatus: 1 })', @@ -106,7 +99,6 @@ describe('Automatically connecting from the command line', function () { it('works with a connection string on the command line', async function () { const compass = await init(this.test?.fullTitle(), { wrapBinary: positionalArgs([connectionStringSuccess]), - noWaitForConnectionScreen: true, }); try { await waitForConnectionSuccessAndCheckConnection( @@ -127,7 +119,6 @@ describe('Automatically connecting from the command line', function () { const compass = await init(this.test?.fullTitle(), { wrapBinary: positionalArgs(args), - noWaitForConnectionScreen: true, }); try { await waitForConnectionSuccessAndCheckConnection(compass, 'Success'); @@ -176,10 +167,8 @@ describe('Automatically connecting from the command line', function () { { connectionStatus: 'failure' } ); expect(error).to.include('Authentication failed'); - if (TEST_MULTIPLE_CONNECTIONS) { - await browser.clickVisible(Selectors.ConnectionToastErrorReviewButton); - await browser.$(Selectors.ConnectionModal).waitForDisplayed(); - } + await browser.clickVisible(Selectors.ConnectionToastErrorReviewButton); + await browser.$(Selectors.ConnectionModal).waitForDisplayed(); const connectFormState = await browser.getConnectFormState(); expect(connectFormState.defaultUsername).to.equal('doesnotexist'); expect(connectFormState.defaultPassword).to.equal('asdf/'); @@ -232,7 +221,6 @@ describe('Automatically connecting from the command line', function () { it('enters auto-connect mode again if the window is hard reloaded', async function () { const compass = await init(this.test?.fullTitle(), { wrapBinary: positionalArgs([connectionStringSuccess]), - noWaitForConnectionScreen: true, }); try { const { browser } = compass; @@ -255,7 +243,6 @@ describe('Automatically connecting from the command line', function () { await browser.execute(() => { location.reload(); }); - await browser.waitForConnectionScreen(); } catch (err: any) { await compass.browser.screenshot( screenshotPathName( @@ -271,7 +258,6 @@ describe('Automatically connecting from the command line', function () { it('does not enter auto-connect mode in new windows', async function () { const compass = await init(this.test?.fullTitle(), { wrapBinary: positionalArgs([connectionStringSuccess]), - noWaitForConnectionScreen: true, }); try { const { browser } = compass; @@ -300,37 +286,23 @@ describe('Automatically connecting from the command line', function () { if (allWindows.length < 2) return false; currentWindow = allWindows.find((w) => w !== currentWindow) as string; await browser.switchToWindow(currentWindow); - - if (TEST_MULTIPLE_CONNECTIONS) { - // the new window should open on the welcome tab - const currentActiveTab = await browser.$( - Selectors.workspaceTab({ active: true }) - ); - const type = await currentActiveTab.getAttribute('data-type'); - return type === 'Welcome'; - } else { - // the new window should land on the connect screen - const connectScreenElement = await browser.$( - Selectors.ConnectSection - ); - return await connectScreenElement.isDisplayed(); - } + // the new window should open on the welcome tab + const currentActiveTab = await browser.$( + Selectors.workspaceTab({ active: true }) + ); + const type = await currentActiveTab.getAttribute('data-type'); + return type === 'Welcome'; }); - if (TEST_MULTIPLE_CONNECTIONS) { - // no toasts to signify that anything is connecting - const toasts = await browser.$(Selectors.LGToastContainer).$$('div'); - expect(toasts).to.have.lengthOf(0); + // no toasts to signify that anything is connecting + const toasts = await browser.$(Selectors.LGToastContainer).$$('div'); + expect(toasts).to.have.lengthOf(0); - // no active connections - const connectionItems = await browser.$$( - Selectors.Multiple.ConnectedConnectionItems - ); - expect(connectionItems).to.have.lengthOf(0); - } else { - // this should always be true because we already waited for it in the waitUntil above - await browser.waitForConnectionScreen(); - } + // no active connections + const connectionItems = await browser.$$( + Selectors.Multiple.ConnectedConnectionItems + ); + expect(connectionItems).to.have.lengthOf(0); } finally { await cleanup(compass); } @@ -340,7 +312,6 @@ describe('Automatically connecting from the command line', function () { let browser; let compass = await init(this.test?.fullTitle(), { wrapBinary: positionalArgs([connectionStringSuccess]), - noWaitForConnectionScreen: true, }); try { browser = compass.browser; @@ -363,23 +334,15 @@ describe('Automatically connecting from the command line', function () { browser = compass.browser; // there should be no connection items - if (TEST_MULTIPLE_CONNECTIONS) { - const connectionItems = await browser.$$( - Selectors.Multiple.ConnectionItems - ); - expect(connectionItems).to.have.lengthOf(0); + const connectionItems = await browser.$$( + Selectors.Multiple.ConnectionItems + ); + expect(connectionItems).to.have.lengthOf(0); - await browser - .$(Selectors.Multiple.NoDeploymentsText) - .waitForDisplayed(); - await browser - .$(Selectors.Multiple.AddNewConnectionButton) - .waitForDisplayed(); - } else { - await browser - .$(Selectors.Single.RecentConnections) - .waitForDisplayed({ reverse: true }); - } + await browser.$(Selectors.Multiple.NoDeploymentsText).waitForDisplayed(); + await browser + .$(Selectors.Multiple.AddNewConnectionButton) + .waitForDisplayed(); } finally { await cleanup(compass); } diff --git a/packages/compass-e2e-tests/tests/connection-form.test.ts b/packages/compass-e2e-tests/tests/connection-form.test.ts index 4e44980e0af..afd961b8be6 100644 --- a/packages/compass-e2e-tests/tests/connection-form.test.ts +++ b/packages/compass-e2e-tests/tests/connection-form.test.ts @@ -8,7 +8,6 @@ import { screenshotIfFailed, skipForWeb, TEST_COMPASS_WEB, - TEST_MULTIPLE_CONNECTIONS, } from '../helpers/compass'; import type { Compass } from '../helpers/compass'; import * as Selectors from '../helpers/selectors'; @@ -64,13 +63,10 @@ describe('Connection form', function () { readPreference: 'defaultReadPreference', fleStoreCredentials: false, fleEncryptedFieldsMap: DEFAULT_FLE_ENCRYPTED_FIELDS_MAP, + connectionColor: 'no-color', + connectionFavorite: false, }; - if (TEST_MULTIPLE_CONNECTIONS) { - expectedState.connectionColor = 'no-color'; - expectedState.connectionFavorite = false; - } - expect(state).to.deep.equal(expectedState); }); @@ -97,14 +93,11 @@ describe('Connection form', function () { readPreference: 'defaultReadPreference', fleStoreCredentials: false, fleEncryptedFieldsMap: DEFAULT_FLE_ENCRYPTED_FIELDS_MAP, + connectionName: 'localhost:27017', + connectionColor: 'no-color', + connectionFavorite: false, }; - if (TEST_MULTIPLE_CONNECTIONS) { - expectedState.connectionName = 'localhost:27017'; - expectedState.connectionColor = 'no-color'; - expectedState.connectionFavorite = false; - } - const state = await browser.getConnectFormState(); expect(state).to.deep.equal(expectedState); @@ -136,14 +129,11 @@ describe('Connection form', function () { readPreference: 'defaultReadPreference', fleStoreCredentials: false, fleEncryptedFieldsMap: DEFAULT_FLE_ENCRYPTED_FIELDS_MAP, + connectionName: 'localhost:27017,127.0.0.1:27091', + connectionColor: 'no-color', + connectionFavorite: false, }; - if (TEST_MULTIPLE_CONNECTIONS) { - expectedState.connectionName = 'localhost:27017,127.0.0.1:27091'; - expectedState.connectionColor = 'no-color'; - expectedState.connectionFavorite = false; - } - const state = await browser.getConnectFormState(); expect(state).to.deep.equal(expectedState); @@ -175,14 +165,11 @@ describe('Connection form', function () { readPreference: 'defaultReadPreference', fleStoreCredentials: false, fleEncryptedFieldsMap: DEFAULT_FLE_ENCRYPTED_FIELDS_MAP, + connectionName: 'localhost', + connectionColor: 'no-color', + connectionFavorite: false, }; - if (TEST_MULTIPLE_CONNECTIONS) { - expectedState.connectionName = 'localhost'; - expectedState.connectionColor = 'no-color'; - expectedState.connectionFavorite = false; - } - const state = await browser.getConnectFormState(); expect(state).to.deep.equal(expectedState); @@ -220,14 +207,11 @@ describe('Connection form', function () { readPreference: 'defaultReadPreference', fleStoreCredentials: false, fleEncryptedFieldsMap: DEFAULT_FLE_ENCRYPTED_FIELDS_MAP, + connectionName: 'localhost:27017', + connectionColor: 'no-color', + connectionFavorite: false, }; - if (TEST_MULTIPLE_CONNECTIONS) { - expectedState.connectionName = 'localhost:27017'; - expectedState.connectionColor = 'no-color'; - expectedState.connectionFavorite = false; - } - const state = await browser.getConnectFormState(true); expect(state).to.deep.equal(expectedState); @@ -265,14 +249,11 @@ describe('Connection form', function () { readPreference: 'defaultReadPreference', fleStoreCredentials: false, fleEncryptedFieldsMap: DEFAULT_FLE_ENCRYPTED_FIELDS_MAP, + connectionName: 'localhost:27017', + connectionColor: 'no-color', + connectionFavorite: false, }; - if (TEST_MULTIPLE_CONNECTIONS) { - expectedState.connectionName = 'localhost:27017'; - expectedState.connectionColor = 'no-color'; - expectedState.connectionFavorite = false; - } - await browser.setValueVisible( Selectors.ConnectionFormStringInput, connectionString @@ -318,14 +299,11 @@ describe('Connection form', function () { readPreference: 'defaultReadPreference', fleStoreCredentials: false, fleEncryptedFieldsMap: DEFAULT_FLE_ENCRYPTED_FIELDS_MAP, + connectionName: 'localhost:27017', + connectionColor: 'no-color', + connectionFavorite: false, }; - if (TEST_MULTIPLE_CONNECTIONS) { - expectedState.connectionName = 'localhost:27017'; - expectedState.connectionColor = 'no-color'; - expectedState.connectionFavorite = false; - } - const state = await browser.getConnectFormState(); expect(state).to.deep.equal(expectedState); @@ -360,14 +338,11 @@ describe('Connection form', function () { readPreference: 'defaultReadPreference', fleStoreCredentials: false, fleEncryptedFieldsMap: DEFAULT_FLE_ENCRYPTED_FIELDS_MAP, + connectionName: 'localhost:27017', + connectionColor: 'no-color', + connectionFavorite: false, }; - if (TEST_MULTIPLE_CONNECTIONS) { - expectedState.connectionName = 'localhost:27017'; - expectedState.connectionColor = 'no-color'; - expectedState.connectionFavorite = false; - } - const state = await browser.getConnectFormState(true); expect(state).to.deep.equal(expectedState); @@ -404,14 +379,11 @@ describe('Connection form', function () { readPreference: 'defaultReadPreference', fleStoreCredentials: false, fleEncryptedFieldsMap: DEFAULT_FLE_ENCRYPTED_FIELDS_MAP, + connectionName: 'localhost:27017', + connectionColor: 'no-color', + connectionFavorite: false, }; - if (TEST_MULTIPLE_CONNECTIONS) { - expectedState.connectionName = 'localhost:27017'; - expectedState.connectionColor = 'no-color'; - expectedState.connectionFavorite = false; - } - const state = await browser.getConnectFormState(true); expect(state).to.deep.equal(expectedState); @@ -450,14 +422,11 @@ describe('Connection form', function () { readPreference: 'defaultReadPreference', fleStoreCredentials: false, fleEncryptedFieldsMap: DEFAULT_FLE_ENCRYPTED_FIELDS_MAP, + connectionName: 'localhost:27017', + connectionColor: 'no-color', + connectionFavorite: false, }; - if (TEST_MULTIPLE_CONNECTIONS) { - expectedState.connectionName = 'localhost:27017'; - expectedState.connectionColor = 'no-color'; - expectedState.connectionFavorite = false; - } - const state = await browser.getConnectFormState(true); expect(state).to.deep.equal(expectedState); @@ -497,14 +466,11 @@ describe('Connection form', function () { }, fleStoreCredentials: false, fleEncryptedFieldsMap: DEFAULT_FLE_ENCRYPTED_FIELDS_MAP, + connectionName: 'localhost:27017', + connectionColor: 'no-color', + connectionFavorite: false, }; - if (TEST_MULTIPLE_CONNECTIONS) { - expectedState.connectionName = 'localhost:27017'; - expectedState.connectionColor = 'no-color'; - expectedState.connectionFavorite = false; - } - const state = await browser.getConnectFormState(); expect(state).to.deep.equal(expectedState); @@ -544,13 +510,10 @@ describe('Connection form', function () { readPreference: 'defaultReadPreference', fleStoreCredentials: false, fleEncryptedFieldsMap: DEFAULT_FLE_ENCRYPTED_FIELDS_MAP, + connectionColor: 'no-color', + connectionFavorite: false, }; - if (TEST_MULTIPLE_CONNECTIONS) { - expectedState.connectionColor = 'no-color'; - expectedState.connectionFavorite = false; - } - expect(await browser.getConnectFormState()).to.deep.equal(expectedState); }); @@ -590,13 +553,10 @@ describe('Connection form', function () { readPreference: 'defaultReadPreference', fleStoreCredentials: false, fleEncryptedFieldsMap: DEFAULT_FLE_ENCRYPTED_FIELDS_MAP, + connectionColor: 'no-color', + connectionFavorite: false, }; - if (TEST_MULTIPLE_CONNECTIONS) { - expectedState.connectionColor = 'no-color'; - expectedState.connectionFavorite = false; - } - expect(await browser.getConnectFormState()).to.deep.equal(expectedState); }); @@ -634,14 +594,11 @@ describe('Connection form', function () { readPreference: 'defaultReadPreference', fleStoreCredentials: false, fleEncryptedFieldsMap: DEFAULT_FLE_ENCRYPTED_FIELDS_MAP, + connectionName: 'localhost:27017', + connectionColor: 'no-color', + connectionFavorite: false, }; - if (TEST_MULTIPLE_CONNECTIONS) { - expectedState.connectionName = 'localhost:27017'; - expectedState.connectionColor = 'no-color'; - expectedState.connectionFavorite = false; - } - const state = await browser.getConnectFormState(false); expect(state).to.deep.equal(expectedState); @@ -656,15 +613,10 @@ describe('Connection form', function () { const favoriteName = 'My Favorite'; const newFavoriteName = 'My Favorite (edited)'; - const Sidebar = TEST_MULTIPLE_CONNECTIONS - ? Selectors.Multiple - : Selectors.Single; + const Sidebar = Selectors.Multiple; // save - await browser.saveFavorite( - favoriteName, - TEST_MULTIPLE_CONNECTIONS ? 'Green' : 'color1' - ); + await browser.saveFavorite(favoriteName, 'Green'); if (process.env.COMPASS_E2E_DISABLE_CLIPBOARD_USAGE !== 'true') { // copy the connection string @@ -689,9 +641,7 @@ describe('Connection form', function () { ); // duplicating opens the modal, in multiple connections you have to save - if (TEST_MULTIPLE_CONNECTIONS) { - await browser.clickVisible(Selectors.ConnectionModalSaveButton); - } + await browser.clickVisible(Selectors.ConnectionModalSaveButton); // delete the duplicate await browser.selectConnectionMenuItem( @@ -702,10 +652,7 @@ describe('Connection form', function () { // edit the original await browser.selectConnection(favoriteName); - await browser.saveFavorite( - newFavoriteName, - TEST_MULTIPLE_CONNECTIONS ? 'Pink' : 'color2' - ); + await browser.saveFavorite(newFavoriteName, 'Pink'); // it should now be updated in the sidebar await browser @@ -713,9 +660,7 @@ describe('Connection form', function () { .waitForDisplayed(); // open the modal so we can perform some actions in there - if (TEST_MULTIPLE_CONNECTIONS) { - await browser.selectConnection(newFavoriteName); - } + await browser.selectConnection(newFavoriteName); // the edit the connection string toggle should be on (because this is a new connection we just saved) const toggle = await browser.$(Selectors.EditConnectionStringToggle); @@ -761,14 +706,11 @@ describe('Connection form', function () { readPreference: 'defaultReadPreference', fleStoreCredentials: false, fleEncryptedFieldsMap: DEFAULT_FLE_ENCRYPTED_FIELDS_MAP, + connectionName: 'localhost:27017', + connectionColor: 'no-color', + connectionFavorite: false, }; - if (TEST_MULTIPLE_CONNECTIONS) { - expectedState.connectionName = 'localhost:27017'; - expectedState.connectionColor = 'no-color'; - expectedState.connectionFavorite = false; - } - const state = await browser.getConnectFormState(true); expect(state).to.deep.equal(expectedState); @@ -781,13 +723,7 @@ describe('Connection form', function () { ); }); - it('supports saving a favorite (multiple connections)', async function () { - if (!TEST_MULTIPLE_CONNECTIONS) { - // this will remain skipped until we remove the test because the test is - // now for the multiple connections case only - this.skip(); - } - + it('supports saving a favorite', async function () { const state: ConnectFormState = { connectionName: 'my-connection', connectionColor: 'Red', @@ -815,51 +751,4 @@ describe('Connection form', function () { tlsInsecure: false, }); }); - - it('supports saving a favorite (single connection)', async function () { - if (TEST_MULTIPLE_CONNECTIONS) { - // this will remain skipped until we remove the test because the test is - // now for the single connection case only - this.skip(); - } - - const favoriteName = 'My New Favorite'; - - // Fill in a valid URI - await browser.setValueVisible( - Selectors.ConnectionFormStringInput, - 'mongodb://127.0.0.1:27091/test' - ); - - // Save & Connect - await browser.clickVisible(Selectors.SaveAndConnectButton); - - // Fill out the favorite info - await browser.$(Selectors.FavoriteModal).waitForDisplayed(); - await browser.setValueVisible(Selectors.FavoriteNameInput, favoriteName); - await browser.clickVisible( - `${Selectors.FavoriteColorSelector} [data-testid="color-pick-color2"]` - ); - - // The modal's button text should read Save & Connect and not the default Save - expect(await browser.$(Selectors.FavoriteSaveButton).getText()).to.equal( - 'Save & Connect' - ); - - await browser.$(Selectors.FavoriteSaveButton).waitForEnabled(); - - await browser.clickVisible(Selectors.FavoriteSaveButton); - await browser.$(Selectors.FavoriteModal).waitForExist({ reverse: true }); - - // Wait for it to connect - const element = await browser.$(Selectors.MyQueriesList); - await element.waitForDisplayed(); - - // It should use the new favorite name as the connection name in the top-left corner - expect(await browser.$(Selectors.SidebarTitle).getText()).to.equal( - favoriteName - ); - - await browser.disconnectAll(); - }); }); diff --git a/packages/compass-e2e-tests/tests/connection.test.ts b/packages/compass-e2e-tests/tests/connection.test.ts index b5477f5151e..36b7fdc725b 100644 --- a/packages/compass-e2e-tests/tests/connection.test.ts +++ b/packages/compass-e2e-tests/tests/connection.test.ts @@ -13,7 +13,6 @@ import { serverSatisfies, skipForWeb, TEST_COMPASS_WEB, - TEST_MULTIPLE_CONNECTIONS, connectionNameFromString, DEFAULT_CONNECTION_NAME_1, MONGODB_TEST_SERVER_PORT, @@ -197,27 +196,19 @@ async function assertCannotCreateDb( dbName: string, collectionName: string ): Promise { - const Sidebar = TEST_MULTIPLE_CONNECTIONS - ? Selectors.Multiple - : Selectors.Single; - - if (TEST_MULTIPLE_CONNECTIONS) { - // navigate to the databases tab so that the connection is - // active/highlighted and then the add button and three dot menu will - // display without needing to hover - await browser.navigateToConnectionTab(connectionName, 'Databases'); - } + const Sidebar = Selectors.Multiple; + + // navigate to the databases tab so that the connection is + // active/highlighted and then the add button and three dot menu will + // display without needing to hover + await browser.navigateToConnectionTab(connectionName, 'Databases'); // open the create database modal from the sidebar - if (TEST_MULTIPLE_CONNECTIONS) { - await browser.selectConnectionMenuItem( - connectionName, - Sidebar.CreateDatabaseButton, - false - ); - } else { - await browser.clickVisible(Sidebar.CreateDatabaseButton); - } + await browser.selectConnectionMenuItem( + connectionName, + Sidebar.CreateDatabaseButton, + false + ); const createModalElement = await browser.$(Selectors.CreateDatabaseModal); await createModalElement.waitForDisplayed(); @@ -333,32 +324,23 @@ describe('Connection string', function () { ); // check the error - if (TEST_MULTIPLE_CONNECTIONS) { - const toastTitle = await browser.$(Selectors.LGToastTitle).getText(); - expect(toastTitle).to.equal('Authentication failed.'); + const toastTitle = await browser.$(Selectors.LGToastTitle).getText(); + expect(toastTitle).to.equal('Authentication failed.'); - const errorMessage = await browser - .$(Selectors.ConnectionToastErrorText) - .getText(); - expect(errorMessage).to.equal( - 'There was a problem connecting to 127.0.0.1:27091' - ); - } else { - const errorMessage = await browser - .$(Selectors.ConnectionFormErrorMessage) - .getText(); - expect(errorMessage).to.equal('Authentication failed.'); - } + const errorMessage = await browser + .$(Selectors.ConnectionToastErrorText) + .getText(); + expect(errorMessage).to.equal( + 'There was a problem connecting to 127.0.0.1:27091' + ); // for multiple connections click the review button in the toast - if (TEST_MULTIPLE_CONNECTIONS) { - await browser.clickVisible(Selectors.ConnectionToastErrorReviewButton); - await browser.$(Selectors.ConnectionModal).waitForDisplayed(); - const errorText = await browser - .$(Selectors.ConnectionFormErrorMessage) - .getText(); - expect(errorText).to.equal('Authentication failed.'); - } + await browser.clickVisible(Selectors.ConnectionToastErrorReviewButton); + await browser.$(Selectors.ConnectionModal).waitForDisplayed(); + const errorText = await browser + .$(Selectors.ConnectionFormErrorMessage) + .getText(); + expect(errorText).to.equal('Authentication failed.'); }); it('can connect to an Atlas replicaset without srv', async function () { @@ -929,10 +911,6 @@ describe('Connection form', function () { }); it('fails for multiple authentication errors', async function () { - if (!TEST_MULTIPLE_CONNECTIONS) { - this.skip(); - } - const connection1Name = 'error-1'; const connection2Name = 'error-2'; diff --git a/packages/compass-e2e-tests/tests/force-connection-options.test.ts b/packages/compass-e2e-tests/tests/force-connection-options.test.ts index 1fcba173446..228cef005b3 100644 --- a/packages/compass-e2e-tests/tests/force-connection-options.test.ts +++ b/packages/compass-e2e-tests/tests/force-connection-options.test.ts @@ -6,7 +6,6 @@ import { positionalArgs, skipForWeb, TEST_COMPASS_WEB, - TEST_MULTIPLE_CONNECTIONS, Selectors, connectionNameFromString, } from '../helpers/compass'; @@ -42,10 +41,8 @@ describe('forceConnectionOptions', function () { }); it('forces the value of a specific connection option', async function () { - if (TEST_MULTIPLE_CONNECTIONS) { - // open the connection modal because that's where the warnings will be displayed - await browser.clickVisible(Selectors.Multiple.SidebarNewConnectionButton); - } + // open the connection modal because that's where the warnings will be displayed + await browser.clickVisible(Selectors.Multiple.SidebarNewConnectionButton); await browser.waitUntil( async () => { @@ -63,10 +60,8 @@ describe('forceConnectionOptions', function () { } ); - if (TEST_MULTIPLE_CONNECTIONS) { - // close the modal again so connectWithConnectionString sees the expected state - await browser.clickVisible(Selectors.ConnectionModalCloseButton); - } + // close the modal again so connectWithConnectionString sees the expected state + await browser.clickVisible(Selectors.ConnectionModalCloseButton); const connectionString = 'mongodb://127.0.0.1:27091/?appName=userSpecifiedAppName'; diff --git a/packages/compass-e2e-tests/tests/import-export-connections.test.ts b/packages/compass-e2e-tests/tests/import-export-connections.test.ts index 3edf8bd8c11..9848f290f77 100644 --- a/packages/compass-e2e-tests/tests/import-export-connections.test.ts +++ b/packages/compass-e2e-tests/tests/import-export-connections.test.ts @@ -1,10 +1,6 @@ import { expect } from 'chai'; import type { Compass } from '../helpers/compass'; -import { - TEST_MULTIPLE_CONNECTIONS, - screenshotIfFailed, - skipForWeb, -} from '../helpers/compass'; +import { screenshotIfFailed, skipForWeb } from '../helpers/compass'; import { init, cleanup, @@ -117,22 +113,13 @@ describe('Connection Import / Export', function () { : connectionString; expect(cs).to.equal(expected); - if (TEST_MULTIPLE_CONNECTIONS) { - // close the modal again so connectWithConnectionString sees the expected state - await browser.clickVisible(Selectors.ConnectionModalCloseButton); - - await browser.selectConnectionMenuItem( - favoriteName, - Selectors.Multiple.RemoveConnectionItem - ); - } else { - await browser.selectConnection(favoriteName); + // close the modal again so connectWithConnectionString sees the expected state + await browser.clickVisible(Selectors.ConnectionModalCloseButton); - await browser.selectConnectionMenuItem( - favoriteName, - Selectors.Single.RemoveConnectionItem - ); - } + await browser.selectConnectionMenuItem( + favoriteName, + Selectors.Multiple.RemoveConnectionItem + ); await waitForConnections(); } @@ -160,12 +147,10 @@ describe('Connection Import / Export', function () { try { const { browser } = compass; - if (TEST_MULTIPLE_CONNECTIONS) { - // open the connection modal so we can fill in the connection string - await browser.clickVisible( - Selectors.Multiple.SidebarNewConnectionButton - ); - } + // open the connection modal so we can fill in the connection string + await browser.clickVisible( + Selectors.Multiple.SidebarNewConnectionButton + ); await browser.setValueVisible( Selectors.ConnectionFormStringInput, @@ -173,10 +158,7 @@ describe('Connection Import / Export', function () { ); await waitForConnections(); - await browser.saveFavorite( - favoriteName, - TEST_MULTIPLE_CONNECTIONS ? 'Orange' : 'color3' - ); + await browser.saveFavorite(favoriteName, 'Orange'); await waitForConnections(); } finally { await cleanup(compass); @@ -213,19 +195,10 @@ describe('Connection Import / Export', function () { ); try { const { browser } = compass; - if (TEST_MULTIPLE_CONNECTIONS) { - await browser.selectConnectionMenuItem( - favoriteName, - Selectors.Multiple.RemoveConnectionItem - ); - } else { - await browser.selectConnection(favoriteName); - - await browser.selectConnectionMenuItem( - favoriteName, - Selectors.Single.RemoveConnectionItem - ); - } + await browser.selectConnectionMenuItem( + favoriteName, + Selectors.Multiple.RemoveConnectionItem + ); await waitForConnections(); } finally { await cleanup(compass); @@ -277,12 +250,8 @@ describe('Connection Import / Export', function () { compass = await init(this.test?.fullTitle(), { firstRun: false }); browser = compass.browser; - if (TEST_MULTIPLE_CONNECTIONS) { - // open the connection modal so we can fill in the connection string - await browser.clickVisible( - Selectors.Multiple.SidebarNewConnectionButton - ); - } + // open the connection modal so we can fill in the connection string + await browser.clickVisible(Selectors.Multiple.SidebarNewConnectionButton); await browser.setValueVisible( Selectors.ConnectionFormStringInput, @@ -291,10 +260,7 @@ describe('Connection Import / Export', function () { await waitForConnections(); - await browser.saveFavorite( - favoriteName, - TEST_MULTIPLE_CONNECTIONS ? 'Orange' : 'color3' - ); + await browser.saveFavorite(favoriteName, 'Orange'); // again: make sure the new favourite is there await waitForConnections(); @@ -310,9 +276,7 @@ describe('Connection Import / Export', function () { for (const variant of variants) { it(`supports exporting and importing connections in ${variant} mode`, async function () { - const Sidebar = TEST_MULTIPLE_CONNECTIONS - ? Selectors.Multiple - : Selectors.Single; + const Sidebar = Selectors.Multiple; { // Make sure file exists so that the file picker works. We could also do work diff --git a/packages/compass-e2e-tests/tests/in-use-encryption.test.ts b/packages/compass-e2e-tests/tests/in-use-encryption.test.ts index 1203a249b3c..64416693e11 100644 --- a/packages/compass-e2e-tests/tests/in-use-encryption.test.ts +++ b/packages/compass-e2e-tests/tests/in-use-encryption.test.ts @@ -6,7 +6,6 @@ import { screenshotIfFailed, serverSatisfies, skipForWeb, - TEST_MULTIPLE_CONNECTIONS, } from '../helpers/compass'; import type { Compass } from '../helpers/compass'; import * as Selectors from '../helpers/selectors'; @@ -24,14 +23,10 @@ async function refresh(browser: CompassBrowser, connectionName: string) { // hit refresh, then wait for a transition to occur that will correlate to the // data actually being refreshed and arriving. - if (TEST_MULTIPLE_CONNECTIONS) { - await browser.selectConnectionMenuItem( - connectionName, - Selectors.Multiple.RefreshDatabasesItem - ); - } else { - await browser.clickVisible(Selectors.Single.RefreshDatabasesButton); - } + await browser.selectConnectionMenuItem( + connectionName, + Selectors.Multiple.RefreshDatabasesItem + ); } /** @@ -118,41 +113,16 @@ describe('CSFLE / QE', function () { }; // Save & Connect - if (TEST_MULTIPLE_CONNECTIONS) { - // in the multiple connections world the favorite form fields are just - // part of the connection form - options.connectionName = connectionName; - options.connectionColor = 'color1'; - options.connectionFavorite = true; - - await browser.setConnectFormState(options); - - await browser.clickVisible(Selectors.ConnectionModalConnectButton); - } else { - // in the single connections world the favorite form fields are in a - // separate modal - await browser.setConnectFormState(options); - await browser.clickVisible(Selectors.SaveAndConnectButton); - await browser.$(Selectors.FavoriteModal).waitForDisplayed(); - await browser.setValueVisible( - Selectors.FavoriteNameInput, - connectionName - ); - await browser.clickVisible( - `${Selectors.FavoriteColorSelector} [data-testid="color-pick-color2"]` - ); - // The modal's button text should read Save & Connect and not the default Save - expect( - await browser.$(Selectors.FavoriteSaveButton).getText() - ).to.equal('Save & Connect'); + // in the multiple connections world the favorite form fields are just + // part of the connection form + options.connectionName = connectionName; + options.connectionColor = 'color1'; + options.connectionFavorite = true; - await browser.$(Selectors.FavoriteSaveButton).waitForEnabled(); - await browser.clickVisible(Selectors.FavoriteSaveButton); - await browser - .$(Selectors.FavoriteModal) - .waitForExist({ reverse: true }); - } + await browser.setConnectFormState(options); + + await browser.clickVisible(Selectors.ConnectionModalConnectButton); // Wait for it to connect await browser.waitForConnectionResult(connectionName, { @@ -172,27 +142,17 @@ describe('CSFLE / QE', function () { // extra pause to make very sure that it loaded the connections await delay(10000); - if (TEST_MULTIPLE_CONNECTIONS) { - // in the multiple connections world, if we clicked the connection it - // would connect and that's not what we want in this case. So we select - // edit from the menu. - await browser.selectConnectionMenuItem( - connectionName, - Selectors.Multiple.EditConnectionItem - ); - } else { - // in the single connections world, clicking the favorite connection in - // the sidebar doesn't connect, it just pre-populates the form - await browser.clickVisible( - Selectors.sidebarConnectionButton(connectionName) - ); - } + // in the multiple connections world, if we clicked the connection it + // would connect and that's not what we want in this case. So we select + // edit from the menu. + await browser.selectConnectionMenuItem( + connectionName, + Selectors.Multiple.EditConnectionItem + ); // The modal should appear and the title of the modal should be the favorite name await browser.waitUntil(async () => { - const connectionTitleSelector = TEST_MULTIPLE_CONNECTIONS - ? Selectors.ConnectionModalTitle - : Selectors.ConnectionTitle; + const connectionTitleSelector = Selectors.ConnectionModalTitle; const text = await browser.$(connectionTitleSelector).getText(); return text === connectionName; }); @@ -905,16 +865,12 @@ describe('CSFLE / QE', function () { name: '"Person Z"', }); - if (TEST_MULTIPLE_CONNECTIONS) { - await browser.clickVisible( - Selectors.sidebarConnectionActionButton( - connectionName, - Selectors.Multiple.InUseEncryptionMarker - ) - ); - } else { - await browser.clickVisible(Selectors.Single.InUseEncryptionMarker); - } + await browser.clickVisible( + Selectors.sidebarConnectionActionButton( + connectionName, + Selectors.Multiple.InUseEncryptionMarker + ) + ); await browser.$(Selectors.CSFLEConnectionModal).waitForDisplayed(); @@ -935,16 +891,12 @@ describe('CSFLE / QE', function () { name: '"Person Z"', }); - if (TEST_MULTIPLE_CONNECTIONS) { - await browser.clickVisible( - Selectors.sidebarConnectionActionButton( - connectionName, - Selectors.Multiple.InUseEncryptionMarker - ) - ); - } else { - await browser.clickVisible(Selectors.Single.InUseEncryptionMarker); - } + await browser.clickVisible( + Selectors.sidebarConnectionActionButton( + connectionName, + Selectors.Multiple.InUseEncryptionMarker + ) + ); await browser.$(Selectors.CSFLEConnectionModal).waitForDisplayed(); diff --git a/packages/compass-e2e-tests/tests/instance-sidebar.test.ts b/packages/compass-e2e-tests/tests/instance-sidebar.test.ts index 0eba8eeb5b6..84feba70b89 100644 --- a/packages/compass-e2e-tests/tests/instance-sidebar.test.ts +++ b/packages/compass-e2e-tests/tests/instance-sidebar.test.ts @@ -7,7 +7,6 @@ import { screenshotIfFailed, DEFAULT_CONNECTION_STRING_1, skipForWeb, - TEST_MULTIPLE_CONNECTIONS, DEFAULT_CONNECTION_NAME_1, } from '../helpers/compass'; import type { Compass } from '../helpers/compass'; @@ -47,15 +46,10 @@ describe('Instance sidebar', function () { it('has a connection info modal with connection info', async function () { skipForWeb(this, "these actions don't exist in compass-web"); - if (TEST_MULTIPLE_CONNECTIONS) { - await browser.selectConnectionMenuItem( - DEFAULT_CONNECTION_NAME_1, - Selectors.Multiple.ClusterInfoItem - ); - } else { - await browser.clickVisible(Selectors.Single.ShowTitleActionsButton); - await browser.clickVisible(Selectors.Single.ClusterInfoItem); - } + await browser.selectConnectionMenuItem( + DEFAULT_CONNECTION_NAME_1, + Selectors.Multiple.ClusterInfoItem + ); const modal = await browser.$(Selectors.ConnectionInfoModal); await modal.waitForDisplayed(); @@ -116,10 +110,8 @@ describe('Instance sidebar', function () { await browser.waitUntil(async () => { const treeItems = await browser.$$(Selectors.SidebarTreeItems); // connection, database, collection for multiple connections (twice - // because there are two connections), otherwise just database and - // collection - const expectedCount = TEST_MULTIPLE_CONNECTIONS ? 6 : 2; - return treeItems.length === expectedCount; + // because there are two connections) + return treeItems.length === 6; }); const dbElement = await browser.$( @@ -155,33 +147,25 @@ describe('Instance sidebar', function () { // TODO(COMPASS-7086): flaky test this.retries(5); - const Sidebar = TEST_MULTIPLE_CONNECTIONS - ? Selectors.Multiple - : Selectors.Single; + const Sidebar = Selectors.Multiple; const dbName = `my-sidebar-database-${Date.now()}`; const collectionName = 'my-collection'; - if (TEST_MULTIPLE_CONNECTIONS) { - // navigate to the databases tab so that the connection is - // active/highlighted and then the add button and three dot menu will - // display without needing to hover - await browser.navigateToConnectionTab( - DEFAULT_CONNECTION_NAME_1, - 'Databases' - ); - } + // navigate to the databases tab so that the connection is + // active/highlighted and then the add button and three dot menu will + // display without needing to hover + await browser.navigateToConnectionTab( + DEFAULT_CONNECTION_NAME_1, + 'Databases' + ); // open the create database modal from the sidebar - if (TEST_MULTIPLE_CONNECTIONS) { - await browser.selectConnectionMenuItem( - DEFAULT_CONNECTION_NAME_1, - Sidebar.CreateDatabaseButton, - false - ); - } else { - await browser.clickVisible(Sidebar.CreateDatabaseButton); - } + await browser.selectConnectionMenuItem( + DEFAULT_CONNECTION_NAME_1, + Sidebar.CreateDatabaseButton, + false + ); await browser.addDatabase(dbName, collectionName); @@ -256,14 +240,10 @@ describe('Instance sidebar', function () { await mongoClient.close(); } - if (TEST_MULTIPLE_CONNECTIONS) { - await browser.selectConnectionMenuItem( - DEFAULT_CONNECTION_NAME_1, - Selectors.Multiple.RefreshDatabasesItem - ); - } else { - await browser.clickVisible(Selectors.Single.RefreshDatabasesButton); - } + await browser.selectConnectionMenuItem( + DEFAULT_CONNECTION_NAME_1, + Selectors.Multiple.RefreshDatabasesItem + ); // wait for the new collection we added via the driver to appear. const newCollectionElement = await browser.$( diff --git a/packages/compass-e2e-tests/tests/logging.test.ts b/packages/compass-e2e-tests/tests/logging.test.ts index 99a06feb216..65658b6772a 100644 --- a/packages/compass-e2e-tests/tests/logging.test.ts +++ b/packages/compass-e2e-tests/tests/logging.test.ts @@ -4,7 +4,6 @@ import { cleanup, screenshotIfFailed, skipForWeb, - TEST_MULTIPLE_CONNECTIONS, DEFAULT_CONNECTION_NAME_1, } from '../helpers/compass'; import type { Compass } from '../helpers/compass'; @@ -28,10 +27,8 @@ describe('Logging and Telemetry integration', function () { try { await browser.connectWithConnectionString(); - if (TEST_MULTIPLE_CONNECTIONS) { - // make sure we generate the screen event that the tests expect - await browser.navigateToMyQueries(); - } + // make sure we generate the screen event that the tests expect + await browser.navigateToMyQueries(); await browser.shellEval(DEFAULT_CONNECTION_NAME_1, 'use test'); await browser.shellEval( diff --git a/packages/compass-e2e-tests/tests/my-queries-tab.test.ts b/packages/compass-e2e-tests/tests/my-queries-tab.test.ts index f9a569c1c13..891577ab9ae 100644 --- a/packages/compass-e2e-tests/tests/my-queries-tab.test.ts +++ b/packages/compass-e2e-tests/tests/my-queries-tab.test.ts @@ -6,7 +6,6 @@ import { cleanup, screenshotIfFailed, skipForWeb, - TEST_MULTIPLE_CONNECTIONS, DEFAULT_CONNECTION_NAME_1, DEFAULT_CONNECTION_STRING_1, DEFAULT_CONNECTION_STRING_2, @@ -169,10 +168,8 @@ describe('My Queries tab', function () { client_1 = new MongoClient(DEFAULT_CONNECTION_STRING_1); await client_1.connect(); - if (TEST_MULTIPLE_CONNECTIONS) { - client_2 = new MongoClient(DEFAULT_CONNECTION_STRING_2); - await client_2.connect(); - } + client_2 = new MongoClient(DEFAULT_CONNECTION_STRING_2); + await client_2.connect(); }); beforeEach(async function () { await createNumbersCollection(); @@ -261,17 +258,13 @@ describe('My Queries tab', function () { .db('test') .renameCollection('numbers', 'numbers-renamed'); - if (TEST_MULTIPLE_CONNECTIONS) { - await browser.selectConnectionMenuItem( - DEFAULT_CONNECTION_NAME_1, - Selectors.Multiple.RefreshDatabasesItem - ); + await browser.selectConnectionMenuItem( + DEFAULT_CONNECTION_NAME_1, + Selectors.Multiple.RefreshDatabasesItem + ); - // go to My Queries because for multiple connections it is not the default tab - await browser.navigateToMyQueries(); - } else { - await browser.clickVisible(Selectors.Single.RefreshDatabasesButton); - } + // go to My Queries because for multiple connections it is not the default tab + await browser.navigateToMyQueries(); // browse to the query await browser.clickVisible( @@ -398,14 +391,10 @@ describe('My Queries tab', function () { .db('test') .renameCollection('numbers', newCollectionName); - if (TEST_MULTIPLE_CONNECTIONS) { - await browser.selectConnectionMenuItem( - DEFAULT_CONNECTION_NAME_1, - Selectors.Multiple.RefreshDatabasesItem - ); - } else { - await browser.clickVisible(Selectors.Single.RefreshDatabasesButton); - } + await browser.selectConnectionMenuItem( + DEFAULT_CONNECTION_NAME_1, + Selectors.Multiple.RefreshDatabasesItem + ); await browser.navigateToMyQueries(); // browse to the query @@ -447,10 +436,6 @@ describe('My Queries tab', function () { 'when a user has multiple connections and only one contains the namespace', function () { it('uses the connection that contains the namespace used by the aggregation/query', async function () { - if (!TEST_MULTIPLE_CONNECTIONS) { - this.skip(); - } - await browser.connectToDefaults(); const favoriteQueryName = 'only one with namespace'; @@ -466,14 +451,10 @@ describe('My Queries tab', function () { await client_1.db('test').dropCollection('numbers'); - if (TEST_MULTIPLE_CONNECTIONS) { - await browser.selectConnectionMenuItem( - DEFAULT_CONNECTION_NAME_1, - Selectors.Multiple.RefreshDatabasesItem - ); - } else { - await browser.clickVisible(Selectors.Single.RefreshDatabasesButton); - } + await browser.selectConnectionMenuItem( + DEFAULT_CONNECTION_NAME_1, + Selectors.Multiple.RefreshDatabasesItem + ); await browser.navigateToMyQueries(); @@ -496,9 +477,6 @@ describe('My Queries tab', function () { 'when a user has multiple connections and none of them contain the namespace', function () { it('opens a modal where users can select a connection and permanently associate a new namespace for an aggregation/query', async function () { - if (!TEST_MULTIPLE_CONNECTIONS) { - this.skip(); - } const newCollectionName = 'numbers-renamed'; await browser.connectToDefaults(); @@ -519,18 +497,14 @@ describe('My Queries tab', function () { .db('test') .renameCollection('numbers', newCollectionName); - if (TEST_MULTIPLE_CONNECTIONS) { - await browser.selectConnectionMenuItem( - DEFAULT_CONNECTION_NAME_1, - Selectors.Multiple.RefreshDatabasesItem - ); - await browser.selectConnectionMenuItem( - DEFAULT_CONNECTION_NAME_2, - Selectors.Multiple.RefreshDatabasesItem - ); - } else { - await browser.clickVisible(Selectors.Single.RefreshDatabasesButton); - } + await browser.selectConnectionMenuItem( + DEFAULT_CONNECTION_NAME_1, + Selectors.Multiple.RefreshDatabasesItem + ); + await browser.selectConnectionMenuItem( + DEFAULT_CONNECTION_NAME_2, + Selectors.Multiple.RefreshDatabasesItem + ); await browser.navigateToMyQueries(); @@ -572,10 +546,6 @@ describe('My Queries tab', function () { 'when a user has multiple connections that contain the same namespace', function () { it('opens a modal where users can select the connection to use for an aggregation/query', async function () { - if (!TEST_MULTIPLE_CONNECTIONS) { - this.skip(); - } - await browser.connectToDefaults(); const favoriteQueryName = 'all with namespace'; @@ -589,18 +559,14 @@ describe('My Queries tab', function () { favoriteQueryName ); - if (TEST_MULTIPLE_CONNECTIONS) { - await browser.selectConnectionMenuItem( - DEFAULT_CONNECTION_NAME_1, - Selectors.Multiple.RefreshDatabasesItem - ); - await browser.selectConnectionMenuItem( - DEFAULT_CONNECTION_NAME_2, - Selectors.Multiple.RefreshDatabasesItem - ); - } else { - await browser.clickVisible(Selectors.Single.RefreshDatabasesButton); - } + await browser.selectConnectionMenuItem( + DEFAULT_CONNECTION_NAME_1, + Selectors.Multiple.RefreshDatabasesItem + ); + await browser.selectConnectionMenuItem( + DEFAULT_CONNECTION_NAME_2, + Selectors.Multiple.RefreshDatabasesItem + ); await browser.navigateToMyQueries(); diff --git a/packages/compass-e2e-tests/tests/oidc.test.ts b/packages/compass-e2e-tests/tests/oidc.test.ts index c626e8aa6df..384911ef668 100644 --- a/packages/compass-e2e-tests/tests/oidc.test.ts +++ b/packages/compass-e2e-tests/tests/oidc.test.ts @@ -8,7 +8,6 @@ import { skipForWeb, TEST_COMPASS_WEB, connectionNameFromString, - TEST_MULTIPLE_CONNECTIONS, } from '../helpers/compass'; import { setupProxyServer } from '../helpers/proxy'; import * as Selectors from '../helpers/selectors'; @@ -257,11 +256,9 @@ describe('OIDC integration', function () { } }; - if (TEST_MULTIPLE_CONNECTIONS) { - await browser.removeConnection(connectionName); - await browser.clickVisible(Selectors.Multiple.SidebarNewConnectionButton); - await browser.$(Selectors.ConnectionModal).waitForDisplayed(); - } + await browser.removeConnection(connectionName); + await browser.clickVisible(Selectors.Multiple.SidebarNewConnectionButton); + await browser.$(Selectors.ConnectionModal).waitForDisplayed(); await browser.setValueVisible( Selectors.ConnectionFormStringInput, connectionString @@ -317,11 +314,9 @@ describe('OIDC integration', function () { }; }; - if (TEST_MULTIPLE_CONNECTIONS) { - await browser.removeConnection(connectionName); - await browser.clickVisible(Selectors.Multiple.SidebarNewConnectionButton); - await browser.$(Selectors.ConnectionModal).waitForDisplayed(); - } + await browser.removeConnection(connectionName); + await browser.clickVisible(Selectors.Multiple.SidebarNewConnectionButton); + await browser.$(Selectors.ConnectionModal).waitForDisplayed(); await browser.setValueVisible( Selectors.ConnectionFormStringInput, connectionString @@ -331,16 +326,14 @@ describe('OIDC integration', function () { // wait for the token to expire (see expires_in above) await browser.pause(10_000); - if (TEST_MULTIPLE_CONNECTIONS) { - // we have to browse somewhere that will fire off commands that require - // authentication so that those commands get rejected due to the expired - // auth and then that will trigger the confirmation modal we expect. - await browser.selectConnectionMenuItem( - connectionName, - Selectors.Multiple.OpenShellItem, - false - ); - } + // we have to browse somewhere that will fire off commands that require + // authentication so that those commands get rejected due to the expired + // auth and then that will trigger the confirmation modal we expect. + await browser.selectConnectionMenuItem( + connectionName, + Selectors.Multiple.OpenShellItem, + false + ); await browser.$(Selectors.ConfirmationModal).waitForDisplayed(); const modalHeader = await browser.$(Selectors.ConfirmationModalHeading); @@ -366,11 +359,9 @@ describe('OIDC integration', function () { }; }; - if (TEST_MULTIPLE_CONNECTIONS) { - await browser.removeConnection(connectionName); - await browser.clickVisible(Selectors.Multiple.SidebarNewConnectionButton); - await browser.$(Selectors.ConnectionModal).waitForDisplayed(); - } + await browser.removeConnection(connectionName); + await browser.clickVisible(Selectors.Multiple.SidebarNewConnectionButton); + await browser.$(Selectors.ConnectionModal).waitForDisplayed(); await browser.setValueVisible( Selectors.ConnectionFormStringInput, connectionString @@ -380,16 +371,14 @@ describe('OIDC integration', function () { // wait for the token to expire (see expires_in above) await browser.pause(10_000); - if (TEST_MULTIPLE_CONNECTIONS) { - // we have to browse somewhere that will fire off commands that require - // authentication so that those commands get rejected due to the expired - // auth and then that will trigger the confirmation modal we expect - await browser.selectConnectionMenuItem( - connectionName, - Selectors.Multiple.OpenShellItem, - false - ); - } + // we have to browse somewhere that will fire off commands that require + // authentication so that those commands get rejected due to the expired + // auth and then that will trigger the confirmation modal we expect + await browser.selectConnectionMenuItem( + connectionName, + Selectors.Multiple.OpenShellItem, + false + ); await browser.$(Selectors.ConfirmationModal).waitForDisplayed(); const modalHeader = await browser.$(Selectors.ConfirmationModalHeading); diff --git a/packages/compass-e2e-tests/tests/protect-connection-strings.test.ts b/packages/compass-e2e-tests/tests/protect-connection-strings.test.ts index 2dcf921c4cd..111a57fb19a 100644 --- a/packages/compass-e2e-tests/tests/protect-connection-strings.test.ts +++ b/packages/compass-e2e-tests/tests/protect-connection-strings.test.ts @@ -4,7 +4,6 @@ import { cleanup, screenshotIfFailed, skipForWeb, - TEST_MULTIPLE_CONNECTIONS, } from '../helpers/compass'; import type { Compass } from '../helpers/compass'; import clipboard from 'clipboardy'; @@ -17,9 +16,7 @@ async function expectCopyConnectionStringToClipboard( favoriteName: string, expected: string ): Promise { - const Sidebar = TEST_MULTIPLE_CONNECTIONS - ? Selectors.Multiple - : Selectors.Single; + const Sidebar = Selectors.Multiple; if (process.env.COMPASS_E2E_DISABLE_CLIPBOARD_USAGE !== 'true') { await browser.selectConnectionMenuItem( favoriteName, @@ -81,10 +78,7 @@ describe('protectConnectionStrings', function () { defaultPassword: 'bar', }; await browser.setConnectFormState(state); - await browser.saveFavorite( - favoriteName, - TEST_MULTIPLE_CONNECTIONS ? 'Yellow' : 'color4' - ); + await browser.saveFavorite(favoriteName, 'Yellow'); await browser.selectConnection(favoriteName); expect(await browser.getConnectFormConnectionString()).to.equal( @@ -106,9 +100,7 @@ describe('protectConnectionStrings', function () { 'shows password when input is focused' ).to.equal('mongodb://foo:bar@localhost:12345/'); - if (TEST_MULTIPLE_CONNECTIONS) { - await browser.clickVisible(Selectors.ConnectionModalCloseButton); - } + await browser.clickVisible(Selectors.ConnectionModalCloseButton); await expectCopyConnectionStringToClipboard( browser, @@ -116,9 +108,7 @@ describe('protectConnectionStrings', function () { 'mongodb://foo:bar@localhost:12345/' ); - if (TEST_MULTIPLE_CONNECTIONS) { - await browser.selectConnection(favoriteName); - } + await browser.selectConnection(favoriteName); await browser.setFeature('protectConnectionStrings', true); @@ -126,9 +116,7 @@ describe('protectConnectionStrings', function () { 'mongodb://foo:*****@localhost:12345/' ); - if (TEST_MULTIPLE_CONNECTIONS) { - await browser.clickVisible(Selectors.ConnectionModalCloseButton); - } + await browser.clickVisible(Selectors.ConnectionModalCloseButton); await expectCopyConnectionStringToClipboard( browser, diff --git a/packages/compass-e2e-tests/tests/read-only.test.ts b/packages/compass-e2e-tests/tests/read-only.test.ts index 1866470ce58..893ec4edb46 100644 --- a/packages/compass-e2e-tests/tests/read-only.test.ts +++ b/packages/compass-e2e-tests/tests/read-only.test.ts @@ -3,7 +3,6 @@ import { cleanup, screenshotIfFailed, skipForWeb, - TEST_MULTIPLE_CONNECTIONS, DEFAULT_CONNECTION_NAME_1, } from '../helpers/compass'; import { expect } from 'chai'; @@ -36,36 +35,25 @@ describe('readOnly: true / Read-Only Edition', function () { }); it('hides and shows the plus icon on the sidebar to create a database', async function () { - const Sidebar = TEST_MULTIPLE_CONNECTIONS - ? Selectors.Multiple - : Selectors.Single; + const Sidebar = Selectors.Multiple; await browser.setFeature('readOnly', true); await browser.connectToDefaults(); - if (TEST_MULTIPLE_CONNECTIONS) { - // navigate to the databases tab so that the connection is - // active/highlighted and then the add button and three dot menu will - // display without needing to hover - await browser.navigateToConnectionTab( - DEFAULT_CONNECTION_NAME_1, - 'Databases' - ); - } - - if (TEST_MULTIPLE_CONNECTIONS) { - expect( - await browser.hasConnectionMenuItem( - DEFAULT_CONNECTION_NAME_1, - Sidebar.CreateDatabaseButton, - false - ) - ).to.be.equal(false); - } else { - expect( - await browser.$(Sidebar.CreateDatabaseButton).isExisting() - ).to.be.equal(false); - } + // navigate to the databases tab so that the connection is + // active/highlighted and then the add button and three dot menu will + // display without needing to hover + await browser.navigateToConnectionTab( + DEFAULT_CONNECTION_NAME_1, + 'Databases' + ); + expect( + await browser.hasConnectionMenuItem( + DEFAULT_CONNECTION_NAME_1, + Sidebar.CreateDatabaseButton, + false + ) + ).to.be.equal(false); await browser.openSettingsModal(); const settingsModal = await browser.$(Selectors.SettingsModal); await settingsModal.waitForDisplayed(); @@ -77,26 +65,18 @@ describe('readOnly: true / Read-Only Edition', function () { // wait for the modal to go away await settingsModal.waitForDisplayed({ reverse: true }); - if (TEST_MULTIPLE_CONNECTIONS) { - await browser.navigateToConnectionTab( - DEFAULT_CONNECTION_NAME_1, - 'Databases' - ); - } + await browser.navigateToConnectionTab( + DEFAULT_CONNECTION_NAME_1, + 'Databases' + ); - if (TEST_MULTIPLE_CONNECTIONS) { - expect( - await browser.hasConnectionMenuItem( - DEFAULT_CONNECTION_NAME_1, - Sidebar.CreateDatabaseButton, - false - ) - ).to.be.equal(true); - } else { - expect( - await browser.$(Sidebar.CreateDatabaseButton).isExisting() - ).to.be.equal(true); - } + expect( + await browser.hasConnectionMenuItem( + DEFAULT_CONNECTION_NAME_1, + Sidebar.CreateDatabaseButton, + false + ) + ).to.be.equal(true); }); it('shows and hides the plus icon on the siderbar to create a collection', async function () { diff --git a/packages/compass-e2e-tests/tests/shell.test.ts b/packages/compass-e2e-tests/tests/shell.test.ts index 742bb7f8acb..e7dada553fe 100644 --- a/packages/compass-e2e-tests/tests/shell.test.ts +++ b/packages/compass-e2e-tests/tests/shell.test.ts @@ -8,7 +8,6 @@ import { skipForWeb, TEST_COMPASS_WEB, DEFAULT_CONNECTION_NAME_1, - TEST_MULTIPLE_CONNECTIONS, } from '../helpers/compass'; import type { Compass } from '../helpers/compass'; import * as Selectors from '../helpers/selectors'; @@ -66,17 +65,12 @@ describe('Shell', function () { it('shows and hides shell based on settings', async function () { await browser.connectToDefaults(); - if (TEST_MULTIPLE_CONNECTIONS) { - expect( - await browser.hasConnectionMenuItem( - DEFAULT_CONNECTION_NAME_1, - Selectors.Multiple.OpenShellItem - ) - ).to.be.equal(true); - } else { - // Will fail if shell is not on the screen eventually - await browser.$(Selectors.ShellSection).waitForExist(); - } + expect( + await browser.hasConnectionMenuItem( + DEFAULT_CONNECTION_NAME_1, + Selectors.Multiple.OpenShellItem + ) + ).to.be.equal(true); await browser.openSettingsModal(); const settingsModal = await browser.$(Selectors.SettingsModal); @@ -89,16 +83,11 @@ describe('Shell', function () { // wait for the modal to go away await settingsModal.waitForDisplayed({ reverse: true }); - if (TEST_MULTIPLE_CONNECTIONS) { - expect( - await browser.hasConnectionMenuItem( - DEFAULT_CONNECTION_NAME_1, - Selectors.Multiple.OpenShellItem - ) - ).to.be.equal(false); - } else { - // Will fail if shell eventually doesn't go away from the screen - await browser.$(Selectors.ShellSection).waitForExist({ reverse: true }); - } + expect( + await browser.hasConnectionMenuItem( + DEFAULT_CONNECTION_NAME_1, + Selectors.Multiple.OpenShellItem + ) + ).to.be.equal(false); }); }); diff --git a/packages/compass-e2e-tests/tests/tabs.test.ts b/packages/compass-e2e-tests/tests/tabs.test.ts index 2e7a55ee36f..adad0084bfb 100644 --- a/packages/compass-e2e-tests/tests/tabs.test.ts +++ b/packages/compass-e2e-tests/tests/tabs.test.ts @@ -5,7 +5,6 @@ import { screenshotIfFailed, DEFAULT_CONNECTION_NAME_1, DEFAULT_CONNECTION_NAME_2, - TEST_MULTIPLE_CONNECTIONS, TEST_COMPASS_WEB, } from '../helpers/compass'; import type { Compass } from '../helpers/compass'; @@ -148,10 +147,6 @@ describe('Global Tabs', function () { }); it("should close a connection's tabs when disconnecting", async function () { - if (!TEST_MULTIPLE_CONNECTIONS) { - this.skip(); - } - // workspace 1: connection 1, Documents tab await browser.navigateToCollectionTab( DEFAULT_CONNECTION_NAME_1,