diff --git a/web/ui/react-app/src/pages/alerts/AlertContents.test.tsx b/web/ui/react-app/src/pages/alerts/AlertContents.test.tsx index e0832f99f..403cad6be 100644 --- a/web/ui/react-app/src/pages/alerts/AlertContents.test.tsx +++ b/web/ui/react-app/src/pages/alerts/AlertContents.test.tsx @@ -23,17 +23,19 @@ describe('AlertsContent', () => { { selector: '#firing-toggler', propName: 'firing' }, ].forEach(testCase => { it(`toggles the ${testCase.propName} checkbox from true to false when clicked and back to true when clicked again`, () => { - wrapper.find(testCase.selector).invoke('onClick')(testCase.propName); + expect(wrapper.find(testCase.selector).prop('checked')).toBe(true); + wrapper.find(testCase.selector).simulate('change', { target: { checked: false } }); expect(wrapper.find(testCase.selector).prop('checked')).toBe(false); - wrapper.find(testCase.selector).invoke('onClick')(testCase.propName); + wrapper.find(testCase.selector).simulate('change', { target: { checked: true } }); expect(wrapper.find(testCase.selector).prop('checked')).toBe(true); }); }); it('toggles the "annotations" checkbox from false to true when clicked and back to false when clicked again', () => { - wrapper.find('#show-annotations-toggler').invoke('onClick')(); + expect(wrapper.find('#show-annotations-toggler').prop('checked')).toBe(false); + wrapper.find('#show-annotations-toggler').simulate('change', { target: { checked: true } }); expect(wrapper.find('#show-annotations-toggler').prop('checked')).toBe(true); - wrapper.find('#show-annotations-toggler').invoke('onClick')(); + wrapper.find('#show-annotations-toggler').simulate('change', { target: { checked: false } }); expect(wrapper.find('#show-annotations-toggler').prop('checked')).toBe(false); }); }); diff --git a/web/ui/react-app/src/pages/alerts/AlertContents.tsx b/web/ui/react-app/src/pages/alerts/AlertContents.tsx index b77f7575a..99d4c9688 100644 --- a/web/ui/react-app/src/pages/alerts/AlertContents.tsx +++ b/web/ui/react-app/src/pages/alerts/AlertContents.tsx @@ -55,10 +55,6 @@ const AlertsContent: FC = ({ groups = [], statsCount }) => { }); }; - const toggleAnnotations = () => { - setShowAnnotations({ checked: !showAnnotations.checked }); - }; - return ( <>
@@ -69,7 +65,7 @@ const AlertsContent: FC = ({ groups = [], statsCount }) => { wrapperStyles={{ marginRight: 10 }} checked={filter[state]} id={`${state}-toggler`} - onClick={toggleFilter(state)} + onChange={toggleFilter(state)} > {state} ({statsCount[state]}) @@ -81,7 +77,7 @@ const AlertsContent: FC = ({ groups = [], statsCount }) => { wrapperStyles={{ marginLeft: 'auto' }} checked={showAnnotations.checked} id="show-annotations-toggler" - onClick={() => toggleAnnotations()} + onChange={({ target }) => setShowAnnotations({ checked: target.checked })} > Show annotations diff --git a/web/ui/react-app/src/pages/alerts/__snapshots__/AlertContents.test.tsx.snap b/web/ui/react-app/src/pages/alerts/__snapshots__/AlertContents.test.tsx.snap index fdbba2c9f..307a724c4 100644 --- a/web/ui/react-app/src/pages/alerts/__snapshots__/AlertContents.test.tsx.snap +++ b/web/ui/react-app/src/pages/alerts/__snapshots__/AlertContents.test.tsx.snap @@ -9,7 +9,7 @@ exports[`AlertsContent matches a snapshot 1`] = ` checked={true} id="inactive-toggler" key="inactive" - onClick={[Function]} + onChange={[Function]} wrapperStyles={ Object { "marginRight": 10, @@ -32,7 +32,7 @@ exports[`AlertsContent matches a snapshot 1`] = ` checked={true} id="pending-toggler" key="pending" - onClick={[Function]} + onChange={[Function]} wrapperStyles={ Object { "marginRight": 10, @@ -55,7 +55,7 @@ exports[`AlertsContent matches a snapshot 1`] = ` checked={true} id="firing-toggler" key="firing" - onClick={[Function]} + onChange={[Function]} wrapperStyles={ Object { "marginRight": 10, @@ -77,7 +77,7 @@ exports[`AlertsContent matches a snapshot 1`] = ` { Metrics Explorer {this.props.metrics.map(metric => ( -

+

{metric}

))}