Skip to content

Commit

Permalink
[Cases] Unskip filter popover, property actions flaky tests (#177611)
Browse files Browse the repository at this point in the history
## Summary

As a follow-up to #176863
unskipping filterPopOver and propertyActions tests

Fixes #176679
Fixes #176680
Fixes #176681
Fixes #176682
Fixes #176683
Fixes #176684
Fixes #176685
Fixes #176686
Fixes #174384
Fixes #174667
Fixes #175310
  • Loading branch information
js-jankisalvi authored Feb 22, 2024
1 parent 2a8d29b commit 9bdea88
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 52 deletions.
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

0 comments on commit 9bdea88

Please sign in to comment.