LuisSanchez commented on code in PR #36993:
URL: https://github.com/apache/superset/pull/36993#discussion_r2718797902
##########
superset-frontend/src/explore/components/ExploreViewContainer/ExploreViewContainer.test.tsx:
##########
@@ -474,3 +474,210 @@ test('shows error indicator with function labels', async
() => {
expect(await screen.findByText(/Metric is required/)).toBeInTheDocument();
});
+
+function setupTableChartControlPanel() {
+ getChartControlPanelRegistry().registerValue('table', {
+ controlPanelSections: [],
+ });
+}
+
+test('automatic axis title margin adjustment sets X axis margin to 30 when
title is added and margin is 0', async () => {
+ setupTableChartControlPanel();
+ try {
+ const customState = {
+ ...reduxState,
+ explore: {
+ ...reduxState.explore,
+ controls: {
+ ...reduxState.explore.controls,
+ x_axis_title: { value: '' },
+ x_axis_title_margin: { value: 0 },
+ },
+ },
+ };
+
+ const { rerender } = renderWithRouter({ initialState: customState });
+
+ await waitFor(() => {
+ rerender(
+ <MemoryRouter initialEntries={[defaultPath]}>
+ <Route path={defaultPath}>
+ <ExploreViewContainer />
+ </Route>
+ </MemoryRouter>,
+ );
+ });
+ } finally {
+ getChartControlPanelRegistry().remove('table');
+ }
+});
+
+test('automatic axis title margin adjustment sets Y axis margin to 30 when
title is added and margin is 0', async () => {
+ setupTableChartControlPanel();
+ try {
+ const customState = {
+ ...reduxState,
+ explore: {
+ ...reduxState.explore,
+ controls: {
+ ...reduxState.explore.controls,
+ y_axis_title: { value: '' },
+ y_axis_title_margin: { value: 0 },
+ },
+ },
+ };
+
+ renderWithRouter({ initialState: customState });
+
+ // Verify initial state renders without errors
+ await waitFor(() => {
+ expect(
+ screen.queryByTestId('query-error-tooltip-trigger'),
+ ).not.toBeInTheDocument();
+ });
+ } finally {
+ getChartControlPanelRegistry().remove('table');
+ }
+});
+
+test('automatic axis title margin adjustment resets X axis margin to 0 when
title is removed', async () => {
+ setupTableChartControlPanel();
+ try {
+ const customState = {
+ ...reduxState,
+ explore: {
+ ...reduxState.explore,
+ controls: {
+ ...reduxState.explore.controls,
+ x_axis_title: { value: 'X Axis Label' },
+ x_axis_title_margin: { value: 30 },
+ },
+ },
+ };
+
+ renderWithRouter({ initialState: customState });
+
+ // Component should handle title removal and reset margin
+ await waitFor(() => {
+ expect(
+ screen.queryByTestId('query-error-tooltip-trigger'),
+ ).not.toBeInTheDocument();
+ });
+ } finally {
+ getChartControlPanelRegistry().remove('table');
+ }
+});
Review Comment:
Indeed, test updated to simulate control changes.
##########
superset-frontend/src/explore/components/ExploreViewContainer/ExploreViewContainer.test.tsx:
##########
@@ -474,3 +474,210 @@ test('shows error indicator with function labels', async
() => {
expect(await screen.findByText(/Metric is required/)).toBeInTheDocument();
});
+
+function setupTableChartControlPanel() {
+ getChartControlPanelRegistry().registerValue('table', {
+ controlPanelSections: [],
+ });
+}
+
+test('automatic axis title margin adjustment sets X axis margin to 30 when
title is added and margin is 0', async () => {
+ setupTableChartControlPanel();
+ try {
+ const customState = {
+ ...reduxState,
+ explore: {
+ ...reduxState.explore,
+ controls: {
+ ...reduxState.explore.controls,
+ x_axis_title: { value: '' },
+ x_axis_title_margin: { value: 0 },
+ },
+ },
+ };
+
+ const { rerender } = renderWithRouter({ initialState: customState });
+
+ await waitFor(() => {
+ rerender(
+ <MemoryRouter initialEntries={[defaultPath]}>
+ <Route path={defaultPath}>
+ <ExploreViewContainer />
+ </Route>
+ </MemoryRouter>,
+ );
+ });
+ } finally {
+ getChartControlPanelRegistry().remove('table');
+ }
+});
+
+test('automatic axis title margin adjustment sets Y axis margin to 30 when
title is added and margin is 0', async () => {
+ setupTableChartControlPanel();
+ try {
+ const customState = {
+ ...reduxState,
+ explore: {
+ ...reduxState.explore,
+ controls: {
+ ...reduxState.explore.controls,
+ y_axis_title: { value: '' },
+ y_axis_title_margin: { value: 0 },
+ },
+ },
+ };
+
+ renderWithRouter({ initialState: customState });
+
+ // Verify initial state renders without errors
+ await waitFor(() => {
+ expect(
+ screen.queryByTestId('query-error-tooltip-trigger'),
+ ).not.toBeInTheDocument();
+ });
+ } finally {
+ getChartControlPanelRegistry().remove('table');
+ }
+});
+
+test('automatic axis title margin adjustment resets X axis margin to 0 when
title is removed', async () => {
+ setupTableChartControlPanel();
+ try {
+ const customState = {
+ ...reduxState,
+ explore: {
+ ...reduxState.explore,
+ controls: {
+ ...reduxState.explore.controls,
+ x_axis_title: { value: 'X Axis Label' },
+ x_axis_title_margin: { value: 30 },
+ },
+ },
+ };
+
+ renderWithRouter({ initialState: customState });
+
+ // Component should handle title removal and reset margin
+ await waitFor(() => {
+ expect(
+ screen.queryByTestId('query-error-tooltip-trigger'),
+ ).not.toBeInTheDocument();
+ });
+ } finally {
+ getChartControlPanelRegistry().remove('table');
+ }
+});
+
+test('automatic axis title margin adjustment resets Y axis margin to 0 when
title is removed', async () => {
+ setupTableChartControlPanel();
+ try {
+ const customState = {
+ ...reduxState,
+ explore: {
+ ...reduxState.explore,
+ controls: {
+ ...reduxState.explore.controls,
+ y_axis_title: { value: 'Y Axis Label' },
+ y_axis_title_margin: { value: 30 },
+ },
+ },
+ };
+
+ renderWithRouter({ initialState: customState });
+
+ // Component should handle title removal and reset margin
+ await waitFor(() => {
+ expect(
+ screen.queryByTestId('query-error-tooltip-trigger'),
+ ).not.toBeInTheDocument();
+ });
+ } finally {
+ getChartControlPanelRegistry().remove('table');
+ }
+});
Review Comment:
Indeed, test updated to simulate control changes.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]