You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "sadpandajoe (via GitHub)" <gi...@apache.org> on 2026/03/20 19:18:31 UTC

[PR] test(sqllab): add extension slot contract tests for all 7 host components [superset]

sadpandajoe opened a new pull request, #38776:
URL: https://github.com/apache/superset/pull/38776

   ### SUMMARY
   
   Adds extension slot contract tests for all 7 SQL Lab extension points (SIP-151), replacing mock anti-patterns with real extension registration.
   
   **Problem**: Existing tests for StatusBar and SqlEditorTopBar mock `ViewListExtension` and `PanelToolbar` entirely, asserting only that the mock appears in the DOM. This means a refactor that breaks extension wiring would pass all tests. The remaining 5 host components (AppLayout, SouthPane, TableExploreTree, ResultSet, QueryHistory) had zero extension integration coverage.
   
   **Solution**: 
   - **Remove mock anti-patterns** in StatusBar (mocked `views` + `ViewListExtension`) and SqlEditorTopBar (mocked `PanelToolbar`), replacing with real `views.registerView()` / `menus.registerMenuItem()` + `commands.registerCommand()` calls
   - **Add host-focused contract tests** for all 7 slots, testing both ViewListExtension (3 slots) and PanelToolbar (4 slots) mechanisms
   - **Add cross-cutting tests** for dispose lifecycle, ErrorBoundary fault isolation, and full command round-trip (register β†’ render β†’ click β†’ callback)
   - **Create shared test helper** (`extensionTestHelpers.ts`) for view/toolbar registration with automatic cleanup
   
   **Test count**: +15 new tests, -3 mock-based tests removed, net +12. All 62 SqlLab tests pass (370 total suite).
   
   **Files changed**:
   | File | Change |
   |------|--------|
   | `StatusBar.test.tsx` | Rewrite: remove 2 `jest.mock` calls, add 3 real registration tests |
   | `SqlEditorTopBar.test.tsx` | Fix: remove PanelToolbar mock, add 2 extension tests |
   | `AppLayout.test.tsx` | Strengthen: add cleanup, empty-state test, assert contributed content |
   | `SouthPane.test.tsx` | Add 3 tests: tab content (ViewListExtension), slot-wide + per-view toolbars |
   | `TableExploreTree.test.tsx` | Add 1 test: leftSidebar toolbar action |
   | `ResultSet.test.tsx` | Add 1 test: results toolbar action (with Redux fixtures) |
   | `QueryHistory.test.tsx` | Add 1 test: queryHistory toolbar action (with Redux fixtures) |
   | `extensionContracts.test.tsx` | New: 3 cross-cutting tests (dispose, ErrorBoundary, command click) |
   | `test-utils/extensionTestHelpers.ts` | New: shared registration + cleanup helpers |
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   N/A β€” test-only changes, no UI modifications.
   
   ### TESTING INSTRUCTIONS
   ```bash
   # Run all affected test files
   npx jest --maxWorkers=4 \
     src/SqlLab/components/StatusBar/StatusBar.test.tsx \
     src/SqlLab/components/SqlEditorTopBar/SqlEditorTopBar.test.tsx \
     src/SqlLab/components/AppLayout/AppLayout.test.tsx \
     src/SqlLab/components/SouthPane/SouthPane.test.tsx \
     src/SqlLab/components/TableExploreTree/TableExploreTree.test.tsx \
     src/SqlLab/components/ResultSet/ResultSet.test.tsx \
     src/SqlLab/components/QueryHistory/QueryHistory.test.tsx \
     src/SqlLab/extensionContracts.test.tsx
   
   # Expected: 8 suites pass, 62 tests pass, 0 failures
   ```
   
   ### ADDITIONAL INFORMATION
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API
   
   πŸ€– Generated with [Claude Code](https://claude.com/claude-code)


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] test(sqllab): add extension slot contract tests for all 7 host components [superset]

Posted by "sadpandajoe (via GitHub)" <gi...@apache.org>.
sadpandajoe merged PR #38776:
URL: https://github.com/apache/superset/pull/38776


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] test(sqllab): add extension slot contract tests for all 7 host components [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on code in PR #38776:
URL: https://github.com/apache/superset/pull/38776#discussion_r2968214759


##########
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:
   <!-- Bito Reply -->
   Yes, the suggestion is valid β€” it adds an assertion to verify that the console error was called when the extension throws, ensuring the error handling is tested and the healthy extension can still render.



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] test(sqllab): add extension slot contract tests for all 7 host components [superset]

