[MX] Fix flaky tests for severity component (#191202)

Issue: https://github.com/elastic/kibana/issues/188951

Fix flaky test:
x-pack/plugins/cases/public/components/case_form_fields/severity.test.tsx

It seems that this wrapper `createAppMockRenderer` is very slow. But we
do not need it for this small and simple component. So I just deleted it
from the test and use common `render` instead.
This commit is contained in:
Julia 2024-08-26 17:59:39 +02:00 committed by GitHub
parent 13972565d7
commit f8e88df324
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -6,9 +6,7 @@
*/
import React from 'react';
import { screen, waitFor } from '@testing-library/react';
import type { AppMockRenderer } from '../../common/mock';
import { createAppMockRenderer } from '../../common/mock';
import { screen, waitFor, render } from '@testing-library/react';
import { Severity } from './severity';
import userEvent from '@testing-library/user-event';
import { waitForEuiPopoverOpen } from '@elastic/eui/lib/test/rtl';
@ -16,28 +14,21 @@ import { FormTestComponent } from '../../common/test_utils';
const onSubmit = jest.fn();
// FLAKY: https://github.com/elastic/kibana/issues/188951
describe.skip('Severity form field', () => {
let appMockRender: AppMockRenderer;
beforeEach(() => {
appMockRender = createAppMockRenderer();
});
describe('Severity form field', () => {
it('renders', async () => {
appMockRender.render(
render(
<FormTestComponent onSubmit={onSubmit}>
<Severity isLoading={false} />
</FormTestComponent>
);
expect(await screen.findByTestId('caseSeverity')).toBeInTheDocument();
expect(await screen.findByTestId('case-severity-selection')).not.toHaveAttribute('disabled');
expect(await screen.findByTestId('case-severity-selection')).toBeEnabled();
});
// default to LOW in this test configuration
it('defaults to the correct value', async () => {
appMockRender.render(
render(
<FormTestComponent onSubmit={onSubmit}>
<Severity isLoading={false} />
</FormTestComponent>
@ -48,7 +39,7 @@ describe.skip('Severity form field', () => {
});
it('selects the correct value when changed', async () => {
appMockRender.render(
render(
<FormTestComponent onSubmit={onSubmit}>
<Severity isLoading={false} />
</FormTestComponent>
@ -70,12 +61,12 @@ describe.skip('Severity form field', () => {
});
it('disables when loading data', async () => {
appMockRender.render(
render(
<FormTestComponent onSubmit={onSubmit}>
<Severity isLoading={true} />
</FormTestComponent>
);
expect(await screen.findByTestId('case-severity-selection')).toHaveAttribute('disabled');
expect(await screen.findByTestId('case-severity-selection')).toBeDisabled();
});
});