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