bito-code-review[bot] commented on code in PR #36993:
URL: https://github.com/apache/superset/pull/36993#discussion_r2707616166


##########
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');
+  }
+});
+
+test('automatic axis title margin adjustment does not change X axis margin 
when title is added but margin is already non-zero', async () => {
+  setupTableChartControlPanel();
+  try {
+    const customState = {
+      ...reduxState,
+      explore: {
+        ...reduxState.explore,
+        controls: {
+          ...reduxState.explore.controls,
+          x_axis_title: { value: '' },
+          x_axis_title_margin: { value: 50 },
+        },
+      },
+    };
+
+    renderWithRouter({ initialState: customState });
+
+    // Component should not override user-set margin values
+    await waitFor(() => {
+      expect(
+        screen.queryByTestId('query-error-tooltip-trigger'),
+      ).not.toBeInTheDocument();
+    });
+  } finally {
+    getChartControlPanelRegistry().remove('table');
+  }
+});

Review Comment:
   <!-- Bito Reply -->
   You're right—the tests added for the automatic axis title margin adjustment 
feature only verify that no error tooltips appear, but they don't actually 
check if the margins are set to 30 when titles are added or reset to 0 when 
removed. The test names suggest they validate the margin logic, but the 
assertions are too shallow.



-- 
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]

Reply via email to