From 4a966ace760e8899b8f84398d2cd836e559d5c4e Mon Sep 17 00:00:00 2001 From: mcasimir Date: Fri, 18 Feb 2022 13:18:01 +0100 Subject: [PATCH 01/14] feat: enable new connection form --- packages/compass-connect/src/components/connect.jsx | 2 +- packages/compass-home/src/components/home.spec.tsx | 10 ++++++---- packages/compass-home/src/components/home.tsx | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/compass-connect/src/components/connect.jsx b/packages/compass-connect/src/components/connect.jsx index 63d084df14f..08bc81aa324 100644 --- a/packages/compass-connect/src/components/connect.jsx +++ b/packages/compass-connect/src/components/connect.jsx @@ -135,7 +135,7 @@ class Connect extends React.Component { } render() { - const showNewConnectForm = process.env.USE_NEW_CONNECT_FORM === 'true'; + const showNewConnectForm = process.env.USE_NEW_CONNECT_FORM !== 'false'; return (
diff --git a/packages/compass-home/src/components/home.spec.tsx b/packages/compass-home/src/components/home.spec.tsx index 7ec93d0abdb..17f960e5243 100644 --- a/packages/compass-home/src/components/home.spec.tsx +++ b/packages/compass-home/src/components/home.spec.tsx @@ -90,9 +90,14 @@ describe('Home [Component]', function () { describe('with the old connect form', function () { beforeEach(function () { + process.env.USE_NEW_CONNECT_FORM = 'false'; return renderHome(); }); + afterEach(function () { + delete process.env.USE_NEW_CONNECT_FORM; + }); + it('renders instance workspace', function () { expect(screen.queryByTestId('test-Instance.Workspace')).to.be.visible; }); @@ -136,13 +141,11 @@ describe('Home [Component]', function () { }); }); - describe('with the new connect form (USE_NEW_CONNECT_FORM=true) and UI status is complete', function () { + describe('when UI status is complete', function () { let dataServiceDisconnectedSpy: sinon.SinonSpy; let listenForDisconnectFake: sinon.SinonSpy; beforeEach(async function () { - process.env.USE_NEW_CONNECT_FORM = 'true'; - listenForDisconnectFake = sinon.fake(); testAppRegistry.on( 'data-service-disconnected', @@ -157,7 +160,6 @@ describe('Home [Component]', function () { }); afterEach(function () { - delete process.env.USE_NEW_CONNECT_FORM; testAppRegistry.removeListener( 'data-service-disconnected', listenForDisconnectFake diff --git a/packages/compass-home/src/components/home.tsx b/packages/compass-home/src/components/home.tsx index a16833bda74..0314107cb13 100644 --- a/packages/compass-home/src/components/home.tsx +++ b/packages/compass-home/src/components/home.tsx @@ -99,7 +99,7 @@ function Home({ appName }: { appName: string }): React.ReactElement | null { const appRegistry = useAppRegistryContext(); const connectRole = useAppRegistryRole(AppRegistryRoles.APPLICATION_CONNECT); const connectedDataService = useRef(); - const showNewConnectForm = process.env.USE_NEW_CONNECT_FORM === 'true'; + const showNewConnectForm = process.env.USE_NEW_CONNECT_FORM !== 'false'; const [{ connectionTitle, isConnected, namespace }, dispatch] = useReducer( reducer, From c1ec8c75f1deb86c821c86b4cd4b1c50dd01eb63 Mon Sep 17 00:00:00 2001 From: mcasimir Date: Fri, 18 Feb 2022 14:57:11 +0100 Subject: [PATCH 02/14] wip: fixing e2e tests --- .../src/components/accordion.spec.tsx | 2 +- .../src/components/accordion.tsx | 4 +- .../src/components/connecting/connecting.tsx | 3 +- .../connection-list/connection-list.tsx | 1 + .../compass-e2e-tests/helpers/selectors.ts | 54 +++++++++---------- .../tests/connection.test.ts | 2 +- .../advanced-connection-options.tsx | 5 +- .../advanced-options-tabs.spec.tsx | 47 ++++++++-------- .../advanced-options-tabs.tsx | 2 +- .../src/components/connect-form-actions.tsx | 6 ++- .../src/components/connect-form.tsx | 2 +- .../components/connection-string-input.tsx | 1 + 12 files changed, 71 insertions(+), 58 deletions(-) diff --git a/packages/compass-components/src/components/accordion.spec.tsx b/packages/compass-components/src/components/accordion.spec.tsx index 705d7dadeb3..3d4fb18b08f 100644 --- a/packages/compass-components/src/components/accordion.spec.tsx +++ b/packages/compass-components/src/components/accordion.spec.tsx @@ -7,7 +7,7 @@ import Accordion from './accordion'; function renderAccordion() { return render( - +

Hello World

); diff --git a/packages/compass-components/src/components/accordion.tsx b/packages/compass-components/src/components/accordion.tsx index e17d924be47..cf35551fc5b 100644 --- a/packages/compass-components/src/components/accordion.tsx +++ b/packages/compass-components/src/components/accordion.tsx @@ -32,7 +32,7 @@ const buttonIconStyles = css({ marginRight: spacing[1], }); interface AccordionProps { - dataTestId?: string; + 'data-testid'?: string; text: string; } function Accordion( @@ -42,7 +42,7 @@ function Accordion( const regionId = useId('region-'); const labelId = useId('label-'); return ( -
+

diff --git a/packages/connection-form/src/components/connect-form.tsx b/packages/connection-form/src/components/connect-form.tsx index 89a56962f46..836c5440e99 100644 --- a/packages/connection-form/src/components/connect-form.tsx +++ b/packages/connection-form/src/components/connect-form.tsx @@ -130,7 +130,7 @@ function ConnectForm({ return ( <> -
+

diff --git a/packages/connection-form/src/components/connection-string-input.tsx b/packages/connection-form/src/components/connection-string-input.tsx index b6a81fa1834..d4c8145cb13 100644 --- a/packages/connection-form/src/components/connection-string-input.tsx +++ b/packages/connection-form/src/components/connection-string-input.tsx @@ -172,6 +172,7 @@ function ConnectStringInput({ className={connectionStringStyles} disabled={!enableEditingConnectionString} id={connectionStringInputId} + data-testid={connectionStringInputId} ref={textAreaEl} aria-labelledby={connectionStringLabelId} placeholder="e.g mongodb+srv://username:password@cluster0-jtpxd.mongodb.net/admin" From 86fdd7f39cceed5fedd594efe0e8457a56d8f0d6 Mon Sep 17 00:00:00 2001 From: mcasimir Date: Fri, 18 Feb 2022 18:29:16 +0100 Subject: [PATCH 03/14] adapt tests for connection screen --- .../src/components/accordion.tsx | 3 +- .../src/components/radio-box-group.tsx | 21 +++ packages/compass-components/src/index.ts | 6 +- .../commands/connect-with-connection-form.ts | 170 ++---------------- packages/compass-e2e-tests/helpers/compass.ts | 10 +- .../compass-e2e-tests/helpers/selectors.ts | 45 ++--- .../tests/connection.test.ts | 5 +- .../authentication-default.tsx | 2 + .../authentication-tab/authentication-tab.tsx | 2 +- .../general-tab/host-input.tsx | 10 +- .../general-tab/scheme-input.tsx | 14 +- 11 files changed, 86 insertions(+), 202 deletions(-) create mode 100644 packages/compass-components/src/components/radio-box-group.tsx diff --git a/packages/compass-components/src/components/accordion.tsx b/packages/compass-components/src/components/accordion.tsx index cf35551fc5b..a87c00d2461 100644 --- a/packages/compass-components/src/components/accordion.tsx +++ b/packages/compass-components/src/components/accordion.tsx @@ -42,10 +42,11 @@ function Accordion( const regionId = useId('region-'); const labelId = useId('label-'); return ( -
+