diff --git a/openmetadata-ui/src/main/resources/ui/src/components/common/TestConnection/TestConnection.test.tsx b/openmetadata-ui/src/main/resources/ui/src/components/common/TestConnection/TestConnection.test.tsx index fac56eefad9..95f3967a332 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/common/TestConnection/TestConnection.test.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/common/TestConnection/TestConnection.test.tsx @@ -54,7 +54,9 @@ jest.mock('utils/ServiceUtils', () => ({ jest.mock('./TestConnectionModal/TestConnectionModal', () => jest .fn() - .mockReturnValue(
Modal
) + .mockImplementation(({ isOpen }) => + isOpen ?
Modal
: null + ) ); jest.mock('rest/workflowAPI', () => ({ @@ -309,10 +311,36 @@ describe('Test Connection Component', () => { ).toBeInTheDocument(); }); + it('Should not show the connection status modal if test connection definition API fails', async () => { + (getTestConnectionDefinitionByName as jest.Mock).mockImplementationOnce( + () => Promise.reject() + ); + + await act(async () => { + render(); + }); + + const testConnectionButton = screen.getByTestId('test-connection-btn'); + + await act(async () => { + userEvent.click(testConnectionButton); + }); + + expect(getTestConnectionDefinitionByName).toHaveBeenCalledWith('Mysql'); + + expect( + screen.queryByTestId('test-connection-modal') + ).not.toBeInTheDocument(); + + // add workflow API should not get called + expect(addWorkflow).not.toHaveBeenCalled(); + }); + it('Test connection button should be disabled is airflow is not available', async () => { (useAirflowStatus as jest.Mock).mockImplementationOnce(() => ({ isAirflowAvailable: false, })); + await act(async () => { render(); }); diff --git a/openmetadata-ui/src/main/resources/ui/src/components/common/TestConnection/TestConnection.tsx b/openmetadata-ui/src/main/resources/ui/src/components/common/TestConnection/TestConnection.tsx index 225ac89f998..748576f0ef7 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/common/TestConnection/TestConnection.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/common/TestConnection/TestConnection.tsx @@ -52,6 +52,7 @@ import { WORKFLOW_COMPLETE_STATUS, } from 'constants/Services.constant'; import { useAirflowStatus } from 'hooks/useAirflowStatus'; +import { showErrorToast } from 'utils/ToastUtils'; import './test-connection.style.less'; const TestConnection: FC = ({ @@ -128,8 +129,9 @@ const TestConnection: FC = ({ const response = await getTestConnectionDefinitionByName(connectionType); setTestConnectionStep(response.steps); + setDialogOpen(true); } catch (error) { - // we will not throw error for this API + throw t('message.test-connection-cannot-be-triggered'); } }; @@ -188,8 +190,6 @@ const TestConnection: FC = ({ // fetch the connection steps for current connectionType await fetchConnectionDefinition(); - setDialogOpen(true); - // create the workflow const response = await addWorkflow(createWorkflowData); @@ -268,6 +268,7 @@ const TestConnection: FC = ({ setIsTestingConnection(false); setMessage(failureMessage); setTestStatus(StatusType.Failed); + showErrorToast(error as AxiosError); } }; diff --git a/openmetadata-ui/src/main/resources/ui/src/locale/languages/en-us.json b/openmetadata-ui/src/main/resources/ui/src/locale/languages/en-us.json index 797e202e73e..db63512a707 100644 --- a/openmetadata-ui/src/main/resources/ui/src/locale/languages/en-us.json +++ b/openmetadata-ui/src/main/resources/ui/src/locale/languages/en-us.json @@ -1172,6 +1172,7 @@ "successfully-completed-the-tour": "You’ve successfully completed the tour.", "team-moved-success": "Team moved successfully!", "team-no-asset": "Your team does not have any assets.", + "test-connection-cannot-be-triggered": "Test connection cannot be triggered.", "test-connection-taking-too-long": "The test connection is taking too long. Please try again.", "test-your-connection-before-creating-service": "Test your connections before creating the service", "testing-your-connection-may-take-two-minutes": "Testing your connections may take up-to 2 minutes", diff --git a/openmetadata-ui/src/main/resources/ui/src/locale/languages/es-es.json b/openmetadata-ui/src/main/resources/ui/src/locale/languages/es-es.json index 6ea46615385..d1021fdfac8 100644 --- a/openmetadata-ui/src/main/resources/ui/src/locale/languages/es-es.json +++ b/openmetadata-ui/src/main/resources/ui/src/locale/languages/es-es.json @@ -1172,6 +1172,7 @@ "successfully-completed-the-tour": "You’ve successfully completed the tour.", "team-moved-success": "Team moved successfully!", "team-no-asset": "Your team does not have any assets.", + "test-connection-cannot-be-triggered": "Test connection cannot be triggered.", "test-connection-taking-too-long": "The test connection is taking too long. Please try again.", "test-your-connection-before-creating-service": "Test your connections before creating the service", "testing-your-connection-may-take-two-minutes": "Testing your connections may take up-to 2 minutes", diff --git a/openmetadata-ui/src/main/resources/ui/src/locale/languages/fr-fr.json b/openmetadata-ui/src/main/resources/ui/src/locale/languages/fr-fr.json index e5ffe256a41..e5a0a676324 100644 --- a/openmetadata-ui/src/main/resources/ui/src/locale/languages/fr-fr.json +++ b/openmetadata-ui/src/main/resources/ui/src/locale/languages/fr-fr.json @@ -1172,6 +1172,7 @@ "successfully-completed-the-tour": "Vous avez fini la visite avec succès.", "team-moved-success": "Team moved successfully!", "team-no-asset": "Votre equipe n'a pas de resources de données", + "test-connection-cannot-be-triggered": "Test connection cannot be triggered.", "test-connection-taking-too-long": "The test connection is taking too long. Please try again.", "test-your-connection-before-creating-service": "Test your connections before creating the service", "testing-your-connection-may-take-two-minutes": "Testing your connections may take up-to 2 minutes", diff --git a/openmetadata-ui/src/main/resources/ui/src/locale/languages/ja-jp.json b/openmetadata-ui/src/main/resources/ui/src/locale/languages/ja-jp.json index 1059a8397b4..df95f66df83 100644 --- a/openmetadata-ui/src/main/resources/ui/src/locale/languages/ja-jp.json +++ b/openmetadata-ui/src/main/resources/ui/src/locale/languages/ja-jp.json @@ -1172,6 +1172,7 @@ "successfully-completed-the-tour": "あなたは無事ツアーを終了しました。", "team-moved-success": "チームの移動が成功しました!", "team-no-asset": "あなたのチームはアセットを持っていません。", + "test-connection-cannot-be-triggered": "Test connection cannot be triggered.", "test-connection-taking-too-long": "The test connection is taking too long. Please try again.", "test-your-connection-before-creating-service": "サービスを作成する前に接続テストをしてください。", "testing-your-connection-may-take-two-minutes": "Testing your connections may take up-to 2 minutes", diff --git a/openmetadata-ui/src/main/resources/ui/src/locale/languages/pt-br.json b/openmetadata-ui/src/main/resources/ui/src/locale/languages/pt-br.json index fa73b8db328..9e8616fcce9 100644 --- a/openmetadata-ui/src/main/resources/ui/src/locale/languages/pt-br.json +++ b/openmetadata-ui/src/main/resources/ui/src/locale/languages/pt-br.json @@ -1172,6 +1172,7 @@ "successfully-completed-the-tour": "Você concluiu o tour com sucesso.", "team-moved-success": "Time movido com sucesso!", "team-no-asset": "Seu time não possui nenhum ativo.", + "test-connection-cannot-be-triggered": "Test connection cannot be triggered.", "test-connection-taking-too-long": "The test connection is taking too long. Please try again.", "test-your-connection-before-creating-service": "Teste suas conexões antes de criar o serviço", "testing-your-connection-may-take-two-minutes": "Testing your connections may take up-to 2 minutes", diff --git a/openmetadata-ui/src/main/resources/ui/src/locale/languages/zh-cn.json b/openmetadata-ui/src/main/resources/ui/src/locale/languages/zh-cn.json index a9fe862489a..761a0d9ebf8 100644 --- a/openmetadata-ui/src/main/resources/ui/src/locale/languages/zh-cn.json +++ b/openmetadata-ui/src/main/resources/ui/src/locale/languages/zh-cn.json @@ -1172,6 +1172,7 @@ "successfully-completed-the-tour": "You’ve successfully completed the tour.", "team-moved-success": "Team moved successfully", "team-no-asset": "Your team does not have any assets", + "test-connection-cannot-be-triggered": "Test connection cannot be triggered.", "test-connection-taking-too-long": "The test connection is taking too long. Please try again.", "test-your-connection-before-creating-service": "Test your connections before creating the service", "testing-your-connection-may-take-two-minutes": "Testing your connections may take up-to 2 minutes",