[ResponseOps][Cases] Fix StatusFilter flaky test (#189982)

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.)
This commit is contained in:
Antonio 2024-08-06 19:04:33 +02:00 committed by GitHub
parent c2f7330625
commit 1cb191fb69
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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: [],
@ -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 () => {
@ -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);
});
});