diff --git a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.test.tsx b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.test.tsx
index 22851f182215c..649a760cb0ac8 100644
--- a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.test.tsx
+++ b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/config_panel/layer_panel.test.tsx
@@ -701,7 +701,7 @@ describe('LayerPanel', () => {
target.columnId !== 'a' ? { dropTypes: ['field_replace'], nextLabel: '' } : undefined
);
- const { instance } = await mountWithReduxStore(
+ const { instance } = mountWithReduxStore(
@@ -760,7 +760,7 @@ describe('LayerPanel', () => {
nextLabel: '',
});
- const { instance } = await mountWithReduxStore(
+ const { instance } = mountWithReduxStore(
@@ -820,7 +820,7 @@ describe('LayerPanel', () => {
const holder = document.createElement('div');
document.body.appendChild(holder);
- const { instance } = await mountWithReduxStore(
+ const { instance } = mountWithReduxStore(
,
@@ -858,7 +858,7 @@ describe('LayerPanel', () => {
],
});
- const { instance } = await mountWithReduxStore(
+ const { instance } = mountWithReduxStore(
@@ -895,7 +895,7 @@ describe('LayerPanel', () => {
],
});
- const { instance } = await mountWithReduxStore(
+ const { instance } = mountWithReduxStore(
@@ -936,7 +936,7 @@ describe('LayerPanel', () => {
mockDatasource.onDrop.mockReturnValue(true);
const updateVisualization = jest.fn();
- const { instance } = await mountWithReduxStore(
+ const { instance } = mountWithReduxStore(
{
mockDatasource.onDrop.mockReturnValue(false);
const updateVisualization = jest.fn();
- const { instance } = await mountWithReduxStore(
+ const { instance } = mountWithReduxStore(
{
mockDatasource.onDrop.mockReturnValue(true);
- const { instance } = await mountWithReduxStore(
+ const { instance } = mountWithReduxStore(
diff --git a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/suggestion_panel.test.tsx b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/suggestion_panel.test.tsx
index cf66ee709ae32..eb422cc388bb9 100644
--- a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/suggestion_panel.test.tsx
+++ b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/suggestion_panel.test.tsx
@@ -116,7 +116,7 @@ describe('suggestion_panel', () => {
});
it('should avoid completely to render SuggestionPanel when in fullscreen mode', async () => {
- const { instance, lensStore } = await mountWithReduxStore(
+ const { instance, lensStore } = mountWithReduxStore(
);
expect(instance.find(SuggestionPanel).exists()).toBe(true);
@@ -131,7 +131,7 @@ describe('suggestion_panel', () => {
});
it('should display apply-changes prompt when changes not applied', async () => {
- const { instance, lensStore } = await mountWithReduxStore(, {
+ const { instance, lensStore } = mountWithReduxStore(, {
preloadedState: {
...preloadedState,
visualization: {
@@ -163,7 +163,7 @@ describe('suggestion_panel', () => {
});
it('should list passed in suggestions', async () => {
- const { instance } = await mountWithReduxStore(, {
+ const { instance } = mountWithReduxStore(, {
preloadedState,
});
@@ -199,10 +199,9 @@ describe('suggestion_panel', () => {
});
it('should not update suggestions if current state is moved to staged preview', async () => {
- const { instance, lensStore } = await mountWithReduxStore(
- ,
- { preloadedState }
- );
+ const { instance, lensStore } = mountWithReduxStore(, {
+ preloadedState,
+ });
getSuggestionsMock.mockClear();
lensStore.dispatch(setState({ stagedPreview }));
instance.update();
@@ -210,10 +209,9 @@ describe('suggestion_panel', () => {
});
it('should update suggestions if staged preview is removed', async () => {
- const { instance, lensStore } = await mountWithReduxStore(
- ,
- { preloadedState }
- );
+ const { instance, lensStore } = mountWithReduxStore(, {
+ preloadedState,
+ });
getSuggestionsMock.mockClear();
lensStore.dispatch(setState({ stagedPreview, ...suggestionState }));
instance.update();
@@ -234,9 +232,7 @@ describe('suggestion_panel', () => {
});
it('should rollback suggestion if current panel is clicked', async () => {
- const { instance, lensStore } = await mountWithReduxStore(
-
- );
+ const { instance, lensStore } = mountWithReduxStore();
act(() => {
instance.find(SELECTORS.SUGGESTION_TILE_BUTTON).at(2).simulate('click');
@@ -261,7 +257,7 @@ describe('suggestion_panel', () => {
});
it('should dispatch visualization switch action if suggestion is clicked', async () => {
- const { instance, lensStore } = await mountWithReduxStore(, {
+ const { instance, lensStore } = mountWithReduxStore(, {
preloadedState,
});
@@ -315,7 +311,7 @@ describe('suggestion_panel', () => {
mockDatasource.toExpression.mockReturnValue('datasource_expression');
- const { instance } = await mountWithReduxStore(, {
+ const { instance } = mountWithReduxStore(, {
preloadedState,
});
@@ -343,14 +339,14 @@ describe('suggestion_panel', () => {
},
};
- const { instance } = await mountWithReduxStore(, {
+ const { instance } = mountWithReduxStore(, {
preloadedState: newPreloadedState,
});
expect(instance.html()).toEqual(null);
});
it('should hide the selections when the accordion is hidden', async () => {
- const { instance } = await mountWithReduxStore();
+ const { instance } = mountWithReduxStore();
expect(instance.find(EuiAccordion)).toHaveLength(1);
act(() => {
instance.find(EuiAccordion).at(0).simulate('change');
diff --git a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.test.tsx b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.test.tsx
index a11f953616b69..194f20fd6bbe1 100644
--- a/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.test.tsx
+++ b/x-pack/platform/plugins/shared/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.test.tsx
@@ -367,7 +367,7 @@ describe('workspace_panel', () => {
const visualizationShowing = () => instance.exists(expressionRendererMock);
- const mounted = await mountWithReduxStore(
+ const mounted = mountWithReduxStore(
{
mockDatasource.getLayers.mockReturnValue(['first']);
const props = defaultProps;
- const mounted = await mountWithReduxStore(
+ const mounted = mountWithReduxStore(
{
mockDatasource.getLayers.mockReturnValue(['first']);
const props = defaultProps;
- const mounted = await mountWithReduxStore(
+ const mounted = mountWithReduxStore(
{
mockDatasource.getLayers.mockReturnValue(['first']);
const props = defaultProps;
- const mounted = await mountWithReduxStore(
+ const mounted = mountWithReduxStore(
{
mockDatasource.toExpression.mockReturnValue('datasource');
mockDatasource.getLayers.mockReturnValue(['table1']);
- const mounted = await mountWithReduxStore(
+ const mounted = mountWithReduxStore(
{
expressionRendererMock = jest.fn((_arg) => );
- const mounted = await mountWithReduxStore(
+ const mounted = mountWithReduxStore(
{
.mockReturnValueOnce('datasource second');
expressionRendererMock = jest.fn((_arg) => );
- const mounted = await mountWithReduxStore(
+ const mounted = mountWithReduxStore(
{
const getUserMessages = jest.fn(() => messages);
- const mounted = await mountWithReduxStore(
+ const mounted = mountWithReduxStore(
{
let userMessages = [] as UserMessage[];
const getUserMessageFn = jest.fn(() => userMessages);
- const mounted = await mountWithReduxStore(
+ const mounted = mountWithReduxStore(
{
const mockAddUserMessages = jest.fn(() => mockRemoveUserMessages);
const mockGetUserMessages = jest.fn(() => []);
- const mounted = await mountWithReduxStore(
+ const mounted = mountWithReduxStore(
{
first: mockDatasource.publicAPIMock,
};
- const mounted = await mountWithReduxStore(
+ const mounted = mountWithReduxStore(
{
framePublicAPI.datasourceLayers = {
first: mockDatasource.publicAPIMock,
};
- const mounted = await mountWithReduxStore(
+ const mounted = mountWithReduxStore(
;
-}) {
+} = {}) {
const data = storeDeps.lensServices.data;
const store = makeConfigureStore(storeDeps, {
lens: {
@@ -119,10 +119,10 @@ export function makeLensStore({
export interface MountStoreProps {
storeDeps?: LensStoreDeps;
preloadedState?: Partial;
- dispatch?: jest.Mock;
}
-export const mountWithReduxStore = async (
+// legacy enzyme usage: remove when all tests are migrated to @testing-library/react
+export const mountWithReduxStore = (
component: React.ReactElement,
store?: MountStoreProps,
options?: {
@@ -131,12 +131,12 @@ export const mountWithReduxStore = async (
attachTo?: HTMLElement;
}
) => {
- const { store: lensStore, deps } = makeLensStore(store || {});
+ const { store: lensStore, deps } = makeLensStore(store);
let wrappingComponent: React.FC> = ({ children }) => (
{children}
);
- if (options?.wrappingComponent) {
+ if (options?.wrappingComponent) {
wrappingComponent = ({ children }) => {
return options?.wrappingComponent?.({
...options?.wrappingComponentProps,
@@ -146,9 +146,9 @@ export const mountWithReduxStore = async (
}
const instance = mountWithProviders(component, {
- ...options,
- wrappingComponent,
- } as unknown as ReactWrapper);
+ ...options,
+ wrappingComponent,
+ } as unknown as ReactWrapper);
return { instance, lensStore, deps };
};
diff --git a/x-pack/platform/plugins/shared/lens/public/state_management/lens_slice.test.ts b/x-pack/platform/plugins/shared/lens/public/state_management/lens_slice.test.ts
index 81bfb55a4cbca..8f79464458d93 100644
--- a/x-pack/platform/plugins/shared/lens/public/state_management/lens_slice.test.ts
+++ b/x-pack/platform/plugins/shared/lens/public/state_management/lens_slice.test.ts
@@ -37,7 +37,7 @@ import { layerTypes } from '../../common/layer_types';
describe('lensSlice', () => {
let store: EnhancedStore<{ lens: LensAppState }>;
beforeEach(() => {
- store = makeLensStore({}).store;
+ store = makeLensStore().store;
jest.clearAllMocks();
});
const customQuery = { query: 'custom' } as Query;
diff --git a/x-pack/platform/plugins/shared/lens/public/test_utils/test_utils.tsx b/x-pack/platform/plugins/shared/lens/public/test_utils/test_utils.tsx
index 26e33239af3ea..fbee7a3146d5e 100644
--- a/x-pack/platform/plugins/shared/lens/public/test_utils/test_utils.tsx
+++ b/x-pack/platform/plugins/shared/lens/public/test_utils/test_utils.tsx
@@ -41,6 +41,7 @@ export const renderWithProviders = (
return rtlRender;
};
+// legacy enzyme usage: remove when all tests are migrated to @testing-library/react
export const mountWithProviders = (component: React.ReactElement, options?: MountRendererProps) => {
const { wrappingComponent, wrappingComponentProps } = options || {};