diff --git a/openmetadata-ui/src/main/resources/ui/src/components/common/InlineAlert/InlineAlert.interface.ts b/openmetadata-ui/src/main/resources/ui/src/components/common/InlineAlert/InlineAlert.interface.ts index 2eb5cfe3948..842c833c657 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/common/InlineAlert/InlineAlert.interface.ts +++ b/openmetadata-ui/src/main/resources/ui/src/components/common/InlineAlert/InlineAlert.interface.ts @@ -18,7 +18,7 @@ export interface InlineAlertProps { alertClassName?: string; type?: InlineAlertType; heading: string; - description: ReactNode; + description?: ReactNode; subDescription?: ReactNode; onClose?: () => void; } diff --git a/openmetadata-ui/src/main/resources/ui/src/components/common/InlineAlert/InlineAlert.test.tsx b/openmetadata-ui/src/main/resources/ui/src/components/common/InlineAlert/InlineAlert.test.tsx index dc1ccbc2934..879faa9f778 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/common/InlineAlert/InlineAlert.test.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/common/InlineAlert/InlineAlert.test.tsx @@ -43,6 +43,14 @@ describe('InlineAlert', () => { expect(screen.getByText('Test Description')).toBeInTheDocument(); }); + it('should not render description when it is not provided', () => { + render(); + + expect( + screen.queryByTestId('inline-alert-description') + ).not.toBeInTheDocument(); + }); + it('should handle show more/less functionality when subDescription is provided', () => { const subDescription = 'Additional details here'; render(); diff --git a/openmetadata-ui/src/main/resources/ui/src/components/common/InlineAlert/InlineAlert.tsx b/openmetadata-ui/src/main/resources/ui/src/components/common/InlineAlert/InlineAlert.tsx index 5e4bea63653..18fe00fdf7a 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/common/InlineAlert/InlineAlert.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/common/InlineAlert/InlineAlert.tsx @@ -102,19 +102,25 @@ function InlineAlert({ {heading} - - {description} - + {description && ( + + {description} + + )} {subDescription && showMore && ( - + {subDescription} )} {subDescription && ( )} { + return jest.fn().mockReturnValue(

InlineAlert

); +}); + const onCancelMock = jest.fn(); const onConfirmMock = jest.fn(); @@ -36,115 +41,55 @@ const testConnectionStepResult = [ ]; const mockOnTestConnection = jest.fn(); +const mockHandleCloseErrorMessage = jest.fn(); -const isConnectionTimeout = false; +const commonProps = { + isOpen: true, + isConnectionTimeout: false, + isTestingConnection: false, + progress: 10, + testConnectionStep, + testConnectionStepResult, + onCancel: onCancelMock, + onConfirm: onConfirmMock, + onTestConnection: mockOnTestConnection, + handleCloseErrorMessage: mockHandleCloseErrorMessage, +}; describe('TestConnectionModal', () => { it('Should render the modal title', () => { - render( - - ); + render(); expect(screen.getByText('label.connection-status')).toBeInTheDocument(); }); it('Should render the steps and their results', () => { - render( - - ); + render(); expect(screen.getByText('Step 1')).toBeInTheDocument(); expect(screen.getByText('Step 2')).toBeInTheDocument(); }); it('Should render the success icon for a passing step', () => { - render( - - ); + render(); expect(screen.getByTestId('success-badge')).toBeInTheDocument(); }); it('Should render the fail icon for a failing step', () => { - render( - - ); + render(); expect(screen.getByTestId('fail-badge')).toBeInTheDocument(); }); it('Should render the awaiting status for a step being tested', () => { - render( - - ); + render(); expect(screen.getAllByText('label.awaiting-status...')).toHaveLength(2); }); it('Should call onCancel when the cancel button is clicked', () => { - render( - - ); + render(); const cancelButton = screen.getByText('Cancel'); fireEvent.click(cancelButton); @@ -153,19 +98,7 @@ describe('TestConnectionModal', () => { }); it('Should call onConfirm when the confirm button is clicked', () => { - render( - - ); + render(); const okButton = screen.getByText('OK'); fireEvent.click(okButton); @@ -174,19 +107,7 @@ describe('TestConnectionModal', () => { }); it('Should render the progress bar with proper value', () => { - render( - - ); + render(); const progressBarValue = screen.getByTestId('progress-bar-value'); expect(progressBarValue).toBeInTheDocument(); @@ -196,17 +117,7 @@ describe('TestConnectionModal', () => { it('Should render the timeout widget if "isConnectionTimeout" is true', () => { render( - + ); expect( @@ -216,17 +127,7 @@ describe('TestConnectionModal', () => { it('Try again button should work', async () => { render( - + ); const tryAgainButton = screen.getByTestId('try-again-button'); @@ -239,4 +140,28 @@ describe('TestConnectionModal', () => { expect(mockOnTestConnection).toHaveBeenCalled(); }); + + it('should not show error message component if error message is not passed', async () => { + render(); + + const errorComponent = screen.queryByText('InlineAlert'); + + expect(errorComponent).not.toBeInTheDocument(); + }); + + it('should show error message component if error message is passed', async () => { + render( + + ); + + const errorComponent = screen.getByText('InlineAlert'); + + expect(errorComponent).toBeInTheDocument(); + }); }); diff --git a/openmetadata-ui/src/main/resources/ui/src/components/common/TestConnection/TestConnectionModal/TestConnectionModal.tsx b/openmetadata-ui/src/main/resources/ui/src/components/common/TestConnection/TestConnectionModal/TestConnectionModal.tsx index c0c5c126a84..0a1066c6ed9 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/common/TestConnection/TestConnectionModal/TestConnectionModal.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/common/TestConnection/TestConnectionModal/TestConnectionModal.tsx @@ -22,8 +22,10 @@ import React, { FC } from 'react'; import { useTranslation } from 'react-i18next'; import { ReactComponent as IconTimeOut } from '../../../../assets/svg/ic-time-out.svg'; import { ReactComponent as IconTimeOutButton } from '../../../../assets/svg/ic-timeout-button.svg'; +import { TEST_CONNECTION_FAILURE_MESSAGE } from '../../../../constants/Services.constant'; import { TestConnectionStepResult } from '../../../../generated/entity/automations/workflow'; import { TestConnectionStep } from '../../../../generated/entity/services/connections/testConnectionDefinition'; +import InlineAlert from '../../InlineAlert/InlineAlert'; import ConnectionStepCard from '../ConnectionStepCard/ConnectionStepCard'; import './test-connection-modal.less'; interface TestConnectionModalProps { @@ -36,6 +38,11 @@ interface TestConnectionModalProps { onCancel: () => void; onConfirm: () => void; onTestConnection: () => void; + errorMessage?: { + description?: string; + subDescription?: string; + }; + handleCloseErrorMessage: () => void; } const TestConnectionModal: FC = ({ @@ -48,6 +55,8 @@ const TestConnectionModal: FC = ({ onCancel, isConnectionTimeout, onTestConnection, + errorMessage, + handleCloseErrorMessage, }) => { const { t } = useTranslation(); @@ -77,6 +86,15 @@ const TestConnectionModal: FC = ({ className="p-x-md w-full overflow-hidden" direction="vertical" size={16}> + {errorMessage && ( + + )} +