Skip to content

Commit

Permalink
[ResponseOps][Cases] Fix StatusFilter flaky test (#189982)
Browse files Browse the repository at this point in the history
fixes #177334

## Summary

The failing test `should render` had waaay too many unnecessary tree
traversals. I reduced the `find`s from 7 to 3 hopefully making the test
significantly faster.

(I did the same on other tests but they weren't failing. Doesn't hurt
though.)
  • Loading branch information
adcoelho authored Aug 6, 2024
1 parent c2f7330 commit 1cb191f
Showing 1 changed file with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ const LABELS = {
inProgress: i18n.STATUS_IN_PROGRESS,
};

// FLAKY: https://github.com/elastic/kibana/issues/177334
describe.skip('StatusFilter', () => {
describe('StatusFilter', () => {
const onChange = jest.fn();
const defaultProps = {
selectedOptionKeys: [],
Expand All @@ -37,16 +36,18 @@ describe.skip('StatusFilter', () => {
it('should render', async () => {
render(<StatusFilter {...defaultProps} />);

expect(await screen.findByTestId('options-filter-popover-button-status')).toBeInTheDocument();
expect(await screen.findByTestId('options-filter-popover-button-status')).not.toBeDisabled();

userEvent.click(await screen.findByRole('button', { name: 'Status' }));

await waitForEuiPopoverOpen();

expect(await screen.findByRole('option', { name: LABELS.open })).toBeInTheDocument();
expect(await screen.findByRole('option', { name: LABELS.inProgress })).toBeInTheDocument();
expect(await screen.findByRole('option', { name: LABELS.closed })).toBeInTheDocument();
expect((await screen.findAllByRole('option')).length).toBe(3);
const options = await screen.findAllByRole('option');

expect(options.length).toBe(3);
expect(options[0]).toHaveTextContent(LABELS.open);
expect(options[1]).toHaveTextContent(LABELS.inProgress);
expect(options[2]).toHaveTextContent(LABELS.closed);
});

it('should call onStatusChanged when changing status to open', async () => {
Expand All @@ -68,10 +69,13 @@ describe.skip('StatusFilter', () => {
render(<StatusFilter {...defaultProps} hiddenStatuses={[CaseStatuses.closed]} />);

userEvent.click(await screen.findByRole('button', { name: 'Status' }));

await waitForEuiPopoverOpen();

expect(await screen.findAllByRole('option')).toHaveLength(2);
expect(await screen.findByRole('option', { name: LABELS.open })).toBeInTheDocument();
expect(await screen.findByRole('option', { name: LABELS.inProgress })).toBeInTheDocument();
const options = await screen.findAllByRole('option');

expect(options.length).toBe(2);
expect(options[0]).toHaveTextContent(LABELS.open);
expect(options[1]).toHaveTextContent(LABELS.inProgress);
});
});

0 comments on commit 1cb191f

Please sign in to comment.