Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Cases] Unskip filter popover, property actions flaky tests #177611

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,16 @@
*/

import React from 'react';
import { waitForEuiPopoverOpen } from '@elastic/eui/lib/test/rtl';
import { waitForEuiPopoverOpen, screen } from '@elastic/eui/lib/test/rtl';
import { waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event';

import type { AppMockRenderer } from '../../common/mock';
import { createAppMockRenderer } from '../../common/mock';

import { FilterPopover } from '.';

// FLAKY: https://github.com/elastic/kibana/issues/176679
// FLAKY: https://github.com/elastic/kibana/issues/176680
// FLAKY: https://github.com/elastic/kibana/issues/176681
// FLAKY: https://github.com/elastic/kibana/issues/176682
// FLAKY: https://github.com/elastic/kibana/issues/176683
// FLAKY: https://github.com/elastic/kibana/issues/176684
// FLAKY: https://github.com/elastic/kibana/issues/176685
// FLAKY: https://github.com/elastic/kibana/issues/176686
describe.skip('FilterPopover ', () => {
describe('FilterPopover ', () => {
let appMockRender: AppMockRenderer;
const onSelectedOptionsChanged = jest.fn();
const tags: string[] = ['coke', 'pepsi'];
Expand All @@ -32,8 +25,8 @@ describe.skip('FilterPopover ', () => {
jest.clearAllMocks();
});

it('renders button label correctly', () => {
const { getByTestId } = appMockRender.render(
it('renders button label correctly', async () => {
appMockRender.render(
<FilterPopover
buttonLabel={'Tags'}
onSelectedOptionsChanged={onSelectedOptionsChanged}
Expand All @@ -42,11 +35,11 @@ describe.skip('FilterPopover ', () => {
/>
);

expect(getByTestId('options-filter-popover-button-Tags')).toBeInTheDocument();
expect(await screen.findByTestId('options-filter-popover-button-Tags')).toBeInTheDocument();
});

it('renders empty label correctly', async () => {
const { getByTestId, getByText } = appMockRender.render(
appMockRender.render(
<FilterPopover
buttonLabel={'Tags'}
onSelectedOptionsChanged={onSelectedOptionsChanged}
Expand All @@ -56,15 +49,15 @@ describe.skip('FilterPopover ', () => {
/>
);

userEvent.click(getByTestId('options-filter-popover-button-Tags'));
userEvent.click(await screen.findByTestId('options-filter-popover-button-Tags'));

await waitForEuiPopoverOpen();

expect(getByText('No options available')).toBeInTheDocument();
expect(await screen.findByText('No options available')).toBeInTheDocument();
});

it('renders string type options correctly', async () => {
const { getByTestId } = appMockRender.render(
appMockRender.render(
<FilterPopover
buttonLabel={'Tags'}
onSelectedOptionsChanged={onSelectedOptionsChanged}
Expand All @@ -73,16 +66,16 @@ describe.skip('FilterPopover ', () => {
/>
);

userEvent.click(getByTestId('options-filter-popover-button-Tags'));
userEvent.click(await screen.findByTestId('options-filter-popover-button-Tags'));

await waitForEuiPopoverOpen();

expect(getByTestId(`options-filter-popover-item-${tags[0]}`)).toBeInTheDocument();
expect(getByTestId(`options-filter-popover-item-${tags[1]}`)).toBeInTheDocument();
expect(await screen.findByTestId(`options-filter-popover-item-${tags[0]}`)).toBeInTheDocument();
expect(await screen.findByTestId(`options-filter-popover-item-${tags[1]}`)).toBeInTheDocument();
});

it('should call onSelectionChange with selected option', async () => {
const { getByTestId } = appMockRender.render(
appMockRender.render(
<FilterPopover
buttonLabel={'Tags'}
onSelectedOptionsChanged={onSelectedOptionsChanged}
Expand All @@ -91,17 +84,19 @@ describe.skip('FilterPopover ', () => {
/>
);

userEvent.click(getByTestId('options-filter-popover-button-Tags'));
userEvent.click(await screen.findByTestId('options-filter-popover-button-Tags'));

await waitForEuiPopoverOpen();

userEvent.click(getByTestId(`options-filter-popover-item-${tags[0]}`));
userEvent.click(await screen.findByTestId(`options-filter-popover-item-${tags[0]}`));

expect(onSelectedOptionsChanged).toHaveBeenCalledWith([tags[0]]);
await waitFor(() => {
expect(onSelectedOptionsChanged).toHaveBeenCalledWith([tags[0]]);
});
});

it('should call onSelectionChange with empty array when option is deselected', async () => {
const { getByTestId } = appMockRender.render(
appMockRender.render(
<FilterPopover
buttonLabel={'Tags'}
onSelectedOptionsChanged={onSelectedOptionsChanged}
Expand All @@ -110,13 +105,15 @@ describe.skip('FilterPopover ', () => {
/>
);

userEvent.click(getByTestId('options-filter-popover-button-Tags'));
userEvent.click(await screen.findByTestId('options-filter-popover-button-Tags'));

await waitForEuiPopoverOpen();

userEvent.click(getByTestId(`options-filter-popover-item-${tags[0]}`));
userEvent.click(await screen.findByTestId(`options-filter-popover-item-${tags[0]}`));

expect(onSelectedOptionsChanged).toHaveBeenCalledWith([]);
await waitFor(() => {
expect(onSelectedOptionsChanged).toHaveBeenCalledWith([]);
});
});

describe('maximum limit', () => {
Expand All @@ -125,7 +122,7 @@ describe.skip('FilterPopover ', () => {
const maxLengthLabel = `You have selected maximum number of ${maxLength} tags to filter`;

it('should show message when maximum options are selected', async () => {
const { getByTestId } = appMockRender.render(
appMockRender.render(
<FilterPopover
buttonLabel={'Tags'}
onSelectedOptionsChanged={onSelectedOptionsChanged}
Expand All @@ -136,18 +133,22 @@ describe.skip('FilterPopover ', () => {
/>
);

userEvent.click(getByTestId('options-filter-popover-button-Tags'));
userEvent.click(await screen.findByTestId('options-filter-popover-button-Tags'));

await waitForEuiPopoverOpen();

expect(getByTestId('maximum-length-warning')).toHaveTextContent(maxLengthLabel);
expect(await screen.findByTestId('maximum-length-warning')).toHaveTextContent(maxLengthLabel);

expect(getByTestId(`options-filter-popover-item-${newTags[3]}`)).toHaveProperty('disabled');
expect(getByTestId(`options-filter-popover-item-${newTags[4]}`)).toHaveProperty('disabled');
expect(await screen.findByTestId(`options-filter-popover-item-${newTags[3]}`)).toHaveProperty(
'disabled'
);
expect(await screen.findByTestId(`options-filter-popover-item-${newTags[4]}`)).toHaveProperty(
'disabled'
);
});

it('should not show message when maximum length label is missing', async () => {
const { getByTestId, queryByTestId } = appMockRender.render(
appMockRender.render(
<FilterPopover
buttonLabel={'Tags'}
onSelectedOptionsChanged={onSelectedOptionsChanged}
Expand All @@ -157,17 +158,21 @@ describe.skip('FilterPopover ', () => {
/>
);

userEvent.click(getByTestId('options-filter-popover-button-Tags'));
userEvent.click(await screen.findByTestId('options-filter-popover-button-Tags'));

await waitForEuiPopoverOpen();

expect(queryByTestId('maximum-length-warning')).not.toBeInTheDocument();
expect(getByTestId(`options-filter-popover-item-${newTags[3]}`)).toHaveProperty('disabled');
expect(getByTestId(`options-filter-popover-item-${newTags[4]}`)).toHaveProperty('disabled');
expect(screen.queryByTestId('maximum-length-warning')).not.toBeInTheDocument();
expect(await screen.findByTestId(`options-filter-popover-item-${newTags[3]}`)).toHaveProperty(
'disabled'
);
expect(await screen.findByTestId(`options-filter-popover-item-${newTags[4]}`)).toHaveProperty(
'disabled'
);
});

it('should not show message and disable options when maximum length property is missing', async () => {
const { getByTestId, queryByTestId } = appMockRender.render(
appMockRender.render(
<FilterPopover
buttonLabel={'Tags'}
onSelectedOptionsChanged={onSelectedOptionsChanged}
Expand All @@ -177,19 +182,19 @@ describe.skip('FilterPopover ', () => {
/>
);

userEvent.click(getByTestId('options-filter-popover-button-Tags'));
userEvent.click(await screen.findByTestId('options-filter-popover-button-Tags'));

await waitForEuiPopoverOpen();

expect(queryByTestId('maximum-length-warning')).not.toBeInTheDocument();
expect(getByTestId(`options-filter-popover-item-${newTags[4]}`)).toHaveProperty(
expect(screen.queryByTestId('maximum-length-warning')).not.toBeInTheDocument();
expect(await screen.findByTestId(`options-filter-popover-item-${newTags[4]}`)).toHaveProperty(
'disabled',
false
);
});

it('should allow to select more options when maximum length property is missing', async () => {
const { getByTestId } = appMockRender.render(
appMockRender.render(
<FilterPopover
buttonLabel={'Tags'}
onSelectedOptionsChanged={onSelectedOptionsChanged}
Expand All @@ -198,13 +203,15 @@ describe.skip('FilterPopover ', () => {
/>
);

userEvent.click(getByTestId('options-filter-popover-button-Tags'));
userEvent.click(await screen.findByTestId('options-filter-popover-button-Tags'));

await waitForEuiPopoverOpen();

userEvent.click(getByTestId(`options-filter-popover-item-${newTags[1]}`));
userEvent.click(await screen.findByTestId(`options-filter-popover-item-${newTags[1]}`));

expect(onSelectedOptionsChanged).toHaveBeenCalledWith([newTags[0], newTags[2], newTags[1]]);
await waitFor(() => {
expect(onSelectedOptionsChanged).toHaveBeenCalledWith([newTags[0], newTags[2], newTags[1]]);
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ import {
} from '../../../common/mock';
import { AlertPropertyActions } from './alert_property_actions';

// FLAKY: https://github.com/elastic/kibana/issues/174667
describe.skip('AlertPropertyActions', () => {
describe('AlertPropertyActions', () => {
let appMock: AppMockRenderer;

const props = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ import {
import { RegisteredAttachmentsPropertyActions } from './registered_attachments_property_actions';
import { AttachmentActionType } from '../../../client/attachment_framework/types';

// FLAKY: https://github.com/elastic/kibana/issues/174384
describe.skip('RegisteredAttachmentsPropertyActions', () => {
describe('RegisteredAttachmentsPropertyActions', () => {
let appMock: AppMockRenderer;

const props = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ import {
import { UserCommentPropertyActions } from './user_comment_property_actions';
import { waitFor } from '@testing-library/react';

// FLAKY: https://github.com/elastic/kibana/issues/175310
describe.skip('UserCommentPropertyActions', () => {
describe('UserCommentPropertyActions', () => {
let appMock: AppMockRenderer;

const props = {
Expand Down