diff --git a/src/plugins/dashboard/public/dashboard_container/embeddable/api/duplicate_dashboard_panel.test.tsx b/src/plugins/dashboard/public/dashboard_container/embeddable/api/duplicate_dashboard_panel.test.tsx
index 39bb0f754cfbed..3b372bf00c27ba 100644
--- a/src/plugins/dashboard/public/dashboard_container/embeddable/api/duplicate_dashboard_panel.test.tsx
+++ b/src/plugins/dashboard/public/dashboard_container/embeddable/api/duplicate_dashboard_panel.test.tsx
@@ -215,8 +215,6 @@ describe('React embeddables', () => {
},
{}
);
- fullApi$.next(fullApi);
- fullApi$.complete();
return {
Component: () =>
TEST DUPLICATE
,
api: fullApi,
@@ -234,6 +232,7 @@ describe('React embeddables', () => {
},
},
});
+
// render a fake Dashboard to initialize react embeddables
const FakeDashboard = () => {
return (
@@ -244,7 +243,11 @@ describe('React embeddables', () => {
dashboard.children$.next({ [panelId]: api })}
+ onApiAvailable={(api) => {
+ fullApi$.next(api as Api & HasSnapshottableState<{}>);
+ fullApi$.complete();
+ dashboard.children$.next({ [panelId]: api });
+ }}
getParentApi={() => ({
getSerializedStateForChild: () =>
panel.explicitInput as unknown as SerializedPanelState