Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Commit

Permalink
fix(explore): rendering regression on standalone (apache#24177)
Browse files Browse the repository at this point in the history
  • Loading branch information
justinpark committed May 23, 2023
1 parent 02d3d53 commit 4613932
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,11 @@ const ExploreChartPanel = ({
if (!bodyClasses.includes(standaloneClass)) {
document.body.className += ` ${standaloneClass}`;
}
return standaloneChartBody;
return (
<div id="app" data-test="standalone-app" ref={resizeObserverRef}>
{standaloneChartBody}
</div>
);
}

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,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', {
Expand All @@ -115,7 +120,7 @@ const renderWithRouter = ({
<ExploreViewContainer />
</Route>
</MemoryRouter>,
{ useRedux: true, initialState: reduxState },
{ useRedux: true, initialState },
);
};

Expand Down Expand Up @@ -143,6 +148,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 }));
Expand Down

0 comments on commit 4613932

Please sign in to comment.