Skip to content

Commit

Permalink
[Lens] Fix bug in metric config panel (#60982)
Browse files Browse the repository at this point in the history
* [Lens] Fix bug in metric config panel

* Fix test
  • Loading branch information
Wylie Conlon authored Mar 24, 2020
1 parent 6506134 commit 6d2aa89
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,46 @@ describe('metric_visualization', () => {
});
});

describe('#getConfiguration', () => {
it('can add a metric when there is no accessor', () => {
expect(
metricVisualization.getConfiguration({
state: {
accessor: undefined,
layerId: 'l1',
},
layerId: 'l1',
frame: mockFrame(),
})
).toEqual({
groups: [
expect.objectContaining({
supportsMoreColumns: true,
}),
],
});
});

it('is not allowed to add a metric once one accessor is set', () => {
expect(
metricVisualization.getConfiguration({
state: {
accessor: 'a',
layerId: 'l1',
},
layerId: 'l1',
frame: mockFrame(),
})
).toEqual({
groups: [
expect.objectContaining({
supportsMoreColumns: false,
}),
],
});
});
});

describe('#setDimension', () => {
it('sets the accessor', () => {
expect(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export const metricVisualization: Visualization<State, PersistableState> = {
groupLabel: i18n.translate('xpack.lens.metric.label', { defaultMessage: 'Metric' }),
layerId: props.state.layerId,
accessors: props.state.accessor ? [props.state.accessor] : [],
supportsMoreColumns: false,
supportsMoreColumns: !props.state.accessor,
filterOperations: (op: OperationMetadata) => !op.isBucketed && op.dataType === 'number',
},
],
Expand Down

0 comments on commit 6d2aa89

Please sign in to comment.