Skip to content

Commit

Permalink
[ResponseOps][Cases] Fix custom fields flaky test. (elastic#189475)
Browse files Browse the repository at this point in the history
fixes elastic#188133

## Summary

I simplified the failing test a bit to make it less likely to timeout.
1. We checked for the test **and** the `id` to make sure the component
was rendered, it was redundant.
2. We looked for all custom fields(4) and I reduced the check to just
2(which have different types).
3. Updated another test that looked for a label to look for an `id`(for
consistency).
  • Loading branch information
adcoelho committed Jul 31, 2024
1 parent 20912a7 commit 60e1257
Showing 1 changed file with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@ import { createAppMockRenderer } from '../../common/mock';
import { FormTestComponent } from '../../common/test_utils';
import { customFieldsConfigurationMock } from '../../containers/mock';
import { CustomFields } from './custom_fields';
import * as i18n from './translations';

// FLAKY: https://github.com/elastic/kibana/issues/188133
describe.skip('CustomFields', () => {
describe('CustomFields', () => {
let appMockRender: AppMockRenderer;
const onSubmit = jest.fn();

Expand All @@ -40,14 +38,17 @@ describe.skip('CustomFields', () => {
</FormTestComponent>
);

expect(await screen.findByText(i18n.ADDITIONAL_FIELDS)).toBeInTheDocument();
expect(await screen.findByTestId('caseCustomFields')).toBeInTheDocument();

for (const item of customFieldsConfigurationMock) {
expect(
await screen.findByTestId(`${item.key}-${item.type}-create-custom-field`)
).toBeInTheDocument();
}
const cf0 = customFieldsConfigurationMock[0];
const cf1 = customFieldsConfigurationMock[1];

expect(
await screen.findByTestId(`${cf0.key}-${cf0.type}-create-custom-field`)
).toBeInTheDocument();
expect(
await screen.findByTestId(`${cf1.key}-${cf1.type}-create-custom-field`)
).toBeInTheDocument();
});

it('should not show the custom fields if the configuration is empty', async () => {
Expand All @@ -61,7 +62,7 @@ describe.skip('CustomFields', () => {
</FormTestComponent>
);

expect(screen.queryByText(i18n.ADDITIONAL_FIELDS)).not.toBeInTheDocument();
expect(screen.queryByTestId('caseCustomFields')).not.toBeInTheDocument();
expect(screen.queryAllByTestId('create-custom-field', { exact: false }).length).toEqual(0);
});

Expand All @@ -76,7 +77,7 @@ describe.skip('CustomFields', () => {
</FormTestComponent>
);

expect(screen.getAllByTestId('form-optional-field-label')).toHaveLength(2);
expect(await screen.findAllByTestId('form-optional-field-label')).toHaveLength(2);
});

it('should not set default value when in edit mode', async () => {
Expand Down

0 comments on commit 60e1257

Please sign in to comment.