mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-09-25 08:50:18 +00:00
This commit is contained in:
parent
9a0784913d
commit
c16da9a52a
@ -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(() => <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 () => {
|
||||
@ -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);
|
||||
});
|
||||
});
|
||||
|
@ -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<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);
|
||||
|
||||
@ -322,6 +339,7 @@ const TestSummary: React.FC<TestSummaryProps> = ({
|
||||
<Col>
|
||||
<DatePickerMenu
|
||||
showSelectedCustomRange
|
||||
defaultValue={defaultRange.key}
|
||||
handleDateRangeChange={handleDateRangeChange}
|
||||
/>
|
||||
</Col>
|
||||
|
Loading…
x
Reference in New Issue
Block a user