Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements: Automator requirements oss #19128

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const EntityHeaderTitle = ({
data-testid={`${serviceName}-${name}`}
gutter={12}
wrap={false}>
{icon && <Col>{icon}</Col>}
{icon && <Col className="flex-center">{icon}</Col>}
<Col
className={
deleted || badge ? 'w-max-full-140' : 'entity-header-content'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,18 @@ import { act, render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import React from 'react';
import { MemoryRouter } from 'react-router-dom';
import { mockIngestionListTableProps } from '../../../../../mocks/IngestionListTable.mock';
import { usePermissionProvider } from '../../../../../context/PermissionProvider/PermissionProvider';
import { mockIngestionData } from '../../../../../mocks/Ingestion.mock';
import {
mockESIngestionData,
mockIngestionListTableProps,
} from '../../../../../mocks/IngestionListTable.mock';
import { ENTITY_PERMISSIONS } from '../../../../../mocks/Permissions.mock';
import { deleteIngestionPipelineById } from '../../../../../rest/ingestionPipelineAPI';
import IngestionListTable from './IngestionListTable';

const mockGetEntityPermissionByFqn = jest.fn();

jest.mock('../../../../../hooks/useApplicationStore', () => ({
useApplicationStore: jest.fn(() => ({
theme: { primaryColor: '#fff' },
Expand Down Expand Up @@ -260,4 +267,33 @@ describe('Ingestion', () => {

expect(deleteIngestionPipelineById).toHaveBeenCalledWith('id');
});

it('should fetch the permissions for all the ingestion pipelines', async () => {
(usePermissionProvider as jest.Mock).mockImplementation(() => ({
getEntityPermissionByFqn: mockGetEntityPermissionByFqn,
}));

await act(async () => {
render(
<IngestionListTable
{...mockIngestionListTableProps}
ingestionData={[mockESIngestionData, mockIngestionData]}
/>,
{
wrapper: MemoryRouter,
}
);
});

expect(mockGetEntityPermissionByFqn).toHaveBeenNthCalledWith(
1,
'ingestionPipeline',
mockESIngestionData.fullyQualifiedName
);
expect(mockGetEntityPermissionByFqn).toHaveBeenNthCalledWith(
2,
'ingestionPipeline',
mockIngestionData.fullyQualifiedName
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,10 @@ function IngestionListTable({
const fetchIngestionPipelinesPermission = useCallback(async () => {
try {
const promises = ingestionData.map((item) =>
getEntityPermissionByFqn(ResourceEntity.INGESTION_PIPELINE, item.name)
getEntityPermissionByFqn(
ResourceEntity.INGESTION_PIPELINE,
item.fullyQualifiedName ?? ''
)
);
const response = await Promise.allSettled(promises);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@
* limitations under the License.
*/

import { IngestionServicePermission } from '../../../../context/PermissionProvider/PermissionProvider.interface';
import { ServiceCategory } from '../../../../enums/service.enum';
import { IngestionPipeline } from '../../../../generated/entity/services/ingestionPipelines/ingestionPipeline';
import { SelectedRowDetails } from './ingestion.interface';
import { ButtonProps } from 'antd';
import { IngestionServicePermission } from '../../../../../../context/PermissionProvider/PermissionProvider.interface';
import { ServiceCategory } from '../../../../../../enums/service.enum';
import { IngestionPipeline } from '../../../../../../generated/entity/services/ingestionPipelines/ingestionPipeline';
import { SelectedRowDetails } from '../../ingestion.interface';

export interface PipelineActionsProps {
pipeline: IngestionPipeline;
Expand All @@ -28,4 +29,5 @@ export interface PipelineActionsProps {
handleEnableDisableIngestion?: (id: string) => Promise<void>;
handleIsConfirmationModalOpen: (value: boolean) => void;
onIngestionWorkflowsUpdate?: () => void;
moreActionButtonProps?: ButtonProps;
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import { Operation } from '../../../../../../generated/entity/policies/accessCon
import { PipelineType } from '../../../../../../generated/entity/services/ingestionPipelines/ingestionPipeline';
import { getLoadingStatus } from '../../../../../../utils/CommonUtils';
import { getLogsViewerPath } from '../../../../../../utils/RouterUtils';
import { PipelineActionsProps } from '../../PipelineActions.interface';
import './pipeline-actions.less';
import { PipelineActionsProps } from './PipelineActions.interface';
import PipelineActionsDropdown from './PipelineActionsDropdown';

function PipelineActions({
Expand All @@ -38,6 +38,7 @@ function PipelineActions({
handleIsConfirmationModalOpen,
onIngestionWorkflowsUpdate,
handleEditClick,
moreActionButtonProps,
}: Readonly<PipelineActionsProps>) {
const history = useHistory();
const { t } = useTranslation();
Expand Down Expand Up @@ -168,6 +169,7 @@ function PipelineActions({
handleIsConfirmationModalOpen={handleIsConfirmationModalOpen}
ingestion={pipeline}
ingestionPipelinePermissions={ingestionPipelinePermissions}
moreActionButtonProps={moreActionButtonProps}
serviceCategory={serviceCategory}
serviceName={serviceName}
triggerIngestion={triggerIngestion}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* limitations under the License.
*/

import { ButtonProps } from 'antd';
import { IngestionServicePermission } from '../../../../../../context/PermissionProvider/PermissionProvider.interface';
import { IngestionPipeline } from '../../../../../../generated/entity/services/ingestionPipelines/ingestionPipeline';
import { SelectedRowDetails } from '../../ingestion.interface';
Expand All @@ -26,4 +27,5 @@ export interface PipelineActionsDropdownProps {
handleDeleteSelection: (row: SelectedRowDetails) => void;
handleIsConfirmationModalOpen: (value: boolean) => void;
onIngestionWorkflowsUpdate?: () => void;
moreActionButtonProps?: ButtonProps;
}
Original file line number Diff line number Diff line change
Expand Up @@ -324,4 +324,26 @@ describe('PipelineActionsDropdown', () => {

expect(screen.queryByText('KillIngestionPipelineModal')).toBeNull();
});

it('should pass the moreActionButtonProps to the more action button', async () => {
const mockOnClick = jest.fn();

await act(async () => {
render(
<PipelineActionsDropdown
{...mockPipelineActionsDropdownProps}
moreActionButtonProps={{
onClick: mockOnClick,
}}
/>,
{
wrapper: MemoryRouter,
}
);
});

await clickOnMoreActions();

expect(mockOnClick).toHaveBeenCalled();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ function PipelineActionsDropdown({
handleIsConfirmationModalOpen,
onIngestionWorkflowsUpdate,
ingestionPipelinePermissions,
moreActionButtonProps,
}: Readonly<PipelineActionsDropdownProps>) {
const history = useHistory();
const { t } = useTranslation();
Expand Down Expand Up @@ -270,6 +271,7 @@ function PipelineActionsDropdown({
icon={<MoreIcon />}
type="link"
onClick={() => setIsOpen((value) => !value)}
{...moreActionButtonProps}
/>
</Dropdown>
{isKillModalOpen && selectedPipeline && id === selectedPipeline?.id && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ const SuccessScreen = ({
<Typography.Paragraph
className="m-b-0"
data-testid="success-line"
ellipsis={{ rows: 3 }}>
ellipsis={{ rows: 7 }}>
aniketkatkar97 marked this conversation as resolved.
Show resolved Hide resolved
{isUndefined(successMessage) ? (
<span>
<span className="m-r-xss font-semibold">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

import { AddIngestionButtonProps } from '../components/Settings/Services/Ingestion/AddIngestionButton.interface';
import { IngestionListTableProps } from '../components/Settings/Services/Ingestion/IngestionListTable/IngestionListTable.interface';
import { PipelineActionsProps } from '../components/Settings/Services/Ingestion/IngestionListTable/PipelineActions/PipelineActions.interface';
import { PipelineActionsDropdownProps } from '../components/Settings/Services/Ingestion/IngestionListTable/PipelineActions/PipelineActionsDropdown.interface';
import { PipelineActionsProps } from '../components/Settings/Services/Ingestion/PipelineActions.interface';
import { ServiceCategory } from '../enums/service.enum';
import { DatabaseServiceType } from '../generated/entity/data/database';
import { ConfigType } from '../generated/entity/services/databaseService';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
* limitations under the License.
*/
import { EntityFields } from '../enums/AdvancedSearch.enum';
import { AdvancedSearchClassBase } from './AdvancedSearchClassBase';
import { SearchIndex } from '../enums/search.enum';
import advancedSearchClassBase, {
AdvancedSearchClassBase,
} from './AdvancedSearchClassBase';

jest.mock('../rest/miscAPI', () => ({
getAggregateFieldOptions: jest.fn().mockImplementation(() =>
Expand Down Expand Up @@ -50,3 +53,134 @@ describe('AdvancedSearchClassBase', () => {
]);
});
});

describe('getEntitySpecificQueryBuilderFields', () => {
it('should return table specific fields', () => {
const result = advancedSearchClassBase.getEntitySpecificQueryBuilderFields([
SearchIndex.TABLE,
]);

expect(Object.keys(result)).toEqual([
EntityFields.DATABASE,
EntityFields.DATABASE_SCHEMA,
EntityFields.TABLE_TYPE,
EntityFields.COLUMN_DESCRIPTION_STATUS,
]);
});

it('should return pipeline specific fields', () => {
const result = advancedSearchClassBase.getEntitySpecificQueryBuilderFields([
SearchIndex.PIPELINE,
]);

expect(Object.keys(result)).toEqual([EntityFields.TASK]);
});

it('should return dashboard specific fields', () => {
const result = advancedSearchClassBase.getEntitySpecificQueryBuilderFields([
SearchIndex.DASHBOARD,
]);

expect(Object.keys(result)).toEqual([
EntityFields.DATA_MODEL,
EntityFields.CHART,
EntityFields.PROJECT,
]);
});

it('should return topic specific fields', () => {
const result = advancedSearchClassBase.getEntitySpecificQueryBuilderFields([
SearchIndex.TOPIC,
]);

expect(Object.keys(result)).toEqual([EntityFields.SCHEMA_FIELD]);
});

it('should return mlModel specific fields', () => {
const result = advancedSearchClassBase.getEntitySpecificQueryBuilderFields([
SearchIndex.MLMODEL,
]);

expect(Object.keys(result)).toEqual([EntityFields.FEATURE]);
});

it('should return container specific fields', () => {
const result = advancedSearchClassBase.getEntitySpecificQueryBuilderFields([
SearchIndex.CONTAINER,
]);

expect(Object.keys(result)).toEqual([EntityFields.CONTAINER_COLUMN]);
});

it('should return searchIndex specific fields', () => {
const result = advancedSearchClassBase.getEntitySpecificQueryBuilderFields([
SearchIndex.SEARCH_INDEX,
]);

expect(Object.keys(result)).toEqual([EntityFields.FIELD]);
});

it('should return dataModel specific fields', () => {
const result = advancedSearchClassBase.getEntitySpecificQueryBuilderFields([
SearchIndex.DASHBOARD_DATA_MODEL,
]);

expect(Object.keys(result)).toEqual([
EntityFields.DATA_MODEL_TYPE,
EntityFields.PROJECT,
]);
});

it('should return apiEndpoint specific fields', () => {
const result = advancedSearchClassBase.getEntitySpecificQueryBuilderFields([
SearchIndex.API_ENDPOINT_INDEX,
]);

expect(Object.keys(result)).toEqual([
EntityFields.REQUEST_SCHEMA_FIELD,
EntityFields.RESPONSE_SCHEMA_FIELD,
]);
});

it('should return glossary specific fields', () => {
const result = advancedSearchClassBase.getEntitySpecificQueryBuilderFields([
SearchIndex.GLOSSARY_TERM,
]);

expect(Object.keys(result)).toEqual([EntityFields.GLOSSARY_TERM_STATUS]);
});

it('should return databaseSchema specific fields', () => {
const result = advancedSearchClassBase.getEntitySpecificQueryBuilderFields([
SearchIndex.DATABASE_SCHEMA,
]);

expect(Object.keys(result)).toEqual([EntityFields.DATABASE]);
});

it('should return empty fields for multiple indices with no common fields', () => {
const result = advancedSearchClassBase.getEntitySpecificQueryBuilderFields([
SearchIndex.TABLE,
SearchIndex.PIPELINE,
]);

expect(Object.keys(result)).toEqual([]);
});

it('should return combined fields for multiple indices with common fields', () => {
const result = advancedSearchClassBase.getEntitySpecificQueryBuilderFields([
SearchIndex.TABLE,
SearchIndex.DATABASE_SCHEMA,
]);

expect(Object.keys(result)).toEqual([EntityFields.DATABASE]);
});

it('should return empty object for unknown index', () => {
const result = advancedSearchClassBase.getEntitySpecificQueryBuilderFields([
'UNKNOWN_INDEX' as SearchIndex,
]);

expect(Object.keys(result)).toEqual([]);
});
});
Loading
Loading