Skip to content

Commit

Permalink
minor fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ShaileshParmar11 committed Nov 21, 2024
1 parent 92e5615 commit 032b209
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/
import { Card, Typography } from 'antd';
import classNames from 'classnames';
import { isUndefined } from 'lodash';
import { isUndefined, last } from 'lodash';
import React, { useEffect, useMemo, useState } from 'react';
import { Link } from 'react-router-dom';
import { fetchCountOfIncidentStatusTypeByDays } from '../../../../rest/dataQualityDashboardAPI';
Expand All @@ -31,31 +31,23 @@ const IncidentTypeAreaChartWidget = ({
const [isChartLoading, setIsChartLoading] = useState(true);
const [chartData, setChartData] = useState<CustomAreaChartData[]>([]);

const totalValueElement = useMemo(() => {
const totalValue = chartData.reduce((acc, curr) => {
return acc + curr.count;
}, 0);

return (
<Typography.Paragraph
className="font-medium chart-widget-link-underline text-xl m-b-0"
data-testid="total-value">
{totalValue}
</Typography.Paragraph>
);
}, [chartData]);

const bodyElement = useMemo(() => {
const latestValue = last(chartData)?.count ?? 0;

return (
<>
<Typography.Paragraph className="text-xs text-grey-muted">
{title}
</Typography.Paragraph>
{totalValueElement}
<Typography.Paragraph
className="font-medium chart-widget-link-underline text-xl m-b-0"
data-testid="total-value">
{latestValue}
</Typography.Paragraph>
<CustomAreaChart data={chartData} name={name} />
</>
);
}, [title, totalValueElement, chartData, name]);
}, [title, chartData, name]);

const getCountOfIncidentStatus = async () => {
setIsChartLoading(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,24 @@ jest.mock('../StatusCardWidget/StatusCardWidget.component', () =>
.fn()
.mockImplementation(() => <div>StatusByDimensionWidget.component</div>)
);
jest.mock('../../../../constants/profiler.constant', () => ({
DIMENSIONS_DATA: [
'Accuracy',
'Completeness',
'Consistency',
'Integrity',
'SQL',
'Uniqueness',
'Validity',
'No Dimension',
],
NO_DIMENSION: 'No Dimension',
}));
jest.mock('../../../../utils/RouterUtils', () => {
return {
getDataQualityPagePath: jest.fn(),
};
});

const chartFilter: DataQualityDashboardChartFilters = {
ownerFqn: 'ownerFqn',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/
import { Card, Typography } from 'antd';
import classNames from 'classnames';
import { isUndefined, toLower } from 'lodash';
import { isUndefined, last, toLower } from 'lodash';
import React, { useEffect, useMemo, useState } from 'react';
import { Link } from 'react-router-dom';
import { fetchTestCaseStatusMetricsByDays } from '../../../../rest/dataQualityDashboardAPI';
Expand All @@ -35,9 +35,7 @@ const TestCaseStatusAreaChartWidget = ({
const [isChartLoading, setIsChartLoading] = useState(true);

const bodyElement = useMemo(() => {
const totalValue = chartData.reduce((acc, curr) => {
return acc + curr.count;
}, 0);
const latestValue = last(chartData)?.count ?? 0;

return (
<>
Expand All @@ -47,7 +45,7 @@ const TestCaseStatusAreaChartWidget = ({
<Typography.Paragraph
className="font-medium text-xl m-b-0 chart-widget-link-underline"
data-testid="total-value">
{totalValue}
{latestValue}
</Typography.Paragraph>
<CustomAreaChart
colorScheme={chartColorScheme}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ const mockUseTestCase: UseTestCaseStoreInterface = {
reset: jest.fn(),
showAILearningBanner: false,
setShowAILearningBanner: jest.fn(),
dqLineageData: undefined,
setDqLineageData: jest.fn(),
};
jest.mock('./useTestCase.store', () => ({
useTestCaseStore: jest.fn().mockImplementation(() => mockUseTestCase),
Expand Down

0 comments on commit 032b209

Please sign in to comment.