Skip to content

Commit

Permalink
feat: release multiple connections COMPASS-7905 (#6138)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
lerouxb authored Aug 23, 2024
1 parent 7c34845 commit 885dafd
Show file tree
Hide file tree
Showing 16 changed files with 55 additions and 158 deletions.
23 changes: 0 additions & 23 deletions .evergreen/buildvariants-and-tasks.in.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
49 changes: 0 additions & 49 deletions .evergreen/buildvariants-and-tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
24 changes: 0 additions & 24 deletions .evergreen/functions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
);
Expand All @@ -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 () {
Expand Down Expand Up @@ -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'
)
);
Expand Down
19 changes: 2 additions & 17 deletions packages/compass-e2e-tests/helpers/compass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -997,20 +996,6 @@ export async function init(
): Promise<Compass> {
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
Expand Down
1 change: 0 additions & 1 deletion packages/compass-e2e-tests/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
13 changes: 0 additions & 13 deletions packages/compass-preferences-model/src/feature-flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export type FeatureFlags = {
newExplainPlan: boolean;
showInsights: boolean;
enableRenameCollectionModal: boolean;
enableNewMultipleConnectionSystem: boolean;
enableQueryHistoryAutocomplete: boolean;
enableProxySupport: boolean;
};
Expand Down Expand Up @@ -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
*/
Expand Down
16 changes: 15 additions & 1 deletion packages/compass-preferences-model/src/preferences-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export type UserConfigurablePreferences = PermanentFeatureFlags &
enablePerformanceAdvisorBanner: boolean;
maximumNumberOfActiveConnections?: number;
enableShowDialogOnQuit: boolean;
enableNewMultipleConnectionSystem: boolean;
enableProxySupport: boolean;
proxy: string;
};
Expand Down Expand Up @@ -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<K>;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -1026,6 +1039,7 @@ function deriveReadOnlyOptionState<K extends keyof AllPreferences>(

// Helper to convert feature flag definitions to preference definitions
function featureFlagToPreferenceDefinition(
key: string,
featureFlag: FeatureFlagDefinition
): PreferenceDefinition<keyof FeatureFlags> {
return {
Expand Down
3 changes: 2 additions & 1 deletion packages/compass-shell/src/plugin.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(
<AppRegistryProvider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
6 changes: 4 additions & 2 deletions packages/compass/src/main/menu.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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([
{
Expand Down Expand Up @@ -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([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ async function renderConnectionForm(
connectionString: 'mongodb://localhost:27017',
},
}}
onConnectClicked={(connectionInfo) => {
onSaveAndConnectClicked={(connectionInfo) => {
void connectSpy(connectionInfo.connectionOptions);
}}
preferences={{ enableOidc: true, showOIDCDeviceAuthFlow }}
Expand Down Expand Up @@ -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;
Expand All @@ -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' },
});

Expand All @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ describe('In-Use Encryption', function () {
connectionString: 'mongodb://localhost:27017',
},
}}
onConnectClicked={(connectionInfo) => {
onSaveAndConnectClicked={(connectionInfo) => {
connectSpy(connectionInfo.connectionOptions);
}}
onSaveClicked={() => {
Expand Down
Loading

0 comments on commit 885dafd

Please sign in to comment.