From 621e5bfdb4888d6ec71bc8f5621b5a4c66cc07b4 Mon Sep 17 00:00:00 2001 From: "Grot (@grafanabot)" <43478413+grafanabot@users.noreply.github.com> Date: Thu, 2 Dec 2021 07:46:04 -0500 Subject: [PATCH] CloudWatch: Make sure MatchExact flag gets the right value (#42621) (#42644) * use value prop instead of depracted checked prop * make sure props are not changed for all tests (cherry picked from commit d1c7db53650b36572292815169eeb055d3b6e053) Co-authored-by: Erik Sundell --- .../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,