Posted by "sadpandajoe (via GitHub)" <gi...@apache.org>.
sadpandajoe commented on code in PR #38776:
URL: https://github.com/apache/superset/pull/38776#discussion_r2968200641


##########
superset-frontend/src/SqlLab/components/AppLayout/AppLayout.test.tsx:
##########
@@ -94,10 +99,20 @@ test('calls setWidth on sidebar resize when not hidden', async () => {
   await waitFor(() => expect(setWidth).toHaveBeenCalled());
 });
 
+test('right sidebar is hidden when no extensions registered', () => {
+  const { queryByText } = render(<AppLayout {...defaultProps} />, {
+    useRedux: true,
+    initialState,
+  });
+  // No right sidebar content β€” the third Splitter.Panel is conditionally omitted
+  expect(queryByText('Right Sidebar Content')).not.toBeInTheDocument();

Review Comment:
   The panel count assertion was intentionally removed β€” the existing `test('renders two panels', ...)` already asserts `toHaveLength(2)` when no extensions are registered. Adding it here would duplicate that test. The `queryByText` absence check is the contract-specific assertion: "no contributed right-sidebar content renders when nothing is registered."



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] test(sqllab): add extension slot contract tests for all 7 host components [superset]

Posted by "michael-s-molina (via GitHub)" <gi...@apache.org>.
michael-s-molina commented on code in PR #38776:
URL: https://github.com/apache/superset/pull/38776#discussion_r2974750574


##########
superset-frontend/src/SqlLab/extensionContracts.test.tsx:
##########
@@ -0,0 +1,97 @@
+/**
+ * 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';
+
+let consoleErrorSpy: jest.SpyInstance;
+
+afterEach(() => {
+  cleanupExtensions();
+  if (consoleErrorSpy) {
+    consoleErrorSpy.mockRestore();
+  }
+});
+
+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', () => {
+  consoleErrorSpy = 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();
+  // Verify the error boundary caught the throwing extension
+  expect(consoleErrorSpy).toHaveBeenCalled();
+});
+
+test('PanelToolbar click executes registered command callback', async () => {
+  const callback = jest.fn();
+  registerToolbarAction(
+    'test.clickLocation',
+    'test-click-cmd',
+    'Click Me',
+    callback,
+  );
+
+  render(<PanelToolbar viewId="test.clickLocation" />);
+
+  await userEvent.click(screen.getByRole('button', { name: 'Click Me' }));
+  expect(callback).toHaveBeenCalledTimes(1);
+});

Review Comment:
   With the comments above, we can remove this file.



##########
superset-frontend/src/SqlLab/extensionContracts.test.tsx:
##########
@@ -0,0 +1,97 @@
+/**
+ * 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';
+
+let consoleErrorSpy: jest.SpyInstance;
+
+afterEach(() => {
+  cleanupExtensions();
+  if (consoleErrorSpy) {
+    consoleErrorSpy.mockRestore();
+  }
+});
+
+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', () => {

Review Comment:
   Maybe move this to `StatusBar.test.tsx` or `AppLayout.test.tsx`?



##########
superset-frontend/src/SqlLab/test-utils/extensionTestHelpers.ts:
##########
@@ -0,0 +1,70 @@
+/**
+ * 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 type { ReactElement } from 'react';
+import { views, menus, commands } from 'src/core';
+import { resetContributions } from 'src/core/commands';
+
+const disposables: Array<{ dispose: () => void }> = [];
+
+/**
+ * Cleans up all tracked extension registrations (views, menus, commands).
+ * Call in afterEach to prevent state leaks between tests.
+ */
+export const cleanupExtensions = () => {

Review Comment:
   Given that these functions are not SQL Lab specific, maybe move them to `superset-frontend/spec/helpers`?



##########
superset-frontend/src/SqlLab/extensionContracts.test.tsx:
##########
@@ -0,0 +1,97 @@
+/**
+ * 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';
+
+let consoleErrorSpy: jest.SpyInstance;
+
+afterEach(() => {
+  cleanupExtensions();
+  if (consoleErrorSpy) {
+    consoleErrorSpy.mockRestore();
+  }
+});
+
+test('disposing a registered view removes it from rendering', () => {

Review Comment:
   This test already exists in `superset-frontend/src/core/views/index.test.ts`



##########
superset-frontend/src/SqlLab/extensionContracts.test.tsx:
##########
@@ -0,0 +1,97 @@
+/**
+ * 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';
+
+let consoleErrorSpy: jest.SpyInstance;
+
+afterEach(() => {
+  cleanupExtensions();
+  if (consoleErrorSpy) {
+    consoleErrorSpy.mockRestore();
+  }
+});
+
+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', () => {
+  consoleErrorSpy = 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();
+  // Verify the error boundary caught the throwing extension
+  expect(consoleErrorSpy).toHaveBeenCalled();
+});
+
+test('PanelToolbar click executes registered command callback', async () => {

Review Comment:
   I think this test should be moved alongside `PanelToolbar` component.



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] test(sqllab): add extension slot contract tests for all 7 host components [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #38776:
URL: https://github.com/apache/superset/pull/38776#issuecomment-4100468504

   AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] test(sqllab): add extension slot contract tests for all 7 host components [superset]

Posted by "netlify[bot] (via GitHub)" <gi...@apache.org>.
netlify[bot] commented on PR #38776:
URL: https://github.com/apache/superset/pull/38776#issuecomment-4100504560

   ### <span aria-hidden="true">βœ…</span> Deploy Preview for *superset-docs-preview* ready!
   
   
   |  Name | Link |
   |:-:|------------------------|
   |<span aria-hidden="true">πŸ”¨</span> Latest commit | 0cd428f81ca6766010d5f8c79be3a23f8a2536e7 |
   |<span aria-hidden="true">πŸ”</span> Latest deploy log | https://app.netlify.com/projects/superset-docs-preview/deploys/69bd9d87824b340008ecf3f8 |
   |<span aria-hidden="true">😎</span> Deploy Preview | [https://deploy-preview-38776--superset-docs-preview.netlify.app](https://deploy-preview-38776--superset-docs-preview.netlify.app) |
   |<span aria-hidden="true">πŸ“±</span> Preview on mobile | <details><summary> Toggle QR Code... </summary><br /><br />![QR Code](https://app.netlify.com/qr-code/eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1cmwiOiJodHRwczovL2RlcGxveS1wcmV2aWV3LTM4Nzc2LS1zdXBlcnNldC1kb2NzLXByZXZpZXcubmV0bGlmeS5hcHAifQ.jxH5FtatZcSrh2bRkOxt6Y3hmtg8Y14eYWa7RJLJVuQ)<br /><br />_Use your smartphone camera to open QR code link._</details> |
   ---
   <!-- [superset-docs-preview Preview](https://deploy-preview-38776--superset-docs-preview.netlify.app) -->
   _To edit notification comments on pull requests, go to your [Netlify project configuration](https://app.netlify.com/projects/superset-docs-preview/configuration/notifications#deploy-notifications)._


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] test(sqllab): add extension slot contract tests for all 7 host components [superset]

Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on PR #38776:
URL: https://github.com/apache/superset/pull/38776#issuecomment-4100476177

   ## **Sequence Diagram**
   
   This PR replaces mocked extension components with real contribution registration in tests for all SQL Lab extension slots. The tests now verify end to end wiring from registration to host rendering, command execution, and cleanup.
   
   ```mermaid
   sequenceDiagram
       participant Test
       participant Helpers
       participant Registry
       participant Host
       participant Toolbar
   
       Test->>Helpers: Register test view or toolbar action
       Helpers->>Registry: Register view command and menu item
       Test->>Host: Render SQL Lab host component
       Host->>Registry: Load contributions for slot
       Registry-->>Host: Return contributed items
       Host->>Toolbar: Render contributed action buttons
       Test->>Toolbar: Click contributed action
       Toolbar->>Registry: Execute command callback
       Test->>Helpers: Run cleanup after test
       Helpers->>Registry: Dispose registrations and reset state
   ```
   
   ---
   *Generated by [CodeAnt AI](https://codeant.ai)*
   


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] test(sqllab): add extension slot contract tests for all 7 host components [superset]

Posted by "sadpandajoe (via GitHub)" <gi...@apache.org>.
sadpandajoe commented on code in PR #38776:
URL: https://github.com/apache/superset/pull/38776#discussion_r2968200059


##########
superset-frontend/src/SqlLab/components/TableExploreTree/TableExploreTree.test.tsx:
##########
@@ -74,6 +79,7 @@ beforeEach(() => {
 afterEach(() => {
   jest.clearAllMocks();
   fetchMock.clearHistory();
+  cleanupExtensions();

Review Comment:
   Pre-existing issue β€” the `beforeEach` at line 58 re-registers all 4 routes every test, so the stale route from the loading-skeleton test is overwritten before the next test runs. The route leak is technically real but benign here. Out of scope for this PR (no behavioral change to TableExploreTree tests).



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

Review Comment:
   Intentional β€” this test exercises the raw `views.registerView().dispose()` contract directly. Using `registerTestView` would hide the dispose call behind the helper's `afterEach` cleanup, which is exactly what we're testing. The `cleanupExtensions()` in `afterEach` handles cleanup if the assertion throws before `dispose()` runs.



##########
superset-frontend/src/SqlLab/extensionContracts.test.tsx:
##########
@@ -0,0 +1,97 @@
+/**
+ * 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';
+
+let consoleErrorSpy: jest.SpyInstance;
+
+afterEach(() => {
+  cleanupExtensions();
+  if (consoleErrorSpy) {
+    consoleErrorSpy.mockRestore();
+  }
+});
+
+test('disposing a registered view removes it from rendering', () => {
+  const disposable = views.registerView(
+    { id: 'dispose-test', name: 'Dispose Test' },
+    ViewLocations.sqllab.statusBar,

Review Comment:
   Duplicate of earlier comment β€” see reply above. Intentional design: testing the raw dispose contract.



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] test(sqllab): add extension slot contract tests for all 7 host components [superset]

Posted by "sadpandajoe (via GitHub)" <gi...@apache.org>.
sadpandajoe commented on PR #38776:
URL: https://github.com/apache/superset/pull/38776#issuecomment-4114158092

   @michael-s-molina thanks for the review. Took your feedback into consideration and made updates.


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] test(sqllab): add extension slot contract tests for all 7 host components [superset]

Posted by "sadpandajoe (via GitHub)" <gi...@apache.org>.
sadpandajoe commented on code in PR #38776:
URL: https://github.com/apache/superset/pull/38776#discussion_r2968209976


##########
superset-frontend/src/SqlLab/components/QueryHistory/QueryHistory.test.tsx:
##########
@@ -81,7 +86,10 @@ const setup = (overrides = {}) => (
   <QueryHistory {...mockedProps} {...overrides} />
 );
 
-afterEach(() => fetchMock.clearHistory().removeRoutes());
+afterEach(() => {
+  fetchMock.clearHistory().removeRoutes();
+  cleanupExtensions();
+});

Review Comment:
   Fixed in e6efa58 β€” added `mockedIsFeatureEnabled.mockReset()` in `afterEach`.



##########
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:
   Fixed in e6efa58 β€” added `expect(consoleErrorSpy).toHaveBeenCalled()` assertion.



##########
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();
+
+  consoleError.mockRestore();

Review Comment:
   Fixed in e6efa58 β€” moved `consoleErrorSpy` to module scope with `afterEach` restore.



##########
superset-frontend/src/SqlLab/components/AppLayout/AppLayout.test.tsx:
##########
@@ -94,10 +99,19 @@ test('calls setWidth on sidebar resize when not hidden', async () => {
   await waitFor(() => expect(setWidth).toHaveBeenCalled());
 });
 
+test('right sidebar is hidden when no extensions registered', () => {
+  const { getAllByTestId } = render(<AppLayout {...defaultProps} />, {
+    useRedux: true,
+    initialState,
+  });
+  expect(getAllByTestId('mock-panel')).toHaveLength(2);

Review Comment:
   Fixed in e6efa58 β€” changed to `queryByText` absence check to avoid duplicating the existing panel count test.



##########
superset-frontend/src/SqlLab/test-utils/extensionTestHelpers.ts:
##########
@@ -0,0 +1,70 @@
+/**
+ * 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 { ReactElement } from 'react';

Review Comment:
   Fixed in e6efa58 β€” changed to `import type { ReactElement }`.



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] test(sqllab): add extension slot contract tests for all 7 host components [superset]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #38776:
URL: https://github.com/apache/superset/pull/38776#discussion_r2967611983


##########
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();
+
+  consoleError.mockRestore();

Review Comment:
   `console.error` is mocked but only restored at the end of the test. If the test fails before reaching the restore call, the mock can leak and affect subsequent tests. Wrap the body in try/finally (or use an afterEach restore) to guarantee `mockRestore()` runs.
   ```suggestion
     try {
       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();
     } finally {
       consoleError.mockRestore();
     }
   ```



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

Review Comment:
   This test registers a view via `views.registerView` but doesn’t use the shared helper that tracks disposables. If an assertion throws before `dispose()` runs, the registration can leak into later tests. Consider using `registerTestView` (and/or wrapping `dispose()` in a try/finally) so cleanup is guaranteed.
   ```suggestion
     const disposable = registerTestView(
       ViewLocations.sqllab.statusBar,
       'dispose-test',
       'Dispose Test',
   ```



##########
superset-frontend/src/SqlLab/test-utils/extensionTestHelpers.ts:
##########
@@ -0,0 +1,70 @@
+/**
+ * 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 { ReactElement } from 'react';

Review Comment:
   This import is type-only; in this codebase tests commonly use `import type { ... }` for React types. Updating this to a type import keeps consistency and avoids accidental runtime imports under stricter TS/ESLint settings.
   ```suggestion
   import type { ReactElement } from 'react';
   ```



##########
superset-frontend/src/SqlLab/components/AppLayout/AppLayout.test.tsx:
##########
@@ -94,10 +99,19 @@ test('calls setWidth on sidebar resize when not hidden', async () => {
   await waitFor(() => expect(setWidth).toHaveBeenCalled());
 });
 
+test('right sidebar is hidden when no extensions registered', () => {
+  const { getAllByTestId } = render(<AppLayout {...defaultProps} />, {
+    useRedux: true,
+    initialState,
+  });
+  expect(getAllByTestId('mock-panel')).toHaveLength(2);

Review Comment:
   This test duplicates the assertion already covered by `test('renders two panels', ...)` above (both assert there are 2 panels when no right-sidebar contributions exist). Consider removing one, or making this one assert something more specific to the right-sidebar contract (e.g., that no right-sidebar extension content/container is rendered).
   ```suggestion
     const { queryByText } = render(<AppLayout {...defaultProps} />, {
       useRedux: true,
       initialState,
     });
     expect(queryByText('Right Sidebar Content')).not.toBeInTheDocument();
   ```



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] test(sqllab): add extension slot contract tests for all 7 host components [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] test(sqllab): add extension slot contract tests for all 7 host components [superset]

Posted by "sadpandajoe (via GitHub)" <gi...@apache.org>.
sadpandajoe commented on code in PR #38776:
URL: https://github.com/apache/superset/pull/38776#discussion_r2977972479


##########
superset-frontend/src/SqlLab/extensionContracts.test.tsx:
##########
@@ -0,0 +1,97 @@
+/**
+ * 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';
+
+let consoleErrorSpy: jest.SpyInstance;
+
+afterEach(() => {
+  cleanupExtensions();
+  if (consoleErrorSpy) {
+    consoleErrorSpy.mockRestore();
+  }
+});
+
+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', () => {
+  consoleErrorSpy = 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();
+  // Verify the error boundary caught the throwing extension
+  expect(consoleErrorSpy).toHaveBeenCalled();
+});
+
+test('PanelToolbar click executes registered command callback', async () => {

Review Comment:
   sounds good



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] test(sqllab): add extension slot contract tests for all 7 host components [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #38776:
URL: https://github.com/apache/superset/pull/38776#issuecomment-4114388978

   AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
   
   <details>
   <summary>
   Bito Usage Guide
   </summary>
   
   **Commands**
         
   Type the following command in the pull request comment and save the comment.
         
   - `/review` - Manually triggers a full AI review.
   
   - `/pause` - Pauses automatic reviews on this pull request.
   - `/resume` - Resumes automatic reviews.
   - `/resolve` - Marks all Bito-posted review comments as resolved.
   - `/abort` - Cancels all in-progress reviews.
   
         
   Refer to the <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/available-commands" target="_blank" rel="noopener noreferrer">documentation</a> for additional commands.
         
   **Configuration**
   
   This repository uses `Superset` You can customize the agent settings <a href="https://alpha.bito.ai/home/ai-agents/code-review-agent" target="_blank" rel="noopener noreferrer">here</a> or contact your Bito workspace admin at evan@preset.io.
         
   **Documentation & Help**
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/getting-started/install-run-using-bito-cloud/create-or-customize-an-agent-instance" target="_blank" rel="noopener noreferrer">Customize agent settings</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/implementing-custom-code-review-rules" target="_blank" rel="noopener noreferrer">Review rules</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent" target="_blank" rel="noopener noreferrer">General documentation</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/faqs" target="_blank" rel="noopener noreferrer">FAQ</a>
   
   </details>
   


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] test(sqllab): add extension slot contract tests for all 7 host components [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #38776:
URL: https://github.com/apache/superset/pull/38776#issuecomment-4101221135

   AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
   
   <details>
   <summary>
   Bito Usage Guide
   </summary>
   
   **Commands**
         
   Type the following command in the pull request comment and save the comment.
         
   - `/review` - Manually triggers a full AI review.
   
   - `/pause` - Pauses automatic reviews on this pull request.
   - `/resume` - Resumes automatic reviews.
   - `/resolve` - Marks all Bito-posted review comments as resolved.
   - `/abort` - Cancels all in-progress reviews.
   
         
   Refer to the <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/available-commands" target="_blank" rel="noopener noreferrer">documentation</a> for additional commands.
         
   **Configuration**
   
   This repository uses `Superset` You can customize the agent settings <a href="https://alpha.bito.ai/home/ai-agents/code-review-agent" target="_blank" rel="noopener noreferrer">here</a> or contact your Bito workspace admin at evan@preset.io.
         
   **Documentation & Help**
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/getting-started/install-run-using-bito-cloud/create-or-customize-an-agent-instance" target="_blank" rel="noopener noreferrer">Customize agent settings</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/implementing-custom-code-review-rules" target="_blank" rel="noopener noreferrer">Review rules</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent" target="_blank" rel="noopener noreferrer">General documentation</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/faqs" target="_blank" rel="noopener noreferrer">FAQ</a>
   
   </details>
   


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] test(sqllab): add extension slot contract tests for all 7 host components [superset]

Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on code in PR #38776:
URL: https://github.com/apache/superset/pull/38776#discussion_r2967577980


##########
superset-frontend/src/SqlLab/components/QueryHistory/QueryHistory.test.tsx:
##########
@@ -81,7 +86,10 @@ const setup = (overrides = {}) => (
   <QueryHistory {...mockedProps} {...overrides} />
 );
 
-afterEach(() => fetchMock.clearHistory().removeRoutes());
+afterEach(() => {
+  fetchMock.clearHistory().removeRoutes();
+  cleanupExtensions();
+});

Review Comment:
   **Suggestion:** The mocked feature-flag function is never reset between tests, so its previous implementation can leak into later tests. When a prior test leaves backend persistence enabled, this test file can make unexpected network requests (without matching fetch routes), causing flaky or failing tests. Reset the mock in `afterEach` instead of only clearing call history inside individual tests. [possible bug]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   - ⚠️ QueryHistory tests make unintended `/api/v1/query/` requests.
   - ⚠️ Test isolation weakens across same-file test cases.
   - ⚠️ CI failures become order-dependent and flaky.
   ```
   </details>
   
   ```suggestion
     mockedIsFeatureEnabled.mockReset();
   ```
   <details>
   <summary><b>Steps of Reproduction βœ… </b></summary>
   
   ```mdx
   1. In
   `superset-frontend/src/SqlLab/components/QueryHistory/QueryHistory.test.tsx:105-107`, run
   test `fetches the query history when the persistence mode is enabled`; it sets
   `mockedIsFeatureEnabled.mockImplementation(...)` to return true for
   `FeatureFlag.SqllabBackendPersistence`.
   
   2. At the end of that test (`QueryHistory.test.tsx:117`), only
   `isFeatureEnabledMock.mockClear()` is called, which clears call history but keeps
   implementation; `afterEach` (`QueryHistory.test.tsx:89-92`) also does not reset
   `mockedIsFeatureEnabled`.
   
   3. Next test `renders contributed toolbar action in queryHistory slot`
   (`QueryHistory.test.tsx:254+`) renders `QueryHistory` without setting feature-flag
   behavior, so it still inherits the previous mock implementation.
   
   4. In component code
   `superset-frontend/src/SqlLab/components/QueryHistory/index.tsx:79-83`,
   `useEditorQueriesQuery` executes with `skip: !isFeatureEnabled(...)`; stale `true`
   disables skip and triggers query fetching, which hits `/api/v1/query/` from
   `superset-frontend/src/hooks/apiResources/queries.ts:114-117` unexpectedly for a test that
   never configured that route.
   ```
   </details>
   <details>
   <summary><b>Prompt for AI Agent πŸ€– </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset-frontend/src/SqlLab/components/QueryHistory/QueryHistory.test.tsx
   **Line:** 92:92
   **Comment:**
   	*Possible Bug: The mocked feature-flag function is never reset between tests, so its previous implementation can leak into later tests. When a prior test leaves backend persistence enabled, this test file can make unexpected network requests (without matching fetch routes), causing flaky or failing tests. Reset the mock in `afterEach` instead of only clearing call history inside individual tests.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
   ```
   </details>
   <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F38776&comment_hash=c792ec8962d15c1a69a382f8f2773bcfe0a5aae539938738ac507d581d7f8b25&reaction=like'>πŸ‘</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F38776&comment_hash=c792ec8962d15c1a69a382f8f2773bcfe0a5aae539938738ac507d581d7f8b25&reaction=dislike'>πŸ‘Ž</a>



##########
superset-frontend/src/SqlLab/components/TableExploreTree/TableExploreTree.test.tsx:
##########
@@ -74,6 +79,7 @@ beforeEach(() => {
 afterEach(() => {
   jest.clearAllMocks();
   fetchMock.clearHistory();
+  cleanupExtensions();

Review Comment:
   **Suggestion:** Route mocks are never removed between tests, so per-test overrides (like the delayed schemas response) can leak into later tests and make them order-dependent or flaky. Keep `cleanupExtensions()` but also remove fetch routes in teardown so each test starts with a clean mock registry. [logic error]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   - ⚠️ TableExploreTree test suite becomes order-dependent.
   - ⚠️ Schema-loading tests can become timing-flaky.
   - ⚠️ CI reliability degrades in SqlLab component tests.
   ```
   </details>
   
   ```suggestion
     fetchMock.removeRoutes();
   ```
   <details>
   <summary><b>Steps of Reproduction βœ… </b></summary>
   
   ```mdx
   1. Run `TableExploreTree` tests in
   `superset-frontend/src/SqlLab/components/TableExploreTree/TableExploreTree.test.tsx`; each
   `beforeEach` registers 4 `fetchMock.get(...)` routes (lines 58-76).
   
   2. In test `shows loading skeleton while fetching schemas` (lines 217-229), a second
   schemas matcher `glob:*/api/v1/database/1/schemas/?*` is added with delayed response.
   
   3. `afterEach` (lines 79-83) only calls `fetchMock.clearHistory()` and
   `cleanupExtensions()`, so route definitions are not removed between tests.
   
   4. Subsequent tests (for example lines 238-266) call `renderComponent()` (lines 103-107),
   which triggers the same schema endpoint; route resolution now depends on accumulated prior
   matchers, creating order-dependent timing/behavior and potential flakiness.
   ```
   </details>
   <details>
   <summary><b>Prompt for AI Agent πŸ€– </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset-frontend/src/SqlLab/components/TableExploreTree/TableExploreTree.test.tsx
   **Line:** 82:82
   **Comment:**
   	*Logic Error: Route mocks are never removed between tests, so per-test overrides (like the delayed schemas response) can leak into later tests and make them order-dependent or flaky. Keep `cleanupExtensions()` but also remove fetch routes in teardown so each test starts with a clean mock registry.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
   ```
   </details>
   <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F38776&comment_hash=57dc6b07f87029c06ae9eae8367a161fa19af617fb369341ec1bc645599a88d9&reaction=like'>πŸ‘</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F38776&comment_hash=57dc6b07f87029c06ae9eae8367a161fa19af617fb369341ec1bc645599a88d9&reaction=dislike'>πŸ‘Ž</a>



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] test(sqllab): add extension slot contract tests for all 7 host components [superset]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #38776:
URL: https://github.com/apache/superset/pull/38776#discussion_r2968190590


##########
superset-frontend/src/SqlLab/extensionContracts.test.tsx:
##########
@@ -0,0 +1,97 @@
+/**
+ * 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';
+
+let consoleErrorSpy: jest.SpyInstance;
+
+afterEach(() => {
+  cleanupExtensions();
+  if (consoleErrorSpy) {
+    consoleErrorSpy.mockRestore();
+  }
+});
+
+test('disposing a registered view removes it from rendering', () => {
+  const disposable = views.registerView(
+    { id: 'dispose-test', name: 'Dispose Test' },
+    ViewLocations.sqllab.statusBar,

Review Comment:
   This test registers a view directly via `views.registerView` and relies on manually calling `disposable.dispose()` later. If an assertion fails before dispose is reached, the view registration can leak into subsequent tests. Use `registerTestView(...)` (it returns a disposable) or ensure disposal in a `try/finally` so cleanup is guaranteed even on failures.
   ```suggestion
     const disposable = registerTestView(
       ViewLocations.sqllab.statusBar,
       'dispose-test',
       'Dispose Test',
   ```



##########
superset-frontend/src/SqlLab/components/AppLayout/AppLayout.test.tsx:
##########
@@ -94,10 +99,20 @@ test('calls setWidth on sidebar resize when not hidden', async () => {
   await waitFor(() => expect(setWidth).toHaveBeenCalled());
 });
 
+test('right sidebar is hidden when no extensions registered', () => {
+  const { queryByText } = render(<AppLayout {...defaultProps} />, {
+    useRedux: true,
+    initialState,
+  });
+  // No right sidebar content β€” the third Splitter.Panel is conditionally omitted
+  expect(queryByText('Right Sidebar Content')).not.toBeInTheDocument();

Review Comment:
   The "right sidebar is hidden" test only asserts that specific contributed text is absent, which would still pass if the right sidebar panel is rendered but empty. To actually verify the contract (third Splitter.Panel omitted), assert the panel count stays at 2 (or explicitly assert the right sidebar container/panel is not rendered).
   ```suggestion
     const { queryByText, getAllByTestId } = render(
       <AppLayout {...defaultProps} />,
       {
         useRedux: true,
         initialState,
       },
     );
     // No right sidebar content β€” the third Splitter.Panel is conditionally omitted
     expect(queryByText('Right Sidebar Content')).not.toBeInTheDocument();
     // Ensure only the two expected panels (main layout) are rendered
     expect(getAllByTestId('mock-panel')).toHaveLength(2);
   ```



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] test(sqllab): add extension slot contract tests for all 7 host components [superset]

Posted by "sadpandajoe (via GitHub)" <gi...@apache.org>.
sadpandajoe commented on code in PR #38776:
URL: https://github.com/apache/superset/pull/38776#discussion_r2977977020


##########
superset-frontend/spec/helpers/extensionTestHelpers.ts:
##########
@@ -0,0 +1,70 @@
+/**
+ * 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 type { ReactElement } from 'react';
+import { views, menus, commands } from 'src/core';
+import { resetContributions } from 'src/core/commands';
+
+const disposables: Array<{ dispose: () => void }> = [];
+
+/**
+ * Cleans up all tracked extension registrations (views, menus, commands).
+ * Call in afterEach to prevent state leaks between tests.
+ */
+export const cleanupExtensions = () => {

Review Comment:
   renamed the file to `extensionTestHelpers.ts`



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org