diff --git a/public/app/plugins/datasource/elasticsearch/components/QueryEditor/MetricAggregationsEditor/SettingsEditor/index.test.tsx b/public/app/plugins/datasource/elasticsearch/components/QueryEditor/MetricAggregationsEditor/SettingsEditor/index.test.tsx index 71849b4bd78..88c8a3aa23b 100644 --- a/public/app/plugins/datasource/elasticsearch/components/QueryEditor/MetricAggregationsEditor/SettingsEditor/index.test.tsx +++ b/public/app/plugins/datasource/elasticsearch/components/QueryEditor/MetricAggregationsEditor/SettingsEditor/index.test.tsx @@ -82,4 +82,45 @@ describe('Settings Editor', () => { expect(settingsButtonEl.textContent).toBe(`Size: ${newSizeValue}`); }); }); + + describe('Rate aggregation', () => { + it('should render correct settings', () => { + const metricId = '1'; + const query: ElasticsearchQuery = { + refId: 'A', + query: '', + metrics: [ + { + id: metricId, + type: 'rate', + settings: {}, + }, + ], + bucketAggs: [], + }; + + const onChange = jest.fn(); + + render( + {}} + range={getDefaultTimeRange()} + > + + + ); + + let settingsButtonEl = screen.getByRole('button'); + fireEvent.click(settingsButtonEl); + + const unitSelectElement = screen.getByTestId('unit-select'); + const modeSelectElement = screen.getByTestId('mode-select'); + + expect(unitSelectElement).toBeInTheDocument(); + expect(modeSelectElement).toBeInTheDocument(); + }); + }); }); diff --git a/public/app/plugins/datasource/elasticsearch/components/QueryEditor/MetricAggregationsEditor/SettingsEditor/index.tsx b/public/app/plugins/datasource/elasticsearch/components/QueryEditor/MetricAggregationsEditor/SettingsEditor/index.tsx index 89a320a33b1..dadecbda697 100644 --- a/public/app/plugins/datasource/elasticsearch/components/QueryEditor/MetricAggregationsEditor/SettingsEditor/index.tsx +++ b/public/app/plugins/datasource/elasticsearch/components/QueryEditor/MetricAggregationsEditor/SettingsEditor/index.tsx @@ -127,7 +127,7 @@ export const SettingsEditor: FunctionComponent = ({ metric, previousMetri {metric.type === 'rate' && ( <> - + dispatch(changeMetricSetting(metric, 'mode', e.value))}