mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2026-01-06 12:36:56 +00:00
fix(ui):test connection should be disabled is airflow is not present (#10862)
This commit is contained in:
parent
608bf51b6a
commit
73947ab207
@ -22,6 +22,7 @@ import {
|
||||
StatusType,
|
||||
WorkflowStatus,
|
||||
} from 'generated/api/automations/createWorkflow';
|
||||
import { useAirflowStatus } from 'hooks/useAirflowStatus';
|
||||
import { ConfigData } from 'interface/service.interface';
|
||||
import React from 'react';
|
||||
import {
|
||||
@ -72,6 +73,12 @@ jest.mock('rest/workflowAPI', () => ({
|
||||
.mockImplementation(() => Promise.resolve(WORKFLOW_DETAILS)),
|
||||
}));
|
||||
|
||||
jest.mock('hooks/useAirflowStatus', () => ({
|
||||
useAirflowStatus: jest
|
||||
.fn()
|
||||
.mockImplementation(() => ({ isAirflowAvailable: true })),
|
||||
}));
|
||||
|
||||
describe('Test Connection Component', () => {
|
||||
it('Should render the child component', async () => {
|
||||
await act(async () => {
|
||||
@ -301,4 +308,30 @@ describe('Test Connection Component', () => {
|
||||
screen.getByText('message.test-connection-taking-too-long')
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
|
||||
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} />);
|
||||
});
|
||||
|
||||
const testConnectionButton = screen.getByTestId('test-connection-btn');
|
||||
|
||||
expect(testConnectionButton).toBeDisabled();
|
||||
});
|
||||
|
||||
it('Test connection button with showDetails false should be disabled is airflow is not available', async () => {
|
||||
(useAirflowStatus as jest.Mock).mockImplementationOnce(() => ({
|
||||
isAirflowAvailable: false,
|
||||
}));
|
||||
await act(async () => {
|
||||
render(<TestConnection {...mockProps} showDetails={false} />);
|
||||
});
|
||||
|
||||
const testConnectionButton = screen.getByTestId('test-connection-button');
|
||||
|
||||
expect(testConnectionButton).toBeDisabled();
|
||||
});
|
||||
});
|
||||
|
||||
@ -51,6 +51,7 @@ import {
|
||||
FETCH_INTERVAL,
|
||||
WORKFLOW_COMPLETE_STATUS,
|
||||
} from 'constants/Services.constant';
|
||||
import { useAirflowStatus } from 'hooks/useAirflowStatus';
|
||||
import './test-connection.style.less';
|
||||
|
||||
const TestConnection: FC<TestConnectionProps> = ({
|
||||
@ -62,6 +63,7 @@ const TestConnection: FC<TestConnectionProps> = ({
|
||||
showDetails = true,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const { isAirflowAvailable } = useAirflowStatus();
|
||||
|
||||
const initialMessage = t(
|
||||
'message.test-your-connection-before-creating-service'
|
||||
@ -114,7 +116,10 @@ const TestConnection: FC<TestConnectionProps> = ({
|
||||
}, [connectionType]);
|
||||
|
||||
const isTestConnectionDisabled =
|
||||
isTestingConnection || isTestingDisabled || !allowTestConn;
|
||||
isTestingConnection ||
|
||||
isTestingDisabled ||
|
||||
!allowTestConn ||
|
||||
!isAirflowAvailable;
|
||||
|
||||
// data fetch handlers
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user