[APM] Extracting custom link flaky test. (#88455)

* extracting the flaky test to another file

* extracting the flaky test to another file
This commit is contained in:
Cauê Marcondes 2021-01-15 17:03:56 +01:00 committed by GitHub
parent fc370b74eb
commit e2fc156bc5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 31 deletions

View file

@ -0,0 +1,29 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import { fireEvent, render } from '@testing-library/react';
import React from 'react';
import { act } from 'react-dom/test-utils';
import { MockApmPluginContextWrapper } from '../../../../../../context/apm_plugin/mock_apm_plugin_context';
import * as apmApi from '../../../../../../services/rest/createCallApmApi';
import { DeleteButton } from './DeleteButton';
describe('Delete custom link', () => {
beforeAll(() => {
jest.spyOn(apmApi, 'callApmApi').mockResolvedValue({});
});
it('deletes a custom link', async () => {
const onDeleteMock = jest.fn();
const { getByText } = render(
<MockApmPluginContextWrapper>
<DeleteButton onDelete={onDeleteMock} customLinkId="1" />
</MockApmPluginContextWrapper>
);
await act(async () => {
fireEvent.click(getByText('Delete'));
});
expect(onDeleteMock).toHaveBeenCalledTimes(1);
});
});

View file

@ -4,12 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/
import {
fireEvent,
render,
RenderResult,
waitFor,
} from '@testing-library/react';
import { fireEvent, render, RenderResult } from '@testing-library/react';
import React from 'react';
import { act } from 'react-dom/test-utils';
import { CustomLinkOverview } from '.';
@ -219,31 +214,6 @@ describe('CustomLink', () => {
expect(saveCustomLinkSpy).toHaveBeenCalledTimes(1);
});
// FLAKY: https://github.com/elastic/kibana/issues/75106
it.skip('deletes a custom link', async () => {
const mockContext = getMockAPMContext({ canSave: true });
const component = render(
<LicenseContext.Provider value={goldLicense}>
<MockApmPluginContextWrapper value={mockContext}>
<CustomLinkOverview />
</MockApmPluginContextWrapper>
</LicenseContext.Provider>
);
expect(component.queryByText('Create link')).not.toBeInTheDocument();
const editButtons = component.getAllByLabelText('Edit');
expect(editButtons.length).toEqual(2);
act(() => {
fireEvent.click(editButtons[0]);
});
await waitFor(() =>
expect(component.queryByText('Create link')).toBeInTheDocument()
);
await act(async () => {
fireEvent.click(component.getByText('Delete'));
});
expect(refetch).toHaveBeenCalled();
});
describe('Filters', () => {
const addFilterField = (component: RenderResult, amount: number) => {
for (let i = 1; i <= amount; i++) {