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


##########
superset-frontend/src/SqlLab/extensionContracts.test.tsx:
##########
@@ -0,0 +1,92 @@
+/**
+ * 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 } from 'spec/helpers/testing-library';
+import userEvent from '@testing-library/user-event';
+import { views } from 'src/core';
+import PanelToolbar from 'src/components/PanelToolbar';
+import StatusBar from 'src/SqlLab/components/StatusBar';
+import { ViewLocations } from 'src/SqlLab/contributions';
+import {
+  registerTestView,
+  registerToolbarAction,
+  cleanupExtensions,
+} from 'src/SqlLab/test-utils/extensionTestHelpers';
+
+afterEach(cleanupExtensions);
+
+test('disposing a registered view removes it from rendering', () => {
+  const disposable = views.registerView(
+    { id: 'dispose-test', name: 'Dispose Test' },
+    ViewLocations.sqllab.statusBar,
+    () => React.createElement('div', null, 'Disposable Content'),
+  );
+
+  const { rerender } = render(<StatusBar />);
+  expect(screen.getByText('Disposable Content')).toBeInTheDocument();
+
+  disposable.dispose();
+  rerender(<StatusBar />);
+  expect(screen.queryByText('Disposable Content')).not.toBeInTheDocument();
+});
+
+test('extension throwing during render does not crash host', () => {
+  const consoleError = jest
+    .spyOn(console, 'error')
+    .mockImplementation(() => {});
+
+  const ThrowingComponent = () => {
+    throw new Error('Extension error');
+  };
+
+  registerTestView(
+    ViewLocations.sqllab.statusBar,
+    'throwing-ext',
+    'Throwing',
+    () => React.createElement(ThrowingComponent),
+  );
+  registerTestView(
+    ViewLocations.sqllab.statusBar,
+    'healthy-ext',
+    'Healthy',
+    () => React.createElement('div', null, 'Healthy Content'),
+  );
+
+  render(<StatusBar />);
+
+  // Healthy extension still renders despite the throwing extension
+  expect(screen.getByText('Healthy Content')).toBeInTheDocument();
+

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Incomplete test assertion</b></div>
   <div id="fix">
   
   The test mocks console.error but doesn't verify it was called, so it can't 
confirm the extension actually threw an error. This risks the test passing even 
if no error occurs, weakening its validation of error-handling behavior.
   </div>
   
   
   <details>
   <summary>
   <b>Code suggestion</b>
   </summary>
   <blockquote>Check the AI-generated fix before applying</blockquote>
   <div id="code">
   
   
   ````suggestion
     // Healthy extension still renders despite the throwing extension
     expect(screen.getByText('Healthy Content')).toBeInTheDocument();
     expect(consoleError).toHaveBeenCalled();
     
   ````
   
   </div>
   </details>
   
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #635ffa</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