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


##########
superset-frontend/src/explore/components/useExploreAdditionalActionsMenu/useExploreAdditionalActionsMenu.test.jsx:
##########
@@ -0,0 +1,156 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import React from 'react';
+import { render, screen, waitFor } from 'spec/helpers/testing-library';
+import { useExploreAdditionalActionsMenu } from './index';
+import * as exploreUtils from 'src/explore/exploreUtils';
+import userEvent from '@testing-library/user-event';
+import { VizType } from '@superset-ui/core';
+
+// Mock exploreUtils
+jest.mock('src/explore/exploreUtils', () => ({
+  __esModule: true,
+  ...jest.requireActual('src/explore/exploreUtils'),
+  exportChart: jest.fn(),
+  getChartKey: jest.fn(() => 'test_chart_key'),
+}));
+
+// Mock @superset-ui/core to ensure t is available
+jest.mock('@superset-ui/core', () => ({
+  ...jest.requireActual('@superset-ui/core'),
+  t: str => str,
+  isFeatureEnabled: () => true, // default to true
+}));
+
+// Mock useToasts
+const mockAddDangerToast = jest.fn();
+jest.mock('src/components/MessageToasts/withToasts', () => ({
+  __esModule: true,
+  default: component => component,
+  useToasts: () => ({
+    addDangerToast: mockAddDangerToast,
+    addSuccessToast: jest.fn(),
+  }),
+}));
+
+const TestComponent = props => {
+  const [menu] = useExploreAdditionalActionsMenu(
+    props.latestQueryFormData,
+    props.canDownloadCSV,
+    props.slice,
+    props.onOpenInEditor,
+    props.onOpenPropertiesModal,
+    props.ownState,
+    props.dashboards,
+    props.showReportModal,
+    props.setCurrentReportDeleting,
+  );
+
+  return (
+    <div>
+      {/* Render buttons to trigger menu items */}
+      {menu.map(item => {
+        if (item && item.label && item.onClick) {
+          return (
+            <button key={item.key} onClick={item.onClick}>
+              {typeof item.label === 'string' ? item.label : 'Complex Label'}
+            </button>
+          );
+        }
+        if (item && item.children) {
+          return item.children.map(child => {
+            if (child && child.label && child.onClick) {
+              return (
+                <button key={child.key} onClick={child.onClick}>
+                  {typeof child.label === 'string'
+                    ? child.label
+                    : 'Complex Label'}
+                </button>
+              );
+            }
+            return null;
+          });
+        }
+        return null;
+      })}
+    </div>
+  );
+};
+
+test('shows 413 error toast when exportCSV fails with 413', async () => {
+  const mockExportChart = exploreUtils.exportChart;
+  const error413 = { status: 413 };
+  mockExportChart.mockRejectedValue(error413);
+
+  const props = {
+    latestQueryFormData: { viz_type: 'table' },

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Incorrect test setup for button label</b></div>
   <div id="fix">
   
   The test uses viz_type 'table' but expects 'Export to original .CSV' button, 
which only appears for pivot tables (viz_type 'pivot_table_v2'). For table viz, 
the button is 'Export to .CSV'.
   </div>
   
   
   <details>
   <summary>
   <b>Code suggestion</b>
   </summary>
   <blockquote>Check the AI-generated fix before applying</blockquote>
   <div id="code">
   
   
   ````suggestion
       latestQueryFormData: { viz_type: 'pivot_table_v2' },
   ````
   
   </div>
   </details>
   
   
   
   </div>
   
   <details>
   <summary><b>Citations</b></summary>
   <ul>
   
   <li>
   Rule Violated: <a 
href="https://github.com/apache/superset/blob/ff0cbb2/AGENTS.md#L21";>AGENTS.md:21</a>
   </li>
   
   </ul>
   </details>
   
   
   
   
   <small><i>Code Review Run #715822</i></small>
   </div>
   
   ---
   Should Bito avoid suggestions like this for future reviews? (<a 
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
   - [ ] Yes, avoid them



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