From 7f844908e184d30806e42aa75e609a63203e6996 Mon Sep 17 00:00:00 2001 From: "JUST.in DO IT" Date: Tue, 23 May 2023 09:49:04 -0700 Subject: [PATCH] fix(explore): rendering regression on standalone (#24177) --- .../components/ExploreChartPanel/index.jsx | 6 +++++- .../ExploreViewContainer.test.tsx | 17 ++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/superset-frontend/src/explore/components/ExploreChartPanel/index.jsx b/superset-frontend/src/explore/components/ExploreChartPanel/index.jsx index 893a10275a25d..0dee4d076e7ea 100644 --- a/superset-frontend/src/explore/components/ExploreChartPanel/index.jsx +++ b/superset-frontend/src/explore/components/ExploreChartPanel/index.jsx @@ -418,7 +418,11 @@ const ExploreChartPanel = ({ if (!bodyClasses.includes(standaloneClass)) { document.body.className += ` ${standaloneClass}`; } - return standaloneChartBody; + return ( +
+ {standaloneChartBody} +
+ ); } return ( diff --git a/superset-frontend/src/explore/components/ExploreViewContainer/ExploreViewContainer.test.tsx b/superset-frontend/src/explore/components/ExploreViewContainer/ExploreViewContainer.test.tsx index fbfb0c3b1de77..1681fdce0d677 100644 --- a/superset-frontend/src/explore/components/ExploreViewContainer/ExploreViewContainer.test.tsx +++ b/superset-frontend/src/explore/components/ExploreViewContainer/ExploreViewContainer.test.tsx @@ -97,14 +97,19 @@ fetchMock.get('glob:*/api/v1/explore/form_data*', {}); fetchMock.get('glob:*/api/v1/chart/favorite_status*', { result: [{ value: true }], }); +fetchMock.get('glob:*/api/v1/chart/*', { + result: {}, +}); const defaultPath = '/explore/'; const renderWithRouter = ({ search = '', overridePathname, + initialState = reduxState, }: { search?: string; overridePathname?: string; + initialState?: object; } = {}) => { const path = overridePathname ?? defaultPath; Object.defineProperty(window, 'location', { @@ -118,7 +123,7 @@ const renderWithRouter = ({ , - { useRedux: true, initialState: reduxState }, + { useRedux: true, initialState }, ); }; @@ -146,6 +151,16 @@ test('generates a new form_data param when none is available', async () => { replaceState.mockRestore(); }); +test('renders chart in standalone mode', () => { + const { queryByTestId } = renderWithRouter({ + initialState: { + ...reduxState, + explore: { ...reduxState.explore, standalone: true }, + }, + }); + expect(queryByTestId('standalone-app')).toBeTruthy(); +}); + test('generates a different form_data param when one is provided and is mounting', async () => { const replaceState = jest.spyOn(window.history, 'replaceState'); await waitFor(() => renderWithRouter({ search: SEARCH }));