Skip to content

Commit

Permalink
refactor: remove KibanaRenderContextProvider and update test setup
Browse files Browse the repository at this point in the history
- Removed KibanaRenderContextProvider from TestProvidersComponent due to
  issues in current overview tests
- Updated test setup in data_quality.test.tsx to include KibanaRenderContextProvider instead
  • Loading branch information
kapral18 committed Jan 5, 2025
1 parent fd9f900 commit 5ab5bfe
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ import { ThemeProvider } from 'styled-components';
import type { Capabilities } from '@kbn/core/public';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';

import { KibanaRenderContextProvider } from '@kbn/react-kibana-context-render';
import { coreMock } from '@kbn/core/public/mocks';
import type { Action } from '@kbn/ui-actions-plugin/public';
import { CellActionsProvider } from '@kbn/cell-actions';
import { TestProvider as ExpandableFlyoutTestProvider } from '@kbn/expandable-flyout/src/test/provider';
Expand Down Expand Up @@ -77,31 +75,29 @@ export const TestProvidersComponent = ({

return (
<MockKibanaContextProvider startServices={startServices}>
<KibanaRenderContextProvider {...coreMock.createStart()}>
<I18nProvider>
<UpsellingProviderMock>
<ReduxStoreProvider store={store}>
<ThemeProvider theme={() => ({ eui: euiDarkVars, darkMode: true })}>
<QueryClientProvider client={queryClient}>
<MockDiscoverInTimelineContext>
<MockAssistantProvider>
<ExpandableFlyoutTestProvider>
<ConsoleManager>
<CellActionsProvider
getTriggerCompatibleActions={() => Promise.resolve(cellActions)}
>
<DragDropContext onDragEnd={onDragEnd}>{children}</DragDropContext>
</CellActionsProvider>
</ConsoleManager>
</ExpandableFlyoutTestProvider>
</MockAssistantProvider>
</MockDiscoverInTimelineContext>
</QueryClientProvider>
</ThemeProvider>
</ReduxStoreProvider>
</UpsellingProviderMock>
</I18nProvider>
</KibanaRenderContextProvider>
<I18nProvider>
<UpsellingProviderMock>
<ReduxStoreProvider store={store}>
<ThemeProvider theme={() => ({ eui: euiDarkVars, darkMode: true })}>
<QueryClientProvider client={queryClient}>
<MockDiscoverInTimelineContext>
<MockAssistantProvider>
<ExpandableFlyoutTestProvider>
<ConsoleManager>
<CellActionsProvider
getTriggerCompatibleActions={() => Promise.resolve(cellActions)}
>
<DragDropContext onDragEnd={onDragEnd}>{children}</DragDropContext>
</CellActionsProvider>
</ConsoleManager>
</ExpandableFlyoutTestProvider>
</MockAssistantProvider>
</MockDiscoverInTimelineContext>
</QueryClientProvider>
</ThemeProvider>
</ReduxStoreProvider>
</UpsellingProviderMock>
</I18nProvider>
</MockKibanaContextProvider>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { useKibana as mockUseKibana } from '../../common/lib/kibana/__mocks__';
import { TestProviders } from '../../common/mock';
import { DataQuality } from './data_quality';
import { useKibana } from '../../common/lib/kibana';
import { KibanaRenderContextProvider } from '@kbn/react-kibana-context-render';

const mockedUseKibana = mockUseKibana();

Expand Down Expand Up @@ -104,11 +105,13 @@ describe('DataQuality', () => {
describe('when indices exist, and loading is complete', () => {
beforeEach(async () => {
render(
<TestProviders>
<MemoryRouter>
<DataQuality />
</MemoryRouter>
</TestProviders>
<KibanaRenderContextProvider {...mockedUseKibana.services}>
<TestProviders>
<MemoryRouter>
<DataQuality />
</MemoryRouter>
</TestProviders>
</KibanaRenderContextProvider>
);

await waitFor(() => {});
Expand Down Expand Up @@ -136,11 +139,13 @@ describe('DataQuality', () => {
mockUseSourcererDataView.mockReturnValue({ ...defaultUseSourcererReturn, loading: true });

render(
<TestProviders>
<MemoryRouter>
<DataQuality />
</MemoryRouter>
</TestProviders>
<KibanaRenderContextProvider {...mockedUseKibana.services}>
<TestProviders>
<MemoryRouter>
<DataQuality />
</MemoryRouter>
</TestProviders>
</KibanaRenderContextProvider>
);

await waitFor(() => {});
Expand Down Expand Up @@ -168,11 +173,13 @@ describe('DataQuality', () => {
mockUseSignalIndex.mockReturnValue({ ...defaultUseSignalIndexReturn, loading: true });

render(
<TestProviders>
<MemoryRouter>
<DataQuality />
</MemoryRouter>
</TestProviders>
<KibanaRenderContextProvider {...mockedUseKibana.services}>
<TestProviders>
<MemoryRouter>
<DataQuality />
</MemoryRouter>
</TestProviders>
</KibanaRenderContextProvider>
);

await waitFor(() => {});
Expand Down Expand Up @@ -205,11 +212,13 @@ describe('DataQuality', () => {
mockUseSignalIndex.mockReturnValue({ ...defaultUseSignalIndexReturn, loading: false });

render(
<TestProviders>
<MemoryRouter>
<DataQuality />
</MemoryRouter>
</TestProviders>
<KibanaRenderContextProvider {...mockedUseKibana.services}>
<TestProviders>
<MemoryRouter>
<DataQuality />
</MemoryRouter>
</TestProviders>
</KibanaRenderContextProvider>
);

await waitFor(() => {});
Expand Down Expand Up @@ -242,11 +251,13 @@ describe('DataQuality', () => {
mockUseSignalIndex.mockReturnValue({ ...defaultUseSignalIndexReturn, loading: false });

render(
<TestProviders>
<MemoryRouter>
<DataQuality />
</MemoryRouter>
</TestProviders>
<KibanaRenderContextProvider {...mockedUseKibana.services}>
<TestProviders>
<MemoryRouter>
<DataQuality />
</MemoryRouter>
</TestProviders>
</KibanaRenderContextProvider>
);

await waitFor(() => {});
Expand Down Expand Up @@ -279,11 +290,13 @@ describe('DataQuality', () => {
mockUseSignalIndex.mockReturnValue({ ...defaultUseSignalIndexReturn, loading: true });

render(
<TestProviders>
<MemoryRouter>
<DataQuality />
</MemoryRouter>
</TestProviders>
<KibanaRenderContextProvider {...mockedUseKibana.services}>
<TestProviders>
<MemoryRouter>
<DataQuality />
</MemoryRouter>
</TestProviders>
</KibanaRenderContextProvider>
);

await waitFor(() => {});
Expand Down Expand Up @@ -335,11 +348,13 @@ describe('DataQuality', () => {
});

render(
<TestProviders>
<MemoryRouter>
<DataQuality />
</MemoryRouter>
</TestProviders>
<KibanaRenderContextProvider {...mockedUseKibana.services}>
<TestProviders>
<MemoryRouter>
<DataQuality />
</MemoryRouter>
</TestProviders>
</KibanaRenderContextProvider>
);

await waitFor(() => {});
Expand Down

0 comments on commit 5ab5bfe

Please sign in to comment.