From 888ce1f20b983e07a1b599b2a7ebe726ed06d10a Mon Sep 17 00:00:00 2001 From: Julian Gernun <17549662+jcger@users.noreply.github.com> Date: Mon, 6 Feb 2023 10:21:03 +0100 Subject: [PATCH] [RAM] Try to fix flaky rules_list test - filter by rule state (#150056) ## Summary Related to https://github.com/elastic/kibana/issues/149061 I won't close the issue with this PR so we can keep getting notified about future fails Updated so it waits until the spinner is gone instead of waiting for "Rule state" text to appear as it's done this way in the rest of the tests and they are not flaky. Instead of assuming that the rule status filter button and it's toolbar are shown from the beginning, we ensure they are present waiting for these elements to appear. (I hope this one was the root cause but we won't be sure until this stops happening) --- .../sections/rules_list/components/rules_list.test.tsx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) 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 b5f2cc2a0cb0a..67c5f7f7ac200 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 @@ -332,15 +332,14 @@ describe('rules_list ', () => { renderWithProviders( ); - await waitFor(() => screen.getByText('Rule state')); + await waitForElementToBeRemoved(() => screen.queryByTestId('centerJustifiedSpinner')); expect(loadRulesWithKueryFilter).toHaveBeenLastCalledWith( expect.objectContaining({ ruleStatusesFilter: ['disabled'], }) ); - - fireEvent.click(screen.getAllByTestId('ruleStatusFilterButton')[0]); - fireEvent.click(screen.getAllByTestId('ruleStatusFilterOption-enabled')[0]); + fireEvent.click((await screen.findAllByTestId('ruleStatusFilterButton'))[0]); + fireEvent.click((await screen.findAllByTestId('ruleStatusFilterOption-enabled'))[0]); expect(loadRulesWithKueryFilter).toHaveBeenLastCalledWith( expect.objectContaining({ ruleStatusesFilter: ['disabled', 'enabled'],