From 885dafded7b7d27b63bd05ae517c2fb5a6650dcc Mon Sep 17 00:00:00 2001 From: Le Roux Bodenstein Date: Fri, 23 Aug 2024 15:34:35 +0100 Subject: [PATCH] feat: release multiple connections COMPASS-7905 (#6138) * invert multiple vs single connections * testing single connection not possible right now * unfocus * port some connection form tests, skip some others for now * skip legacy connections tests * skip more single connection usage * skip some tests in the sidebar * skip more * skip a test in compass-shell * move enableNewMultipleConnectionSystem from a feature flag to a preference so it can be set to false in compass-web * TODO ticket numbers --- .evergreen/buildvariants-and-tasks.in.yml | 23 --------- .evergreen/buildvariants-and-tasks.yml | 49 ------------------- .evergreen/functions.yml | 24 --------- .../sc-connections-navigation-tree.spec.tsx | 3 +- .../components/legacy-connections.spec.tsx | 9 ++-- packages/compass-e2e-tests/helpers/compass.ts | 19 +------ packages/compass-e2e-tests/index.ts | 1 - .../src/feature-flags.ts | 13 ----- .../src/preferences-schema.ts | 16 +++++- packages/compass-shell/src/plugin.spec.tsx | 3 +- .../legacy/navigation-items.spec.tsx | 3 +- packages/compass/src/main/menu.spec.ts | 6 ++- .../authentication-oidc.spec.tsx | 14 ++++-- .../csfle-tab/csfle-tab.spec.tsx | 2 +- .../src/components/connection-form.spec.tsx | 25 ++++------ .../src/hooks/use-connection-color.spec.tsx | 3 +- 16 files changed, 55 insertions(+), 158 deletions(-) diff --git a/.evergreen/buildvariants-and-tasks.in.yml b/.evergreen/buildvariants-and-tasks.in.yml index 010e6b8d925..1c3989548c6 100644 --- a/.evergreen/buildvariants-and-tasks.in.yml +++ b/.evergreen/buildvariants-and-tasks.in.yml @@ -246,14 +246,6 @@ buildvariants: - name: e2e-coverage-<%= group.number %> <% } %> - - name: e2e-multiple-connections - display_name: E2E Multiple Connections - run_on: ubuntu2004-large - tasks: - <% for(const group of E2E_TEST_GROUPS) { %> - - name: e2e-multiple-connections-<%= group.number %> - <% } %> - - name: csfle-tests display_name: CSFLE Tests run_on: ubuntu2004-large @@ -340,21 +332,6 @@ tasks: debug: 'compass-e2e-tests*,electron*,hadron*,mongo*' <% } %> -<% for(const group of E2E_TEST_GROUPS) { %> - - name: e2e-multiple-connections-<%= group.number %> - tags: ['required-for-publish', 'run-on-pr'] - commands: - - func: prepare - - func: install - - func: bootstrap - - func: test-multiple-connections - vars: - e2e_test_groups: <%= E2E_TEST_GROUPS.length %> - e2e_test_group: <%= group.number %> - debug: 'compass-e2e-tests*,electron*,hadron*,mongo*' - mongodb_version: latest-enterprise -<% } %> - - name: generate-vulnerability-report tags: ['required-for-publish', 'run-on-pr'] commands: diff --git a/.evergreen/buildvariants-and-tasks.yml b/.evergreen/buildvariants-and-tasks.yml index 87aa8c6166e..c14cd01bda6 100644 --- a/.evergreen/buildvariants-and-tasks.yml +++ b/.evergreen/buildvariants-and-tasks.yml @@ -220,13 +220,6 @@ buildvariants: - name: e2e-coverage-1 - name: e2e-coverage-2 - name: e2e-coverage-3 - - name: e2e-multiple-connections - display_name: E2E Multiple Connections - run_on: ubuntu2004-large - tasks: - - name: e2e-multiple-connections-1 - - name: e2e-multiple-connections-2 - - name: e2e-multiple-connections-3 - name: csfle-tests display_name: CSFLE Tests run_on: ubuntu2004-large @@ -338,48 +331,6 @@ tasks: e2e_test_groups: 3 e2e_test_group: 3 debug: compass-e2e-tests*,electron*,hadron*,mongo* - - name: e2e-multiple-connections-1 - tags: - - required-for-publish - - run-on-pr - commands: - - func: prepare - - func: install - - func: bootstrap - - func: test-multiple-connections - vars: - e2e_test_groups: 3 - e2e_test_group: 1 - debug: compass-e2e-tests*,electron*,hadron*,mongo* - mongodb_version: latest-enterprise - - name: e2e-multiple-connections-2 - tags: - - required-for-publish - - run-on-pr - commands: - - func: prepare - - func: install - - func: bootstrap - - func: test-multiple-connections - vars: - e2e_test_groups: 3 - e2e_test_group: 2 - debug: compass-e2e-tests*,electron*,hadron*,mongo* - mongodb_version: latest-enterprise - - name: e2e-multiple-connections-3 - tags: - - required-for-publish - - run-on-pr - commands: - - func: prepare - - func: install - - func: bootstrap - - func: test-multiple-connections - vars: - e2e_test_groups: 3 - e2e_test_group: 3 - debug: compass-e2e-tests*,electron*,hadron*,mongo* - mongodb_version: latest-enterprise - name: generate-vulnerability-report tags: - required-for-publish diff --git a/.evergreen/functions.yml b/.evergreen/functions.yml index 6e4896d36dd..0e8412d7f4a 100644 --- a/.evergreen/functions.yml +++ b/.evergreen/functions.yml @@ -602,30 +602,6 @@ functions: tar czf coverage.tgz packages/compass-e2e-tests/coverage - test-multiple-connections: - - command: shell.exec - # Fail the task if it's idle for 10 mins - timeout_secs: 600 - params: - working_dir: src - shell: bash - env: - <<: *compass-env - DEBUG: ${debug|} - MONGODB_VERSION: ${mongodb_version|} - MONGODB_RUNNER_VERSION: ${mongodb_version|} - E2E_TEST_GROUPS: ${e2e_test_groups} - E2E_TEST_GROUP: ${e2e_test_group} - HADRON_DISTRIBUTION: compass - script: | - set -e - # Load environment variables - eval $(.evergreen/print-compass-env.sh) - - echo "Running E2E tests for multiple connections" - - npm run --unsafe-perm --workspace compass-e2e-tests test-ci -- -- --test-multiple-connections - test-packaged-app: - command: shell.exec # Fail the task if it's idle for 10 mins diff --git a/packages/compass-connections-navigation/src/sc-connections-navigation-tree.spec.tsx b/packages/compass-connections-navigation/src/sc-connections-navigation-tree.spec.tsx index c6755e046df..6786dd26aa7 100644 --- a/packages/compass-connections-navigation/src/sc-connections-navigation-tree.spec.tsx +++ b/packages/compass-connections-navigation/src/sc-connections-navigation-tree.spec.tsx @@ -93,7 +93,8 @@ function renderComponent( ); } -describe('ConnectionsNavigationTree -- Single connection usage', function () { +// TODO(COMPASS-7906): remove +describe.skip('ConnectionsNavigationTree -- Single connection usage', function () { let preferences: PreferencesAccess; afterEach(cleanup); diff --git a/packages/compass-connections/src/components/legacy-connections.spec.tsx b/packages/compass-connections/src/components/legacy-connections.spec.tsx index 5a4f5cd553c..768d96bd776 100644 --- a/packages/compass-connections/src/components/legacy-connections.spec.tsx +++ b/packages/compass-connections/src/components/legacy-connections.spec.tsx @@ -42,7 +42,7 @@ async function loadSavedConnectionAndConnect(connectionInfo: ConnectionInfo) { // Wait for the connection to load in the form. await waitFor(() => - expect(screen.queryByRole('textbox')?.textContent).to.equal( + expect(screen.queryByTestId('connectionString')?.textContent).to.equal( connectionInfo.connectionOptions.connectionString ) ); @@ -54,7 +54,8 @@ async function loadSavedConnectionAndConnect(connectionInfo: ConnectionInfo) { await waitFor(() => expect(screen.queryByText('Cancel')).to.not.exist); } -describe('Connections Component', function () { +// TODO(COMPASS-7906): remove +describe.skip('Connections Component', function () { let preferences: PreferencesAccess; before(async function () { @@ -367,7 +368,9 @@ describe('Connections Component', function () { // Wait for the connection to load in the form. await waitFor(() => - expect(screen.queryByRole('textbox')?.textContent).to.equal( + expect( + screen.queryByTestId('connectionString')?.textContent + ).to.equal( 'mongodb://localhost:27099/?connectTimeoutMS=5000&serverSelectionTimeoutMS=5000' ) ); diff --git a/packages/compass-e2e-tests/helpers/compass.ts b/packages/compass-e2e-tests/helpers/compass.ts index ba67adc1e4b..450b9185590 100644 --- a/packages/compass-e2e-tests/helpers/compass.ts +++ b/packages/compass-e2e-tests/helpers/compass.ts @@ -46,9 +46,8 @@ let MONGODB_USE_ENTERPRISE = // should we test compass-web (true) or compass electron (false)? export const TEST_COMPASS_WEB = process.argv.includes('--test-compass-web'); -export const TEST_MULTIPLE_CONNECTIONS = process.argv.includes( - '--test-multiple-connections' -); +// multiple connections is now the default when we're not testing compass-web +export const TEST_MULTIPLE_CONNECTIONS = !TEST_COMPASS_WEB; /* A helper so we can easily find all the tests we're skipping in compass-web. @@ -997,20 +996,6 @@ export async function init( ): Promise { name = pathName(name ?? formattedDate()); - // Use the multiple connections feature flag when testing multiple connections - // so that compass starts up with it already enabled. But be careful not to - // override the env var because there are tests that set it. - if ( - TEST_MULTIPLE_CONNECTIONS && - !process.env.COMPASS_GLOBAL_CONFIG_FILE_FOR_TESTING - ) { - process.env.COMPASS_GLOBAL_CONFIG_FILE_FOR_TESTING = path.join( - __dirname, - '..', - 'multiple-connections.yaml' - ); - } - // Unfortunately mocha's type is that this.test inside a test or hook is // optional even though it always exists. So we have a lot of // this.test?.fullTitle() and therefore we hopefully won't end up with a lot diff --git a/packages/compass-e2e-tests/index.ts b/packages/compass-e2e-tests/index.ts index 484ebece2ae..82c102442e3 100644 --- a/packages/compass-e2e-tests/index.ts +++ b/packages/compass-e2e-tests/index.ts @@ -25,7 +25,6 @@ const debug = Debug('compass-e2e-tests'); const allowedArgs = [ '--test-compass-web', - '--test-multiple-connections', '--no-compile', '--no-native-modules', '--test-packaged-app', diff --git a/packages/compass-preferences-model/src/feature-flags.ts b/packages/compass-preferences-model/src/feature-flags.ts index 0e3c28a238e..12542101c8a 100644 --- a/packages/compass-preferences-model/src/feature-flags.ts +++ b/packages/compass-preferences-model/src/feature-flags.ts @@ -18,7 +18,6 @@ export type FeatureFlags = { newExplainPlan: boolean; showInsights: boolean; enableRenameCollectionModal: boolean; - enableNewMultipleConnectionSystem: boolean; enableQueryHistoryAutocomplete: boolean; enableProxySupport: boolean; }; @@ -64,18 +63,6 @@ export const featureFlags: Required<{ }, }, - /** - * Feature flag for the new multiple connection UI. - * Epic: COMPASS-6410 - */ - enableNewMultipleConnectionSystem: { - stage: 'development', - description: { - short: 'Enables support for multiple connections.', - long: 'Allows users to open multiple connections in the same window.', - }, - }, - /** * Feature flag for adding query history items to the query bar autocompletion. COMPASS-8096 */ diff --git a/packages/compass-preferences-model/src/preferences-schema.ts b/packages/compass-preferences-model/src/preferences-schema.ts index f7cfa99b9d5..56d238eb255 100644 --- a/packages/compass-preferences-model/src/preferences-schema.ts +++ b/packages/compass-preferences-model/src/preferences-schema.ts @@ -67,6 +67,7 @@ export type UserConfigurablePreferences = PermanentFeatureFlags & enablePerformanceAdvisorBanner: boolean; maximumNumberOfActiveConnections?: number; enableShowDialogOnQuit: boolean; + enableNewMultipleConnectionSystem: boolean; enableProxySupport: boolean; proxy: string; }; @@ -213,7 +214,7 @@ const featureFlagsProps: Required<{ }> = Object.fromEntries( Object.entries(featureFlags).map(([key, value]) => [ key as keyof FeatureFlags, - featureFlagToPreferenceDefinition(value), + featureFlagToPreferenceDefinition(key, value), ]) ) as unknown as Required<{ [K in keyof FeatureFlags]: PreferenceDefinition; @@ -780,6 +781,18 @@ export const storedUserPreferencesProps: Required<{ type: 'boolean', }, + enableNewMultipleConnectionSystem: { + ui: true, + cli: true, + global: true, + description: { + short: 'Enables support for multiple connections.', + long: 'Allows users to open multiple connections in the same window.', + }, + validator: z.boolean().default(true), + type: 'boolean', + }, + proxy: { ui: true, cli: true, @@ -1026,6 +1039,7 @@ function deriveReadOnlyOptionState( // Helper to convert feature flag definitions to preference definitions function featureFlagToPreferenceDefinition( + key: string, featureFlag: FeatureFlagDefinition ): PreferenceDefinition { return { diff --git a/packages/compass-shell/src/plugin.spec.tsx b/packages/compass-shell/src/plugin.spec.tsx index a4e98309ad7..494a3439afa 100644 --- a/packages/compass-shell/src/plugin.spec.tsx +++ b/packages/compass-shell/src/plugin.spec.tsx @@ -63,7 +63,8 @@ describe('CompassShellPlugin', function () { wrapper = null; }); - it('returns a renderable plugin', async function () { + // TODO(COMPASS-7906): remove + it.skip('returns a renderable plugin', async function () { connectionsManager['connectionStatuses'].set('1', 'connected'); wrapper = mount( diff --git a/packages/compass-sidebar/src/components/legacy/navigation-items.spec.tsx b/packages/compass-sidebar/src/components/legacy/navigation-items.spec.tsx index fa889808165..182a91d6d45 100644 --- a/packages/compass-sidebar/src/components/legacy/navigation-items.spec.tsx +++ b/packages/compass-sidebar/src/components/legacy/navigation-items.spec.tsx @@ -42,7 +42,8 @@ function renderNavigationItems( const createDatabaseText = 'Create database'; const refreshCTAText = 'Refresh databases'; -describe('NavigationItems [Component]', function () { +// TODO(COMPASS-7906): remove +describe.skip('NavigationItems [Component]', function () { afterEach(cleanup); describe('when rendered', function () { diff --git a/packages/compass/src/main/menu.spec.ts b/packages/compass/src/main/menu.spec.ts index d920163062b..3f5255c149f 100644 --- a/packages/compass/src/main/menu.spec.ts +++ b/packages/compass/src/main/menu.spec.ts @@ -287,7 +287,8 @@ describe('CompassMenu', function () { } }); - it('[single-connection] should generate a menu template for darwin', function () { + // TODO(COMPASS-7906): remove + it.skip('[single-connection] should generate a menu template for darwin', function () { sinon.stub(process, 'platform').value('darwin'); expect(serializable(CompassMenu.getTemplate(0))).to.deep.equal([ { @@ -457,7 +458,8 @@ describe('CompassMenu', function () { }); ['linux', 'win32'].forEach((platform) => { - it(`[single-connection] should generate a menu template for ${platform}`, function () { + // TODO(COMPASS-7906): remove + it.skip(`[single-connection] should generate a menu template for ${platform}`, function () { sinon.stub(process, 'platform').value(platform); expect(serializable(CompassMenu.getTemplate(0))).to.deep.equal([ diff --git a/packages/connection-form/src/components/advanced-options-tabs/authentication-tab/authentication-oidc.spec.tsx b/packages/connection-form/src/components/advanced-options-tabs/authentication-tab/authentication-oidc.spec.tsx index e069a3f33b2..4564f4d640d 100644 --- a/packages/connection-form/src/components/advanced-options-tabs/authentication-tab/authentication-oidc.spec.tsx +++ b/packages/connection-form/src/components/advanced-options-tabs/authentication-tab/authentication-oidc.spec.tsx @@ -28,7 +28,7 @@ async function renderConnectionForm( connectionString: 'mongodb://localhost:27017', }, }} - onConnectClicked={(connectionInfo) => { + onSaveAndConnectClicked={(connectionInfo) => { void connectSpy(connectionInfo.connectionOptions); }} preferences={{ enableOidc: true, showOIDCDeviceAuthFlow }} @@ -77,6 +77,7 @@ describe('Authentication OIDC Connection Form', function () { try { await waitFor(() => expect(connectSpy).to.have.been.calledOnce); } catch (e) { + // this only finds something if it is a validation error const errors = screen.getByTestId( 'connection-error-summary' ).textContent; @@ -101,7 +102,7 @@ describe('Authentication OIDC Connection Form', function () { }); it('handles principal (username) changes', async function () { - fireEvent.change(screen.getAllByRole('textbox')[1], { + fireEvent.change(screen.getByTestId('connection-oidc-username-input'), { target: { value: 'goodSandwich' }, }); @@ -112,9 +113,12 @@ describe('Authentication OIDC Connection Form', function () { }); it('handles the auth redirect flow uri changes', async function () { - fireEvent.change(screen.getAllByRole('textbox')[2], { - target: { value: 'goodSandwiches' }, - }); + fireEvent.change( + screen.getByTestId('connection-oidc-auth-code-flow-redirect-uri-input'), + { + target: { value: 'goodSandwiches' }, + } + ); await expectToConnectWith({ connectionString: diff --git a/packages/connection-form/src/components/advanced-options-tabs/csfle-tab/csfle-tab.spec.tsx b/packages/connection-form/src/components/advanced-options-tabs/csfle-tab/csfle-tab.spec.tsx index 87e4dbcadd8..d9dba077a74 100644 --- a/packages/connection-form/src/components/advanced-options-tabs/csfle-tab/csfle-tab.spec.tsx +++ b/packages/connection-form/src/components/advanced-options-tabs/csfle-tab/csfle-tab.spec.tsx @@ -89,7 +89,7 @@ describe('In-Use Encryption', function () { connectionString: 'mongodb://localhost:27017', }, }} - onConnectClicked={(connectionInfo) => { + onSaveAndConnectClicked={(connectionInfo) => { connectSpy(connectionInfo.connectionOptions); }} onSaveClicked={() => { diff --git a/packages/connection-form/src/components/connection-form.spec.tsx b/packages/connection-form/src/components/connection-form.spec.tsx index 8aa1d2e7de3..02ef5f682b6 100644 --- a/packages/connection-form/src/components/connection-form.spec.tsx +++ b/packages/connection-form/src/components/connection-form.spec.tsx @@ -38,7 +38,6 @@ describe('ConnectionForm Component', function () { return render( { - /* */ - }} connectionErrorMessage="connection error" initialConnectionInfo={{ id: 'test', @@ -331,10 +327,10 @@ describe('ConnectionForm Component', function () { expect(screen.getByText('connection error')).to.be.visible; }); - it('should show a Save & Connect button when there is no existing connection', function () { + // TODO(COMPASS-7762) + it.skip('should show a Save & Connect button when there is no existing connection', function () { render(