Skip to content

Commit

Permalink
Merge branch 'main' into data_insight_refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
chirag-madlani authored Jul 27, 2024
2 parents d245011 + b9e57c7 commit 418fbd6
Show file tree
Hide file tree
Showing 21 changed files with 147 additions and 20 deletions.
2 changes: 1 addition & 1 deletion ingestion/tests/unit/test_column_type_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def test_check_datalake_type():
"column10": DataType.JSON,
"column11": DataType.ARRAY,
}
df = pd.read_csv("ingestion/tests/unit/test_column_type_parser.csv")
df = pd.read_csv(root + "/test_column_type_parser.csv")
for column_name in df.columns.values.tolist():
assert assert_col_type_dict.get(
column_name
Expand Down
2 changes: 1 addition & 1 deletion ingestion/tests/unit/test_protobuf_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def test_complex_protobuf_schema_files(self):
We'll read the files under ./ingestion/tests/unit/resources/protobuf_parser and parse them
This will be similar in way to how we get the data from kafka source
"""
resource_path = "./ingestion/tests/unit/resources/protobuf_parser/"
resource_path = f"{os.path.dirname(__file__)}/resources/protobuf_parser/"
schema_name = "employee"
file_list = os.listdir(resource_path)
schema_text = ""
Expand Down
13 changes: 12 additions & 1 deletion ingestion/tests/unit/test_sample_usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
Query parser utils tests
"""
import json
import os.path
from unittest import TestCase

from metadata.workflow.usage import UsageWorkflow
Expand Down Expand Up @@ -78,7 +79,17 @@ def test_join_count(self):
"shopify.fact_sale": 3,
"shopify.raw_customer": 10,
}
workflow = UsageWorkflow.create(json.loads(config))
config_dict = json.loads(config)
config_dict["source"]["serviceConnection"]["config"]["connectionOptions"][
"sampleDataFolder"
] = (
os.path.dirname(__file__)
+ "/../../../"
+ config_dict["source"]["serviceConnection"]["config"]["connectionOptions"][
"sampleDataFolder"
]
)
workflow = UsageWorkflow.create(config_dict)
workflow.execute()
table_usage_map = {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ component that can be run from - **literally** - anywhere.

In order to install it, you just need to get it from [PyPI](https://pypi.org/project/openmetadata-ingestion/).

```shell
pip install openmetadata-ingestion
```

We will show further examples later, but a piece of code is the best showcase for its simplicity. In order to run
a full ingestion process, you just need to execute a single function. For example, if we wanted to run the metadata
ingestion from within a simple Python script:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ component that can be run from - **literally** - anywhere.

In order to install it, you just need to get it from [PyPI](https://pypi.org/project/openmetadata-ingestion/).

```shell
pip install openmetadata-ingestion
```

We will show further examples later, but a piece of code is the best showcase for its simplicity. In order to run
a full ingestion process, you just need to execute a single function. For example, if we wanted to run the metadata
ingestion from within a simple Python script:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ component that can be run from - **literally** - anywhere.

In order to install it, you just need to get it from [PyPI](https://pypi.org/project/openmetadata-ingestion/).

```shell
pip install openmetadata-ingestion
```

We will show further examples later, but a piece of code is the best showcase for its simplicity. In order to run
a full ingestion process, you just need to execute a single function. For example, if we wanted to run the metadata
ingestion from within a simple Python script:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ export const createDescriptionTask = (
// select value from dropdown
verifyResponseStatusCode('@suggestApi', 200);

cy.get(
'.ant-select-dropdown .rc-virtual-list .rc-virtual-list-holder-inner'
).should('be.visible');

cy.get(`[data-testid="${value.assignee ?? assignee}"]`)
.should('be.visible')
.trigger('mouseover')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ test('Table difference test case', async ({ page }) => {
await test.step('Delete', async () => {
await deleteTestCase(page, testCase.name);
});
} catch (error) {
} finally {
await table1.delete(apiContext);
await table2.delete(apiContext);

Expand Down Expand Up @@ -212,7 +212,7 @@ test('Custom SQL Query', async ({ page }) => {
await test.step('Delete', async () => {
await deleteTestCase(page, testCase.name);
});
} catch (error) {
} finally {
await table.delete(apiContext);
await afterAction();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import {
} from '../../../utils/EntityUtils';
import { getEntityFQN } from '../../../utils/FeedUtils';
import { generateFormFields } from '../../../utils/formUtils';
import { isValidJSONString } from '../../../utils/StringsUtils';
import { showErrorToast, showSuccessToast } from '../../../utils/ToastUtils';
import Loader from '../../common/Loader/Loader';
import RichTextEditor from '../../common/RichTextEditor/RichTextEditor';
Expand Down Expand Up @@ -144,7 +145,10 @@ const EditTestCaseModal: React.FC<EditTestCaseModalProps> = ({
(definition) => definition.name === curr.name
);

if (param?.dataType === TestDataType.Array) {
if (
param?.dataType === TestDataType.Array &&
isValidJSONString(curr.value)
) {
const value = JSON.parse(curr.value || '[]');

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ import testCaseResultTabClassBase from './TestCaseResultTabClassBase';

const TestCaseResultTab = () => {
const { t } = useTranslation();
const { testCase: testCaseData, setTestCase } = useTestCaseStore();
const {
testCase: testCaseData,
setTestCase,
showAILearningBanner,
} = useTestCaseStore();
const additionalComponent =
testCaseResultTabClassBase.getAdditionalComponents();
const [isDescriptionEdit, setIsDescriptionEdit] = useState<boolean>(false);
Expand Down Expand Up @@ -116,6 +120,11 @@ const TestCaseResultTab = () => {
[]
);

const AlertComponent = useMemo(
() => testCaseResultTabClassBase.getAlertBanner(),
[]
);

const testCaseParams = useMemo(() => {
if (testCaseData?.useDynamicAssertion) {
return (
Expand Down Expand Up @@ -224,6 +233,13 @@ const TestCaseResultTab = () => {
</Col>
) : null}

{showAILearningBanner &&
testCaseData?.useDynamicAssertion &&
AlertComponent && (
<Col span={24}>
<AlertComponent />
</Col>
)}
{testCaseData && (
<Col className="test-case-result-tab-graph" span={24}>
<TestSummary data={testCaseData} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { TestCase } from '../../../../generated/tests/testCase';
import { checkPermission } from '../../../../utils/PermissionsUtils';
import TestCaseResultTab from './TestCaseResultTab.component';

const mockTestCaseData = {
const mockTestCaseData: TestCase = {
id: '1b748634-d24b-4879-9791-289f2f90fc3c',
name: 'table_column_count_equals',
fullyQualifiedName:
Expand Down Expand Up @@ -68,6 +68,7 @@ const mockTestCaseData = {
const mockUseTestCaseStore = {
testCase: mockTestCaseData,
setTestCase: jest.fn(),
showAILearningBanner: false,
};

jest.mock(
Expand All @@ -76,6 +77,11 @@ jest.mock(
useTestCaseStore: jest.fn().mockImplementation(() => mockUseTestCaseStore),
})
);
const mockBannerComponent = () => <div>BannerComponent</div>;
jest.mock('./TestCaseResultTabClassBase', () => ({
getAdditionalComponents: jest.fn().mockReturnValue([]),
getAlertBanner: jest.fn().mockImplementation(() => mockBannerComponent),
}));
jest.mock('../../../common/EntityDescription/DescriptionV1', () => {
return jest.fn().mockImplementation(() => <div>DescriptionV1</div>);
});
Expand Down Expand Up @@ -189,4 +195,32 @@ describe('TestCaseResultTab', () => {

mockUseTestCaseStore.testCase.useDynamicAssertion = false;
});

it('Should show banner if banner component is available, useDynamicAssertion and showAILearningBanner is true', async () => {
mockTestCaseData.useDynamicAssertion = true;
mockUseTestCaseStore.showAILearningBanner = true;

render(<TestCaseResultTab />);

const bannerComponent = await screen.findByText('BannerComponent');

expect(bannerComponent).toBeInTheDocument();

mockTestCaseData.useDynamicAssertion = false;
mockUseTestCaseStore.showAILearningBanner = false;
});

it('Should not show banner if banner component is available, useDynamicAssertion is false and showAILearningBanner is true', async () => {
mockTestCaseData.useDynamicAssertion = false;
mockUseTestCaseStore.showAILearningBanner = true;

render(<TestCaseResultTab />);

const bannerComponent = screen.queryByText('BannerComponent');

expect(bannerComponent).not.toBeInTheDocument();

mockTestCaseData.useDynamicAssertion = false;
mockUseTestCaseStore.showAILearningBanner = false;
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ class TestCaseResultTabClassBase {
public getAdditionalComponents(): Array<AdditionalComponentInterface> {
return [];
}

public getAlertBanner(): React.FC | null {
return null;
}
}

const testCaseResultTabClassBase = new TestCaseResultTabClassBase();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,15 @@ jest.mock(
})),
})
);
const mockSetShowAILearningBanner = jest.fn();
jest.mock(
'../../../../pages/IncidentManager/IncidentManagerDetailPage/useTestCase.store',
() => ({
useTestCaseStore: jest.fn().mockImplementation(() => ({
setShowAILearningBanner: mockSetShowAILearningBanner,
})),
})
);

describe('TestSummaryGraph', () => {
it('should display error placeholder when the result data is empty', () => {
Expand Down Expand Up @@ -214,4 +223,10 @@ describe('TestSummaryGraph', () => {
expect(minLineChart).toBeInTheDocument();
expect(maxLineChart).toBeInTheDocument();
});

it('should call mockSetShowAILearningBanner', () => {
render(<TestSummaryGraph {...mockProps} />);

expect(mockSetShowAILearningBanner).toHaveBeenCalledWith(false);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import {
ThreadTaskStatus,
} from '../../../../generated/entity/feed/thread';
import { TestCaseStatus } from '../../../../generated/tests/testCase';
import { useTestCaseStore } from '../../../../pages/IncidentManager/IncidentManagerDetailPage/useTestCase.store';
import {
axisTickFormatter,
updateActiveChartFilter,
Expand All @@ -72,6 +73,7 @@ function TestSummaryGraph({
}: Readonly<TestSummaryGraphProps>) {
const { t } = useTranslation();
const { entityThread = [] } = useActivityFeedProvider();
const { setShowAILearningBanner } = useTestCaseStore();
const chartRef = useRef(null);
const [chartMouseEvent, setChartMouseEvent] =
useState<CategoricalChartState>();
Expand All @@ -91,11 +93,14 @@ function TestSummaryGraph({
}, [chartRef, chartMouseEvent]);

const chartData = useMemo(() => {
return prepareChartData({
const data = prepareChartData({
testCaseParameterValue: testCaseParameterValue ?? [],
testCaseResults,
entityThread,
});
setShowAILearningBanner(data.showAILearningBanner);

return data;
}, [testCaseResults, entityThread, testCaseParameterValue]);

const incidentData = useMemo(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { t } from 'i18next';
import katex from 'katex';
import React from 'react';
import ReactDOMServer from 'react-dom/server';
import { ReactComponent as CopyIcon } from '../../../../assets/svg/icon-copy.svg';
import CopyIcon from '../../../../assets/svg/icon-copy.svg';
import {
markdownTextAndIdRegex,
MARKDOWN_MATCH_ID,
Expand Down Expand Up @@ -116,9 +116,14 @@ export const customHTMLRenderer: CustomHTMLRenderer = {
data-testid="copied-message">
{t('label.copied')}
</span>
<span data-testid="code-block-copy-icon">
<CopyIcon className="code-copy-button" data-copied="false" />
</span>
<img
className="code-copy-button"
data-copied="false"
data-testid="code-block-copy-icon"
height={24}
src={CopyIcon}
width={24}
/>
</>
),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,15 +232,14 @@
}
}
.code-copy-button {
display: none;
position: absolute;
top: 16px;
top: 8px;
right: 40px;
pointer-events: all;
cursor: pointer;
z-index: 1;
width: 16px;
opacity: 0;
padding: 8px;
padding: 2px;
background: @border-color;
border-radius: 4px;
}
Expand All @@ -260,7 +259,7 @@

.code-block {
&:hover .code-copy-button[data-copied='false'] {
opacity: 1;
display: inline-block;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ const mockUseTestCase: UseTestCaseStoreInterface = {
isLoading: false,
setIsLoading: jest.fn(),
reset: jest.fn(),
showAILearningBanner: false,
setShowAILearningBanner: jest.fn(),
};
jest.mock('./useTestCase.store', () => ({
useTestCaseStore: jest.fn().mockImplementation(() => mockUseTestCase),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,26 @@ import { TestCase } from '../../../generated/tests/testCase';
export interface UseTestCaseStoreInterface {
testCase: TestCase | undefined;
isLoading: boolean;
showAILearningBanner: boolean;
setTestCase: (testCase: TestCase) => void;
setIsLoading: (isLoading: boolean) => void;
setShowAILearningBanner: (showBanner: boolean) => void;
reset: () => void;
}
export const useTestCaseStore = create<UseTestCaseStoreInterface>()((set) => ({
testCase: undefined,
isLoading: true,
showAILearningBanner: false,
setTestCase: (testCase: TestCase) => {
set({ testCase });
},
setIsLoading: (isLoading: boolean) => {
set({ isLoading });
},
setShowAILearningBanner: (showAILearningBanner: boolean) => {
set({ showAILearningBanner });
},
reset: () => {
set({ testCase: undefined, isLoading: true });
set({ testCase: undefined, isLoading: true, showAILearningBanner: false });
},
}));
Loading

0 comments on commit 418fbd6

Please sign in to comment.