Fixed test (#59208)
This commit is contained in:
parent
30c9b02045
commit
5cdb0153dc
|
@ -4,13 +4,12 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
import * as React from 'react';
|
||||
import { mountWithIntl } from 'test_utils/enzyme_helpers';
|
||||
import { mountWithIntl, nextTick } from 'test_utils/enzyme_helpers';
|
||||
import { act } from 'react-dom/test-utils';
|
||||
import { coreMock } from '../../../../../../../src/core/public/mocks';
|
||||
import { AlertAdd } from './alert_add';
|
||||
import { actionTypeRegistryMock } from '../../action_type_registry.mock';
|
||||
import { ValidationResult } from '../../../types';
|
||||
import { AppDeps } from '../../app';
|
||||
import { AlertsContextProvider } from '../../context/alerts_context';
|
||||
import { alertTypeRegistryMock } from '../../alert_type_registry.mock';
|
||||
import { chartPluginMock } from '../../../../../../../src/plugins/charts/public/mocks';
|
||||
|
@ -19,38 +18,19 @@ import { ReactWrapper } from 'enzyme';
|
|||
const actionTypeRegistry = actionTypeRegistryMock.create();
|
||||
const alertTypeRegistry = alertTypeRegistryMock.create();
|
||||
|
||||
// FLAKY: https://github.com/elastic/kibana/issues/58970
|
||||
describe.skip('alert_add', () => {
|
||||
let deps: AppDeps | null;
|
||||
describe('alert_add', () => {
|
||||
let deps: any;
|
||||
let wrapper: ReactWrapper<any>;
|
||||
|
||||
async function setup() {
|
||||
const mockes = coreMock.createSetup();
|
||||
const [
|
||||
{
|
||||
chrome,
|
||||
docLinks,
|
||||
application: { capabilities },
|
||||
},
|
||||
] = await mockes.getStartServices();
|
||||
deps = {
|
||||
chrome,
|
||||
docLinks,
|
||||
toastNotifications: mockes.notifications.toasts,
|
||||
injectedMetadata: mockes.injectedMetadata,
|
||||
http: mockes.http,
|
||||
uiSettings: mockes.uiSettings,
|
||||
dataPlugin: dataPluginMock.createStartContract(),
|
||||
charts: chartPluginMock.createStartContract(),
|
||||
capabilities: {
|
||||
...capabilities,
|
||||
alerting: {
|
||||
delete: true,
|
||||
save: true,
|
||||
show: true,
|
||||
},
|
||||
},
|
||||
setBreadcrumbs: jest.fn(),
|
||||
actionTypeRegistry: actionTypeRegistry as any,
|
||||
alertTypeRegistry: alertTypeRegistry as any,
|
||||
};
|
||||
|
@ -86,29 +66,29 @@ describe.skip('alert_add', () => {
|
|||
actionTypeRegistry.list.mockReturnValue([actionTypeModel]);
|
||||
actionTypeRegistry.has.mockReturnValue(true);
|
||||
|
||||
wrapper = mountWithIntl(
|
||||
<AlertsContextProvider
|
||||
value={{
|
||||
addFlyoutVisible: true,
|
||||
setAddFlyoutVisibility: state => {},
|
||||
reloadAlerts: () => {
|
||||
return new Promise<void>(() => {});
|
||||
},
|
||||
http: deps.http,
|
||||
actionTypeRegistry: deps.actionTypeRegistry,
|
||||
alertTypeRegistry: deps.alertTypeRegistry,
|
||||
toastNotifications: deps.toastNotifications,
|
||||
uiSettings: deps.uiSettings,
|
||||
}}
|
||||
>
|
||||
<AlertAdd consumer={'alerting'} />
|
||||
</AlertsContextProvider>
|
||||
);
|
||||
// Wait for active space to resolve before requesting the component to update
|
||||
await act(async () => {
|
||||
if (deps) {
|
||||
wrapper = mountWithIntl(
|
||||
<AlertsContextProvider
|
||||
value={{
|
||||
addFlyoutVisible: true,
|
||||
setAddFlyoutVisibility: state => {},
|
||||
reloadAlerts: () => {
|
||||
return new Promise<void>(() => {});
|
||||
},
|
||||
http: deps.http,
|
||||
actionTypeRegistry: deps.actionTypeRegistry,
|
||||
alertTypeRegistry: deps.alertTypeRegistry,
|
||||
toastNotifications: deps.toastNotifications,
|
||||
uiSettings: deps.uiSettings,
|
||||
}}
|
||||
>
|
||||
<AlertAdd consumer={'alerting'} />
|
||||
</AlertsContextProvider>
|
||||
);
|
||||
}
|
||||
await nextTick();
|
||||
wrapper.update();
|
||||
});
|
||||
await waitForRender(wrapper);
|
||||
}
|
||||
|
||||
it('renders alert add flyout', async () => {
|
||||
|
@ -117,9 +97,3 @@ describe.skip('alert_add', () => {
|
|||
expect(wrapper.find('[data-test-subj="saveAlertButton"]').exists()).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
async function waitForRender(wrapper: ReactWrapper<any, any>) {
|
||||
await Promise.resolve();
|
||||
await Promise.resolve();
|
||||
wrapper.update();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue