mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-09-27 09:55:36 +00:00
This commit is contained in:
parent
9a0784913d
commit
c16da9a52a
@ -19,6 +19,7 @@ import {
|
|||||||
MOCK_TEST_CASE_RESULT,
|
MOCK_TEST_CASE_RESULT,
|
||||||
} from '../../../mocks/TestSuite.mock';
|
} from '../../../mocks/TestSuite.mock';
|
||||||
import { getListTestCaseResults } from '../../../rest/testAPI';
|
import { getListTestCaseResults } from '../../../rest/testAPI';
|
||||||
|
import { getEpochMillisForPastDays } from '../../../utils/date-time/DateTimeUtils';
|
||||||
import { TestSummaryProps } from '../profilerDashboard.interface';
|
import { TestSummaryProps } from '../profilerDashboard.interface';
|
||||||
import TestSummary from './TestSummary';
|
import TestSummary from './TestSummary';
|
||||||
|
|
||||||
@ -62,6 +63,13 @@ jest.mock('../../Loader/Loader', () => {
|
|||||||
jest.mock('../../SchemaEditor/SchemaEditor', () => {
|
jest.mock('../../SchemaEditor/SchemaEditor', () => {
|
||||||
return jest.fn().mockImplementation(() => <div>SchemaEditor.component</div>);
|
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', () => {
|
describe('TestSummary component', () => {
|
||||||
it('Component should render', async () => {
|
it('Component should render', async () => {
|
||||||
@ -149,4 +157,12 @@ describe('TestSummary component', () => {
|
|||||||
|
|
||||||
expect(mockHistory.goBack).toHaveBeenCalled();
|
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';
|
} from '../../../constants/Color.constants';
|
||||||
import {
|
import {
|
||||||
COLORS,
|
COLORS,
|
||||||
DEFAULT_RANGE_DATA,
|
PROFILER_FILTER_RANGE,
|
||||||
} from '../../../constants/profiler.constant';
|
} from '../../../constants/profiler.constant';
|
||||||
import { CSMode } from '../../../enums/codemirror.enum';
|
import { CSMode } from '../../../enums/codemirror.enum';
|
||||||
import { ERROR_PLACEHOLDER_TYPE, SIZE } from '../../../enums/common.enum';
|
import { ERROR_PLACEHOLDER_TYPE, SIZE } from '../../../enums/common.enum';
|
||||||
@ -50,7 +50,11 @@ import {
|
|||||||
} from '../../../generated/tests/testCase';
|
} from '../../../generated/tests/testCase';
|
||||||
import { getListTestCaseResults } from '../../../rest/testAPI';
|
import { getListTestCaseResults } from '../../../rest/testAPI';
|
||||||
import { axisTickFormatter } from '../../../utils/ChartUtils';
|
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 { getTestCaseDetailsPath } from '../../../utils/RouterUtils';
|
||||||
import { getEncodedFqn } from '../../../utils/StringsUtils';
|
import { getEncodedFqn } from '../../../utils/StringsUtils';
|
||||||
import { showErrorToast } from '../../../utils/ToastUtils';
|
import { showErrorToast } from '../../../utils/ToastUtils';
|
||||||
@ -76,13 +80,26 @@ const TestSummary: React.FC<TestSummaryProps> = ({
|
|||||||
data,
|
data,
|
||||||
showExpandIcon = true,
|
showExpandIcon = true,
|
||||||
}) => {
|
}) => {
|
||||||
|
const defaultRange = useMemo(
|
||||||
|
() => ({
|
||||||
|
initialRange: {
|
||||||
|
startTs: getEpochMillisForPastDays(
|
||||||
|
PROFILER_FILTER_RANGE.last30days.days
|
||||||
|
),
|
||||||
|
endTs: getCurrentMillis(),
|
||||||
|
},
|
||||||
|
key: 'last30days',
|
||||||
|
}),
|
||||||
|
[]
|
||||||
|
);
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
const [chartData, setChartData] = useState<ChartDataType>(
|
const [chartData, setChartData] = useState<ChartDataType>(
|
||||||
{} as ChartDataType
|
{} as ChartDataType
|
||||||
);
|
);
|
||||||
const [results, setResults] = useState<TestCaseResult[]>([]);
|
const [results, setResults] = useState<TestCaseResult[]>([]);
|
||||||
const [dateRangeObject, setDateRangeObject] =
|
const [dateRangeObject, setDateRangeObject] = useState<DateRangeObject>(
|
||||||
useState<DateRangeObject>(DEFAULT_RANGE_DATA);
|
defaultRange.initialRange
|
||||||
|
);
|
||||||
const [isLoading, setIsLoading] = useState(true);
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
const [isGraphLoading, setIsGraphLoading] = useState(true);
|
const [isGraphLoading, setIsGraphLoading] = useState(true);
|
||||||
|
|
||||||
@ -322,6 +339,7 @@ const TestSummary: React.FC<TestSummaryProps> = ({
|
|||||||
<Col>
|
<Col>
|
||||||
<DatePickerMenu
|
<DatePickerMenu
|
||||||
showSelectedCustomRange
|
showSelectedCustomRange
|
||||||
|
defaultValue={defaultRange.key}
|
||||||
handleDateRangeChange={handleDateRangeChange}
|
handleDateRangeChange={handleDateRangeChange}
|
||||||
/>
|
/>
|
||||||
</Col>
|
</Col>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user