mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-12-19 03:27:19 +00:00
fix(ui): add fixes for workflow API (#23917)
* add fixes for workflow API * Fix the ingestion runner display name being passed to API --------- Co-authored-by: Aniket Katkar <aniketkatkar97@gmail.com>
This commit is contained in:
parent
8af7ac4c1a
commit
f98ea0fa87
@ -238,6 +238,54 @@ describe('Test Connection Component', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Should create workflow with ingestionRunner when ingestionRunner is present in formData', async () => {
|
||||||
|
jest.useFakeTimers();
|
||||||
|
await act(async () => {
|
||||||
|
render(
|
||||||
|
<TestConnection
|
||||||
|
{...mockProps}
|
||||||
|
getData={() =>
|
||||||
|
({
|
||||||
|
...FORM_DATA,
|
||||||
|
ingestionRunner: 'custom-runner-name',
|
||||||
|
} as ConfigData)
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
const controller = new AbortController();
|
||||||
|
|
||||||
|
const testConnectionButton = screen.getByTestId('test-connection-btn');
|
||||||
|
|
||||||
|
await act(async () => {
|
||||||
|
fireEvent.click(testConnectionButton);
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(addWorkflow).toHaveBeenCalledWith(
|
||||||
|
CREATE_WORKFLOW_PAYLOAD_WITH_RUNNER,
|
||||||
|
controller.signal
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Should create workflow without ingestionRunner field when ingestionRunner is not in formData and in extraInfo', async () => {
|
||||||
|
jest.useFakeTimers();
|
||||||
|
await act(async () => {
|
||||||
|
render(<TestConnection {...mockProps} />);
|
||||||
|
});
|
||||||
|
const controller = new AbortController();
|
||||||
|
|
||||||
|
const testConnectionButton = screen.getByTestId('test-connection-btn');
|
||||||
|
|
||||||
|
await act(async () => {
|
||||||
|
fireEvent.click(testConnectionButton);
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(addWorkflow).toHaveBeenCalledWith(
|
||||||
|
CREATE_WORKFLOW_PAYLOAD,
|
||||||
|
controller.signal
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
it('Should show success message if test connection successful', async () => {
|
it('Should show success message if test connection successful', async () => {
|
||||||
jest.useFakeTimers();
|
jest.useFakeTimers();
|
||||||
await act(async () => {
|
await act(async () => {
|
||||||
|
|||||||
@ -280,16 +280,24 @@ const TestConnection: FC<TestConnectionProps> = ({
|
|||||||
timeoutId?: number;
|
timeoutId?: number;
|
||||||
} = {};
|
} = {};
|
||||||
|
|
||||||
|
const { ingestionRunner, ...rest } = updatedFormData as ConfigObject & {
|
||||||
|
ingestionRunner?: string;
|
||||||
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
const ingestionRunnerValue = extraInfo ?? ingestionRunner;
|
||||||
|
|
||||||
const createWorkflowData: CreateWorkflow = {
|
const createWorkflowData: CreateWorkflow = {
|
||||||
name: getTestConnectionName(connectionType),
|
name: getTestConnectionName(connectionType),
|
||||||
workflowType: WorkflowType.TestConnection,
|
workflowType: WorkflowType.TestConnection,
|
||||||
request: {
|
request: {
|
||||||
connection: { config: updatedFormData as ConfigObject },
|
connection: { config: rest },
|
||||||
serviceType,
|
serviceType,
|
||||||
connectionType,
|
connectionType,
|
||||||
serviceName,
|
serviceName,
|
||||||
ingestionRunner: extraInfo,
|
...(ingestionRunnerValue && {
|
||||||
|
ingestionRunner: ingestionRunnerValue,
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -17,6 +17,7 @@ import { MemoryRouter, useNavigate } from 'react-router-dom';
|
|||||||
|
|
||||||
import { noop } from 'lodash';
|
import { noop } from 'lodash';
|
||||||
import { act } from 'react';
|
import { act } from 'react';
|
||||||
|
import { TestConnectionProps } from '../../components/common/TestConnection/TestConnection.interface';
|
||||||
import { ROUTES } from '../../constants/constants';
|
import { ROUTES } from '../../constants/constants';
|
||||||
import { OPEN_METADATA } from '../../constants/Services.constant';
|
import { OPEN_METADATA } from '../../constants/Services.constant';
|
||||||
import { usePermissionProvider } from '../../context/PermissionProvider/PermissionProvider';
|
import { usePermissionProvider } from '../../context/PermissionProvider/PermissionProvider';
|
||||||
@ -42,6 +43,7 @@ import {
|
|||||||
getWorkflowInstancesForApplication,
|
getWorkflowInstancesForApplication,
|
||||||
getWorkflowInstanceStateById,
|
getWorkflowInstanceStateById,
|
||||||
} from '../../rest/workflowAPI';
|
} from '../../rest/workflowAPI';
|
||||||
|
import serviceUtilClassBase from '../../utils/ServiceUtilClassBase';
|
||||||
import { getCountLabel, shouldTestConnection } from '../../utils/ServiceUtils';
|
import { getCountLabel, shouldTestConnection } from '../../utils/ServiceUtils';
|
||||||
import { showErrorToast } from '../../utils/ToastUtils';
|
import { showErrorToast } from '../../utils/ToastUtils';
|
||||||
import { useRequiredParams } from '../../utils/useRequiredParams';
|
import { useRequiredParams } from '../../utils/useRequiredParams';
|
||||||
@ -357,11 +359,16 @@ jest.mock(
|
|||||||
);
|
);
|
||||||
|
|
||||||
jest.mock('../../components/common/TestConnection/TestConnection', () =>
|
jest.mock('../../components/common/TestConnection/TestConnection', () =>
|
||||||
jest.fn().mockImplementation(({ serviceCategory }: any) => (
|
jest
|
||||||
<div data-testid="test-connection">
|
.fn()
|
||||||
<span data-testid="test-connection-category">{serviceCategory}</span>
|
.mockImplementation(
|
||||||
</div>
|
({ serviceCategory, extraInfo }: TestConnectionProps) => (
|
||||||
))
|
<div data-testid="test-connection">
|
||||||
|
<span data-testid="test-connection-category">{serviceCategory}</span>
|
||||||
|
<span data-testid="test-connection-extra-info">{extraInfo}</span>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
jest.mock('../../components/common/ErrorWithPlaceholder/ErrorPlaceHolder', () =>
|
jest.mock('../../components/common/ErrorWithPlaceholder/ErrorPlaceHolder', () =>
|
||||||
@ -1092,6 +1099,38 @@ describe('ServiceDetailsPage', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('Test connection tab', () => {
|
||||||
|
const mockServiceUtil = serviceUtilClassBase as jest.Mocked<
|
||||||
|
typeof serviceUtilClassBase
|
||||||
|
>;
|
||||||
|
|
||||||
|
it('should pass ingestion runner name to TestConnection component', async () => {
|
||||||
|
const ingestionRunnerName = 'IngestionRunner1';
|
||||||
|
mockServiceUtil.getServiceExtraInfo.mockReturnValue({
|
||||||
|
name: ingestionRunnerName,
|
||||||
|
});
|
||||||
|
(useRequiredParams as jest.Mock).mockImplementation(() => ({
|
||||||
|
serviceCategory: ServiceCategory.DATABASE_SERVICES,
|
||||||
|
tab: EntityTabs.CONNECTION,
|
||||||
|
}));
|
||||||
|
(getServiceByFQN as jest.Mock).mockImplementationOnce(() =>
|
||||||
|
Promise.resolve({
|
||||||
|
...mockServiceDetails,
|
||||||
|
ingestionRunnerName,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
await renderComponent();
|
||||||
|
|
||||||
|
await waitFor(() => {
|
||||||
|
expect(screen.getByTestId('test-connection')).toBeInTheDocument();
|
||||||
|
expect(
|
||||||
|
screen.getByTestId('test-connection-extra-info')
|
||||||
|
).toHaveTextContent(ingestionRunnerName);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('Utility Function Integration', () => {
|
describe('Utility Function Integration', () => {
|
||||||
it('should use correct service utilities', async () => {
|
it('should use correct service utilities', async () => {
|
||||||
(getPipelineServiceHostIp as jest.Mock).mockResolvedValue({});
|
(getPipelineServiceHostIp as jest.Mock).mockResolvedValue({});
|
||||||
|
|||||||
@ -1467,7 +1467,7 @@ const ServiceDetailsPage: FunctionComponent = () => {
|
|||||||
{allowTestConn && (
|
{allowTestConn && (
|
||||||
<TestConnection
|
<TestConnection
|
||||||
connectionType={serviceDetails?.serviceType ?? ''}
|
connectionType={serviceDetails?.serviceType ?? ''}
|
||||||
extraInfo={extraInfoData?.name || extraInfoData?.displayName}
|
extraInfo={extraInfoData?.name}
|
||||||
getData={() => connectionDetails}
|
getData={() => connectionDetails}
|
||||||
hostIp={hostIp}
|
hostIp={hostIp}
|
||||||
isTestingDisabled={isTestingDisabled}
|
isTestingDisabled={isTestingDisabled}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user