diff --git a/public/app/plugins/datasource/cloudwatch/components/Stats.test.tsx b/public/app/plugins/datasource/cloudwatch/components/Stats.test.tsx index f5cbb8a2cce..c698c454c1e 100644 --- a/public/app/plugins/datasource/cloudwatch/components/Stats.test.tsx +++ b/public/app/plugins/datasource/cloudwatch/components/Stats.test.tsx @@ -8,12 +8,14 @@ describe('Stats', () => { it('should render component', () => { render( {}} stats={['Average', 'Maximum', 'Minimum', 'Sum', 'SampleCount'].map(toOption)} /> ); - expect(screen.getByTestId('stats')).toBeInTheDocument(); + expect(screen.getByText('Average')).toBeInTheDocument(); + expect(screen.getByText('Minimum')).toBeInTheDocument(); }); }); diff --git a/public/app/plugins/datasource/cloudwatch/components/Stats.tsx b/public/app/plugins/datasource/cloudwatch/components/Stats.tsx index ac430191b49..748b19f77b6 100644 --- a/public/app/plugins/datasource/cloudwatch/components/Stats.tsx +++ b/public/app/plugins/datasource/cloudwatch/components/Stats.tsx @@ -14,7 +14,7 @@ const removeText = '-- remove stat --'; const removeOption: SelectableValue = { label: removeText, value: removeText }; export const Stats: FunctionComponent = ({ stats, values, onChange, variableOptionGroup }) => ( -
+ <> {values && values.map((value, index) => ( = ({ stats, values, onChange, varia onChange={({ value }) => onChange([...values, value!])} options={[...stats.filter(({ value }) => !values.includes(value!)), variableOptionGroup]} /> -
+ );