Skip to content

Commit

Permalink
#12539 change the default "last 3 days" for Data Quality TestCaseResu…
Browse files Browse the repository at this point in the history
…lts (#14328)
  • Loading branch information
ShaileshParmar11 authored Dec 11, 2023
1 parent 9a07849 commit c16da9a
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -62,6 +63,13 @@ jest.mock('../../Loader/Loader', () => {
jest.mock('../../SchemaEditor/SchemaEditor', () => {
return jest.fn().mockImplementation(() => <div>SchemaEditor.component</div>);
});
jest.mock('../../../utils/date-time/DateTimeUtils', () => {
return {
formatDateTime: jest.fn(),
getCurrentMillis: jest.fn(),
getEpochMillisForPastDays: jest.fn(),
};
});

describe('TestSummary component', () => {
it('Component should render', async () => {
Expand Down Expand Up @@ -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(<TestSummary data={MOCK_SQL_TEST_CASE} />);

expect(MockGetEpochMillisForPastDays).toHaveBeenCalledWith(30);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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';
Expand All @@ -76,13 +80,26 @@ const TestSummary: React.FC<TestSummaryProps> = ({
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<ChartDataType>(
{} as ChartDataType
);
const [results, setResults] = useState<TestCaseResult[]>([]);
const [dateRangeObject, setDateRangeObject] =
useState<DateRangeObject>(DEFAULT_RANGE_DATA);
const [dateRangeObject, setDateRangeObject] = useState<DateRangeObject>(
defaultRange.initialRange
);
const [isLoading, setIsLoading] = useState(true);
const [isGraphLoading, setIsGraphLoading] = useState(true);

Expand Down Expand Up @@ -322,6 +339,7 @@ const TestSummary: React.FC<TestSummaryProps> = ({
<Col>
<DatePickerMenu
showSelectedCustomRange
defaultValue={defaultRange.key}
handleDateRangeChange={handleDateRangeChange}
/>
</Col>
Expand Down

0 comments on commit c16da9a

Please sign in to comment.