diff --git a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.test.tsx b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.test.tsx index d644b2f3e173f..c957258e91ff1 100644 --- a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.test.tsx +++ b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.test.tsx @@ -1510,6 +1510,27 @@ describe('DatabaseModal', () => { expect(allowFileUploadText).not.toBeInTheDocument(); expect(schemasForFileUploadText).not.toBeInTheDocument(); }); + + it('if the SSH Tunneling toggle is not displayed, nothing should get displayed', async () => { + const SSHTunnelingToggle = screen.queryByTestId('ssh-tunnel-switch'); + expect(SSHTunnelingToggle).not.toBeInTheDocument(); + const SSHTunnelServerAddressInput = screen.queryByTestId( + 'ssh-tunnel-server_address-input', + ); + expect(SSHTunnelServerAddressInput).not.toBeInTheDocument(); + const SSHTunnelServerPortInput = screen.queryByTestId( + 'ssh-tunnel-server_port-input', + ); + expect(SSHTunnelServerPortInput).not.toBeInTheDocument(); + const SSHTunnelUsernameInput = screen.queryByTestId( + 'ssh-tunnel-username-input', + ); + expect(SSHTunnelUsernameInput).not.toBeInTheDocument(); + const SSHTunnelPasswordInput = screen.queryByTestId( + 'ssh-tunnel-password-input', + ); + expect(SSHTunnelPasswordInput).not.toBeInTheDocument(); + }); }); describe('DatabaseModal w errors as objects', () => { diff --git a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx index 418b14f113537..3d52cdcaf61ce 100644 --- a/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx +++ b/superset-frontend/src/views/CRUD/data/database/DatabaseModal/index.tsx @@ -1154,7 +1154,7 @@ const DatabaseModal: FunctionComponent = ({ }, [passwordsNeeded]); useEffect(() => { - if (db) { + if (db && isSSHTunneling) { setUseSSHTunneling(!isEmpty(db?.ssh_tunnel)); } }, [db]);