From d1c7db53650b36572292815169eeb055d3b6e053 Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Thu, 2 Dec 2021 13:31:23 +0100 Subject: [PATCH] CloudWatch: Make sure MatchExact flag gets the right value (#42621) * use value prop instead of depracted checked prop * make sure props are not changed for all tests --- .../MetricStatEditor/MetricStatEditor.test.tsx | 12 ++++++++++++ .../components/MetricStatEditor/MetricStatEditor.tsx | 3 ++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/public/app/plugins/datasource/cloudwatch/components/MetricStatEditor/MetricStatEditor.test.tsx b/public/app/plugins/datasource/cloudwatch/components/MetricStatEditor/MetricStatEditor.test.tsx index 12d57c3c452..e2b70b4dbd1 100644 --- a/public/app/plugins/datasource/cloudwatch/components/MetricStatEditor/MetricStatEditor.test.tsx +++ b/public/app/plugins/datasource/cloudwatch/components/MetricStatEditor/MetricStatEditor.test.tsx @@ -87,4 +87,16 @@ describe('MetricStatEditor', () => { expect(screen.queryByText('Match exact')).toBeNull(); }); }); + + describe('match exact', () => { + it('should be checked when value is true', () => { + render(); + expect(screen.getByLabelText('Match exact - optional')).toBeChecked(); + }); + + it('should be unchecked when value is false', () => { + render(); + expect(screen.getByLabelText('Match exact - optional')).not.toBeChecked(); + }); + }); }); diff --git a/public/app/plugins/datasource/cloudwatch/components/MetricStatEditor/MetricStatEditor.tsx b/public/app/plugins/datasource/cloudwatch/components/MetricStatEditor/MetricStatEditor.tsx index 541c30eee06..67d80da3449 100644 --- a/public/app/plugins/datasource/cloudwatch/components/MetricStatEditor/MetricStatEditor.tsx +++ b/public/app/plugins/datasource/cloudwatch/components/MetricStatEditor/MetricStatEditor.tsx @@ -109,7 +109,8 @@ export function MetricStatEditor({ tooltip="Only show metrics that exactly match all defined dimension names." > { onQueryChange({ ...query,