Skip to content

Commit

Permalink
[RAM] Try to fix flaky rules_list test - filter by rule state (#150056)
Browse files Browse the repository at this point in the history
## Summary

Related to #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)
  • Loading branch information
jcger authored Feb 6, 2023
1 parent f637820 commit 888ce1f
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -332,15 +332,14 @@ describe('rules_list ', () => {
renderWithProviders(
<RulesList statusFilter={['disabled']} onStatusFilterChange={onStatusFilterChangeMock} />
);
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'],
Expand Down

0 comments on commit 888ce1f

Please sign in to comment.