Skip to content

Commit 9f11d0d

Browse files
authored
[Vis: Default editor] Add unit tests for metric_agg and extended_bounds, fix types (#47815)
* Add unit tests for metric_agg and extended_bounds * Fix types * Code refactoring, create agg_utils and tests * Remove unused translations * Fix typos * Update snapshots
1 parent 5b16546 commit 9f11d0d

21 files changed

+800
-216
lines changed

src/legacy/ui/public/agg_types/agg_utils.ts

Lines changed: 0 additions & 39 deletions
This file was deleted.

src/legacy/ui/public/vis/editors/default/components/agg.test.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import { act } from 'react-dom/test-utils';
2626
import { DefaultEditorAggParams } from './agg_params';
2727
import { IndexPattern } from 'ui/index_patterns';
2828
import { AggType } from 'ui/agg_types';
29-
import { Schema } from 'ui/vis/editors/default/schemas';
3029

3130
jest.mock('./agg_params', () => ({
3231
DefaultEditorAggParams: () => null,
@@ -158,7 +157,7 @@ describe('DefaultEditorAgg component', () => {
158157
it('should add schema component', () => {
159158
defaultProps.agg.schema = {
160159
editorComponent: () => <div className="schemaComponent"></div>,
161-
} as Schema;
160+
} as any;
162161
const comp = mount(<DefaultEditorAgg {...defaultProps} />);
163162

164163
expect(comp.find('.schemaComponent').exists()).toBeTruthy();

src/legacy/ui/public/vis/editors/default/components/agg_common_props.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,13 @@ import { AggConfig, VisState, VisParams } from '../../..';
2222
import { AggParams } from '../agg_params';
2323
import { AggGroupNames } from '../agg_groups';
2424

25-
export type OnAggParamsChange = (
26-
params: AggParams | VisParams,
27-
paramName: string,
28-
value: unknown
25+
export type OnAggParamsChange = <
26+
Params extends AggParams | VisParams,
27+
ParamName extends keyof Params
28+
>(
29+
params: Params,
30+
paramName: ParamName,
31+
value: Params[ParamName]
2932
) => void;
3033

3134
export interface DefaultEditorAggCommonProps {

src/legacy/ui/public/vis/editors/default/controls/__snapshots__/extended_bounds.test.tsx.snap

Lines changed: 44 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/legacy/ui/public/vis/editors/default/controls/__snapshots__/metric_agg.test.tsx.snap

Lines changed: 35 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/legacy/ui/public/vis/editors/default/controls/agg_control_props.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@
1919

2020
import { VisParams } from '../../..';
2121
import { AggParams } from '../agg_params';
22+
import { OnAggParamsChange } from '../components/agg_common_props';
2223

23-
export interface AggControlProps<T> {
24+
export interface AggControlProps {
2425
aggParams: AggParams;
2526
editorStateParams: VisParams;
26-
setValue(params: AggParams, paramName: string, value: T): void;
27+
setValue: OnAggParamsChange;
2728
}

src/legacy/ui/public/vis/editors/default/controls/agg_control_react_wrapper.tsx

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)