Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Lens] Rename operations to map exposed names for Formula #94710

Merged
merged 19 commits into from
Mar 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ const initialState: IndexPatternPrivateState = {
label: 'My Op',
dataType: 'number',
isBucketed: false,
operationType: 'avg',
operationType: 'average',
sourceField: 'memory',
},
},
Expand All @@ -200,7 +200,7 @@ const initialState: IndexPatternPrivateState = {
label: 'My Op',
dataType: 'number',
isBucketed: false,
operationType: 'avg',
operationType: 'average',
sourceField: 'bytes',
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ describe('BucketNestingEditor', () => {
layer={{
columnOrder: ['a', 'b', 'c'],
columns: {
a: mockCol({ operationType: 'avg', isBucketed: false }),
a: mockCol({ operationType: 'average', isBucketed: false }),
b: mockCol({ operationType: 'max', isBucketed: false }),
c: mockCol({ operationType: 'min', isBucketed: false }),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ describe('IndexPatternDimensionEditorPanel', () => {
label: 'Unique count of source',
dataType: 'number',
isBucketed: false,
operationType: 'cardinality',
operationType: 'unique_count',
sourceField: 'source,',
},
})}
Expand Down Expand Up @@ -414,7 +414,7 @@ describe('IndexPatternDimensionEditorPanel', () => {

const items: EuiListGroupItemProps[] = wrapper.find(EuiListGroup).prop('listItems') || [];

expect(items.find(({ id }) => id === 'derivative')!['data-test-subj']).toContain(
expect(items.find(({ id }) => id === 'differences')!['data-test-subj']).toContain(
'incompatible'
);
expect(items.find(({ id }) => id === 'cumulative_sum')!['data-test-subj']).toContain(
Expand Down Expand Up @@ -462,7 +462,7 @@ describe('IndexPatternDimensionEditorPanel', () => {
'incompatible'
);

expect(items.find(({ id }) => id === 'derivative')!['data-test-subj']).not.toContain(
expect(items.find(({ id }) => id === 'differences')!['data-test-subj']).not.toContain(
'incompatible'
);
expect(items.find(({ id }) => id === 'moving_average')!['data-test-subj']).not.toContain(
Expand Down Expand Up @@ -817,15 +817,15 @@ describe('IndexPatternDimensionEditorPanel', () => {
it('should select compatible operation if field not compatible with selected operation', () => {
wrapper = mount(<IndexPatternDimensionEditorComponent {...defaultProps} columnId={'col2'} />);

wrapper.find('button[data-test-subj="lns-indexPatternDimension-avg"]').simulate('click');
wrapper.find('button[data-test-subj="lns-indexPatternDimension-average"]').simulate('click');
expect(setState).toHaveBeenCalledWith(
{
...state,
layers: {
first: {
...state.layers.first,
incompleteColumns: {
col2: { operationType: 'avg' },
col2: { operationType: 'average' },
},
},
},
Expand All @@ -838,7 +838,7 @@ describe('IndexPatternDimensionEditorPanel', () => {
.filter('[data-test-subj="indexPattern-dimension-field"]');
const options = comboBox.prop('options');

// options[1][2] is a `source` field of type `string` which doesn't support `avg` operation
// options[1][2] is a `source` field of type `string` which doesn't support `average` operation
act(() => {
comboBox.prop('onChange')!([options![1].options![2]]);
});
Expand Down Expand Up @@ -885,7 +885,7 @@ describe('IndexPatternDimensionEditorPanel', () => {

// Transition to a field operation (incompatible)
wrapper
.find('button[data-test-subj="lns-indexPatternDimension-avg incompatible"]')
.find('button[data-test-subj="lns-indexPatternDimension-average incompatible"]')
.simulate('click');

// Now check that the dimension gets cleaned up on state update
Expand All @@ -896,7 +896,7 @@ describe('IndexPatternDimensionEditorPanel', () => {
first: {
...state.layers.first,
incompleteColumns: {
col2: { operationType: 'avg' },
col2: { operationType: 'average' },
},
},
},
Expand All @@ -914,7 +914,7 @@ describe('IndexPatternDimensionEditorPanel', () => {
dataType: 'number',
isBucketed: false,
label: '',
operationType: 'avg',
operationType: 'average',
sourceField: 'bytes',
},
})}
Expand Down Expand Up @@ -1037,7 +1037,7 @@ describe('IndexPatternDimensionEditorPanel', () => {
wrapper = shallow(
<IndexPatternDimensionEditorComponent
{...getProps({
operationType: 'avg',
operationType: 'average',
sourceField: 'bytes',
})}
/>
Expand Down Expand Up @@ -1143,7 +1143,7 @@ describe('IndexPatternDimensionEditorPanel', () => {
label: 'Sum of bytes per hour',
});
wrapper = mount(<IndexPatternDimensionEditorComponent {...props} />);
wrapper.find('button[data-test-subj="lns-indexPatternDimension-avg"]').simulate('click');
wrapper.find('button[data-test-subj="lns-indexPatternDimension-average"]').simulate('click');
expect(props.setState).toHaveBeenCalledWith(
{
...props.state,
Expand Down Expand Up @@ -1478,7 +1478,7 @@ describe('IndexPatternDimensionEditorPanel', () => {
it('should support selecting the operation before the field', () => {
wrapper = mount(<IndexPatternDimensionEditorComponent {...defaultProps} columnId={'col2'} />);

wrapper.find('button[data-test-subj="lns-indexPatternDimension-avg"]').simulate('click');
wrapper.find('button[data-test-subj="lns-indexPatternDimension-average"]').simulate('click');

expect(setState).toHaveBeenCalledWith(
{
Expand All @@ -1488,7 +1488,7 @@ describe('IndexPatternDimensionEditorPanel', () => {
...state.layers.first,
incompleteColumns: {
col2: {
operationType: 'avg',
operationType: 'average',
},
},
},
Expand Down Expand Up @@ -1516,7 +1516,7 @@ describe('IndexPatternDimensionEditorPanel', () => {
columns: {
...state.layers.first.columns,
col2: expect.objectContaining({
operationType: 'avg',
operationType: 'average',
sourceField: 'bytes',
}),
},
Expand Down Expand Up @@ -1547,7 +1547,7 @@ describe('IndexPatternDimensionEditorPanel', () => {
/>
);

wrapper.find('button[data-test-subj="lns-indexPatternDimension-avg"]').simulate('click');
wrapper.find('button[data-test-subj="lns-indexPatternDimension-average"]').simulate('click');

expect(setState).toHaveBeenCalledWith(
{
Expand All @@ -1559,7 +1559,7 @@ describe('IndexPatternDimensionEditorPanel', () => {
...initialState.layers.first.columns,
col2: expect.objectContaining({
sourceField: 'bytes',
operationType: 'avg',
operationType: 'average',
// Other parts of this don't matter for this test
}),
},
Expand Down Expand Up @@ -1601,7 +1601,7 @@ describe('IndexPatternDimensionEditorPanel', () => {
wrapper = mount(<IndexPatternDimensionEditorComponent {...defaultProps} columnId={'col2'} />);

act(() => {
wrapper.find('button[data-test-subj="lns-indexPatternDimension-avg"]').simulate('click');
wrapper.find('button[data-test-subj="lns-indexPatternDimension-average"]').simulate('click');
});

const options = wrapper
Expand Down Expand Up @@ -1790,7 +1790,7 @@ describe('IndexPatternDimensionEditorPanel', () => {
dataType: 'number',
isBucketed: false,
// Private
operationType: 'avg',
operationType: 'average',
sourceField: 'memory',
},
});
Expand Down Expand Up @@ -1831,7 +1831,7 @@ describe('IndexPatternDimensionEditorPanel', () => {
dataType: 'number',
isBucketed: false,
// Private
operationType: 'avg',
operationType: 'average',
sourceField: 'memory',
params: {
format: { id: 'bytes', params: { decimals: 0 } },
Expand Down Expand Up @@ -1871,7 +1871,7 @@ describe('IndexPatternDimensionEditorPanel', () => {
dataType: 'number',
isBucketed: false,
// Private
operationType: 'avg',
operationType: 'average',
sourceField: 'memory',
params: {
format: { id: 'bytes', params: { decimals: 2 } },
Expand Down Expand Up @@ -1914,7 +1914,7 @@ describe('IndexPatternDimensionEditorPanel', () => {
expect(wrapper.find('ReferenceEditor')).toHaveLength(0);

wrapper
.find('button[data-test-subj="lns-indexPatternDimension-derivative incompatible"]')
.find('button[data-test-subj="lns-indexPatternDimension-differences incompatible"]')
.simulate('click');

expect(wrapper.find('ReferenceEditor')).toHaveLength(1);
Expand All @@ -1926,7 +1926,7 @@ describe('IndexPatternDimensionEditorPanel', () => {
label: 'Differences of (incomplete)',
dataType: 'number',
isBucketed: false,
operationType: 'derivative',
operationType: 'differences',
references: ['col2'],
params: {},
},
Expand All @@ -1939,7 +1939,7 @@ describe('IndexPatternDimensionEditorPanel', () => {
expect(wrapper.find('ReferenceEditor')).toHaveLength(1);

wrapper
.find('button[data-test-subj="lns-indexPatternDimension-avg incompatible"]')
.find('button[data-test-subj="lns-indexPatternDimension-average incompatible"]')
.simulate('click');

expect(wrapper.find('ReferenceEditor')).toHaveLength(0);
Expand All @@ -1948,10 +1948,10 @@ describe('IndexPatternDimensionEditorPanel', () => {
it('should show a warning when the current dimension is no longer configurable', () => {
const stateWithInvalidCol: IndexPatternPrivateState = getStateWithColumns({
col1: {
label: 'Invalid derivative',
label: 'Invalid differences',
dataType: 'number',
isBucketed: false,
operationType: 'derivative',
operationType: 'differences',
references: ['ref1'],
},
});
Expand All @@ -1962,7 +1962,7 @@ describe('IndexPatternDimensionEditorPanel', () => {

expect(
wrapper
.find('[data-test-subj="lns-indexPatternDimension-derivative incompatible"]')
.find('[data-test-subj="lns-indexPatternDimension-differences incompatible"]')
.find('EuiText[color="danger"]')
.first()
).toBeTruthy();
Expand All @@ -1975,7 +1975,7 @@ describe('IndexPatternDimensionEditorPanel', () => {
label: 'Avg',
dataType: 'number',
isBucketed: false,
operationType: 'avg',
operationType: 'average',
sourceField: 'bytes',
},
}),
Expand Down Expand Up @@ -2010,6 +2010,8 @@ describe('IndexPatternDimensionEditorPanel', () => {
<IndexPatternDimensionEditorComponent {...defaultProps} state={stateWithoutTime} />
);

expect(wrapper.find('[data-test-subj="lns-indexPatternDimension-derivative"]')).toHaveLength(0);
expect(wrapper.find('[data-test-subj="lns-indexPatternDimension-differences"]')).toHaveLength(
0
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -1035,7 +1035,7 @@ describe('IndexPatternDimensionEditorPanel', () => {
},
},
col3: {
operationType: 'avg',
operationType: 'average',
sourceField: 'memory',
label: 'average of memory',
dataType: 'number',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ describe('reference editor', () => {
label: 'Average of bytes',
dataType: 'number',
isBucketed: false,
operationType: 'avg',
operationType: 'average',
sourceField: 'bytes',
},
},
Expand Down Expand Up @@ -192,7 +192,7 @@ describe('reference editor', () => {
label: 'Average of bytes',
dataType: 'number',
isBucketed: false,
operationType: 'avg',
operationType: 'average',
sourceField: 'bytes',
},
},
Expand Down Expand Up @@ -233,7 +233,7 @@ describe('reference editor', () => {
label: 'Average of bytes',
dataType: 'number',
isBucketed: false,
operationType: 'avg',
operationType: 'average',
sourceField: 'bytes',
},
},
Expand Down Expand Up @@ -276,7 +276,7 @@ describe('reference editor', () => {
label: 'Average of bytes',
dataType: 'number',
isBucketed: false,
operationType: 'avg',
operationType: 'average',
sourceField: 'bytes',
},
},
Expand All @@ -296,9 +296,9 @@ describe('reference editor', () => {
expect(subFunctionSelect.prop('selectedOptions')).toEqual(
expect.arrayContaining([
expect.objectContaining({
'data-test-subj': 'lns-indexPatternDimension-avg incompatible',
'data-test-subj': 'lns-indexPatternDimension-average incompatible',
label: 'Average',
value: 'avg',
value: 'average',
}),
])
);
Expand Down Expand Up @@ -334,7 +334,7 @@ describe('reference editor', () => {
label: 'Average of bytes',
dataType: 'number',
isBucketed: false,
operationType: 'avg',
operationType: 'average',
sourceField: 'bytes',
},
},
Expand All @@ -352,7 +352,7 @@ describe('reference editor', () => {
const fieldSelect = wrapper.find(FieldSelect);
expect(fieldSelect.prop('fieldIsInvalid')).toEqual(true);
expect(fieldSelect.prop('selectedField')).toEqual('bytes');
expect(fieldSelect.prop('selectedOperationType')).toEqual('avg');
expect(fieldSelect.prop('selectedOperationType')).toEqual('average');
expect(fieldSelect.prop('incompleteOperation')).toEqual('max');
expect(fieldSelect.prop('markAllFieldsCompatible')).toEqual(false);
});
Expand All @@ -369,7 +369,7 @@ describe('reference editor', () => {
label: 'Average of bytes',
dataType: 'number',
isBucketed: false,
operationType: 'avg',
operationType: 'average',
sourceField: 'bytes',
},
},
Expand All @@ -387,7 +387,7 @@ describe('reference editor', () => {
const fieldSelect = wrapper.find(FieldSelect);
expect(fieldSelect.prop('fieldIsInvalid')).toEqual(false);
expect(fieldSelect.prop('selectedField')).toEqual('timestamp');
expect(fieldSelect.prop('selectedOperationType')).toEqual('avg');
expect(fieldSelect.prop('selectedOperationType')).toEqual('average');
expect(fieldSelect.prop('incompleteOperation')).toBeUndefined();
});

Expand Down Expand Up @@ -423,7 +423,7 @@ describe('reference editor', () => {
label: 'Average of missing',
dataType: 'number',
isBucketed: false,
operationType: 'avg',
operationType: 'average',
sourceField: 'missing',
},
},
Expand All @@ -438,7 +438,7 @@ describe('reference editor', () => {
const fieldSelect = wrapper.find(FieldSelect);
expect(fieldSelect.prop('fieldIsInvalid')).toEqual(true);
expect(fieldSelect.prop('selectedField')).toEqual('missing');
expect(fieldSelect.prop('selectedOperationType')).toEqual('avg');
expect(fieldSelect.prop('selectedOperationType')).toEqual('average');
expect(fieldSelect.prop('incompleteOperation')).toBeUndefined();
expect(fieldSelect.prop('markAllFieldsCompatible')).toEqual(false);
});
Expand Down
Loading