mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-12-16 10:08:08 +00:00
chore(ui): Show error message if test definition API fails (#10885)
* chore(ui): Show error message if test definition API fails * test: add unit test --------- Co-authored-by: Chirag Madlani <12962843+chirag-madlani@users.noreply.github.com>
This commit is contained in:
parent
d5a072d83b
commit
31a5464090
@ -54,7 +54,9 @@ jest.mock('utils/ServiceUtils', () => ({
|
||||
jest.mock('./TestConnectionModal/TestConnectionModal', () =>
|
||||
jest
|
||||
.fn()
|
||||
.mockReturnValue(<div data-testid="test-connection-modal">Modal</div>)
|
||||
.mockImplementation(({ isOpen }) =>
|
||||
isOpen ? <div data-testid="test-connection-modal">Modal</div> : 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(<TestConnection {...mockProps} />);
|
||||
});
|
||||
|
||||
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(<TestConnection {...mockProps} />);
|
||||
});
|
||||
|
||||
@ -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<TestConnectionProps> = ({
|
||||
@ -128,8 +129,9 @@ const TestConnection: FC<TestConnectionProps> = ({
|
||||
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<TestConnectionProps> = ({
|
||||
// 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<TestConnectionProps> = ({
|
||||
setIsTestingConnection(false);
|
||||
setMessage(failureMessage);
|
||||
setTestStatus(StatusType.Failed);
|
||||
showErrorToast(error as AxiosError);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -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",
|
||||
|
||||
@ -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",
|
||||
|
||||
@ -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",
|
||||
|
||||
@ -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",
|
||||
|
||||
@ -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",
|
||||
|
||||
@ -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",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user