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'],