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:
Sweta Agarwalla 2025-10-16 15:16:17 +05:30 committed by GitHub
parent 8af7ac4c1a
commit f98ea0fa87
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 103 additions and 8 deletions

View File

@ -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 () => {
jest.useFakeTimers();
await act(async () => {

View File

@ -280,16 +280,24 @@ const TestConnection: FC<TestConnectionProps> = ({
timeoutId?: number;
} = {};
const { ingestionRunner, ...rest } = updatedFormData as ConfigObject & {
ingestionRunner?: string;
};
try {
const ingestionRunnerValue = extraInfo ?? ingestionRunner;
const createWorkflowData: CreateWorkflow = {
name: getTestConnectionName(connectionType),
workflowType: WorkflowType.TestConnection,
request: {
connection: { config: updatedFormData as ConfigObject },
connection: { config: rest },
serviceType,
connectionType,
serviceName,
ingestionRunner: extraInfo,
...(ingestionRunnerValue && {
ingestionRunner: ingestionRunnerValue,
}),
},
};

View File

@ -17,6 +17,7 @@ import { MemoryRouter, useNavigate } from 'react-router-dom';
import { noop } from 'lodash';
import { act } from 'react';
import { TestConnectionProps } from '../../components/common/TestConnection/TestConnection.interface';
import { ROUTES } from '../../constants/constants';
import { OPEN_METADATA } from '../../constants/Services.constant';
import { usePermissionProvider } from '../../context/PermissionProvider/PermissionProvider';
@ -42,6 +43,7 @@ import {
getWorkflowInstancesForApplication,
getWorkflowInstanceStateById,
} from '../../rest/workflowAPI';
import serviceUtilClassBase from '../../utils/ServiceUtilClassBase';
import { getCountLabel, shouldTestConnection } from '../../utils/ServiceUtils';
import { showErrorToast } from '../../utils/ToastUtils';
import { useRequiredParams } from '../../utils/useRequiredParams';
@ -357,11 +359,16 @@ jest.mock(
);
jest.mock('../../components/common/TestConnection/TestConnection', () =>
jest.fn().mockImplementation(({ serviceCategory }: any) => (
jest
.fn()
.mockImplementation(
({ 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', () =>
@ -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', () => {
it('should use correct service utilities', async () => {
(getPipelineServiceHostIp as jest.Mock).mockResolvedValue({});

View File

@ -1467,7 +1467,7 @@ const ServiceDetailsPage: FunctionComponent = () => {
{allowTestConn && (
<TestConnection
connectionType={serviceDetails?.serviceType ?? ''}
extraInfo={extraInfoData?.name || extraInfoData?.displayName}
extraInfo={extraInfoData?.name}
getData={() => connectionDetails}
hostIp={hostIp}
isTestingDisabled={isTestingDisabled}