From 261c415e23d764649208b9547f1b5669dd2d1aad Mon Sep 17 00:00:00 2001 From: Ester Marti Date: Thu, 22 Apr 2021 17:22:20 +0200 Subject: [PATCH] Add test for rate aggreation settings editor --- .../SettingsEditor/index.test.tsx | 41 +++++++++++++++++++ .../SettingsEditor/index.tsx | 4 +- 2 files changed, 43 insertions(+), 2 deletions(-) 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))}