From 5f9a502304c677203aab12cdd63a554a272b5e7f Mon Sep 17 00:00:00 2001 From: mcasimir Date: Mon, 14 Feb 2022 16:00:12 +0100 Subject: [PATCH 1/9] wip: canonicalize hostname select --- package-lock.json | 20 +++---- packages/compass-components/package.json | 2 +- .../authentication-gssapi.spec.tsx | 12 ++-- .../authentication-gssapi.tsx | 58 +++++++++++++++---- 4 files changed, 63 insertions(+), 29 deletions(-) diff --git a/package-lock.json b/package-lock.json index 16b8d3138e5..6c7c50439e5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5682,13 +5682,13 @@ } }, "node_modules/@leafygreen-ui/select": { - "version": "3.0.8", - "resolved": "https://registry.npmjs.org/@leafygreen-ui/select/-/select-3.0.8.tgz", - "integrity": "sha512-p7d1QTnXrZ7FlkPzhvC4W91I5nrjWLnkzueNvMEqt812VbJg2udS20KYP5YJ2pgDUB6vdLbLpvmAc0uyYDFeWQ==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@leafygreen-ui/select/-/select-3.1.0.tgz", + "integrity": "sha512-gcTYv+86C0pLJ4SaDvgKbmXEQAABkLe+7HfaobnjLnlHqa5/93w43g5WPq1xFgWHiHezckQnSIZcXDABLkl5gw==", "dependencies": { "@leafygreen-ui/button": "^12.0.4", "@leafygreen-ui/emotion": "^4.0.0", - "@leafygreen-ui/hooks": "^7.0.0", + "@leafygreen-ui/hooks": "^7.1.1", "@leafygreen-ui/icon": "^11.6.0", "@leafygreen-ui/lib": "^9.0.1", "@leafygreen-ui/palette": "^3.2.2", @@ -63147,7 +63147,7 @@ "@leafygreen-ui/radio-box-group": "^6.1.4", "@leafygreen-ui/radio-group": "^7.0.6", "@leafygreen-ui/segmented-control": "^0.9.1", - "@leafygreen-ui/select": "^3.0.8", + "@leafygreen-ui/select": "^3.1.0", "@leafygreen-ui/table": "^2.0.5", "@leafygreen-ui/tabs": "^5.1.3", "@leafygreen-ui/text-area": "^4.0.3", @@ -109203,13 +109203,13 @@ } }, "@leafygreen-ui/select": { - "version": "3.0.8", - "resolved": "https://registry.npmjs.org/@leafygreen-ui/select/-/select-3.0.8.tgz", - "integrity": "sha512-p7d1QTnXrZ7FlkPzhvC4W91I5nrjWLnkzueNvMEqt812VbJg2udS20KYP5YJ2pgDUB6vdLbLpvmAc0uyYDFeWQ==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@leafygreen-ui/select/-/select-3.1.0.tgz", + "integrity": "sha512-gcTYv+86C0pLJ4SaDvgKbmXEQAABkLe+7HfaobnjLnlHqa5/93w43g5WPq1xFgWHiHezckQnSIZcXDABLkl5gw==", "requires": { "@leafygreen-ui/button": "^12.0.4", "@leafygreen-ui/emotion": "^4.0.0", - "@leafygreen-ui/hooks": "^7.0.0", + "@leafygreen-ui/hooks": "^7.1.1", "@leafygreen-ui/icon": "^11.6.0", "@leafygreen-ui/lib": "^9.0.1", "@leafygreen-ui/palette": "^3.2.2", @@ -115067,7 +115067,7 @@ "@leafygreen-ui/radio-box-group": "^6.1.4", "@leafygreen-ui/radio-group": "^7.0.6", "@leafygreen-ui/segmented-control": "^0.9.1", - "@leafygreen-ui/select": "^3.0.8", + "@leafygreen-ui/select": "3.1.0", "@leafygreen-ui/table": "^2.0.5", "@leafygreen-ui/tabs": "^5.1.3", "@leafygreen-ui/text-area": "^4.0.3", diff --git a/packages/compass-components/package.json b/packages/compass-components/package.json index 9bd1ff6612a..fc9e50f9c01 100644 --- a/packages/compass-components/package.json +++ b/packages/compass-components/package.json @@ -54,7 +54,7 @@ "@leafygreen-ui/radio-box-group": "^6.1.4", "@leafygreen-ui/radio-group": "^7.0.6", "@leafygreen-ui/segmented-control": "^0.9.1", - "@leafygreen-ui/select": "^3.0.8", + "@leafygreen-ui/select": "^3.1.0", "@leafygreen-ui/table": "^2.0.5", "@leafygreen-ui/tabs": "^5.1.3", "@leafygreen-ui/text-area": "^4.0.3", diff --git a/packages/connection-form/src/components/advanced-options-tabs/authentication-tab/authentication-gssapi.spec.tsx b/packages/connection-form/src/components/advanced-options-tabs/authentication-tab/authentication-gssapi.spec.tsx index 25246343f7f..7217c850058 100644 --- a/packages/connection-form/src/components/advanced-options-tabs/authentication-tab/authentication-gssapi.spec.tsx +++ b/packages/connection-form/src/components/advanced-options-tabs/authentication-tab/authentication-gssapi.spec.tsx @@ -4,15 +4,15 @@ import { expect } from 'chai'; import sinon from 'sinon'; import ConnectionStringUrl from 'mongodb-connection-string-url'; -import AuthenticationGssapi, { - GSSAPI_CANONICALIZE_HOST_NAME_LABEL, - GSSAPI_PRINCIPAL_NAME_LABEL, - GSSAPI_SERVICE_NAME_LABEL, - GSSAPI_SERVICE_REALM_LABEL, -} from './authentication-gssapi'; +import AuthenticationGssapi from './authentication-gssapi'; import type { ConnectionFormError } from '../../../utils/validation'; import type { UpdateConnectionFormField } from '../../../hooks/use-connect-form'; +const GSSAPI_PRINCIPAL_NAME_LABEL = 'Principal'; +const GSSAPI_SERVICE_NAME_LABEL = 'Service Name'; +const GSSAPI_CANONICALIZE_HOST_NAME_LABEL = 'Canonicalize Host Name'; +const GSSAPI_SERVICE_REALM_LABEL = 'Service Realm'; + function renderComponent({ errors = [], connectionStringUrl = new ConnectionStringUrl('mongodb://localhost:27017'), diff --git a/packages/connection-form/src/components/advanced-options-tabs/authentication-tab/authentication-gssapi.tsx b/packages/connection-form/src/components/advanced-options-tabs/authentication-tab/authentication-gssapi.tsx index c3f011881bb..77b1efe6582 100644 --- a/packages/connection-form/src/components/advanced-options-tabs/authentication-tab/authentication-gssapi.tsx +++ b/packages/connection-form/src/components/advanced-options-tabs/authentication-tab/authentication-gssapi.tsx @@ -1,7 +1,14 @@ import React from 'react'; -import { Checkbox, TextInput } from '@mongodb-js/compass-components'; +import { + Select, + Option, + TextInput, + Label, +} from '@mongodb-js/compass-components'; import type ConnectionStringUrl from 'mongodb-connection-string-url'; +import util from 'util'; + import type { UpdateConnectionFormField } from '../../../hooks/use-connect-form'; import FormFieldContainer from '../../form-field-container'; import type { ConnectionFormError } from '../../../utils/validation'; @@ -11,10 +18,10 @@ import { parseAuthMechanismProperties, } from '../../../utils/connection-string-helpers'; -export const GSSAPI_PRINCIPAL_NAME_LABEL = 'Principal'; -export const GSSAPI_SERVICE_NAME_LABEL = 'Service Name'; -export const GSSAPI_CANONICALIZE_HOST_NAME_LABEL = 'Canonicalize Host Name'; -export const GSSAPI_SERVICE_REALM_LABEL = 'Service Realm'; +const GSSAPI_PRINCIPAL_NAME_LABEL = 'Principal'; +const GSSAPI_SERVICE_NAME_LABEL = 'Service Name'; +const GSSAPI_CANONICALIZE_HOST_NAME_LABEL = 'Canonicalize Host Name'; +const GSSAPI_SERVICE_REALM_LABEL = 'Service Realm'; function AuthenticationGSSAPI({ errors, @@ -38,6 +45,12 @@ function AuthenticationGSSAPI({ 'CANONICALIZE_HOST_NAME' ); + const GSSAPI_CANONICALIZE_HOST_NAME_OPTIONS: Record = { + None: 'none', + Forward: 'forward', + 'Forward and reverse': 'forwardAndReverse', + }; + return ( <> @@ -74,19 +87,40 @@ function AuthenticationGSSAPI({ - ) => { + + +
+
+        value={util.inspect(canonicalizeHostname)}
+      
Date: Mon, 14 Feb 2022 16:03:22 +0100 Subject: [PATCH 2/9] fix name attribute --- .../authentication-tab/authentication-gssapi.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/connection-form/src/components/advanced-options-tabs/authentication-tab/authentication-gssapi.tsx b/packages/connection-form/src/components/advanced-options-tabs/authentication-tab/authentication-gssapi.tsx index 77b1efe6582..c7109c4eac1 100644 --- a/packages/connection-form/src/components/advanced-options-tabs/authentication-tab/authentication-gssapi.tsx +++ b/packages/connection-form/src/components/advanced-options-tabs/authentication-tab/authentication-gssapi.tsx @@ -94,7 +94,7 @@ function AuthenticationGSSAPI({ {GSSAPI_CANONICALIZE_HOST_NAME_LABEL} { + onChange={(event): void => { updateConnectionFormField({ type: 'update-auth-mechanism-property', key: 'CANONICALIZE_HOST_NAME', - value: name, + value: event.target.value, }); }} - allowDeselect={true} value={canonicalizeHostname} > {Object.entries(GSSAPI_CANONICALIZE_HOST_NAME_OPTIONS).map( - ([label, value]) => ( - + ) )} - + -
-
-        value={util.inspect(canonicalizeHostname)}
-      
- + + + { + if (!checked) { + updateConnectionFormField({ + type: 'update-password', + password: '', + }); + } + + setShowPassword(checked); + }} /> + {showPassword && ( + ) => { + updateConnectionFormField({ + type: 'update-password', + password: value, + }); + }} + label={GSSAPI_PASSWORD_LABEL} + value={password} + type="password" + optional + /> + )} ); diff --git a/packages/connection-form/src/components/advanced-options-tabs/authentication-tab/authentication-tab.tsx b/packages/connection-form/src/components/advanced-options-tabs/authentication-tab/authentication-tab.tsx index 7e0ad87a071..57553c9b2a8 100644 --- a/packages/connection-form/src/components/advanced-options-tabs/authentication-tab/authentication-tab.tsx +++ b/packages/connection-form/src/components/advanced-options-tabs/authentication-tab/authentication-tab.tsx @@ -79,7 +79,7 @@ const containerStyles = css({ const contentStyles = css({ marginTop: spacing[3], - width: '50%', + width: spacing[7] * 5, }); function getSelectedAuthTabForConnectionString( @@ -151,11 +151,7 @@ function AuthenticationTab({ - + {options.map(({ title, id }) => { return ( Date: Wed, 16 Feb 2022 11:51:30 +0100 Subject: [PATCH 4/9] use test ids instead of labels --- .../authentication-gssapi.spec.tsx | 14 ++++------- .../authentication-gssapi.tsx | 25 +++++++++---------- 2 files changed, 17 insertions(+), 22 deletions(-) diff --git a/packages/connection-form/src/components/advanced-options-tabs/authentication-tab/authentication-gssapi.spec.tsx b/packages/connection-form/src/components/advanced-options-tabs/authentication-tab/authentication-gssapi.spec.tsx index 6234345a776..9f851809f52 100644 --- a/packages/connection-form/src/components/advanced-options-tabs/authentication-tab/authentication-gssapi.spec.tsx +++ b/packages/connection-form/src/components/advanced-options-tabs/authentication-tab/authentication-gssapi.spec.tsx @@ -4,11 +4,7 @@ import { expect } from 'chai'; import sinon from 'sinon'; import ConnectionStringUrl from 'mongodb-connection-string-url'; -import AuthenticationGssapi, { - GSSAPI_PRINCIPAL_NAME_LABEL, - GSSAPI_SERVICE_NAME_LABEL, - GSSAPI_SERVICE_REALM_LABEL, -} from './authentication-gssapi'; +import AuthenticationGssapi from './authentication-gssapi'; import type { ConnectionFormError } from '../../../utils/validation'; import type { UpdateConnectionFormField } from '../../../hooks/use-connect-form'; @@ -43,7 +39,7 @@ describe('AuthenticationGssapi Component', function () { }); expect(updateConnectionFormFieldSpy.callCount).to.equal(0); - fireEvent.change(screen.getByLabelText(GSSAPI_PRINCIPAL_NAME_LABEL), { + fireEvent.change(screen.getByTestId('gssapi-principal-input'), { target: { value: 'good sandwich' }, }); }); @@ -64,7 +60,7 @@ describe('AuthenticationGssapi Component', function () { }); expect(updateConnectionFormFieldSpy.callCount).to.equal(0); - fireEvent.change(screen.getByLabelText(GSSAPI_SERVICE_NAME_LABEL), { + fireEvent.change(screen.getByTestId('gssapi-service-name-input'), { target: { value: 'good sandwich' }, }); }); @@ -86,7 +82,7 @@ describe('AuthenticationGssapi Component', function () { }); expect(updateConnectionFormFieldSpy.callCount).to.equal(0); - fireEvent.change(screen.getByLabelText(GSSAPI_SERVICE_REALM_LABEL), { + fireEvent.change(screen.getByTestId('gssapi-service-realm-input'), { target: { value: 'good sandwich' }, }); }); @@ -101,7 +97,7 @@ describe('AuthenticationGssapi Component', function () { }); }); - describe.only('when canoncalize hostname is empty', function () { + describe('when canoncalize hostname is empty', function () { beforeEach(function () { renderComponent({ updateConnectionFormField: updateConnectionFormFieldSpy, diff --git a/packages/connection-form/src/components/advanced-options-tabs/authentication-tab/authentication-gssapi.tsx b/packages/connection-form/src/components/advanced-options-tabs/authentication-tab/authentication-gssapi.tsx index fc505f1be8b..6f56fcd70fc 100644 --- a/packages/connection-form/src/components/advanced-options-tabs/authentication-tab/authentication-gssapi.tsx +++ b/packages/connection-form/src/components/advanced-options-tabs/authentication-tab/authentication-gssapi.tsx @@ -18,13 +18,7 @@ import { parseAuthMechanismProperties, } from '../../../utils/connection-string-helpers'; -export const GSSAPI_PRINCIPAL_NAME_LABEL = 'Principal'; -export const GSSAPI_SERVICE_NAME_LABEL = 'Service Name'; -export const GSSAPI_CANONICALIZE_HOST_NAME_LABEL = 'Canonicalize Host Name'; -export const GSSAPI_SERVICE_REALM_LABEL = 'Service Realm'; -export const GSSAPI_SHOW_PASSWORD_LABEL = 'Provide password directly'; -export const GSSAPI_PASSWORD_LABEL = 'Password'; -export const GSSAPI_CANONICALIZE_HOST_NAME_OPTIONS: Record< +const GSSAPI_CANONICALIZE_HOST_NAME_OPTIONS: Record< string, { label: string; value: string } > = { @@ -80,7 +74,8 @@ function AuthenticationGSSAPI({ username: value, }); }} - label={GSSAPI_PRINCIPAL_NAME_LABEL} + data-testid="gssapi-principal-input" + label="Principal" errorMessage={kerberosPrincipalError} state={kerberosPrincipalError ? 'error' : undefined} value={principal || ''} @@ -89,6 +84,7 @@ function AuthenticationGSSAPI({ ) => { @@ -99,7 +95,7 @@ function AuthenticationGSSAPI({ }); }} optional - label={GSSAPI_SERVICE_NAME_LABEL} + label="Service Name" value={serviceName || ''} /> @@ -109,7 +105,7 @@ function AuthenticationGSSAPI({ id="canonicalize-hostname-label" htmlFor="canonicalize-hostname-select" > - {GSSAPI_CANONICALIZE_HOST_NAME_LABEL} + Canonicalize Host Name { if (!checked) { updateConnectionFormField({ @@ -178,7 +176,8 @@ function AuthenticationGSSAPI({ password: value, }); }} - label={GSSAPI_PASSWORD_LABEL} + data-testid="gssapi-password-input" + label="Password" value={password} type="password" optional From 0859e92b5d61ab2964f1a06287da06a83d2a7013 Mon Sep 17 00:00:00 2001 From: mcasimir Date: Wed, 16 Feb 2022 12:45:48 +0100 Subject: [PATCH 5/9] add tests for password input --- .../authentication-gssapi.spec.tsx | 75 ++++++++++++++++++- 1 file changed, 74 insertions(+), 1 deletion(-) diff --git a/packages/connection-form/src/components/advanced-options-tabs/authentication-tab/authentication-gssapi.spec.tsx b/packages/connection-form/src/components/advanced-options-tabs/authentication-tab/authentication-gssapi.spec.tsx index 9f851809f52..fc7e34c1765 100644 --- a/packages/connection-form/src/components/advanced-options-tabs/authentication-tab/authentication-gssapi.spec.tsx +++ b/packages/connection-form/src/components/advanced-options-tabs/authentication-tab/authentication-gssapi.spec.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { render, screen, fireEvent } from '@testing-library/react'; +import { render, screen, fireEvent, cleanup } from '@testing-library/react'; import { expect } from 'chai'; import sinon from 'sinon'; import ConnectionStringUrl from 'mongodb-connection-string-url'; @@ -27,6 +27,8 @@ function renderComponent({ } describe('AuthenticationGssapi Component', function () { + afterEach(cleanup); + let updateConnectionFormFieldSpy: sinon.SinonSpy; beforeEach(function () { updateConnectionFormFieldSpy = sinon.spy(); @@ -174,6 +176,77 @@ describe('AuthenticationGssapi Component', function () { }); }); + describe('when password is not in the connection string', function () { + beforeEach(function () { + renderComponent({ + updateConnectionFormField: updateConnectionFormFieldSpy, + }); + + expect(updateConnectionFormFieldSpy.callCount).to.equal(0); + }); + + it('allows to edit the password when enter password directly is enabled', function () { + expect(screen.queryByTestId('gssapi-password-input')).to.not.exist; + const checkbox = screen.getByTestId('gssapi-password-checkbox'); + expect(checkbox.closest('input').checked).to.be.false; + + fireEvent.click(checkbox); + + const passwordInput = screen.getByTestId('gssapi-password-input'); + + fireEvent.change(passwordInput, { + target: { value: 'some-password' }, + }); + + expect(updateConnectionFormFieldSpy.callCount).to.equal(1); + expect(updateConnectionFormFieldSpy.firstCall.args[0]).to.deep.equal({ + type: 'update-password', + password: 'some-password', + }); + }); + }); + + describe('when password is in the connection string', function () { + beforeEach(function () { + renderComponent({ + connectionStringUrl: new ConnectionStringUrl( + 'mongodb://user:password@localhost:27017' + ), + updateConnectionFormField: updateConnectionFormFieldSpy, + }); + + expect(updateConnectionFormFieldSpy.callCount).to.equal(0); + }); + + it('enables the checkbox and shows the password input', function () { + const checkbox = screen.getByTestId('gssapi-password-checkbox'); + expect(checkbox.closest('input').checked).to.be.true; + const passwordInput = screen.queryByTestId('gssapi-password-input'); + expect(passwordInput).to.exist; + expect(passwordInput.closest('input').value).to.equal('password'); + }); + + it('resets the password and hides the input when the checkbox is unchecked', function () { + const checkbox = screen.getByTestId('gssapi-password-checkbox'); + expect(checkbox.closest('input').checked).to.be.true; + fireEvent.click(checkbox); + + expect(updateConnectionFormFieldSpy.callCount).to.equal(1); + expect(updateConnectionFormFieldSpy.firstCall.args[0]).to.deep.equal({ + type: 'update-password', + password: '', + }); + }); + + // it('shows the password input', function () { + // expect(screen.queryByTestId('gssapi-password-input')).to.not.exist; + // const checkbox = screen.getByTestId('gssapi-password-checkbox'); + // fireEvent.click(checkbox); + + // expect(screen.queryByTestId('gssapi-password-input')).to.exist; + // }); + }); + it('renders an error when there is a kerberosPrincipal error', function () { renderComponent({ errors: [ From b4aab1f52708e3a07db9f34ecafd82c8f00ccadf Mon Sep 17 00:00:00 2001 From: mcasimir Date: Wed, 16 Feb 2022 12:51:26 +0100 Subject: [PATCH 6/9] cleanup --- .../authentication-gssapi.spec.tsx | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/packages/connection-form/src/components/advanced-options-tabs/authentication-tab/authentication-gssapi.spec.tsx b/packages/connection-form/src/components/advanced-options-tabs/authentication-tab/authentication-gssapi.spec.tsx index fc7e34c1765..8fd635b9cc1 100644 --- a/packages/connection-form/src/components/advanced-options-tabs/authentication-tab/authentication-gssapi.spec.tsx +++ b/packages/connection-form/src/components/advanced-options-tabs/authentication-tab/authentication-gssapi.spec.tsx @@ -1,5 +1,11 @@ import React from 'react'; -import { render, screen, fireEvent, cleanup } from '@testing-library/react'; +import { + render, + screen, + fireEvent, + cleanup, + waitFor, +} from '@testing-library/react'; import { expect } from 'chai'; import sinon from 'sinon'; import ConnectionStringUrl from 'mongodb-connection-string-url'; @@ -226,7 +232,7 @@ describe('AuthenticationGssapi Component', function () { expect(passwordInput.closest('input').value).to.equal('password'); }); - it('resets the password and hides the input when the checkbox is unchecked', function () { + it('resets the password when the checkbox is unchecked', function () { const checkbox = screen.getByTestId('gssapi-password-checkbox'); expect(checkbox.closest('input').checked).to.be.true; fireEvent.click(checkbox); @@ -237,14 +243,6 @@ describe('AuthenticationGssapi Component', function () { password: '', }); }); - - // it('shows the password input', function () { - // expect(screen.queryByTestId('gssapi-password-input')).to.not.exist; - // const checkbox = screen.getByTestId('gssapi-password-checkbox'); - // fireEvent.click(checkbox); - - // expect(screen.queryByTestId('gssapi-password-input')).to.exist; - // }); }); it('renders an error when there is a kerberosPrincipal error', function () { From 53de5ce96ac6458cfd813ae3160792b69567d3c0 Mon Sep 17 00:00:00 2001 From: mcasimir Date: Wed, 16 Feb 2022 13:05:09 +0100 Subject: [PATCH 7/9] undo select bump --- package-lock.json | 20 ++++++++++---------- packages/compass-components/package.json | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6c7c50439e5..16b8d3138e5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5682,13 +5682,13 @@ } }, "node_modules/@leafygreen-ui/select": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/@leafygreen-ui/select/-/select-3.1.0.tgz", - "integrity": "sha512-gcTYv+86C0pLJ4SaDvgKbmXEQAABkLe+7HfaobnjLnlHqa5/93w43g5WPq1xFgWHiHezckQnSIZcXDABLkl5gw==", + "version": "3.0.8", + "resolved": "https://registry.npmjs.org/@leafygreen-ui/select/-/select-3.0.8.tgz", + "integrity": "sha512-p7d1QTnXrZ7FlkPzhvC4W91I5nrjWLnkzueNvMEqt812VbJg2udS20KYP5YJ2pgDUB6vdLbLpvmAc0uyYDFeWQ==", "dependencies": { "@leafygreen-ui/button": "^12.0.4", "@leafygreen-ui/emotion": "^4.0.0", - "@leafygreen-ui/hooks": "^7.1.1", + "@leafygreen-ui/hooks": "^7.0.0", "@leafygreen-ui/icon": "^11.6.0", "@leafygreen-ui/lib": "^9.0.1", "@leafygreen-ui/palette": "^3.2.2", @@ -63147,7 +63147,7 @@ "@leafygreen-ui/radio-box-group": "^6.1.4", "@leafygreen-ui/radio-group": "^7.0.6", "@leafygreen-ui/segmented-control": "^0.9.1", - "@leafygreen-ui/select": "^3.1.0", + "@leafygreen-ui/select": "^3.0.8", "@leafygreen-ui/table": "^2.0.5", "@leafygreen-ui/tabs": "^5.1.3", "@leafygreen-ui/text-area": "^4.0.3", @@ -109203,13 +109203,13 @@ } }, "@leafygreen-ui/select": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/@leafygreen-ui/select/-/select-3.1.0.tgz", - "integrity": "sha512-gcTYv+86C0pLJ4SaDvgKbmXEQAABkLe+7HfaobnjLnlHqa5/93w43g5WPq1xFgWHiHezckQnSIZcXDABLkl5gw==", + "version": "3.0.8", + "resolved": "https://registry.npmjs.org/@leafygreen-ui/select/-/select-3.0.8.tgz", + "integrity": "sha512-p7d1QTnXrZ7FlkPzhvC4W91I5nrjWLnkzueNvMEqt812VbJg2udS20KYP5YJ2pgDUB6vdLbLpvmAc0uyYDFeWQ==", "requires": { "@leafygreen-ui/button": "^12.0.4", "@leafygreen-ui/emotion": "^4.0.0", - "@leafygreen-ui/hooks": "^7.1.1", + "@leafygreen-ui/hooks": "^7.0.0", "@leafygreen-ui/icon": "^11.6.0", "@leafygreen-ui/lib": "^9.0.1", "@leafygreen-ui/palette": "^3.2.2", @@ -115067,7 +115067,7 @@ "@leafygreen-ui/radio-box-group": "^6.1.4", "@leafygreen-ui/radio-group": "^7.0.6", "@leafygreen-ui/segmented-control": "^0.9.1", - "@leafygreen-ui/select": "3.1.0", + "@leafygreen-ui/select": "^3.0.8", "@leafygreen-ui/table": "^2.0.5", "@leafygreen-ui/tabs": "^5.1.3", "@leafygreen-ui/text-area": "^4.0.3", diff --git a/packages/compass-components/package.json b/packages/compass-components/package.json index fc9e50f9c01..9bd1ff6612a 100644 --- a/packages/compass-components/package.json +++ b/packages/compass-components/package.json @@ -54,7 +54,7 @@ "@leafygreen-ui/radio-box-group": "^6.1.4", "@leafygreen-ui/radio-group": "^7.0.6", "@leafygreen-ui/segmented-control": "^0.9.1", - "@leafygreen-ui/select": "^3.1.0", + "@leafygreen-ui/select": "^3.0.8", "@leafygreen-ui/table": "^2.0.5", "@leafygreen-ui/tabs": "^5.1.3", "@leafygreen-ui/text-area": "^4.0.3", From df3a0839554082a91a86885e6e59dd25cbe3391b Mon Sep 17 00:00:00 2001 From: mcasimir Date: Wed, 16 Feb 2022 15:30:13 +0100 Subject: [PATCH 8/9] default to none --- .../authentication-gssapi.spec.tsx | 28 ++++++------------- .../authentication-gssapi.tsx | 7 ++--- 2 files changed, 11 insertions(+), 24 deletions(-) diff --git a/packages/connection-form/src/components/advanced-options-tabs/authentication-tab/authentication-gssapi.spec.tsx b/packages/connection-form/src/components/advanced-options-tabs/authentication-tab/authentication-gssapi.spec.tsx index 8fd635b9cc1..625cb5714ed 100644 --- a/packages/connection-form/src/components/advanced-options-tabs/authentication-tab/authentication-gssapi.spec.tsx +++ b/packages/connection-form/src/components/advanced-options-tabs/authentication-tab/authentication-gssapi.spec.tsx @@ -1,11 +1,5 @@ import React from 'react'; -import { - render, - screen, - fireEvent, - cleanup, - waitFor, -} from '@testing-library/react'; +import { render, screen, fireEvent, cleanup } from '@testing-library/react'; import { expect } from 'chai'; import sinon from 'sinon'; import ConnectionStringUrl from 'mongodb-connection-string-url'; @@ -114,16 +108,12 @@ describe('AuthenticationGssapi Component', function () { expect(updateConnectionFormFieldSpy.callCount).to.equal(0); }); - it('updates the form field with CANONICALIZE_HOST_NAME none', function () { - const button = screen.getByTestId('gssapi-canonicalize-host-name-none'); - fireEvent.click(button); + it('selects None', function () { + const radio = screen + .getByTestId('gssapi-canonicalize-host-name-none') + .closest('input'); - expect(updateConnectionFormFieldSpy.callCount).to.equal(1); - expect(updateConnectionFormFieldSpy.firstCall.args[0]).to.deep.equal({ - key: 'CANONICALIZE_HOST_NAME', - type: 'update-auth-mechanism-property', - value: 'none', - }); + expect(radio.checked).to.be.true; }); it('updates the form field with CANONICALIZE_HOST_NAME forward', function () { @@ -167,10 +157,8 @@ describe('AuthenticationGssapi Component', function () { expect(updateConnectionFormFieldSpy.callCount).to.equal(0); }); - it('resets CANONICALIZE_HOST_NAME when Default is selected', function () { - const button = screen.getByTestId( - 'gssapi-canonicalize-host-name-default' - ); + it('resets CANONICALIZE_HOST_NAME when None is selected', function () { + const button = screen.getByTestId('gssapi-canonicalize-host-name-none'); fireEvent.click(button); expect(updateConnectionFormFieldSpy.callCount).to.equal(1); diff --git a/packages/connection-form/src/components/advanced-options-tabs/authentication-tab/authentication-gssapi.tsx b/packages/connection-form/src/components/advanced-options-tabs/authentication-tab/authentication-gssapi.tsx index 6f56fcd70fc..2112b5679e8 100644 --- a/packages/connection-form/src/components/advanced-options-tabs/authentication-tab/authentication-gssapi.tsx +++ b/packages/connection-form/src/components/advanced-options-tabs/authentication-tab/authentication-gssapi.tsx @@ -22,7 +22,6 @@ const GSSAPI_CANONICALIZE_HOST_NAME_OPTIONS: Record< string, { label: string; value: string } > = { - default: { label: 'Default', value: '' }, none: { label: 'None', value: 'none' }, forward: { label: 'Forward', value: 'forward' }, forwardAndReverse: { @@ -52,7 +51,7 @@ function AuthenticationGSSAPI({ const serviceName = authMechanismProperties.get('SERVICE_NAME'); const serviceRealm = authMechanismProperties.get('SERVICE_REALM'); const canonicalizeHostname = - authMechanismProperties.get('CANONICALIZE_HOST_NAME') || ''; + authMechanismProperties.get('CANONICALIZE_HOST_NAME') || 'none'; const [showPassword, setShowPassword] = useState(false); @@ -111,11 +110,11 @@ function AuthenticationGSSAPI({ name="canonicalize-hostname" id="canonicalize-hostname-select" aria-labelledby="canonicalize-hostname-label" - onChange={(event): void => { + onChange={({ target: { value } }): void => { updateConnectionFormField({ type: 'update-auth-mechanism-property', key: 'CANONICALIZE_HOST_NAME', - value: event.target.value, + value: value === 'none' ? '' : value, }); }} value={canonicalizeHostname} From 4cecae7a0a26b36869ad3f75c7f578e3a7555b20 Mon Sep 17 00:00:00 2001 From: mcasimir Date: Wed, 16 Feb 2022 16:59:34 +0100 Subject: [PATCH 9/9] fix test --- .../authentication-tab/authentication-gssapi.spec.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/connection-form/src/components/advanced-options-tabs/authentication-tab/authentication-gssapi.spec.tsx b/packages/connection-form/src/components/advanced-options-tabs/authentication-tab/authentication-gssapi.spec.tsx index 625cb5714ed..f5a57689e82 100644 --- a/packages/connection-form/src/components/advanced-options-tabs/authentication-tab/authentication-gssapi.spec.tsx +++ b/packages/connection-form/src/components/advanced-options-tabs/authentication-tab/authentication-gssapi.spec.tsx @@ -150,7 +150,7 @@ describe('AuthenticationGssapi Component', function () { renderComponent({ updateConnectionFormField: updateConnectionFormFieldSpy, connectionStringUrl: new ConnectionStringUrl( - 'mongodb://localhost:27017/?authMechanism=GSSAPI&authSource=%24external&authMechanismProperties=CANONICALIZE_HOST_NAME%3Anone' + 'mongodb://localhost:27017/?authMechanism=GSSAPI&authSource=%24external&authMechanismProperties=CANONICALIZE_HOST_NAME%3Aforward' ), });