fix(ssh_tunnel): Fix bug on database edition for databases with ssh tunnels (#23006)

Co-authored-by: Lyndsi Kay Williams <55605634+lyndsiWilliams@users.noreply.github.com>
This commit is contained in:
Antonio Rivero Martinez 2023-02-08 17:58:42 -03:00 committed by GitHub
parent 7bb9b810ee
commit ddd8d17aa4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 2 deletions

View File

@ -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', () => {

View File

@ -1154,10 +1154,10 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps> = ({
}, [passwordsNeeded]);
useEffect(() => {
if (db) {
if (db && isSSHTunneling) {
setUseSSHTunneling(!isEmpty(db?.ssh_tunnel));
}
}, [db]);
}, [db, isSSHTunneling]);
const onDbImport = async (info: UploadChangeParam) => {
setImportingErrorMessage('');