[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:
parent
fc370b74eb
commit
e2fc156bc5
|
@ -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);
|
||||||
|
});
|
||||||
|
});
|
|
@ -4,12 +4,7 @@
|
||||||
* you may not use this file except in compliance with the Elastic License.
|
* you may not use this file except in compliance with the Elastic License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {
|
import { fireEvent, render, RenderResult } from '@testing-library/react';
|
||||||
fireEvent,
|
|
||||||
render,
|
|
||||||
RenderResult,
|
|
||||||
waitFor,
|
|
||||||
} from '@testing-library/react';
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { act } from 'react-dom/test-utils';
|
import { act } from 'react-dom/test-utils';
|
||||||
import { CustomLinkOverview } from '.';
|
import { CustomLinkOverview } from '.';
|
||||||
|
@ -219,31 +214,6 @@ describe('CustomLink', () => {
|
||||||
expect(saveCustomLinkSpy).toHaveBeenCalledTimes(1);
|
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', () => {
|
describe('Filters', () => {
|
||||||
const addFilterField = (component: RenderResult, amount: number) => {
|
const addFilterField = (component: RenderResult, amount: number) => {
|
||||||
for (let i = 1; i <= amount; i++) {
|
for (let i = 1; i <= amount; i++) {
|
||||||
|
|
Loading…
Reference in a new issue