From 87c64dd14a6d9c508249a55036ca7c13ee33363b Mon Sep 17 00:00:00 2001
From: Julian Gernun <17549662+jcger@users.noreply.github.com>
Date: Mon, 21 Nov 2022 09:18:34 +0100
Subject: [PATCH] [RAM] Fix broken action type filter in rules list (#145691)
## Summary
Closes https://github.com/elastic/kibana/issues/145636
https://user-images.githubusercontent.com/17549662/202652963-205d1590-5cdf-4b4c-8f8b-e1133e6c274c.mov
### Checklist
- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
---
.../rules_list/components/rules_list.test.tsx | 29 +++++++++++++++++++
.../rules_list/components/rules_list.tsx | 2 +-
2 files changed, 30 insertions(+), 1 deletion(-)
diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/rules_list/components/rules_list.test.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/rules_list/components/rules_list.test.tsx
index 59876bd48b459..928feb0aa900f 100644
--- a/x-pack/plugins/triggers_actions_ui/public/application/sections/rules_list/components/rules_list.test.tsx
+++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/rules_list/components/rules_list.test.tsx
@@ -555,6 +555,35 @@ describe('rules_list component with props', () => {
await setup();
expect(wrapper.find('ActionTypeFilter')).toHaveLength(1);
});
+
+ it('filters when the action type filter is changed', async () => {
+ wrapper = mountWithIntl();
+ await act(async () => {
+ await nextTick();
+ wrapper.update();
+ });
+ (getIsExperimentalFeatureEnabled as jest.Mock).mockImplementation(() => true);
+ loadRulesWithKueryFilter.mockReset();
+ await setup();
+
+ wrapper.find(`[data-test-subj="actionTypeFilterButton"]`).first().simulate('click');
+ await act(async () => {
+ await nextTick();
+ wrapper.update();
+ });
+ wrapper.find(`[data-test-subj="actionTypetestFilterOption"]`).first().simulate('click');
+ expect(
+ wrapper.find('[data-test-subj="actionTypetestFilterOption"] EuiIcon[type="check"]').exists()
+ ).toBeTruthy(); // tick icon is being shown
+ expect(
+ wrapper
+ .find('[data-test-subj="actionTypetest2FilterOption"] EuiIcon[type="empty"]')
+ .exists()
+ ).toBeTruthy(); // doesnt have a tick icon
+ expect(
+ wrapper.find('[data-test-subj="actionTypeFilterButton"] .euiNotificationBadge').text()
+ ).toEqual('1'); // badge is being shown
+ });
});
describe('showCreateRuleButton prop', () => {
diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/rules_list/components/rules_list.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/rules_list/components/rules_list.tsx
index ae7b2dc8b437e..791bfa5e76574 100644
--- a/x-pack/plugins/triggers_actions_ui/public/application/sections/rules_list/components/rules_list.tsx
+++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/rules_list/components/rules_list.tsx
@@ -644,7 +644,7 @@ export const RulesList = ({
key="action-type-filter"
actionTypes={actionTypes}
onChange={setActionTypesFilter}
- filters={typesFilter}
+ filters={actionTypesFilter}
/>
),
...getRuleOutcomeOrStatusFilter(),