From c16da9a52ad8dfd4c5a152c3a49c317493eb201b Mon Sep 17 00:00:00 2001 From: Shailesh Parmar Date: Mon, 11 Dec 2023 16:49:59 +0530 Subject: [PATCH] #12539 change the default "last 3 days" for Data Quality TestCaseResults (#14328) --- .../component/TestSummary.test.tsx | 16 ++++++++++++ .../component/TestSummary.tsx | 26 ++++++++++++++++--- 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/openmetadata-ui/src/main/resources/ui/src/components/ProfilerDashboard/component/TestSummary.test.tsx b/openmetadata-ui/src/main/resources/ui/src/components/ProfilerDashboard/component/TestSummary.test.tsx index a2aec0e3391..3f7ad2ccdfd 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/ProfilerDashboard/component/TestSummary.test.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/ProfilerDashboard/component/TestSummary.test.tsx @@ -19,6 +19,7 @@ import { MOCK_TEST_CASE_RESULT, } from '../../../mocks/TestSuite.mock'; import { getListTestCaseResults } from '../../../rest/testAPI'; +import { getEpochMillisForPastDays } from '../../../utils/date-time/DateTimeUtils'; import { TestSummaryProps } from '../profilerDashboard.interface'; import TestSummary from './TestSummary'; @@ -62,6 +63,13 @@ jest.mock('../../Loader/Loader', () => { jest.mock('../../SchemaEditor/SchemaEditor', () => { return jest.fn().mockImplementation(() =>
SchemaEditor.component
); }); +jest.mock('../../../utils/date-time/DateTimeUtils', () => { + return { + formatDateTime: jest.fn(), + getCurrentMillis: jest.fn(), + getEpochMillisForPastDays: jest.fn(), + }; +}); describe('TestSummary component', () => { it('Component should render', async () => { @@ -149,4 +157,12 @@ describe('TestSummary component', () => { expect(mockHistory.goBack).toHaveBeenCalled(); }); + + it('default time range should be 30 days', async () => { + const MockGetEpochMillisForPastDays = + getEpochMillisForPastDays as jest.Mock; + render(); + + expect(MockGetEpochMillisForPastDays).toHaveBeenCalledWith(30); + }); }); diff --git a/openmetadata-ui/src/main/resources/ui/src/components/ProfilerDashboard/component/TestSummary.tsx b/openmetadata-ui/src/main/resources/ui/src/components/ProfilerDashboard/component/TestSummary.tsx index 00dc7d7d504..7370c7a728f 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/ProfilerDashboard/component/TestSummary.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/ProfilerDashboard/component/TestSummary.tsx @@ -39,7 +39,7 @@ import { } from '../../../constants/Color.constants'; import { COLORS, - DEFAULT_RANGE_DATA, + PROFILER_FILTER_RANGE, } from '../../../constants/profiler.constant'; import { CSMode } from '../../../enums/codemirror.enum'; import { ERROR_PLACEHOLDER_TYPE, SIZE } from '../../../enums/common.enum'; @@ -50,7 +50,11 @@ import { } from '../../../generated/tests/testCase'; import { getListTestCaseResults } from '../../../rest/testAPI'; import { axisTickFormatter } from '../../../utils/ChartUtils'; -import { formatDateTime } from '../../../utils/date-time/DateTimeUtils'; +import { + formatDateTime, + getCurrentMillis, + getEpochMillisForPastDays, +} from '../../../utils/date-time/DateTimeUtils'; import { getTestCaseDetailsPath } from '../../../utils/RouterUtils'; import { getEncodedFqn } from '../../../utils/StringsUtils'; import { showErrorToast } from '../../../utils/ToastUtils'; @@ -76,13 +80,26 @@ const TestSummary: React.FC = ({ data, showExpandIcon = true, }) => { + const defaultRange = useMemo( + () => ({ + initialRange: { + startTs: getEpochMillisForPastDays( + PROFILER_FILTER_RANGE.last30days.days + ), + endTs: getCurrentMillis(), + }, + key: 'last30days', + }), + [] + ); const history = useHistory(); const [chartData, setChartData] = useState( {} as ChartDataType ); const [results, setResults] = useState([]); - const [dateRangeObject, setDateRangeObject] = - useState(DEFAULT_RANGE_DATA); + const [dateRangeObject, setDateRangeObject] = useState( + defaultRange.initialRange + ); const [isLoading, setIsLoading] = useState(true); const [isGraphLoading, setIsGraphLoading] = useState(true); @@ -322,6 +339,7 @@ const TestSummary: React.FC = ({