From 7d0d97bae7b9a3f5d51b5059c7affef2f55c571c Mon Sep 17 00:00:00 2001 From: Evan Rusackas Date: Sun, 18 Jan 2026 10:11:09 -0800 Subject: [PATCH] fix(tests): fix test failures in ChartRenderer, ExploreChartHeader, and Chart - ChartRenderer.test.tsx: Remove viz_type from formData to allow vizType prop to take precedence for suppressContextMenu test, use as unknown for test data type assertions - ExploreChartHeader.test.tsx: Fix placeholder text assertion - use findByDisplayValue instead of findByText since chart has a title - ExploreViewContainer: Pass exploreState prop to ExploreChartPanel to match original behavior of spread props - ExploreChartPanel: Add exploreState to props interface Co-Authored-By: Claude Opus 4.5 --- .../src/components/Chart/ChartRenderer.test.tsx | 10 ++++------ .../ExploreChartHeader/ExploreChartHeader.test.tsx | 4 +++- .../src/explore/components/ExploreChartPanel/index.tsx | 1 + .../explore/components/ExploreViewContainer/index.tsx | 1 + 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/superset-frontend/src/components/Chart/ChartRenderer.test.tsx b/superset-frontend/src/components/Chart/ChartRenderer.test.tsx index c54b40f5f31..31b20466389 100644 --- a/superset-frontend/src/components/Chart/ChartRenderer.test.tsx +++ b/superset-frontend/src/components/Chart/ChartRenderer.test.tsx @@ -81,12 +81,12 @@ const mockActions: MockActions = { const requiredProps: Partial = { chartId: 1, datasource: {} as ChartRendererProps['datasource'], - formData: { testControl: 'foo', datasource: '', viz_type: VizType.Table }, + formData: { + testControl: 'foo', + } as unknown as ChartRendererProps['formData'], latestQueryFormData: { testControl: 'bar', - datasource: '', - viz_type: VizType.Table, - }, + } as unknown as ChartRendererProps['latestQueryFormData'], vizType: VizType.Table, source: ChartSource.Dashboard, actions: mockActions as ChartRendererProps['actions'], @@ -122,8 +122,6 @@ test('should use latestQueryFormData instead of formData when chartIsStale is tr expect(getByTestId('mock-super-chart')).toHaveTextContent( JSON.stringify({ testControl: 'bar', - datasource: '', - viz_type: VizType.Table, }), ); }); diff --git a/superset-frontend/src/explore/components/ExploreChartHeader/ExploreChartHeader.test.tsx b/superset-frontend/src/explore/components/ExploreChartHeader/ExploreChartHeader.test.tsx index 49faa6384c2..82230fc0b05 100644 --- a/superset-frontend/src/explore/components/ExploreChartHeader/ExploreChartHeader.test.tsx +++ b/superset-frontend/src/explore/components/ExploreChartHeader/ExploreChartHeader.test.tsx @@ -174,8 +174,10 @@ describe('ExploreChartHeader', () => { render(, { useRedux: true }); const newChartName = 'New chart name'; const prevChartName = props.sliceName; + + // Wait for the component to render with the chart title expect( - await screen.findByText(/add the name of the chart/i), + await screen.findByDisplayValue(prevChartName ?? ''), ).toBeInTheDocument(); userEvent.click(screen.getByLabelText('Menu actions trigger')); diff --git a/superset-frontend/src/explore/components/ExploreChartPanel/index.tsx b/superset-frontend/src/explore/components/ExploreChartPanel/index.tsx index 9183be5b654..07aa069eadf 100644 --- a/superset-frontend/src/explore/components/ExploreChartPanel/index.tsx +++ b/superset-frontend/src/explore/components/ExploreChartPanel/index.tsx @@ -88,6 +88,7 @@ export interface ExploreChartPanelProps { errorMessage?: ReactNode; triggerRender?: boolean; chartAlert?: string; + exploreState?: JsonObject; } type PanelSizes = [number, number]; diff --git a/superset-frontend/src/explore/components/ExploreViewContainer/index.tsx b/superset-frontend/src/explore/components/ExploreViewContainer/index.tsx index 175591c5fd3..64df98b2b7b 100644 --- a/superset-frontend/src/explore/components/ExploreViewContainer/index.tsx +++ b/superset-frontend/src/explore/components/ExploreViewContainer/index.tsx @@ -839,6 +839,7 @@ function ExploreViewContainer(props: ExploreViewContainerProps) { errorMessage={dataTabErrorMessage} chartIsStale={chartIsStale} onQuery={onQuery} + exploreState={props.exploreState} /> ); }